2003-09-17 07:44:49 +00:00
|
|
|
/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
|
2003-09-17 07:32:52 +00:00
|
|
|
|
|
|
|
menu.h for the Openbox window manager
|
|
|
|
Copyright (c) 2003 Ben Jansens
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
See the COPYING file for a copy of the GNU General Public License.
|
|
|
|
*/
|
|
|
|
|
2003-04-14 21:26:01 +00:00
|
|
|
#ifndef __menu_h
|
|
|
|
#define __menu_h
|
|
|
|
|
|
|
|
#include "action.h"
|
2003-07-10 17:03:05 +00:00
|
|
|
#include "window.h"
|
2003-05-09 23:15:28 +00:00
|
|
|
#include "geom.h"
|
2003-08-28 07:34:03 +00:00
|
|
|
#include "render/render.h"
|
|
|
|
#include "parser/parse.h"
|
2003-04-15 18:29:55 +00:00
|
|
|
|
2003-04-14 21:26:01 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2003-07-10 17:03:05 +00:00
|
|
|
struct _ObClient;
|
2003-08-28 02:10:23 +00:00
|
|
|
struct _ObMenuFrame;
|
2003-08-28 07:34:03 +00:00
|
|
|
struct _ObMenuEntryFrame;
|
2003-07-10 17:03:05 +00:00
|
|
|
|
2003-07-26 06:02:58 +00:00
|
|
|
typedef struct _ObMenu ObMenu;
|
2003-07-10 19:27:12 +00:00
|
|
|
typedef struct _ObMenuEntry ObMenuEntry;
|
2003-08-28 02:10:23 +00:00
|
|
|
typedef struct _ObNormalMenuEntry ObNormalMenuEntry;
|
|
|
|
typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry;
|
|
|
|
typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry;
|
2003-04-22 03:48:34 +00:00
|
|
|
|
2003-08-28 05:44:13 +00:00
|
|
|
typedef void (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame, gpointer data);
|
2003-09-07 19:03:20 +00:00
|
|
|
typedef void (*ObMenuExecuteFunc)(struct _ObMenuEntry *entry,
|
|
|
|
guint state, gpointer data);
|
2003-08-28 07:34:03 +00:00
|
|
|
typedef void (*ObMenuDestroyFunc)(struct _ObMenu *menu, gpointer data);
|
2003-04-22 03:48:34 +00:00
|
|
|
|
2003-07-10 19:27:12 +00:00
|
|
|
struct _ObMenu
|
|
|
|
{
|
2003-08-28 02:10:23 +00:00
|
|
|
/* Name of the menu. Used in the showmenu action. */
|
2003-07-10 19:27:12 +00:00
|
|
|
gchar *name;
|
2003-08-28 02:10:23 +00:00
|
|
|
/* Displayed title */
|
|
|
|
gchar *title;
|
2003-07-26 06:02:58 +00:00
|
|
|
|
2003-08-30 05:15:12 +00:00
|
|
|
/* Command to execute to rebuild the menu */
|
|
|
|
gchar *execute;
|
|
|
|
|
2003-07-26 06:02:58 +00:00
|
|
|
/* ObMenuEntry list */
|
2003-04-14 21:26:01 +00:00
|
|
|
GList *entries;
|
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
/* plugin data */
|
|
|
|
gpointer data;
|
2003-08-28 05:44:13 +00:00
|
|
|
|
|
|
|
ObMenuUpdateFunc update_func;
|
2003-08-28 07:34:03 +00:00
|
|
|
ObMenuExecuteFunc execute_func;
|
|
|
|
ObMenuDestroyFunc destroy_func;
|
2003-09-04 15:30:34 +00:00
|
|
|
|
|
|
|
/* Pipe-menu parent, we get destroyed when it is destroyed */
|
|
|
|
ObMenu *pipe_creator;
|
2003-07-10 19:27:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2003-08-28 02:10:23 +00:00
|
|
|
OB_MENU_ENTRY_TYPE_NORMAL,
|
|
|
|
OB_MENU_ENTRY_TYPE_SUBMENU,
|
|
|
|
OB_MENU_ENTRY_TYPE_SEPARATOR
|
|
|
|
} ObMenuEntryType;
|
2003-07-10 19:27:12 +00:00
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
struct _ObNormalMenuEntry {
|
|
|
|
gchar *label;
|
2003-04-14 21:26:01 +00:00
|
|
|
|
2003-08-28 06:32:27 +00:00
|
|
|
/* state */
|
|
|
|
gboolean enabled;
|
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
/* List of ObActions */
|
|
|
|
GSList *actions;
|
2003-08-28 08:08:18 +00:00
|
|
|
|
|
|
|
/* Icon shit */
|
|
|
|
gint icon_width;
|
|
|
|
gint icon_height;
|
|
|
|
RrPixel32 *icon_data;
|
2003-08-30 19:03:06 +00:00
|
|
|
|
|
|
|
/* Mask icon */
|
|
|
|
RrPixmapMask *mask;
|
2003-09-02 18:53:08 +00:00
|
|
|
RrColor *mask_normal_color;
|
|
|
|
RrColor *mask_disabled_color;
|
|
|
|
RrColor *mask_selected_color;
|
2003-08-28 02:10:23 +00:00
|
|
|
};
|
2003-04-14 21:26:01 +00:00
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
struct _ObSubmenuMenuEntry {
|
2003-08-28 07:49:57 +00:00
|
|
|
gchar *name;
|
2003-07-10 19:27:12 +00:00
|
|
|
ObMenu *submenu;
|
2003-08-28 02:10:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _ObSeparatorMenuEntry {
|
|
|
|
gchar foo; /* placeholder */
|
|
|
|
};
|
2003-04-14 21:26:01 +00:00
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
struct _ObMenuEntry
|
|
|
|
{
|
|
|
|
ObMenuEntryType type;
|
|
|
|
ObMenu *menu;
|
|
|
|
|
2003-08-28 05:44:13 +00:00
|
|
|
gint id;
|
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
union u {
|
|
|
|
ObNormalMenuEntry normal;
|
|
|
|
ObSubmenuMenuEntry submenu;
|
|
|
|
ObSeparatorMenuEntry separator;
|
|
|
|
} data;
|
|
|
|
};
|
2003-04-15 18:29:55 +00:00
|
|
|
|
2003-09-03 18:11:39 +00:00
|
|
|
void menu_startup(gboolean reconfig);
|
|
|
|
void menu_shutdown(gboolean reconfig);
|
2003-04-15 18:29:55 +00:00
|
|
|
|
2003-08-28 17:32:49 +00:00
|
|
|
ObMenu* menu_new(gchar *name, gchar *title, gpointer data);
|
2003-08-29 07:57:18 +00:00
|
|
|
void menu_free(ObMenu *menu);
|
2003-04-16 05:36:51 +00:00
|
|
|
|
2003-08-30 05:15:12 +00:00
|
|
|
/* Repopulate a pipe-menu by running its command */
|
|
|
|
void menu_pipe_execute(ObMenu *self);
|
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
void menu_show(gchar *name, gint x, gint y, struct _ObClient *client);
|
2003-04-16 18:09:11 +00:00
|
|
|
|
2003-08-29 07:57:18 +00:00
|
|
|
void menu_set_update_func(ObMenu *menu, ObMenuUpdateFunc func);
|
|
|
|
void menu_set_execute_func(ObMenu *menu, ObMenuExecuteFunc func);
|
|
|
|
void menu_set_destroy_func(ObMenu *menu, ObMenuDestroyFunc func);
|
|
|
|
|
2003-08-28 02:10:23 +00:00
|
|
|
/* functions for building menus */
|
2003-08-29 07:57:18 +00:00
|
|
|
ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, gchar *label,
|
2003-08-28 17:32:49 +00:00
|
|
|
GSList *actions);
|
2003-08-29 07:57:18 +00:00
|
|
|
ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, gchar *submenu);
|
|
|
|
ObMenuEntry* menu_add_separator(ObMenu *menu, gint id);
|
|
|
|
|
|
|
|
void menu_clear_entries(ObMenu *menu);
|
|
|
|
void menu_entry_remove(ObMenuEntry *self);
|
2003-08-28 05:44:13 +00:00
|
|
|
|
|
|
|
ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
|
2003-04-22 01:04:29 +00:00
|
|
|
|
2003-08-29 07:57:18 +00:00
|
|
|
/* fills in the submenus, for use when a menu is being shown */
|
2003-08-28 07:49:57 +00:00
|
|
|
void menu_find_submenus(ObMenu *self);
|
|
|
|
|
2003-04-14 21:26:01 +00:00
|
|
|
#endif
|