]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
load menu plugins automatically from whats in the menu file
[chaz/openbox] / openbox / menu.h
1 #ifndef __menu_h
2 #define __menu_h
3
4 #include "action.h"
5 #include "window.h"
6 #include "render/render.h"
7 #include "geom.h"
8
9 #include <glib.h>
10
11 struct _ObClient;
12 struct _ObMenuFrame;
13
14 typedef struct _ObMenu ObMenu;
15 typedef struct _ObMenuEntry ObMenuEntry;
16 typedef struct _ObNormalMenuEntry ObNormalMenuEntry;
17 typedef struct _ObSubmenuMenuEntry ObSubmenuMenuEntry;
18 typedef struct _ObSeparatorMenuEntry ObSeparatorMenuEntry;
19
20 typedef void (*ObMenuUpdateFunc)(struct _ObMenuFrame *frame, gpointer data);
21
22 extern GList *menu_visible;
23
24 struct _ObMenu
25 {
26 /* Name of the menu. Used in the showmenu action. */
27 gchar *name;
28 /* Displayed title */
29 gchar *title;
30
31 /* ObMenuEntry list */
32 GList *entries;
33
34 /* plugin data */
35 gpointer data;
36
37 ObMenuUpdateFunc update_func;
38 };
39
40 typedef enum
41 {
42 OB_MENU_ENTRY_TYPE_NORMAL,
43 OB_MENU_ENTRY_TYPE_SUBMENU,
44 OB_MENU_ENTRY_TYPE_SEPARATOR
45 } ObMenuEntryType;
46
47 struct _ObNormalMenuEntry {
48 gchar *label;
49
50 /* state */
51 gboolean enabled;
52
53 /* List of ObActions */
54 GSList *actions;
55 };
56
57 struct _ObSubmenuMenuEntry {
58 ObMenu *submenu;
59 };
60
61 struct _ObSeparatorMenuEntry {
62 gchar foo; /* placeholder */
63 };
64
65 struct _ObMenuEntry
66 {
67 ObMenuEntryType type;
68 ObMenu *menu;
69
70 gint id;
71
72 union u {
73 ObNormalMenuEntry normal;
74 ObSubmenuMenuEntry submenu;
75 ObSeparatorMenuEntry separator;
76 } data;
77 };
78
79 void menu_startup();
80 void menu_shutdown();
81
82 void menu_parse();
83
84 gboolean menu_new(gchar *name, gchar *title, gpointer data);
85 void menu_free(gchar *name);
86
87 void menu_set_update_func(gchar *name, ObMenuUpdateFunc func);
88
89 void menu_show(gchar *name, gint x, gint y, struct _ObClient *client);
90
91 /* functions for building menus */
92 void menu_clear_entries(gchar *name);
93 void menu_add_normal(gchar *name, gint id, gchar *label, GSList *actions);
94 void menu_add_submenu(gchar *name, gint id, gchar *submenu);
95 void menu_add_separator(gchar *name, gint id);
96
97 ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);
98
99 #endif
This page took 0.039899 seconds and 5 git commands to generate.