]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
check if they have a group
[chaz/openbox] / openbox / menu.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 menu.h for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef __menu_h
20 #define __menu_h
21
22 #include "action.h"
23 #include "window.h"
24 #include "geom.h"
25 #include "render/render.h"
26 #include "parser/parse.h"
27
28 #include <glib.h>
29
30 struct _ObClient;
31 struct _ObMenuFrame;
32 struct _ObMenuEntryFrame;
33
34 typedef struct _ObMenu ObMenu;
35 typedef struct _ObMenuEntry ObMenuEntry;
36 typedef struct _ObNormalMenuEntry ObNormalMenuEntry;
37 typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry;
38 typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry;
39
40 typedef void (*ObMenuShowFunc)(struct _ObMenuFrame *frame, gpointer data);
41 typedef void (*ObMenuHideFunc)(struct _ObMenuFrame *frame, gpointer data);
42 typedef gboolean (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame,
43 gpointer data);
44 typedef void (*ObMenuExecuteFunc)(struct _ObMenuEntry *entry,
45 struct _ObMenuFrame *frame,
46 struct _ObClient *client,
47 guint state, gpointer data, Time time);
48 typedef void (*ObMenuDestroyFunc)(struct _ObMenu *menu, gpointer data);
49 /*! @param x is the mouse x coordinate. on return it should be the x coordinate
50 for the menu
51 @param y is the mouse y coordinate. on return it should be the y coordinate
52 for the menu
53 */
54 typedef void (*ObMenuPlaceFunc)(struct _ObMenuFrame *frame, gint *x, gint *y,
55 gint button, gpointer data);
56
57 struct _ObMenu
58 {
59 /* Name of the menu. Used in the showmenu action. */
60 gchar *name;
61 /* Displayed title */
62 gchar *title;
63 /*! The shortcut key that would be used to activate this menu if it was
64 displayed as a submenu */
65 gunichar shortcut;
66 /*! The shortcut's position in the string */
67 guint shortcut_position;
68
69 /*! If the shortcut key should be shown in menu entries even when it
70 is the first character in the string */
71 gboolean show_all_shortcuts;
72
73 /* Command to execute to rebuild the menu */
74 gchar *execute;
75
76 /* ObMenuEntry list */
77 GList *entries;
78
79 /* plugin data */
80 gpointer data;
81
82 ObMenuShowFunc show_func;
83 ObMenuHideFunc hide_func;
84 ObMenuUpdateFunc update_func;
85 ObMenuExecuteFunc execute_func;
86 ObMenuDestroyFunc destroy_func;
87 ObMenuPlaceFunc place_func;
88
89 /* Pipe-menu parent, we get destroyed when it is destroyed */
90 ObMenu *pipe_creator;
91
92 /* The menu used as the destination for the "More..." entry for this menu*/
93 ObMenu *more_menu;
94 };
95
96 typedef enum
97 {
98 OB_MENU_ENTRY_TYPE_NORMAL,
99 OB_MENU_ENTRY_TYPE_SUBMENU,
100 OB_MENU_ENTRY_TYPE_SEPARATOR
101 } ObMenuEntryType;
102
103 struct _ObNormalMenuEntry {
104 gchar *label;
105 /*! The shortcut key that would be used to activate this menu entry */
106 gunichar shortcut;
107 /*! The shortcut's position in the string */
108 guint shortcut_position;
109
110 /* state */
111 gboolean enabled;
112
113 /* List of ObActions */
114 GSList *actions;
115
116 /* Icon shit */
117 gint icon_width;
118 gint icon_height;
119 gint icon_alpha;
120 RrPixel32 *icon_data;
121
122 /* Mask icon */
123 RrPixmapMask *mask;
124 RrColor *mask_normal_color;
125 RrColor *mask_selected_color;
126 RrColor *mask_disabled_color;
127 RrColor *mask_disabled_selected_color;
128 };
129
130 struct _ObSubmenuMenuEntry {
131 gchar *name;
132 ObMenu *submenu;
133 guint show_from;
134 };
135
136 struct _ObSeparatorMenuEntry {
137 gchar *label;
138 };
139
140 struct _ObMenuEntry
141 {
142 guint ref;
143
144 ObMenuEntryType type;
145 ObMenu *menu;
146
147 gint id;
148
149 union u {
150 ObNormalMenuEntry normal;
151 ObSubmenuMenuEntry submenu;
152 ObSeparatorMenuEntry separator;
153 } data;
154 };
155
156 void menu_startup(gboolean reconfig);
157 void menu_shutdown(gboolean reconfig);
158
159 void menu_entry_ref(ObMenuEntry *self);
160 void menu_entry_unref(ObMenuEntry *self);
161
162 /*! @param allow_shortcut this should be false when the label is coming from
163 outside data like window or desktop titles */
164 ObMenu* menu_new(const gchar *name, const gchar *title,
165 gboolean allow_shortcut_selection, gpointer data);
166 void menu_free(ObMenu *menu);
167
168 /* Repopulate a pipe-menu by running its command */
169 void menu_pipe_execute(ObMenu *self);
170
171 void menu_show_all_shortcuts(ObMenu *self, gboolean show);
172
173 void menu_show(gchar *name, gint x, gint y, gint button,
174 struct _ObClient *client);
175 gboolean menu_hide_delay_reached();
176
177 void menu_set_show_func(ObMenu *menu, ObMenuShowFunc func);
178 void menu_set_hide_func(ObMenu *menu, ObMenuHideFunc func);
179 void menu_set_update_func(ObMenu *menu, ObMenuUpdateFunc func);
180 void menu_set_execute_func(ObMenu *menu, ObMenuExecuteFunc func);
181 void menu_set_destroy_func(ObMenu *menu, ObMenuDestroyFunc func);
182 void menu_set_place_func(ObMenu *menu, ObMenuPlaceFunc func);
183
184 /* functions for building menus */
185 /*! @param allow_shortcut this should be false when the label is coming from
186 outside data like window or desktop titles */
187 ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, const gchar *label,
188 GSList *actions, gboolean allow_shortcut);
189 ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, const gchar *submenu);
190 ObMenuEntry* menu_add_separator(ObMenu *menu, gint id, const gchar *label);
191
192 void menu_clear_entries(ObMenu *menu);
193 void menu_entry_remove(ObMenuEntry *self);
194
195 void menu_entry_set_label(ObMenuEntry *self, const gchar *label,
196 gboolean allow_shortcut);
197
198 ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
199
200 /* fills in the submenus, for use when a menu is being shown */
201 void menu_find_submenus(ObMenu *self);
202
203 ObMenuEntry* menu_get_more(ObMenu *menu, guint show_from);
204
205 #endif
This page took 0.039745 seconds and 4 git commands to generate.