icon-handling



Hi all,

Seeing this bug on bugzilla:
http://bugzilla.gnome.org/show_bug.cgi?id=114041
I realized the problem for the first time, although it's quite obvious. 
And there even was a fix suggested on this list, which never got 
implemented:
http://mail.gnome.org/archives/balsa-list/2003-April/msg00189.html

I think some things went wrong there. ;)

Had a look on the issue and I suggest the attached patch. Although 
undocumented in the API, gnome_window_set_default_icon_* is part of 
libgnomeui since 2.0, so I just used it without any checks. And the 
"set_icon"-function isn't needed imho, looks liek a relict from balsa-
1? the default-icon does all we want. Compiles fine for me, fixes all 
problems.

Looking further into the icon-stuff, some things obviously need 
adapting to the Gnome2-way. Anyone already working on that? There are 
several bugs about it. If not, I'd try to take care.

bye,

Darko
diff -urN balsa-2.0.12/src/main.c balsa-2.0.12-windowicon/src/main.c
--- balsa-2.0.12/src/main.c	2003-06-03 21:53:23.000000000 +0200
+++ balsa-2.0.12-windowicon/src/main.c	2003-07-23 23:33:41.000000000 +0200
@@ -22,9 +22,7 @@
 #include "config.h"
 
 #include <gnome.h>
-#ifdef HAVE_LIBGNOMEUI_GNOME_WINDOW_ICON_H
 #include <libgnomeui/gnome-window-icon.h>
-#endif
 
 #ifdef GTKHTML_HAVE_GCONF
 # include <gconf/gconf.h>
@@ -389,11 +387,7 @@
     mailboxes_init();
 
     default_icon = balsa_pixmap_finder("balsa_icon.png");
-#ifdef HAVE_LIBGNOMEUI_GNOME_WINDOW_ICON_H
     gnome_window_icon_set_default_from_file(default_icon);
-#endif
-    /* GTK-2.2 has a function for this but we do not require 2.2 yet.
-       gtk_window_set_default_icon_from_file(default_icon, NULL); */
     g_free(default_icon);
 
     signal( SIGPIPE, SIG_IGN );
diff -urN balsa-2.0.12/src/main-window.c balsa-2.0.12-windowicon/src/main-window.c
--- balsa-2.0.12/src/main-window.c	2003-06-30 21:00:21.000000000 +0200
+++ balsa-2.0.12-windowicon/src/main-window.c	2003-07-23 23:37:59.000000000 +0200
@@ -204,8 +204,6 @@
 static void show_mbtree_cb(GtkWidget * widget, gpointer data);
 static void show_mbtabs_cb(GtkWidget * widget, gpointer data);
 
-static void set_icon(GnomeApp * app);
-
 static void notebook_size_alloc_cb(GtkWidget * notebook,
                                    GtkAllocation * alloc);
 static void mw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc);
@@ -1006,9 +1004,6 @@
     balsa_toolbar_set_button_active(toolbar, BALSA_PIXMAP_SHOW_PREVIEW,
                                     balsa_app.previewpane);
 
-    /* we can only set icon after realization, as we have no windows before. */
-    g_signal_connect(G_OBJECT(window), "realize",
-                     G_CALLBACK(set_icon), NULL);
     g_signal_connect(G_OBJECT(window), "size_allocate",
                      G_CALLBACK(mw_size_alloc_cb), NULL);
     g_signal_connect(G_OBJECT (window), "destroy",
@@ -3017,70 +3012,6 @@
 
 }
 
-static void
-set_icon(GnomeApp * app)
-{
-    GdkPixbuf *pb = NULL;
-    GdkWindow *ic_win, *w;
-    GdkWindowAttr att;
-    XIconSize *is;
-    gint i, count, j;
-    char *filename;
-
-    w = GTK_WIDGET(app)->window;
-
-    if ((XGetIconSizes(GDK_DISPLAY(), GDK_ROOT_WINDOW(), &is, &count))
-        && (count > 0)) {
-        i = 0;                  /* use first icon size - not much point using the others */
-        att.width = is[i].max_width;
-        att.height = is[i].max_height;
-        /*
-         * raster had:
-         * att.height = 3 * att.width / 4;
-         * but this didn't work  (it scaled the icons incorrectly
-         */
-
-        /* make sure the icon is inside the min and max sizes */
-        if (att.height < is[i].min_height)
-            att.height = is[i].min_height;
-        if (att.height > is[i].max_height)
-            att.height = is[i].max_height;
-        if (is[i].width_inc > 0) {
-            j = ((att.width - is[i].min_width) / is[i].width_inc);
-            att.width = is[i].min_width + (j * is[i].width_inc);
-        }
-        if (is[i].height_inc > 0) {
-            j = ((att.height - is[i].min_height) / is[i].height_inc);
-            att.height = is[i].min_height + (j * is[i].height_inc);
-        }
-        XFree(is);
-    } else {
-        /* no icon size hints at all? ok - invent our own size */
-        att.width = 32;
-        att.height = 24;
-    }
-    att.event_mask = GDK_ALL_EVENTS_MASK;
-    att.wclass = GDK_INPUT_OUTPUT;
-    att.window_type = GDK_WINDOW_TOPLEVEL;
-    att.x = 0;
-    att.y = 0;
-    att.visual = gdk_rgb_get_visual();
-    att.colormap = gdk_rgb_get_colormap();
-    ic_win = gdk_window_new(NULL, &att, GDK_WA_VISUAL | GDK_WA_COLORMAP);
-    gdk_window_set_icon(w, ic_win, NULL, NULL);
-
-    if( (filename = balsa_pixmap_finder("balsa_icon.png")) ) {
-#if BALSA_MAJOR < 2
-        pb = gdk_pixbuf_new_from_file(filename);
-#else
-        pb = gdk_pixbuf_new_from_file(filename, NULL);
-#endif                          /* BALSA_MAJOR < 2 */
-        gdk_window_clear(ic_win);
-        g_object_unref(G_OBJECT(pb));
-        g_free(filename);
-    }
-}
-
 /* PKGW: remember when they change the position of the vpaned. */
 static void
 notebook_size_alloc_cb(GtkWidget * notebook, GtkAllocation * alloc)

PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]