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.
25 #include "render/render.h"
26 #include "parser/parse.h"
32 struct _ObMenuEntryFrame
;
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
;
40 typedef gboolean (*ObMenuUpdateFunc
)(struct _ObMenuFrame
*frame
,
42 typedef void (*ObMenuExecuteFunc
)(struct _ObMenuEntry
*entry
,
43 guint state
, gpointer data
, Time time
);
44 typedef void (*ObMenuDestroyFunc
)(struct _ObMenu
*menu
, gpointer data
);
45 /*! @param x is the mouse x coordinate. on return it should be the x coordinate
47 @param y is the mouse y coordinate. on return it should be the y coordinate
50 typedef void (*ObMenuPlaceFunc
)(struct _ObMenuFrame
*frame
, gint
*x
, gint
*y
,
51 gint button
, gpointer data
);
55 /* Name of the menu. Used in the showmenu action. */
59 /*! The shortcut key that would be used to activate this menu if it was
60 displayed as a submenu */
62 /*! The shortcut's position in the string */
63 guint shortcut_position
;
65 /*! If the shortcut key should be shown in menu entries even when it
66 is the first character in the string */
67 gboolean show_all_shortcuts
;
69 /* Command to execute to rebuild the menu */
72 /* ObMenuEntry list */
78 ObMenuUpdateFunc update_func
;
79 ObMenuExecuteFunc execute_func
;
80 ObMenuDestroyFunc destroy_func
;
81 ObMenuPlaceFunc place_func
;
83 /* Pipe-menu parent, we get destroyed when it is destroyed */
89 OB_MENU_ENTRY_TYPE_NORMAL
,
90 OB_MENU_ENTRY_TYPE_SUBMENU
,
91 OB_MENU_ENTRY_TYPE_SEPARATOR
94 struct _ObNormalMenuEntry
{
96 /*! The shortcut key that would be used to activate this menu entry */
98 /*! The shortcut's position in the string */
99 guint shortcut_position
;
104 /* List of ObActions */
110 RrPixel32
*icon_data
;
114 RrColor
*mask_normal_color
;
115 RrColor
*mask_disabled_color
;
116 RrColor
*mask_selected_color
;
119 struct _ObSubmenuMenuEntry
{
124 struct _ObSeparatorMenuEntry
{
130 ObMenuEntryType type
;
136 ObNormalMenuEntry normal
;
137 ObSubmenuMenuEntry submenu
;
138 ObSeparatorMenuEntry separator
;
142 void menu_startup(gboolean reconfig
);
143 void menu_shutdown(gboolean reconfig
);
145 /*! @param allow_shortcut this should be false when the label is coming from
146 outside data like window or desktop titles */
147 ObMenu
* menu_new(const gchar
*name
, const gchar
*title
,
148 gboolean allow_shortcut
, gpointer data
);
149 void menu_free(ObMenu
*menu
);
151 /* Repopulate a pipe-menu by running its command */
152 void menu_pipe_execute(ObMenu
*self
);
154 void menu_show_all_shortcuts(ObMenu
*self
, gboolean show
);
156 void menu_show(gchar
*name
, gint x
, gint y
, gint button
,
157 struct _ObClient
*client
);
159 void menu_set_update_func(ObMenu
*menu
, ObMenuUpdateFunc func
);
160 void menu_set_execute_func(ObMenu
*menu
, ObMenuExecuteFunc func
);
161 void menu_set_destroy_func(ObMenu
*menu
, ObMenuDestroyFunc func
);
162 void menu_set_place_func(ObMenu
*menu
, ObMenuPlaceFunc func
);
164 /* functions for building menus */
165 /*! @param allow_shortcut this should be false when the label is coming from
166 outside data like window or desktop titles */
167 ObMenuEntry
* menu_add_normal(ObMenu
*menu
, gint id
, const gchar
*label
,
168 GSList
*actions
, gboolean allow_shortcut
);
169 ObMenuEntry
* menu_add_submenu(ObMenu
*menu
, gint id
, const gchar
*submenu
);
170 ObMenuEntry
* menu_add_separator(ObMenu
*menu
, gint id
, const gchar
*label
);
172 void menu_clear_entries(ObMenu
*menu
);
173 void menu_entry_remove(ObMenuEntry
*self
);
175 void menu_entry_set_label(ObMenuEntry
*self
, const gchar
*label
,
176 gboolean allow_shortcut
);
178 ObMenuEntry
* menu_find_entry_id(ObMenu
*self
, gint id
);
180 /* fills in the submenus, for use when a menu is being shown */
181 void menu_find_submenus(ObMenu
*self
);