From 0352abfa88892bc17bdff2022745e3c1b312edd0 Mon Sep 17 00:00:00 2001 From: Kadlcik Libor Date: Tue, 25 Mar 2008 21:58:12 +0100 Subject: This patch implements support for icons in user-defined menus into Openbox Image loading is done using the Imlib2 library. I chose Imlib2 because it's pretty fast, it's easy to use, supports many file formats (tested xpm, gif, jpeg, png) and doesn't introduce too much bloat (it depends :)). I ported the patch to 3.4.7-pre3 and added some enhancements. Caching is much better now, and icons can be disabled at compile time using --disable-imlib2 option. What's new? Syntax of configuration files (namely rc.xml and menu.xml) has been changed slightly to allow users to associate icons to menu entries. This is done by specifying path to icon file in the new "icon" attribute in "" element, e.g: x-terminal-emulator -T Vim -e vim If user doesn't want to display any icons in his user-defined menus, he/she can disable icons in rc.xml, inside "" section: ... no ... Default value is "yes". (New boolean variable "config_menu_user_show_icons" has been added to source code.) An icon is loaded (using menu_item_attach_icon()) when a new entry of menu is created. Fortunately, I haven't notice any performance problems because of this :). --- openbox/config.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'openbox/config.c') diff --git a/openbox/config.c b/openbox/config.c index 0241e3f4..304079c9 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -96,6 +96,7 @@ guint config_submenu_show_delay; guint config_submenu_hide_delay; gboolean config_menu_client_list_icons; gboolean config_menu_manage_desktops; +gboolean config_menu_user_show_icons; GSList *config_menu_files; @@ -820,6 +821,14 @@ static void parse_menu(xmlNodePtr node, gpointer d) config_menu_client_list_icons = obt_xml_node_bool(n); if ((n = obt_xml_find_node(node, "manageDesktops"))) config_menu_manage_desktops = obt_xml_node_bool(n); + if ((n = obt_xml_find_node(node, "showIcons"))) { + config_menu_user_show_icons = obt_xml_node_bool(n); + #ifndef USE_IMLIB2 + if (config_menu_user_show_icons) + g_message(_("Openbox was compiled without Imlib2." + " Icons in user-defined menus will NOT be loaded.")); + #endif + } while ((node = obt_xml_find_node(node, "file"))) { gchar *c = obt_xml_node_string(node); @@ -1025,6 +1034,7 @@ void config_startup(ObtXmlInst *i) config_menu_client_list_icons = TRUE; config_menu_manage_desktops = TRUE; config_menu_files = NULL; + config_menu_user_show_icons = TRUE; obt_xml_register(i, "menu", parse_menu, NULL); -- cgit v1.2.3