prefix and capitalize ObMenu ObMenuEntry and ObMenuEntryRenderType
make the ObMenuEntryRenderType a standard enum instead bitflags
This commit is contained in:
parent
1ffc7fa9ec
commit
a95dc346fe
10 changed files with 132 additions and 130 deletions
|
@ -318,8 +318,8 @@ void client_unmanage_all()
|
||||||
/* called by client_unmanage() to close any menus referencing this client */
|
/* called by client_unmanage() to close any menus referencing this client */
|
||||||
void client_close_menus(gpointer key, gpointer value, gpointer self)
|
void client_close_menus(gpointer key, gpointer value, gpointer self)
|
||||||
{
|
{
|
||||||
if (((Menu *)value)->client == (ObClient *)self)
|
if (((ObMenu *)value)->client == (ObClient *)self)
|
||||||
menu_hide((Menu *)value);
|
menu_hide((ObMenu *)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_unmanage(ObClient *self)
|
void client_unmanage(ObClient *self)
|
||||||
|
|
|
@ -449,7 +449,7 @@ static void event_process(XEvent *e)
|
||||||
ObClient *client = NULL;
|
ObClient *client = NULL;
|
||||||
ObDock *dock = NULL;
|
ObDock *dock = NULL;
|
||||||
ObDockApp *dockapp = NULL;
|
ObDockApp *dockapp = NULL;
|
||||||
Menu *menu = NULL;
|
ObMenu *menu = NULL;
|
||||||
ObWindow *obwin = NULL;
|
ObWindow *obwin = NULL;
|
||||||
|
|
||||||
window = event_get_window(e);
|
window = event_get_window(e);
|
||||||
|
@ -963,9 +963,9 @@ static void event_handle_client(ObClient *client, XEvent *e)
|
||||||
|
|
||||||
static void event_handle_menu(ObClient *client, XEvent *e)
|
static void event_handle_menu(ObClient *client, XEvent *e)
|
||||||
{
|
{
|
||||||
static MenuEntry *over = NULL;
|
static ObMenuEntry *over = NULL;
|
||||||
MenuEntry *entry;
|
ObMenuEntry *entry;
|
||||||
Menu *top;
|
ObMenu *top;
|
||||||
GSList *it;
|
GSList *it;
|
||||||
|
|
||||||
top = g_slist_nth_data(menu_visible, 0);
|
top = g_slist_nth_data(menu_visible, 0);
|
||||||
|
@ -999,7 +999,7 @@ static void event_handle_menu(ObClient *client, XEvent *e)
|
||||||
g_message("BUTTON RELEASED");
|
g_message("BUTTON RELEASED");
|
||||||
|
|
||||||
for (it = menu_visible; it; it = g_slist_next(it)) {
|
for (it = menu_visible; it; it = g_slist_next(it)) {
|
||||||
Menu *m = it->data;
|
ObMenu *m = it->data;
|
||||||
if (e->xbutton.x_root >= m->location.x - ob_rr_theme->bwidth &&
|
if (e->xbutton.x_root >= m->location.x - ob_rr_theme->bwidth &&
|
||||||
e->xbutton.y_root >= m->location.y - ob_rr_theme->bwidth &&
|
e->xbutton.y_root >= m->location.y - ob_rr_theme->bwidth &&
|
||||||
e->xbutton.x_root < m->location.x + m->size.width +
|
e->xbutton.x_root < m->location.x + m->size.width +
|
||||||
|
@ -1046,7 +1046,7 @@ static void event_handle_menu(ObClient *client, XEvent *e)
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
g_message("motion");
|
g_message("motion");
|
||||||
for (it = menu_visible; it; it = g_slist_next(it)) {
|
for (it = menu_visible; it; it = g_slist_next(it)) {
|
||||||
Menu *m = it->data;
|
ObMenu *m = it->data;
|
||||||
if ((entry = menu_find_entry_by_pos(it->data,
|
if ((entry = menu_find_entry_by_pos(it->data,
|
||||||
e->xmotion.x_root -
|
e->xmotion.x_root -
|
||||||
m->location.x,
|
m->location.x,
|
||||||
|
|
|
@ -21,7 +21,7 @@ static void parse_menu(xmlDocPtr doc, xmlNodePtr node, void *data)
|
||||||
Action *act;
|
Action *act;
|
||||||
xmlNodePtr nact;
|
xmlNodePtr nact;
|
||||||
gchar *id = NULL, *title = NULL, *label = NULL;
|
gchar *id = NULL, *title = NULL, *label = NULL;
|
||||||
Menu *menu, *parent;
|
ObMenu *menu, *parent;
|
||||||
|
|
||||||
if (!parse_attr_string("id", node->parent, &id))
|
if (!parse_attr_string("id", node->parent, &id))
|
||||||
goto parse_menu_fail;
|
goto parse_menu_fail;
|
||||||
|
@ -30,9 +30,9 @@ static void parse_menu(xmlDocPtr doc, xmlNodePtr node, void *data)
|
||||||
|
|
||||||
g_message("menu label %s", title);
|
g_message("menu label %s", title);
|
||||||
|
|
||||||
menu = menu_new(title, id, data ? *((Menu**)data) : NULL);
|
menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL);
|
||||||
if (data)
|
if (data)
|
||||||
*((Menu**)data) = menu;
|
*((ObMenu**)data) = menu;
|
||||||
|
|
||||||
while (node) {
|
while (node) {
|
||||||
if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) {
|
if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) {
|
||||||
|
@ -62,14 +62,14 @@ parse_menu_fail:
|
||||||
g_free(title);
|
g_free(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_control_show(Menu *self, int x, int y, ObClient *client);
|
void menu_control_show(ObMenu *self, int x, int y, ObClient *client);
|
||||||
|
|
||||||
void menu_destroy_hash_key(Menu *menu)
|
void menu_destroy_hash_key(ObMenu *menu)
|
||||||
{
|
{
|
||||||
g_free(menu);
|
g_free(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_destroy_hash_value(Menu *self)
|
void menu_destroy_hash_value(ObMenu *self)
|
||||||
{
|
{
|
||||||
GList *it;
|
GList *it;
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ void menu_destroy_hash_value(Menu *self)
|
||||||
g_free(self);
|
g_free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_entry_free(MenuEntry *self)
|
void menu_entry_free(ObMenuEntry *self)
|
||||||
{
|
{
|
||||||
g_free(self->label);
|
g_free(self->label);
|
||||||
action_free(self->action);
|
action_free(self->action);
|
||||||
|
@ -112,9 +112,9 @@ void menu_entry_free(MenuEntry *self)
|
||||||
void menu_startup()
|
void menu_startup()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Menu *m;
|
ObMenu *m;
|
||||||
Menu *s;
|
ObMenu *s;
|
||||||
Menu *t;
|
ObMenu *t;
|
||||||
Action *a;
|
Action *a;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -183,13 +183,13 @@ static Window createWindow(Window parent, unsigned long mask,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu *menu_new_full(char *label, char *name, Menu *parent,
|
ObMenu *menu_new_full(char *label, char *name, ObMenu *parent,
|
||||||
menu_controller_show show, menu_controller_update update)
|
menu_controller_show show, menu_controller_update update)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes attrib;
|
XSetWindowAttributes attrib;
|
||||||
Menu *self;
|
ObMenu *self;
|
||||||
|
|
||||||
self = g_new0(Menu, 1);
|
self = g_new0(ObMenu, 1);
|
||||||
self->obwin.type = Window_Menu;
|
self->obwin.type = Window_Menu;
|
||||||
self->label = g_strdup(label);
|
self->label = g_strdup(label);
|
||||||
self->name = g_strdup(name);
|
self->name = g_strdup(name);
|
||||||
|
@ -239,11 +239,11 @@ void menu_free(char *name)
|
||||||
g_hash_table_remove(menu_hash, name);
|
g_hash_table_remove(menu_hash, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry *menu_entry_new_full(char *label, Action *action,
|
ObMenuEntry *menu_entry_new_full(char *label, Action *action,
|
||||||
MenuEntryRenderType render_type,
|
ObMenuEntryRenderType render_type,
|
||||||
gpointer submenu)
|
gpointer submenu)
|
||||||
{
|
{
|
||||||
MenuEntry *menu_entry = g_new0(MenuEntry, 1);
|
ObMenuEntry *menu_entry = g_new0(ObMenuEntry, 1);
|
||||||
|
|
||||||
menu_entry->label = g_strdup(label);
|
menu_entry->label = g_strdup(label);
|
||||||
menu_entry->render_type = render_type;
|
menu_entry->render_type = render_type;
|
||||||
|
@ -257,7 +257,7 @@ MenuEntry *menu_entry_new_full(char *label, Action *action,
|
||||||
return menu_entry;
|
return menu_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu)
|
void menu_entry_set_submenu(ObMenuEntry *entry, ObMenu *submenu)
|
||||||
{
|
{
|
||||||
g_assert(entry != NULL);
|
g_assert(entry != NULL);
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu)
|
||||||
entry->parent->invalid = TRUE;
|
entry->parent->invalid = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_add_entry(Menu *menu, MenuEntry *entry)
|
void menu_add_entry(ObMenu *menu, ObMenuEntry *entry)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes attrib;
|
XSetWindowAttributes attrib;
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ void menu_add_entry(Menu *menu, MenuEntry *entry)
|
||||||
|
|
||||||
void menu_show(char *name, int x, int y, ObClient *client)
|
void menu_show(char *name, int x, int y, ObClient *client)
|
||||||
{
|
{
|
||||||
Menu *self;
|
ObMenu *self;
|
||||||
|
|
||||||
self = g_hash_table_lookup(menu_hash, name);
|
self = g_hash_table_lookup(menu_hash, name);
|
||||||
if (!self) {
|
if (!self) {
|
||||||
|
@ -303,7 +303,7 @@ void menu_show(char *name, int x, int y, ObClient *client)
|
||||||
menu_show_full(self, x, y, client);
|
menu_show_full(self, x, y, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_show_full(Menu *self, int x, int y, ObClient *client)
|
void menu_show_full(ObMenu *self, int x, int y, ObClient *client)
|
||||||
{
|
{
|
||||||
g_assert(self != NULL);
|
g_assert(self != NULL);
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ void menu_show_full(Menu *self, int x, int y, ObClient *client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_hide(Menu *self) {
|
void menu_hide(ObMenu *self) {
|
||||||
if (self->shown) {
|
if (self->shown) {
|
||||||
XUnmapWindow(ob_display, self->frame);
|
XUnmapWindow(ob_display, self->frame);
|
||||||
self->shown = FALSE;
|
self->shown = FALSE;
|
||||||
|
@ -343,11 +343,11 @@ void menu_hide(Menu *self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_clear(Menu *self) {
|
void menu_clear(ObMenu *self) {
|
||||||
GList *it;
|
GList *it;
|
||||||
|
|
||||||
for (it = self->entries; it; it = it->next) {
|
for (it = self->entries; it; it = it->next) {
|
||||||
MenuEntry *entry = it->data;
|
ObMenuEntry *entry = it->data;
|
||||||
menu_entry_free(entry);
|
menu_entry_free(entry);
|
||||||
}
|
}
|
||||||
self->entries = NULL;
|
self->entries = NULL;
|
||||||
|
@ -355,19 +355,19 @@ void menu_clear(Menu *self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MenuEntry *menu_find_entry(Menu *menu, Window win)
|
ObMenuEntry *menu_find_entry(ObMenu *menu, Window win)
|
||||||
{
|
{
|
||||||
GList *it;
|
GList *it;
|
||||||
|
|
||||||
for (it = menu->entries; it; it = it->next) {
|
for (it = menu->entries; it; it = it->next) {
|
||||||
MenuEntry *entry = it->data;
|
ObMenuEntry *entry = it->data;
|
||||||
if (entry->item == win)
|
if (entry->item == win)
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuEntry *menu_find_entry_by_pos(Menu *menu, int x, int y)
|
ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y)
|
||||||
{
|
{
|
||||||
if (x < 0 || x >= menu->size.width || y < 0 || y >= menu->size.height)
|
if (x < 0 || x >= menu->size.width || y < 0 || y >= menu->size.height)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -379,9 +379,9 @@ MenuEntry *menu_find_entry_by_pos(Menu *menu, int x, int y)
|
||||||
return g_list_nth_data(menu->entries, y / menu->item_h);
|
return g_list_nth_data(menu->entries, y / menu->item_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_entry_fire(MenuEntry *self)
|
void menu_entry_fire(ObMenuEntry *self)
|
||||||
{
|
{
|
||||||
Menu *m;
|
ObMenu *m;
|
||||||
|
|
||||||
if (self->action) {
|
if (self->action) {
|
||||||
self->action->data.any.c = self->parent->client;
|
self->action->data.any.c = self->parent->client;
|
||||||
|
@ -398,7 +398,7 @@ void menu_entry_fire(MenuEntry *self)
|
||||||
Default menu controller action for showing.
|
Default menu controller action for showing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void menu_control_show(Menu *self, int x, int y, ObClient *client) {
|
void menu_control_show(ObMenu *self, int x, int y, ObClient *client) {
|
||||||
guint i;
|
guint i;
|
||||||
Rect *a = NULL;
|
Rect *a = NULL;
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ void menu_control_show(Menu *self, int x, int y, ObClient *client) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_control_mouseover(MenuEntry *self, gboolean enter) {
|
void menu_control_mouseover(ObMenuEntry *self, gboolean enter) {
|
||||||
int x;
|
int x;
|
||||||
Rect *a;
|
Rect *a;
|
||||||
|
|
||||||
|
|
103
openbox/menu.h
103
openbox/menu.h
|
@ -10,32 +10,32 @@
|
||||||
|
|
||||||
struct _ObClient;
|
struct _ObClient;
|
||||||
|
|
||||||
struct Menu;
|
typedef struct _ObMenu ObMenu;
|
||||||
struct MenuEntry;
|
typedef struct _ObMenuEntry ObMenuEntry;
|
||||||
|
|
||||||
typedef void(*menu_controller_show)(struct Menu *self,
|
typedef void(*menu_controller_show)(ObMenu *self, int x, int y,
|
||||||
int x, int y, struct _ObClient *);
|
struct _ObClient *);
|
||||||
typedef void(*menu_controller_update)(struct Menu *self);
|
typedef void(*menu_controller_update)(ObMenu *self);
|
||||||
typedef void(*menu_controller_mouseover)(struct MenuEntry *self,
|
typedef void(*menu_controller_mouseover)(ObMenuEntry *self, gboolean enter);
|
||||||
gboolean enter);
|
|
||||||
|
|
||||||
extern GHashTable *menu_hash;
|
extern GHashTable *menu_hash;
|
||||||
extern GSList *menu_visible;
|
extern GSList *menu_visible;
|
||||||
|
|
||||||
typedef struct Menu {
|
struct _ObMenu
|
||||||
|
{
|
||||||
ObWindow obwin;
|
ObWindow obwin;
|
||||||
|
|
||||||
char *label;
|
gchar *label;
|
||||||
char *name;
|
gchar *name;
|
||||||
|
|
||||||
GList *entries;
|
GList *entries;
|
||||||
|
|
||||||
gboolean shown;
|
gboolean shown;
|
||||||
gboolean invalid;
|
gboolean invalid;
|
||||||
|
|
||||||
struct Menu *parent;
|
ObMenu *parent;
|
||||||
|
|
||||||
struct Menu *open_submenu;
|
ObMenu *open_submenu;
|
||||||
|
|
||||||
/* place a menu on screen */
|
/* place a menu on screen */
|
||||||
menu_controller_show show;
|
menu_controller_show show;
|
||||||
|
@ -52,11 +52,11 @@ typedef struct Menu {
|
||||||
Window frame;
|
Window frame;
|
||||||
Window title;
|
Window title;
|
||||||
RrAppearance *a_title;
|
RrAppearance *a_title;
|
||||||
int title_min_w, title_h;
|
gint title_min_w, title_h;
|
||||||
Window items;
|
Window items;
|
||||||
RrAppearance *a_items;
|
RrAppearance *a_items;
|
||||||
int bullet_w;
|
gint bullet_w;
|
||||||
int item_h;
|
gint item_h;
|
||||||
Point location;
|
Point location;
|
||||||
Size size;
|
Size size;
|
||||||
guint xin_area; /* index of the xinerama head/area */
|
guint xin_area; /* index of the xinerama head/area */
|
||||||
|
@ -64,38 +64,39 @@ typedef struct Menu {
|
||||||
/* plugin stuff */
|
/* plugin stuff */
|
||||||
char *plugin;
|
char *plugin;
|
||||||
void *plugin_data;
|
void *plugin_data;
|
||||||
} Menu;
|
};
|
||||||
|
|
||||||
typedef enum MenuEntryRenderType {
|
typedef enum
|
||||||
MenuEntryRenderType_None = 0,
|
{
|
||||||
MenuEntryRenderType_Submenu = 1 << 0,
|
OB_MENU_ENTRY_RENDER_TYPE_NONE,
|
||||||
MenuEntryRenderType_Boolean = 1 << 1,
|
OB_MENU_ENTRY_RENDER_TYPE_SUBMENU,
|
||||||
MenuEntryRenderType_Separator = 1 << 2,
|
OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN,
|
||||||
|
OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR,
|
||||||
|
OB_MENU_ENTRY_RENDER_TYPE_OTHER /* XXX what is this? */
|
||||||
|
} ObMenuEntryRenderType;
|
||||||
|
|
||||||
MenuEntryRenderType_Other = 1 << 7
|
struct _ObMenuEntry
|
||||||
} MenuEntryRenderType;
|
{
|
||||||
|
|
||||||
typedef struct MenuEntry {
|
|
||||||
char *label;
|
char *label;
|
||||||
Menu *parent;
|
ObMenu *parent;
|
||||||
|
|
||||||
Action *action;
|
Action *action;
|
||||||
|
|
||||||
MenuEntryRenderType render_type;
|
ObMenuEntryRenderType render_type;
|
||||||
gboolean hilite;
|
gboolean hilite;
|
||||||
gboolean enabled;
|
gboolean enabled;
|
||||||
gboolean boolean_value;
|
gboolean boolean_value;
|
||||||
|
|
||||||
Menu *submenu;
|
ObMenu *submenu;
|
||||||
|
|
||||||
/* render stuff */
|
/* render stuff */
|
||||||
Window item;
|
Window item;
|
||||||
RrAppearance *a_item;
|
RrAppearance *a_item;
|
||||||
RrAppearance *a_disabled;
|
RrAppearance *a_disabled;
|
||||||
RrAppearance *a_hilite;
|
RrAppearance *a_hilite;
|
||||||
int y;
|
gint y;
|
||||||
int min_w;
|
gint min_w;
|
||||||
} MenuEntry;
|
};
|
||||||
|
|
||||||
void menu_startup();
|
void menu_startup();
|
||||||
void menu_shutdown();
|
void menu_shutdown();
|
||||||
|
@ -103,48 +104,48 @@ void menu_shutdown();
|
||||||
#define menu_new(l, n, p) \
|
#define menu_new(l, n, p) \
|
||||||
menu_new_full(l, n, p, NULL, NULL)
|
menu_new_full(l, n, p, NULL, NULL)
|
||||||
|
|
||||||
Menu *menu_new_full(char *label, char *name, Menu *parent,
|
ObMenu *menu_new_full(char *label, char *name, ObMenu *parent,
|
||||||
menu_controller_show show, menu_controller_update update);
|
menu_controller_show show, menu_controller_update update);
|
||||||
void menu_free(char *name);
|
void menu_free(char *name);
|
||||||
|
|
||||||
void menu_show(char *name, int x, int y, struct _ObClient *client);
|
void menu_show(char *name, int x, int y, struct _ObClient *client);
|
||||||
void menu_show_full(Menu *menu, int x, int y, struct _ObClient *client);
|
void menu_show_full(ObMenu *menu, int x, int y, struct _ObClient *client);
|
||||||
|
|
||||||
void menu_hide(Menu *self);
|
void menu_hide(ObMenu *self);
|
||||||
|
|
||||||
void menu_clear(Menu *self);
|
void menu_clear(ObMenu *self);
|
||||||
|
|
||||||
MenuEntry *menu_entry_new_full(char *label, Action *action,
|
ObMenuEntry *menu_entry_new_full(char *label, Action *action,
|
||||||
MenuEntryRenderType render_type,
|
ObMenuEntryRenderType render_type,
|
||||||
gpointer submenu);
|
gpointer submenu);
|
||||||
|
|
||||||
#define menu_entry_new(label, action) \
|
#define menu_entry_new(label, action) \
|
||||||
menu_entry_new_full(label, action, MenuEntryRenderType_None, NULL)
|
menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL)
|
||||||
|
|
||||||
#define menu_entry_new_separator(label) \
|
#define menu_entry_new_separator(label) \
|
||||||
menu_entry_new_full(label, NULL, MenuEntryRenderType_Separator, NULL)
|
menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL)
|
||||||
|
|
||||||
#define menu_entry_new_submenu(label, submenu) \
|
#define menu_entry_new_submenu(label, submenu) \
|
||||||
menu_entry_new_full(label, NULL, MenuEntryRenderType_Submenu, submenu)
|
menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu)
|
||||||
|
|
||||||
#define menu_entry_new_boolean(label, action) \
|
#define menu_entry_new_boolean(label, action) \
|
||||||
menu_entry_new_full(label, action, MenuEntryRenderType_Boolean, NULL)
|
menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL)
|
||||||
|
|
||||||
void menu_entry_free(MenuEntry *entry);
|
void menu_entry_free(ObMenuEntry *entry);
|
||||||
|
|
||||||
void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu);
|
void menu_entry_set_submenu(ObMenuEntry *entry, ObMenu *submenu);
|
||||||
|
|
||||||
void menu_add_entry(Menu *menu, MenuEntry *entry);
|
void menu_add_entry(ObMenu *menu, ObMenuEntry *entry);
|
||||||
|
|
||||||
MenuEntry *menu_find_entry(Menu *menu, Window win);
|
ObMenuEntry *menu_find_entry(ObMenu *menu, Window win);
|
||||||
MenuEntry *menu_find_entry_by_pos(Menu *menu, int x, int y);
|
ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y);
|
||||||
|
|
||||||
void menu_entry_render(MenuEntry *self);
|
void menu_entry_render(ObMenuEntry *self);
|
||||||
|
|
||||||
void menu_entry_fire(MenuEntry *self);
|
void menu_entry_fire(ObMenuEntry *self);
|
||||||
|
|
||||||
void menu_render(Menu *self);
|
void menu_render(ObMenu *self);
|
||||||
void menu_render_full(Menu *self);
|
void menu_render_full(ObMenu *self);
|
||||||
|
|
||||||
void menu_control_mouseover(MenuEntry *entry, gboolean enter);
|
void menu_control_mouseover(ObMenuEntry *entry, gboolean enter);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#include "openbox.h"
|
#include "openbox.h"
|
||||||
#include "render/theme.h"
|
#include "render/theme.h"
|
||||||
|
|
||||||
void menu_render_full(Menu *self);
|
void menu_render_full(ObMenu *self);
|
||||||
|
|
||||||
void menu_render(Menu *self) {
|
void menu_render(ObMenu *self) {
|
||||||
if (self->update) {
|
if (self->update) {
|
||||||
self->update(self);
|
self->update(self);
|
||||||
} else if (self->invalid) {
|
} else if (self->invalid) {
|
||||||
|
@ -14,7 +14,7 @@ void menu_render(Menu *self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_render_full(Menu *self) {
|
void menu_render_full(ObMenu *self) {
|
||||||
GList *it;
|
GList *it;
|
||||||
int items_h = 0;
|
int items_h = 0;
|
||||||
int nitems = 0; /* each item, only one is used */
|
int nitems = 0; /* each item, only one is used */
|
||||||
|
@ -47,7 +47,7 @@ void menu_render_full(Menu *self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (it = self->entries; it; it = it->next) {
|
for (it = self->entries; it; it = it->next) {
|
||||||
MenuEntry *e = it->data;
|
ObMenuEntry *e = it->data;
|
||||||
int h;
|
int h;
|
||||||
|
|
||||||
if (e->a_item == NULL) {
|
if (e->a_item == NULL) {
|
||||||
|
@ -95,7 +95,7 @@ void menu_render_full(Menu *self) {
|
||||||
|
|
||||||
item_y = 0;
|
item_y = 0;
|
||||||
for (it = self->entries; it; it = it->next) {
|
for (it = self->entries; it; it = it->next) {
|
||||||
((MenuEntry*)it->data)->y = item_y;
|
((ObMenuEntry*)it->data)->y = item_y;
|
||||||
menu_entry_render(it->data);
|
menu_entry_render(it->data);
|
||||||
item_y += self->item_h;
|
item_y += self->item_h;
|
||||||
}
|
}
|
||||||
|
@ -103,24 +103,24 @@ void menu_render_full(Menu *self) {
|
||||||
self->invalid = FALSE;
|
self->invalid = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_entry_render(MenuEntry *self)
|
void menu_entry_render(ObMenuEntry *self)
|
||||||
{
|
{
|
||||||
Menu *menu = self->parent;
|
ObMenu *menu = self->parent;
|
||||||
RrAppearance *a;
|
RrAppearance *a;
|
||||||
|
|
||||||
switch (self->render_type) {
|
switch (self->render_type) {
|
||||||
case MenuEntryRenderType_Submenu:
|
case OB_MENU_ENTRY_RENDER_TYPE_SUBMENU:
|
||||||
/* TODO: submenu mask */
|
/* TODO: submenu mask */
|
||||||
case MenuEntryRenderType_Boolean:
|
case OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN:
|
||||||
/* TODO: boolean check */
|
/* TODO: boolean check */
|
||||||
a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item)
|
a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item)
|
||||||
: self->a_disabled;
|
: self->a_disabled;
|
||||||
break;
|
break;
|
||||||
case MenuEntryRenderType_None:
|
case OB_MENU_ENTRY_RENDER_TYPE_NONE:
|
||||||
a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item )
|
a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item )
|
||||||
: self->a_disabled;
|
: self->a_disabled;
|
||||||
break;
|
break;
|
||||||
case MenuEntryRenderType_Separator:
|
case OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR:
|
||||||
a = self->a_item;
|
a = self->a_item;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -128,7 +128,8 @@ void menu_entry_render(MenuEntry *self)
|
||||||
g_message("unhandled render_type");
|
g_message("unhandled render_type");
|
||||||
a = !self->enabled ? self->a_disabled :
|
a = !self->enabled ? self->a_disabled :
|
||||||
(self->hilite &&
|
(self->hilite &&
|
||||||
(self->action || self->render_type == MenuEntryRenderType_Submenu) ?
|
(self->action ||
|
||||||
|
self->render_type == OB_MENU_ENTRY_RENDER_TYPE_SUBMENU) ?
|
||||||
self->a_hilite : self->a_item);
|
self->a_hilite : self->a_item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ Window window_top(ObWindow *self)
|
||||||
{
|
{
|
||||||
switch (self->type) {
|
switch (self->type) {
|
||||||
case Window_Menu:
|
case Window_Menu:
|
||||||
return ((Menu*)self)->frame;
|
return ((ObMenu*)self)->frame;
|
||||||
case Window_Dock:
|
case Window_Dock:
|
||||||
return ((ObDock*)self)->frame;
|
return ((ObDock*)self)->frame;
|
||||||
case Window_DockApp:
|
case Window_DockApp:
|
||||||
|
|
|
@ -33,12 +33,12 @@ typedef struct InternalWindow {
|
||||||
#define WINDOW_IS_CLIENT(win) (((ObWindow*)win)->type == Window_Client)
|
#define WINDOW_IS_CLIENT(win) (((ObWindow*)win)->type == Window_Client)
|
||||||
#define WINDOW_IS_INTERNAL(win) (((ObWindow*)win)->type == Window_Internal)
|
#define WINDOW_IS_INTERNAL(win) (((ObWindow*)win)->type == Window_Internal)
|
||||||
|
|
||||||
struct Menu;
|
struct _ObMenu;
|
||||||
struct _ObDock;
|
struct _ObDock;
|
||||||
struct _ObDockApp;
|
struct _ObDockApp;
|
||||||
struct _ObClient;
|
struct _ObClient;
|
||||||
|
|
||||||
#define WINDOW_AS_MENU(win) ((struct Menu*)win)
|
#define WINDOW_AS_MENU(win) ((struct _ObMenu*)win)
|
||||||
#define WINDOW_AS_DOCK(win) ((struct _ObDock*)win)
|
#define WINDOW_AS_DOCK(win) ((struct _ObDock*)win)
|
||||||
#define WINDOW_AS_DOCKAPP(win) ((struct _ObDockApp*)win)
|
#define WINDOW_AS_DOCKAPP(win) ((struct _ObDockApp*)win)
|
||||||
#define WINDOW_AS_CLIENT(win) ((struct _ObClient*)win)
|
#define WINDOW_AS_CLIENT(win) ((struct _ObClient*)win)
|
||||||
|
|
|
@ -13,20 +13,20 @@
|
||||||
static char *PLUGIN_NAME = "client_menu";
|
static char *PLUGIN_NAME = "client_menu";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Menu *send_to_menu;
|
static ObMenu *send_to_menu;
|
||||||
static Menu *layer_menu;
|
static ObMenu *layer_menu;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gint foo;
|
gint foo;
|
||||||
} Client_Menu_Data;
|
} Client_Menu_Data;
|
||||||
|
|
||||||
#define CLIENT_MENU(m) ((Menu *)m)
|
#define CLIENT_MENU(m) ((ObMenu *)m)
|
||||||
#define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((Menu *)m)->plugin_data)
|
#define CLIENT_MENU_DATA(m) ((Client_Menu_Data *)((ObMenu *)m)->plugin_data)
|
||||||
|
|
||||||
void client_menu_clean_up(Menu *m) {
|
void client_menu_clean_up(ObMenu *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_send_to_update(Menu *self)
|
void client_send_to_update(ObMenu *self)
|
||||||
{
|
{
|
||||||
guint i = 0;
|
guint i = 0;
|
||||||
GList *it = self->entries;
|
GList *it = self->entries;
|
||||||
|
@ -36,7 +36,7 @@ void client_send_to_update(Menu *self)
|
||||||
if (i >= screen_num_desktops)
|
if (i >= screen_num_desktops)
|
||||||
break;
|
break;
|
||||||
if (strcmp(screen_desktop_names[i],
|
if (strcmp(screen_desktop_names[i],
|
||||||
((MenuEntry *)it->data)->label) != 0)
|
((ObMenuEntry *)it->data)->label) != 0)
|
||||||
break;
|
break;
|
||||||
++i;
|
++i;
|
||||||
it = it->next;
|
it = it->next;
|
||||||
|
@ -46,7 +46,7 @@ void client_send_to_update(Menu *self)
|
||||||
menu_clear(self);
|
menu_clear(self);
|
||||||
g_message("update");
|
g_message("update");
|
||||||
for (i = 0; i < screen_num_desktops; ++i) {
|
for (i = 0; i < screen_num_desktops; ++i) {
|
||||||
MenuEntry *e;
|
ObMenuEntry *e;
|
||||||
Action *a = action_from_string("sendtodesktop");
|
Action *a = action_from_string("sendtodesktop");
|
||||||
a->data.sendto.desk = i;
|
a->data.sendto.desk = i;
|
||||||
a->data.sendto.follow = FALSE;
|
a->data.sendto.follow = FALSE;
|
||||||
|
@ -59,7 +59,7 @@ void client_send_to_update(Menu *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void client_menu_show(Menu *self, int x, int y, Client *client)
|
void client_menu_show(ObMenu *self, int x, int y, Client *client)
|
||||||
{
|
{
|
||||||
int newy;
|
int newy;
|
||||||
g_assert(!self->invalid);
|
g_assert(!self->invalid);
|
||||||
|
@ -91,13 +91,13 @@ void plugin_setup_config() { }
|
||||||
|
|
||||||
void plugin_shutdown() { }
|
void plugin_shutdown() { }
|
||||||
|
|
||||||
void plugin_destroy (Menu *m)
|
void plugin_destroy (ObMenu *m)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void *plugin_create() /* TODO: need config */
|
void *plugin_create() /* TODO: need config */
|
||||||
{
|
{
|
||||||
Menu *m = menu_new_full(NULL, "client-menu", NULL,
|
ObMenu *m = menu_new_full(NULL, "client-menu", NULL,
|
||||||
/*client_menu_show*/NULL, NULL);
|
/*client_menu_show*/NULL, NULL);
|
||||||
menu_add_entry(m, menu_entry_new_submenu("Send To Workspace",
|
menu_add_entry(m, menu_entry_new_submenu("Send To Workspace",
|
||||||
send_to_menu));
|
send_to_menu));
|
||||||
|
@ -136,8 +136,8 @@ void *plugin_create() /* TODO: need config */
|
||||||
|
|
||||||
void plugin_startup()
|
void plugin_startup()
|
||||||
{
|
{
|
||||||
Menu *t;
|
ObMenu *t;
|
||||||
/* create a Send To Workspace Menu */
|
/* create a Send To Workspace ObMenu */
|
||||||
send_to_menu = menu_new_full(NULL, "send-to-workspace",
|
send_to_menu = menu_new_full(NULL, "send-to-workspace",
|
||||||
NULL, NULL, client_send_to_update);
|
NULL, NULL, client_send_to_update);
|
||||||
|
|
||||||
|
@ -149,6 +149,6 @@ void plugin_startup()
|
||||||
menu_add_entry(layer_menu, menu_entry_new("Bottom Layer",
|
menu_add_entry(layer_menu, menu_entry_new("Bottom Layer",
|
||||||
action_from_string("sendtobottomlayer")));
|
action_from_string("sendtobottomlayer")));
|
||||||
|
|
||||||
t = (Menu *)plugin_create("client_menu");
|
t = (ObMenu *)plugin_create("client_menu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ typedef struct Fifo_Menu_Data{
|
||||||
event_fd_handler *handler;
|
event_fd_handler *handler;
|
||||||
} Fifo_Menu_Data;
|
} Fifo_Menu_Data;
|
||||||
|
|
||||||
#define FIFO_MENU(m) ((Menu *)m)
|
#define FIFO_MENU(m) ((ObMenu *)m)
|
||||||
#define FIFO_MENU_DATA(m) ((Fifo_Menu_Data *)((Menu *)m)->plugin_data)
|
#define FIFO_MENU_DATA(m) ((Fifo_Menu_Data *)((ObMenu *)m)->plugin_data)
|
||||||
|
|
||||||
|
|
||||||
void fifo_menu_clean_up(Menu *m) {
|
void fifo_menu_clean_up(ObMenu *m) {
|
||||||
if (FIFO_MENU_DATA(m)->buf != NULL) {
|
if (FIFO_MENU_DATA(m)->buf != NULL) {
|
||||||
g_free(FIFO_MENU_DATA(m)->buf);
|
g_free(FIFO_MENU_DATA(m)->buf);
|
||||||
FIFO_MENU_DATA(m)->buf = NULL;
|
FIFO_MENU_DATA(m)->buf = NULL;
|
||||||
|
@ -43,7 +43,7 @@ void plugin_startup()
|
||||||
void plugin_shutdown() { }
|
void plugin_shutdown() { }
|
||||||
|
|
||||||
void fifo_menu_handler(int fd, void *d) {
|
void fifo_menu_handler(int fd, void *d) {
|
||||||
Menu *menu = d;
|
ObMenu *menu = d;
|
||||||
char *tmpbuf = NULL;
|
char *tmpbuf = NULL;
|
||||||
unsigned long num_read;
|
unsigned long num_read;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -116,7 +116,7 @@ void fifo_menu_handler(int fd, void *d) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void plugin_destroy (Menu *m)
|
void plugin_destroy (ObMenu *m)
|
||||||
{
|
{
|
||||||
fifo_menu_clean_up(m);
|
fifo_menu_clean_up(m);
|
||||||
if (FIFO_MENU_DATA(m)->handler != NULL) {
|
if (FIFO_MENU_DATA(m)->handler != NULL) {
|
||||||
|
@ -141,7 +141,7 @@ void *plugin_create() /* TODO: need config */
|
||||||
event_fd_handler *h;
|
event_fd_handler *h;
|
||||||
|
|
||||||
Fifo_Menu_Data *d = g_new(Fifo_Menu_Data, 1);
|
Fifo_Menu_Data *d = g_new(Fifo_Menu_Data, 1);
|
||||||
Menu *m = menu_new("", PLUGIN_NAME, NULL);
|
ObMenu *m = menu_new("", PLUGIN_NAME, NULL);
|
||||||
|
|
||||||
d->fd = -1;
|
d->fd = -1;
|
||||||
d->buf = NULL;
|
d->buf = NULL;
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "kernel/action.h"
|
#include "kernel/action.h"
|
||||||
#include "kernel/event.h"
|
#include "kernel/event.h"
|
||||||
|
|
||||||
#define TIMED_MENU(m) ((Menu *)m)
|
#define TIMED_MENU(m) ((ObMenu *)m)
|
||||||
#define TIMED_MENU_DATA(m) ((Timed_Menu_Data *)((Menu *)m)->plugin_data)
|
#define TIMED_MENU_DATA(m) ((Timed_Menu_Data *)((ObMenu *)m)->plugin_data)
|
||||||
static char *PLUGIN_NAME = "timed_menu";
|
static char *PLUGIN_NAME = "timed_menu";
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -41,7 +41,7 @@ void plugin_startup()
|
||||||
{ }
|
{ }
|
||||||
void plugin_shutdown() { }
|
void plugin_shutdown() { }
|
||||||
|
|
||||||
void timed_menu_clean_up(Menu *m) {
|
void timed_menu_clean_up(ObMenu *m) {
|
||||||
if (TIMED_MENU_DATA(m)->buf != NULL) {
|
if (TIMED_MENU_DATA(m)->buf != NULL) {
|
||||||
fprintf(stderr, "%s", TIMED_MENU_DATA(m)->buf);
|
fprintf(stderr, "%s", TIMED_MENU_DATA(m)->buf);
|
||||||
g_free(TIMED_MENU_DATA(m)->buf);
|
g_free(TIMED_MENU_DATA(m)->buf);
|
||||||
|
@ -66,7 +66,7 @@ void timed_menu_clean_up(Menu *m) {
|
||||||
|
|
||||||
void timed_menu_read_pipe(int fd, void *d)
|
void timed_menu_read_pipe(int fd, void *d)
|
||||||
{
|
{
|
||||||
Menu *menu = d;
|
ObMenu *menu = d;
|
||||||
char *tmpbuf = NULL;
|
char *tmpbuf = NULL;
|
||||||
unsigned long num_read;
|
unsigned long num_read;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -125,7 +125,7 @@ void timed_menu_read_pipe(int fd, void *d)
|
||||||
|
|
||||||
void timed_menu_timeout_handler(void *d)
|
void timed_menu_timeout_handler(void *d)
|
||||||
{
|
{
|
||||||
Menu *data = d;
|
ObMenu *data = d;
|
||||||
if (!data->shown && TIMED_MENU_DATA(data)->fd == -1) {
|
if (!data->shown && TIMED_MENU_DATA(data)->fd == -1) {
|
||||||
switch (TIMED_MENU_DATA(data)->type) {
|
switch (TIMED_MENU_DATA(data)->type) {
|
||||||
case (TIMED_MENU_PIPE): {
|
case (TIMED_MENU_PIPE): {
|
||||||
|
@ -187,7 +187,7 @@ void timed_menu_timeout_handler(void *d)
|
||||||
void *plugin_create()
|
void *plugin_create()
|
||||||
{
|
{
|
||||||
Timed_Menu_Data *d = g_new(Timed_Menu_Data, 1);
|
Timed_Menu_Data *d = g_new(Timed_Menu_Data, 1);
|
||||||
Menu *m = menu_new("", PLUGIN_NAME, NULL);
|
ObMenu *m = menu_new("", PLUGIN_NAME, NULL);
|
||||||
|
|
||||||
m->plugin = PLUGIN_NAME;
|
m->plugin = PLUGIN_NAME;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue