summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
Diffstat (limited to 'openbox')
-rw-r--r--openbox/client_list_combined_menu.c2
-rw-r--r--openbox/client_list_menu.c2
-rw-r--r--openbox/config.c19
-rw-r--r--openbox/config.h4
-rw-r--r--openbox/imageload.c143
-rw-r--r--openbox/imageload.h7
-rw-r--r--openbox/menu.c35
7 files changed, 32 insertions, 180 deletions
diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c
index 22840ad6..f4aae884 100644
--- a/openbox/client_list_combined_menu.c
+++ b/openbox/client_list_combined_menu.c
@@ -67,7 +67,7 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
e = menu_add_normal(menu, desktop, c->title, NULL, FALSE);
}
- if (config_menu_client_list_icons) {
+ if (config_menu_show_icons) {
e->data.normal.icon = client_icon(c);
RrImageRef(e->data.normal.icon);
e->data.normal.icon_alpha =
diff --git a/openbox/client_list_menu.c b/openbox/client_list_menu.c
index 3f79f621..2d62c3e9 100644
--- a/openbox/client_list_menu.c
+++ b/openbox/client_list_menu.c
@@ -69,7 +69,7 @@ static gboolean desk_menu_update(ObMenuFrame *frame, gpointer data)
e = menu_add_normal(menu, d->desktop, c->title, NULL, FALSE);
}
- if (config_menu_client_list_icons) {
+ if (config_menu_show_icons) {
e->data.normal.icon = client_icon(c);
RrImageRef(e->data.normal.icon);
e->data.normal.icon_alpha = c->iconic ? OB_ICONIC_ALPHA : 0xff;
diff --git a/openbox/config.c b/openbox/config.c
index 304079c9..6963559d 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -94,9 +94,8 @@ guint config_menu_hide_delay;
gboolean config_menu_middle;
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;
+gboolean config_menu_show_icons;
GSList *config_menu_files;
@@ -817,17 +816,14 @@ static void parse_menu(xmlNodePtr node, gpointer d)
config_submenu_show_delay = obt_xml_node_int(n);
if ((n = obt_xml_find_node(node, "submenuHideDelay")))
config_submenu_hide_delay = obt_xml_node_int(n);
- if ((n = obt_xml_find_node(node, "applicationIcons")))
- 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
+ config_menu_show_icons = obt_xml_node_bool(n);
+#ifndef USE_IMLIB2
+ if (config_menu_show_icons)
+ g_message(_("Openbox was compiled without Imlib2 image loading support. Icons in menus will not be loaded."));
+#endif
}
while ((node = obt_xml_find_node(node, "file"))) {
@@ -1031,10 +1027,9 @@ void config_startup(ObtXmlInst *i)
config_menu_middle = FALSE;
config_submenu_show_delay = 200;
config_submenu_hide_delay = 400;
- config_menu_client_list_icons = TRUE;
config_menu_manage_desktops = TRUE;
config_menu_files = NULL;
- config_menu_user_show_icons = TRUE;
+ config_menu_show_icons = TRUE;
obt_xml_register(i, "menu", parse_menu, NULL);
diff --git a/openbox/config.h b/openbox/config.h
index 1825f477..0e4ccb5c 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -193,12 +193,10 @@ extern gboolean config_menu_middle;
extern guint config_submenu_show_delay;
/*! Delay before closing a submenu in milliseconds */
extern guint config_submenu_hide_delay;
-/*! Show icons in client_list_menu */
-extern gboolean config_menu_client_list_icons;
/*! Show manage desktops in client_list_menu */
extern gboolean config_menu_manage_desktops;
/*! Load & show icons in user-defined menus */
-extern gboolean config_menu_user_show_icons;
+extern gboolean config_menu_show_icons;
/*! User-specified menu files */
extern GSList *config_menu_files;
/*! Per app settings */
diff --git a/openbox/imageload.c b/openbox/imageload.c
deleted file mode 100644
index e7c1ddf7..00000000
--- a/openbox/imageload.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
- imageload.c for the Openbox window manager
- by Libor Kadlcik (aka KadlSoft)
-*/
-
-/*
- All loaded images are cached. There's no separate cache for the images,
- instead they are simply stored in image cache (RrImageCache) as RrImages,
- ready to be used.
- Every RrImage loaded from file is associated with name of the file. This is
- done by file name table (RrImageCache.file_name_table), which is a simple
- hash table, where file names are keys to pointers to RrImage.
- If you request to load file that is already in image cache, nothing will be
- loaded and you just got the RrImage from cache.
- When RrImage is destroyed (see RrImageDestroyNotify), the file name - pointer
- to RrImage pair is removed from the file name table.
-*/
-
-#include "debug.h"
-#include "menu.h"
-#include "openbox.h"
-#include "gettext.h"
-#include "obrender/render.h"
-#include "obrender/image.h"
-#include "obrender/imagecache.h"
-#include "imageload.h"
-#include <Imlib2.h>
-
-#ifndef USE_IMLIB2
-RrImage* RrImageFetchFromFile(RrImageCache *cache, const gchar *name)
-{
- return NULL;
-}
-#else
-
-static void CreateFileNameTable(RrImageCache *self)
-{
- g_assert(self->file_name_table == NULL);
- self->file_name_table = g_hash_table_new(&g_str_hash, &g_str_equal);
-}
-
-static void DestroyFileNameTable(RrImageCache *self)
-{
- g_assert(g_hash_table_size(self->file_name_table) == 0);
- g_hash_table_destroy(self->file_name_table);
- self->file_name_table = NULL;
-}
-
-/*! Return file name from which this image has been loaded. */
-static gchar* GetFileName(RrImage *image)
-{
- GHashTableIter iter;
- void *key, *value;
-
- g_hash_table_iter_init(&iter, image->cache->file_name_table);
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- if (value == image)
- return key;
- }
- return NULL;
-}
-
-/* RrImage is about to be deleted. So remove it from file name table. */
-static void RrImageDestroyNotify(RrImage *image)
-{
- gchar *file_name = GetFileName(image);
- g_assert(file_name != NULL);
- ob_debug("Image \"%s\" no longer needed", file_name);
- g_hash_table_remove(image->cache->file_name_table, file_name);
- g_free(file_name);
-
- if (g_hash_table_size(image->cache->file_name_table) == 0) {
- ob_debug("No RrImage in file_name_table, destroying");
- DestroyFileNameTable(image->cache);
- }
-}
-
-#if (RrDefaultAlphaOffset != 24 || RrDefaultRedOffset != 16 \
- || RrDefaultGreenOffset != 8 || RrDefaultBlueOffset != 0)
-#error RrImageFetchFromFile cannot handle current bit layout of RrPixel32.
-#endif
-
-/*! Load image from specified file and create RrImage for it (RrImage will be
- linked into specified image cache). Reference count of the RrImage will
- be set to 1.
- If that image has already been loaded into the image cache, RrImage
- from the cache will be returned and its reference count will be incremented.
-*/
-RrImage* RrImageFetchFromFile(RrImageCache *cache, const gchar *name)
-{
- RrImage *rr_image, *found_rr_image;
- gint w, h;
- DATA32 *ro_data;
-
- imlib_set_color_usage(128);
-
- if (cache->file_name_table == NULL)
- CreateFileNameTable(cache);
-
- /* Find out if that image has already been loaded to this cache. */
- rr_image = g_hash_table_lookup(cache->file_name_table, name);
- if (rr_image && rr_image->cache == cache) {
- ob_debug("\"%s\" already loaded in this image cache.", name);
- RrImageRef(rr_image);
- return rr_image;
- }
-
- Imlib_Image imlib_image = imlib_load_image(name);
- if (imlib_image == NULL) {
- g_message(_("Cannot load image from file \"%s\""), name);
- return NULL;
- }
-
- /* Get data and dimensions of the image. */
- imlib_context_set_image(imlib_image);
- g_message("Alpha = %d\n", imlib_image_has_alpha());
- ro_data = imlib_image_get_data_for_reading_only();
- w = imlib_image_get_width();
- h = imlib_image_get_height();
- ob_debug("Loaded \"%s\", dimensions %dx%d", name, w, h);
-
- /* There must not be any duplicated pictures in RrImageCache. */
- found_rr_image = RrImageCacheFind(cache, ro_data, w, h);
- if (found_rr_image) {
- rr_image = found_rr_image;
- RrImageRef(rr_image);
- ob_debug("Image \"%s\" is duplicate", name);
- }
- else {
- /* Create RrImage from the image and add it to file name table. */
- rr_image = RrImageNew(cache);
- RrImageSetDestroyFunc(rr_image, &RrImageDestroyNotify);
- /* XXX: Is Imlib2's format of DATA32 always identical to RrPixel32? */
- RrImageAddPicture(rr_image, ro_data, w, h);
- g_hash_table_insert(cache->file_name_table, g_strdup(name), rr_image);
- }
-
- imlib_free_image();
-
- return rr_image;
-}
-
-#endif
diff --git a/openbox/imageload.h b/openbox/imageload.h
deleted file mode 100644
index 21e7c9b0..00000000
--- a/openbox/imageload.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __imageload_h
-#define __imageload_h
-
-#include "obrender/render.h"
-RrImage* RrImageFetchFromFile(RrImageCache *cache, const gchar *name);
-
-#endif
diff --git a/openbox/menu.c b/openbox/menu.c
index 77d9548c..524220c0 100644
--- a/openbox/menu.c
+++ b/openbox/menu.c
@@ -36,7 +36,6 @@
#include "gettext.h"
#include "obt/xml.h"
#include "obt/paths.h"
-#include "imageload.h"
typedef struct _ObMenuParseState ObMenuParseState;
@@ -275,29 +274,39 @@ static void parse_menu_item(xmlNodePtr node, gpointer data)
if (state->parent) {
/* Don't try to extract "icon" attribute if icons in user-defined
- menus are not enabled. */
- if (!(config_menu_user_show_icons &&
- obt_xml_attr_string(node, "icon", &icon)))
- {
- icon = NULL;
- }
+ menus are not enabled. */
if (obt_xml_attr_string(node, "label", &label)) {
+ xmlNodePtr c;
GSList *acts = NULL;
- node = obt_xml_find_node(node->children, "action");
- while (node) {
- ObActionsAct *action = actions_parse(node);
+ c = obt_xml_find_node(node->children, "action");
+ while (c) {
+ ObActionsAct *action = actions_parse(c);
if (action)
acts = g_slist_append(acts, action);
- node = obt_xml_find_node(node->next, "action");
+ c = obt_xml_find_node(node->next, "action");
}
e = menu_add_normal(state->parent, -1, label, acts, TRUE);
- if (icon) { /* Icon will be used. */
- e->data.normal.icon = RrImageFetchFromFile(ob_rr_icons, icon);
+ if (config_menu_show_icons &&
+ obt_xml_attr_string(node, "icon", &icon))
+ {
+ RrImage *ic;
+
+ ic = RrImageCacheFindName(ob_rr_icons, icon);
+ if (ic)
+ RrImageRef(ic);
+ else {
+ ic = RrImageNew(ob_rr_icons);
+ if (!RrImageAddPictureName(ic, icon))
+ RrImageUnref(ic); /* no need to keep it around */
+ }
+ e->data.normal.icon = ic;
+
if (e->data.normal.icon)
e->data.normal.icon_alpha = 0xff;
+
g_free(icon);
}
g_free(label);