]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
dont kill interactive actions when the client dies, just remove teh client pointer.
[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 Ben 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);
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
52 /* Command to execute to rebuild the menu */
53 gchar *execute;
54
55 /* ObMenuEntry list */
56 GList *entries;
57
58 /* plugin data */
59 gpointer data;
60
61 ObMenuUpdateFunc update_func;
62 ObMenuExecuteFunc execute_func;
63 ObMenuDestroyFunc destroy_func;
64
65 /* Pipe-menu parent, we get destroyed when it is destroyed */
66 ObMenu *pipe_creator;
67 };
68
69 typedef enum
70 {
71 OB_MENU_ENTRY_TYPE_NORMAL,
72 OB_MENU_ENTRY_TYPE_SUBMENU,
73 OB_MENU_ENTRY_TYPE_SEPARATOR
74 } ObMenuEntryType;
75
76 struct _ObNormalMenuEntry {
77 gchar *label;
78
79 /* state */
80 gboolean enabled;
81
82 /* List of ObActions */
83 GSList *actions;
84
85 /* Icon shit */
86 gint icon_width;
87 gint icon_height;
88 RrPixel32 *icon_data;
89
90 /* Mask icon */
91 RrPixmapMask *mask;
92 RrColor *mask_normal_color;
93 RrColor *mask_disabled_color;
94 RrColor *mask_selected_color;
95 };
96
97 struct _ObSubmenuMenuEntry {
98 gchar *name;
99 ObMenu *submenu;
100 };
101
102 struct _ObSeparatorMenuEntry {
103 gchar foo; /* placeholder */
104 };
105
106 struct _ObMenuEntry
107 {
108 ObMenuEntryType type;
109 ObMenu *menu;
110
111 gint id;
112
113 union u {
114 ObNormalMenuEntry normal;
115 ObSubmenuMenuEntry submenu;
116 ObSeparatorMenuEntry separator;
117 } data;
118 };
119
120 void menu_startup(gboolean reconfig);
121 void menu_shutdown(gboolean reconfig);
122
123 ObMenu* menu_new(gchar *name, gchar *title, gpointer data);
124 void menu_free(ObMenu *menu);
125
126 /* Repopulate a pipe-menu by running its command */
127 void menu_pipe_execute(ObMenu *self);
128
129 void menu_show(gchar *name, gint x, gint y, struct _ObClient *client);
130
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);
134
135 /* functions for building menus */
136 ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, gchar *label,
137 GSList *actions);
138 ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, gchar *submenu);
139 ObMenuEntry* menu_add_separator(ObMenu *menu, gint id);
140
141 void menu_clear_entries(ObMenu *menu);
142 void menu_entry_remove(ObMenuEntry *self);
143
144 ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
145
146 /* fills in the submenus, for use when a menu is being shown */
147 void menu_find_submenus(ObMenu *self);
148
149 #endif
This page took 0.041475 seconds and 4 git commands to generate.