]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
add a notifier for clients changing desktops. use it to update the send-to menu if...
[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 guint state, gpointer data, Time time);
46 typedef void (*ObMenuDestroyFunc)(struct _ObMenu *menu, gpointer data);
47 /*! @param x is the mouse x coordinate. on return it should be the x coordinate
48 for the menu
49 @param y is the mouse y coordinate. on return it should be the y coordinate
50 for the menu
51 */
52 typedef void (*ObMenuPlaceFunc)(struct _ObMenuFrame *frame, gint *x, gint *y,
53 gint button, gpointer data);
54
55 struct _ObMenu
56 {
57 /* Name of the menu. Used in the showmenu action. */
58 gchar *name;
59 /* Displayed title */
60 gchar *title;
61 /*! The shortcut key that would be used to activate this menu if it was
62 displayed as a submenu */
63 gunichar shortcut;
64 /*! The shortcut's position in the string */
65 guint shortcut_position;
66
67 /*! If the shortcut key should be shown in menu entries even when it
68 is the first character in the string */
69 gboolean show_all_shortcuts;
70
71 /* Command to execute to rebuild the menu */
72 gchar *execute;
73
74 /* ObMenuEntry list */
75 GList *entries;
76
77 /* plugin data */
78 gpointer data;
79
80 ObMenuShowFunc show_func;
81 ObMenuHideFunc hide_func;
82 ObMenuUpdateFunc update_func;
83 ObMenuExecuteFunc execute_func;
84 ObMenuDestroyFunc destroy_func;
85 ObMenuPlaceFunc place_func;
86
87 /* Pipe-menu parent, we get destroyed when it is destroyed */
88 ObMenu *pipe_creator;
89
90 /* The menu used as the destination for the "More..." entry for this menu*/
91 ObMenu *more_menu;
92 };
93
94 typedef enum
95 {
96 OB_MENU_ENTRY_TYPE_NORMAL,
97 OB_MENU_ENTRY_TYPE_SUBMENU,
98 OB_MENU_ENTRY_TYPE_SEPARATOR
99 } ObMenuEntryType;
100
101 struct _ObNormalMenuEntry {
102 gchar *label;
103 /*! The shortcut key that would be used to activate this menu entry */
104 gunichar shortcut;
105 /*! The shortcut's position in the string */
106 guint shortcut_position;
107
108 /* state */
109 gboolean enabled;
110
111 /* List of ObActions */
112 GSList *actions;
113
114 /* Icon shit */
115 gint icon_width;
116 gint icon_height;
117 RrPixel32 *icon_data;
118
119 /* Mask icon */
120 RrPixmapMask *mask;
121 RrColor *mask_normal_color;
122 RrColor *mask_selected_color;
123 RrColor *mask_disabled_color;
124 RrColor *mask_disabled_selected_color;
125 };
126
127 struct _ObSubmenuMenuEntry {
128 gchar *name;
129 ObMenu *submenu;
130 guint show_from;
131 };
132
133 struct _ObSeparatorMenuEntry {
134 gchar *label;
135 };
136
137 struct _ObMenuEntry
138 {
139 guint ref;
140
141 ObMenuEntryType type;
142 ObMenu *menu;
143
144 gint id;
145
146 union u {
147 ObNormalMenuEntry normal;
148 ObSubmenuMenuEntry submenu;
149 ObSeparatorMenuEntry separator;
150 } data;
151 };
152
153 void menu_startup(gboolean reconfig);
154 void menu_shutdown(gboolean reconfig);
155
156 void menu_entry_ref(ObMenuEntry *self);
157 void menu_entry_unref(ObMenuEntry *self);
158
159 /*! @param allow_shortcut this should be false when the label is coming from
160 outside data like window or desktop titles */
161 ObMenu* menu_new(const gchar *name, const gchar *title,
162 gboolean allow_shortcut_selection, gpointer data);
163 void menu_free(ObMenu *menu);
164
165 /* Repopulate a pipe-menu by running its command */
166 void menu_pipe_execute(ObMenu *self);
167
168 void menu_show_all_shortcuts(ObMenu *self, gboolean show);
169
170 void menu_show(gchar *name, gint x, gint y, gint button,
171 struct _ObClient *client);
172
173 void menu_set_show_func(ObMenu *menu, ObMenuShowFunc func);
174 void menu_set_hide_func(ObMenu *menu, ObMenuHideFunc func);
175 void menu_set_update_func(ObMenu *menu, ObMenuUpdateFunc func);
176 void menu_set_execute_func(ObMenu *menu, ObMenuExecuteFunc func);
177 void menu_set_destroy_func(ObMenu *menu, ObMenuDestroyFunc func);
178 void menu_set_place_func(ObMenu *menu, ObMenuPlaceFunc func);
179
180 /* functions for building menus */
181 /*! @param allow_shortcut this should be false when the label is coming from
182 outside data like window or desktop titles */
183 ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, const gchar *label,
184 GSList *actions, gboolean allow_shortcut);
185 ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, const gchar *submenu);
186 ObMenuEntry* menu_add_separator(ObMenu *menu, gint id, const gchar *label);
187
188 void menu_clear_entries(ObMenu *menu);
189 void menu_entry_remove(ObMenuEntry *self);
190
191 void menu_entry_set_label(ObMenuEntry *self, const gchar *label,
192 gboolean allow_shortcut);
193
194 ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
195
196 /* fills in the submenus, for use when a menu is being shown */
197 void menu_find_submenus(ObMenu *self);
198
199 ObMenuEntry* menu_get_more(ObMenu *menu, guint show_from);
200
201 #endif
This page took 0.046085 seconds and 5 git commands to generate.