]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
little bit of an actions overhaul, added action_run* so that duplicated code can...
[chaz/openbox] / openbox / menu.h
1 #ifndef __menu_h
2 #define __menu_h
3
4 #include "action.h"
5 #include "window.h"
6 #include "geom.h"
7 #include "render/render.h"
8 #include "parser/parse.h"
9
10 #include <glib.h>
11
12 struct _ObClient;
13 struct _ObMenuFrame;
14 struct _ObMenuEntryFrame;
15
16 typedef struct _ObMenu ObMenu;
17 typedef struct _ObMenuEntry ObMenuEntry;
18 typedef struct _ObNormalMenuEntry ObNormalMenuEntry;
19 typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry;
20 typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry;
21
22 typedef void (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame, gpointer data);
23 typedef void (*ObMenuExecuteFunc)(struct _ObMenuEntry *entry,
24 guint state, gpointer data);
25 typedef void (*ObMenuDestroyFunc)(struct _ObMenu *menu, gpointer data);
26
27 struct _ObMenu
28 {
29 /* Name of the menu. Used in the showmenu action. */
30 gchar *name;
31 /* Displayed title */
32 gchar *title;
33
34 /* Command to execute to rebuild the menu */
35 gchar *execute;
36
37 /* ObMenuEntry list */
38 GList *entries;
39
40 /* plugin data */
41 gpointer data;
42
43 ObMenuUpdateFunc update_func;
44 ObMenuExecuteFunc execute_func;
45 ObMenuDestroyFunc destroy_func;
46
47 /* Pipe-menu parent, we get destroyed when it is destroyed */
48 ObMenu *pipe_creator;
49 };
50
51 typedef enum
52 {
53 OB_MENU_ENTRY_TYPE_NORMAL,
54 OB_MENU_ENTRY_TYPE_SUBMENU,
55 OB_MENU_ENTRY_TYPE_SEPARATOR
56 } ObMenuEntryType;
57
58 struct _ObNormalMenuEntry {
59 gchar *label;
60
61 /* state */
62 gboolean enabled;
63
64 /* List of ObActions */
65 GSList *actions;
66
67 /* Icon shit */
68 gint icon_width;
69 gint icon_height;
70 RrPixel32 *icon_data;
71
72 /* Mask icon */
73 RrPixmapMask *mask;
74 RrColor *mask_normal_color;
75 RrColor *mask_disabled_color;
76 RrColor *mask_selected_color;
77 };
78
79 struct _ObSubmenuMenuEntry {
80 gchar *name;
81 ObMenu *submenu;
82 };
83
84 struct _ObSeparatorMenuEntry {
85 gchar foo; /* placeholder */
86 };
87
88 struct _ObMenuEntry
89 {
90 ObMenuEntryType type;
91 ObMenu *menu;
92
93 gint id;
94
95 union u {
96 ObNormalMenuEntry normal;
97 ObSubmenuMenuEntry submenu;
98 ObSeparatorMenuEntry separator;
99 } data;
100 };
101
102 void menu_startup(gboolean reconfig);
103 void menu_shutdown(gboolean reconfig);
104
105 ObMenu* menu_new(gchar *name, gchar *title, gpointer data);
106 void menu_free(ObMenu *menu);
107
108 /* Repopulate a pipe-menu by running its command */
109 void menu_pipe_execute(ObMenu *self);
110
111 void menu_show(gchar *name, gint x, gint y, struct _ObClient *client);
112
113 void menu_set_update_func(ObMenu *menu, ObMenuUpdateFunc func);
114 void menu_set_execute_func(ObMenu *menu, ObMenuExecuteFunc func);
115 void menu_set_destroy_func(ObMenu *menu, ObMenuDestroyFunc func);
116
117 /* functions for building menus */
118 ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, gchar *label,
119 GSList *actions);
120 ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, gchar *submenu);
121 ObMenuEntry* menu_add_separator(ObMenu *menu, gint id);
122
123 void menu_clear_entries(ObMenu *menu);
124 void menu_entry_remove(ObMenuEntry *self);
125
126 ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
127
128 /* fills in the submenus, for use when a menu is being shown */
129 void menu_find_submenus(ObMenu *self);
130
131 #endif
This page took 0.04818 seconds and 5 git commands to generate.