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