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