Allow setting icons for submenus
This commit is contained in:
parent
6ad5f085fa
commit
588aa0790a
3 changed files with 32 additions and 9 deletions
|
@ -326,6 +326,8 @@ static void parse_menu(xmlNodePtr node, gpointer data)
|
||||||
ObMenuParseState *state = data;
|
ObMenuParseState *state = data;
|
||||||
gchar *name = NULL, *title = NULL, *script = NULL;
|
gchar *name = NULL, *title = NULL, *script = NULL;
|
||||||
ObMenu *menu;
|
ObMenu *menu;
|
||||||
|
ObMenuEntry *e;
|
||||||
|
gchar *icon;
|
||||||
|
|
||||||
if (!obt_xml_attr_string(node, "id", &name))
|
if (!obt_xml_attr_string(node, "id", &name))
|
||||||
goto parse_menu_fail;
|
goto parse_menu_fail;
|
||||||
|
@ -349,8 +351,20 @@ static void parse_menu(xmlNodePtr node, gpointer data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->parent)
|
if (state->parent) {
|
||||||
menu_add_submenu(state->parent, -1, name);
|
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:
|
parse_menu_fail:
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
@ -534,6 +548,7 @@ void menu_entry_unref(ObMenuEntry *self)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OB_MENU_ENTRY_TYPE_SUBMENU:
|
case OB_MENU_ENTRY_TYPE_SUBMENU:
|
||||||
|
RrImageUnref(self->data.submenu.icon);
|
||||||
g_free(self->data.submenu.name);
|
g_free(self->data.submenu.name);
|
||||||
break;
|
break;
|
||||||
case OB_MENU_ENTRY_TYPE_SEPARATOR:
|
case OB_MENU_ENTRY_TYPE_SEPARATOR:
|
||||||
|
|
|
@ -103,6 +103,10 @@ typedef enum
|
||||||
} ObMenuEntryType;
|
} ObMenuEntryType;
|
||||||
|
|
||||||
struct _ObNormalMenuEntry {
|
struct _ObNormalMenuEntry {
|
||||||
|
/* Icon stuff. If you set this, make sure you RrImageRef() it too. */
|
||||||
|
RrImage *icon;
|
||||||
|
gint icon_alpha;
|
||||||
|
|
||||||
gchar *label;
|
gchar *label;
|
||||||
/*! The shortcut key that would be used to activate this menu entry */
|
/*! The shortcut key that would be used to activate this menu entry */
|
||||||
gunichar shortcut;
|
gunichar shortcut;
|
||||||
|
@ -117,10 +121,6 @@ struct _ObNormalMenuEntry {
|
||||||
/* List of ObActions */
|
/* List of ObActions */
|
||||||
GSList *actions;
|
GSList *actions;
|
||||||
|
|
||||||
/* Icon stuff. If you set this, make sure you RrImageRef() it too. */
|
|
||||||
RrImage *icon;
|
|
||||||
gint icon_alpha;
|
|
||||||
|
|
||||||
/* Mask icon */
|
/* Mask icon */
|
||||||
RrPixmapMask *mask;
|
RrPixmapMask *mask;
|
||||||
RrColor *mask_normal_color;
|
RrColor *mask_normal_color;
|
||||||
|
@ -132,8 +132,13 @@ struct _ObNormalMenuEntry {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ObSubmenuMenuEntry {
|
struct _ObSubmenuMenuEntry {
|
||||||
|
/* Icon stuff. If you set this, make sure you RrImageRef() it too. */
|
||||||
|
RrImage *icon;
|
||||||
|
gint icon_alpha;
|
||||||
|
|
||||||
gchar *name;
|
gchar *name;
|
||||||
ObMenu *submenu;
|
ObMenu *submenu;
|
||||||
|
|
||||||
guint show_from;
|
guint show_from;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,8 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
|
||||||
self->text = createWindow(self->window, 0, NULL);
|
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->window, self);
|
||||||
g_hash_table_insert(menu_frame_map, &self->text, 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);
|
self->icon = createWindow(self->window, 0, NULL);
|
||||||
g_hash_table_insert(menu_frame_map, &self->icon, self);
|
g_hash_table_insert(menu_frame_map, &self->icon, self);
|
||||||
}
|
}
|
||||||
|
@ -209,7 +210,8 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
|
||||||
XDestroyWindow(obt_display, self->window);
|
XDestroyWindow(obt_display, self->window);
|
||||||
g_hash_table_remove(menu_frame_map, &self->text);
|
g_hash_table_remove(menu_frame_map, &self->text);
|
||||||
g_hash_table_remove(menu_frame_map, &self->window);
|
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);
|
XDestroyWindow(obt_display, self->icon);
|
||||||
g_hash_table_remove(menu_frame_map, &self->icon);
|
g_hash_table_remove(menu_frame_map, &self->icon);
|
||||||
}
|
}
|
||||||
|
@ -522,7 +524,8 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
|
||||||
g_assert_not_reached();
|
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)
|
self->entry->data.normal.icon)
|
||||||
{
|
{
|
||||||
RrAppearance *clear;
|
RrAppearance *clear;
|
||||||
|
|
Loading…
Reference in a new issue