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 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);
47 /* Name of the menu. Used in the showmenu action. */
52 /* Command to execute to rebuild the menu */
55 /* ObMenuEntry list */
61 ObMenuUpdateFunc update_func;
62 ObMenuExecuteFunc execute_func;
63 ObMenuDestroyFunc destroy_func;
65 /* Pipe-menu parent, we get destroyed when it is destroyed */
71 OB_MENU_ENTRY_TYPE_NORMAL,
72 OB_MENU_ENTRY_TYPE_SUBMENU,
73 OB_MENU_ENTRY_TYPE_SEPARATOR
76 struct _ObNormalMenuEntry {
82 /* List of ObActions */
92 RrColor *mask_normal_color;
93 RrColor *mask_disabled_color;
94 RrColor *mask_selected_color;
97 struct _ObSubmenuMenuEntry {
102 struct _ObSeparatorMenuEntry {
108 ObMenuEntryType type;
114 ObNormalMenuEntry normal;
115 ObSubmenuMenuEntry submenu;
116 ObSeparatorMenuEntry separator;
120 void menu_startup(gboolean reconfig);
121 void menu_shutdown(gboolean reconfig);
123 ObMenu* menu_new(const gchar *name, const gchar *title, gpointer data);
124 void menu_free(ObMenu *menu);
126 /* Repopulate a pipe-menu by running its command */
127 void menu_pipe_execute(ObMenu *self);
129 void menu_show(gchar *name, gint x, gint y, struct _ObClient *client);
131 void menu_set_update_func(ObMenu *menu, ObMenuUpdateFunc func);
132 void menu_set_execute_func(ObMenu *menu, ObMenuExecuteFunc func);
133 void menu_set_destroy_func(ObMenu *menu, ObMenuDestroyFunc func);
135 /* functions for building menus */
136 ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, const gchar *label,
138 ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, const gchar *submenu);
139 ObMenuEntry* menu_add_separator(ObMenu *menu, gint id, const gchar *label);
141 void menu_clear_entries(ObMenu *menu);
142 void menu_entry_remove(ObMenuEntry *self);
144 ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
146 /* fills in the submenus, for use when a menu is being shown */
147 void menu_find_submenus(ObMenu *self);