1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 menu.h for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
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.
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.
16 See the COPYING file for a copy of the GNU General Public License.
24 #include "render/render.h"
25 #include "parser/parse.h"
31 struct _ObMenuEntryFrame
;
33 typedef struct _ObMenu ObMenu
;
34 typedef struct _ObMenuEntry ObMenuEntry
;
35 typedef struct _ObNormalMenuEntry ObNormalMenuEntry
;
36 typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry
;
37 typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry
;
39 typedef void (*ObMenuShowFunc
)(struct _ObMenuFrame
*frame
, gpointer data
);
40 typedef void (*ObMenuHideFunc
)(struct _ObMenuFrame
*frame
, gpointer data
);
41 typedef gboolean (*ObMenuUpdateFunc
)(struct _ObMenuFrame
*frame
,
43 typedef void (*ObMenuExecuteFunc
)(struct _ObMenuEntry
*entry
,
44 struct _ObMenuFrame
*frame
,
45 struct _ObClient
*client
,
46 guint state
, gpointer data
);
47 typedef void (*ObMenuDestroyFunc
)(struct _ObMenu
*menu
, gpointer data
);
48 /*! @param x is the mouse x coordinate. on return it should be the x coordinate
50 @param y is the mouse y coordinate. on return it should be the y coordinate
53 typedef void (*ObMenuPlaceFunc
)(struct _ObMenuFrame
*frame
, gint
*x
, gint
*y
,
54 gboolean mouse
, gpointer data
);
58 /* Name of the menu. Used in the showmenu action. */
62 /*! The shortcut key that would be used to activate this menu if it was
63 displayed as a submenu */
65 /*! The shortcut's position in the string */
66 guint shortcut_position
;
67 /*! If the shortcut was specified by & and should always be drawn */
68 gboolean shortcut_always_show
;
70 /*! If the shortcut key should be shown in menu entries even when it
71 is the first character in the string */
72 gboolean show_all_shortcuts
;
74 /* Command to execute to rebuild the menu */
77 /* ObMenuEntry list */
83 ObMenuShowFunc show_func
;
84 ObMenuHideFunc hide_func
;
85 ObMenuUpdateFunc update_func
;
86 ObMenuExecuteFunc execute_func
;
87 ObMenuDestroyFunc destroy_func
;
88 ObMenuPlaceFunc place_func
;
90 /* Pipe-menu parent, we get destroyed when it is destroyed */
93 /* The menu used as the destination for the "More..." entry for this menu*/
99 OB_MENU_ENTRY_TYPE_NORMAL
,
100 OB_MENU_ENTRY_TYPE_SUBMENU
,
101 OB_MENU_ENTRY_TYPE_SEPARATOR
104 struct _ObNormalMenuEntry
{
106 /*! The shortcut key that would be used to activate this menu entry */
108 /*! The shortcut's position in the string */
109 guint shortcut_position
;
110 /*! If the shortcut was specified by & and should always be drawn */
111 gboolean shortcut_always_show
;
116 /* List of ObActions */
123 RrPixel32
*icon_data
;
127 RrColor
*mask_normal_color
;
128 RrColor
*mask_selected_color
;
129 RrColor
*mask_disabled_color
;
130 RrColor
*mask_disabled_selected_color
;
135 struct _ObSubmenuMenuEntry
{
141 struct _ObSeparatorMenuEntry
{
149 ObMenuEntryType type
;
155 ObNormalMenuEntry normal
;
156 ObSubmenuMenuEntry submenu
;
157 ObSeparatorMenuEntry separator
;
161 void menu_startup(gboolean reconfig
);
162 void menu_shutdown(gboolean reconfig
);
164 void menu_entry_ref(ObMenuEntry
*self
);
165 void menu_entry_unref(ObMenuEntry
*self
);
167 ObMenu
* menu_new(const gchar
*name
, const gchar
*title
,
168 gboolean allow_shortcut_selection
, gpointer data
);
169 void menu_free(ObMenu
*menu
);
171 /*! Repopulate a pipe-menu by running its command */
172 void menu_pipe_execute(ObMenu
*self
);
173 /*! Clear a pipe-menu's entries */
174 void menu_clear_pipe_caches();
176 void menu_show_all_shortcuts(ObMenu
*self
, gboolean show
);
178 void menu_show(gchar
*name
, gint x
, gint y
, gboolean mouse
,
179 struct _ObClient
*client
);
180 gboolean
menu_hide_delay_reached();
182 void menu_set_show_func(ObMenu
*menu
, ObMenuShowFunc func
);
183 void menu_set_hide_func(ObMenu
*menu
, ObMenuHideFunc func
);
184 void menu_set_update_func(ObMenu
*menu
, ObMenuUpdateFunc func
);
185 void menu_set_execute_func(ObMenu
*menu
, ObMenuExecuteFunc func
);
186 void menu_set_destroy_func(ObMenu
*menu
, ObMenuDestroyFunc func
);
187 void menu_set_place_func(ObMenu
*menu
, ObMenuPlaceFunc func
);
189 /* functions for building menus */
190 /*! @param allow_shortcut this should be false when the label is coming from
191 outside data like window or desktop titles */
192 ObMenuEntry
* menu_add_normal(ObMenu
*menu
, gint id
, const gchar
*label
,
193 GSList
*actions
, gboolean allow_shortcut
);
194 ObMenuEntry
* menu_add_submenu(ObMenu
*menu
, gint id
, const gchar
*submenu
);
195 ObMenuEntry
* menu_add_separator(ObMenu
*menu
, gint id
, const gchar
*label
);
197 void menu_clear_entries(ObMenu
*menu
);
198 void menu_entry_remove(ObMenuEntry
*self
);
200 void menu_entry_set_label(ObMenuEntry
*self
, const gchar
*label
,
201 gboolean allow_shortcut
);
203 ObMenuEntry
* menu_find_entry_id(ObMenu
*self
, gint id
);
205 /* fills in the submenus, for use when a menu is being shown */
206 void menu_find_submenus(ObMenu
*self
);
208 ObMenuEntry
* menu_get_more(ObMenu
*menu
, guint show_from
);