all repos — openbox @ 588aa0790abd0bf6452843c0e3490482e90b3654

openbox fork - make it a bit more like ryudo

Allow setting icons for submenus
Mikael Magnusson mikachu@gmail.com
commit

588aa0790abd0bf6452843c0e3490482e90b3654

parent

6ad5f085fa5a38ab8373769cac5cd52839d0a7a5

3 files changed, 32 insertions(+), 9 deletions(-)

jump to
M openbox/menu.copenbox/menu.c

@@ -326,6 +326,8 @@ {

ObMenuParseState *state = data; gchar *name = NULL, *title = NULL, *script = NULL; ObMenu *menu; + ObMenuEntry *e; + gchar *icon; if (!obt_xml_attr_string(node, "id", &name)) goto parse_menu_fail;

@@ -349,8 +351,20 @@ }

} } - if (state->parent) - menu_add_submenu(state->parent, -1, name); + if (state->parent) { + e = menu_add_submenu(state->parent, -1, name); + + if (config_menu_show_icons && + obt_xml_attr_string(node, "icon", &icon)) + { + e->data.submenu.icon = RrImageNewFromName(ob_rr_icons, icon); + + if (e->data.submenu.icon) + e->data.submenu.icon_alpha = 0xff; + + g_free(icon); + } + } parse_menu_fail: g_free(name);

@@ -534,6 +548,7 @@ self->data.normal.actions);

} break; case OB_MENU_ENTRY_TYPE_SUBMENU: + RrImageUnref(self->data.submenu.icon); g_free(self->data.submenu.name); break; case OB_MENU_ENTRY_TYPE_SEPARATOR:
M openbox/menu.hopenbox/menu.h

@@ -103,6 +103,10 @@ OB_MENU_ENTRY_TYPE_SEPARATOR

} ObMenuEntryType; struct _ObNormalMenuEntry { + /* Icon stuff. If you set this, make sure you RrImageRef() it too. */ + RrImage *icon; + gint icon_alpha; + gchar *label; /*! The shortcut key that would be used to activate this menu entry */ gunichar shortcut;

@@ -117,10 +121,6 @@

/* List of ObActions */ GSList *actions; - /* Icon stuff. If you set this, make sure you RrImageRef() it too. */ - RrImage *icon; - gint icon_alpha; - /* Mask icon */ RrPixmapMask *mask; RrColor *mask_normal_color;

@@ -132,8 +132,13 @@ gpointer data;

}; struct _ObSubmenuMenuEntry { + /* Icon stuff. If you set this, make sure you RrImageRef() it too. */ + RrImage *icon; + gint icon_alpha; + gchar *name; ObMenu *submenu; + guint show_from; };
M openbox/menuframe.copenbox/menuframe.c

@@ -181,7 +181,8 @@ self->window = createWindow(self->frame->window, CWEventMask, &attr);

self->text = createWindow(self->window, 0, NULL); g_hash_table_insert(menu_frame_map, &self->window, self); g_hash_table_insert(menu_frame_map, &self->text, self); - if (entry->type == OB_MENU_ENTRY_TYPE_NORMAL) { + if ((entry->type == OB_MENU_ENTRY_TYPE_NORMAL) || + (entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)) { self->icon = createWindow(self->window, 0, NULL); g_hash_table_insert(menu_frame_map, &self->icon, self); }

@@ -209,7 +210,8 @@ XDestroyWindow(obt_display, self->text);

XDestroyWindow(obt_display, self->window); g_hash_table_remove(menu_frame_map, &self->text); g_hash_table_remove(menu_frame_map, &self->window); - if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) { + if ((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) || + (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)) { XDestroyWindow(obt_display, self->icon); g_hash_table_remove(menu_frame_map, &self->icon); }

@@ -522,7 +524,8 @@ default:

g_assert_not_reached(); } - if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && + if (((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) || + (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)) && self->entry->data.normal.icon) { RrAppearance *clear;