aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilles Dartiguelongue <gdartigu@svn.gnome.org>2008-08-16 09:08:03 +0800
committerGilles Dartiguelongue <gdartigu@src.gnome.org>2008-08-16 09:08:03 +0800
commitb29fa407bd8373edff0ae1482601dfc5eb3b6eab (patch)
tree2e37ea1397ad9f8c47a45d410a1fd048dd178f6c
parent9c9a6acf0c8b0e60617ba08a6a99187e2eae2a74 (diff)
downloadgsoc2013-evolution-b29fa407bd8373edff0ae1482601dfc5eb3b6eab.tar.gz
gsoc2013-evolution-b29fa407bd8373edff0ae1482601dfc5eb3b6eab.tar.zst
gsoc2013-evolution-b29fa407bd8373edff0ae1482601dfc5eb3b6eab.zip
Make evolution respect GTK_ICON_SIZE changes, part of bug #416258.
2008-08-16 Gilles Dartiguelongue <gdartigu@svn.gnome.org> * e-icon-factory.c: (e_icon_size_to_gtk_icon_size), (e_icon_factory_get_icon_filename), (e_icon_factory_get_icon): Make evolution respect GTK_ICON_SIZE changes, part of bug #416258. svn path=/trunk/; revision=36000
-rw-r--r--e-util/ChangeLog6
-rw-r--r--e-util/e-icon-factory.c73
2 files changed, 49 insertions, 30 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 0c80024a22..94a063ff3b 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-16 Gilles Dartiguelongue <gdartigu@svn.gnome.org>
+
+ * e-icon-factory.c: (e_icon_size_to_gtk_icon_size),
+ (e_icon_factory_get_icon_filename), (e_icon_factory_get_icon):
+ Make evolution respect GTK_ICON_SIZE changes, part of bug #416258.
+
2008-08-14 Matthew Barnes <mbarnes@redhat.com>
* e-util.c (e_display_help):
diff --git a/e-util/e-icon-factory.c b/e-util/e-icon-factory.c
index 2ca724c5f2..e1e60f91fd 100644
--- a/e-util/e-icon-factory.c
+++ b/e-util/e-icon-factory.c
@@ -34,22 +34,14 @@
#include <libgnomeui/gnome-thumbnail.h>
#endif
+#include <gtk/gtkiconfactory.h>
+
#include "e-icon-factory.h"
#include "e-util-private.h"
#include "art/broken-image-16.xpm"
#include "art/broken-image-24.xpm"
-static int sizes[E_ICON_NUM_SIZES] = {
- 16, /* menu */
- 20, /* button */
- 18, /* small toolbar */
- 24, /* large toolbar */
- 32, /* dnd */
- 48, /* dialog */
-};
-
-
typedef struct {
char *name;
GdkPixbuf *pixbuf;
@@ -173,21 +165,25 @@ load_icon (const char *icon_key, const char *icon_name, int size, int scale)
return icon_new (icon_key, pixbuf);
}
-
-/* temporary workaround for code that has not yet been ported to the new icon_size API */
-static int
-pixel_size_to_icon_size (int pixel_size)
+static GtkIconSize
+e_icon_size_to_gtk_icon_size (guint size)
{
- int i, icon_size = -1;
-
- for (i = 0; i < E_ICON_NUM_SIZES; i++) {
- if (pixel_size == sizes[i]) {
- icon_size = i;
- break;
- }
+ switch (size) {
+ case E_ICON_SIZE_MENU:
+ return GTK_ICON_SIZE_MENU;
+ case E_ICON_SIZE_BUTTON:
+ return GTK_ICON_SIZE_BUTTON;
+ case E_ICON_SIZE_SMALL_TOOLBAR:
+ return GTK_ICON_SIZE_SMALL_TOOLBAR;
+ case E_ICON_SIZE_LARGE_TOOLBAR:
+ return GTK_ICON_SIZE_LARGE_TOOLBAR;
+ case E_ICON_SIZE_DND:
+ return GTK_ICON_SIZE_DND;
+ case E_ICON_SIZE_DIALOG:
+ return GTK_ICON_SIZE_DIALOG;
+ default:
+ g_assert_not_reached ();
}
-
- return icon_size;
}
static void
@@ -264,21 +260,30 @@ e_icon_factory_get_icon_filename (const char *icon_name, int icon_size)
{
GtkIconInfo *icon_info;
char *filename;
+ gint width, height;
g_return_val_if_fail (icon_name != NULL, NULL);
g_return_val_if_fail (strcmp (icon_name, ""), NULL);
if (icon_size >= E_ICON_NUM_SIZES) {
- g_warning (
+ g_critical (
"calling %s with unknown icon_size value (%d)",
G_STRFUNC, icon_size);
- if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1)
+ /* if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1)*/
return NULL;
}
+ if (! gtk_icon_size_lookup_for_settings (gtk_settings_get_default (),
+ e_icon_size_to_gtk_icon_size (icon_size),
+ &width, &height))
+ return NULL;
+
+ g_message ("Size is %d", icon_size);
+ g_message ("looking up %s at %dx%d", icon_name, width, height);
+
g_static_mutex_lock (&mutex);
icon_info = gtk_icon_theme_lookup_icon (
- icon_theme, icon_name, sizes[icon_size], 0);
+ icon_theme, icon_name, height, 0);
if (icon_info != NULL) {
filename = g_strdup (
gtk_icon_info_get_filename (icon_info));
@@ -310,17 +315,25 @@ e_icon_factory_get_icon (const char *icon_name, int icon_size)
GdkPixbuf *pixbuf;
char *icon_key;
Icon *icon;
- int size;
+ int size, width, height;
if (icon_size >= E_ICON_NUM_SIZES) {
- g_warning (
+ g_critical (
"calling %s with unknown icon_size value (%d)",
G_STRFUNC, icon_size);
- if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1)
+ /*if ((icon_size = pixel_size_to_icon_size (icon_size)) == -1) */
return NULL;
}
- size = sizes[icon_size];
+ if (! gtk_icon_size_lookup_for_settings (gtk_settings_get_default (),
+ e_icon_size_to_gtk_icon_size (icon_size),
+ &width, &height))
+ return NULL;
+
+ g_message ("Size is %d", icon_size);
+ g_message ("looking up %s at %dx%d", icon_name, width, height);
+
+ size = height;
if (icon_name == NULL || !strcmp (icon_name, "")) {
if (size >= 24)