Index: panel-plugin/triggerlauncher.c =================================================================== RCS file: /cvsroot/xfce/xfce4/xfce4-trigger-launcher/panel-plugin/triggerlauncher.c,v retrieving revision 1.15 diff -u -r1.15 triggerlauncher.c --- panel-plugin/triggerlauncher.c 26 Nov 2004 23:27:12 -0000 1.15 +++ panel-plugin/triggerlauncher.c 30 Nov 2004 22:33:53 -0000 @@ -98,7 +98,8 @@ /* State */ gboolean switched_on; - + GdkPixbuf* icon_pixbuf1; + GdkPixbuf* icon_pixbuf2; } t_tl; @@ -122,16 +123,8 @@ static GdkPixbuf * xfce_tl_get_pixbuf_for(t_tl *tl, gboolean on) { - GdkPixbuf *pb; - char *i = tl->options.icon1; - if (on) i = tl->options.icon2; - - if (i) { - pb = gdk_pixbuf_new_from_file(i, NULL); - } else { - pb = get_pixbuf_by_id(DEFAULT_ICON); - } - + GdkPixbuf *pb = on ? tl->icon_pixbuf2 : tl->icon_pixbuf1; + g_object_ref(pb); return (pb); } @@ -234,6 +227,29 @@ } static +GdkPixbuf* replace_pixbuf (GdkPixbuf* old_pixbuf, char const* name) +{ + if (old_pixbuf) + g_object_unref(old_pixbuf); + + return name + ? gdk_pixbuf_new_from_file (name, NULL) + : get_pixbuf_by_id(DEFAULT_ICON); +} + +static +void tl_icon1_changed (t_tl *tl) +{ + tl->icon_pixbuf1 = replace_pixbuf(tl->icon_pixbuf1, tl->options.icon1); +} + +static +void tl_icon2_changed (t_tl *tl) +{ + tl->icon_pixbuf2 = replace_pixbuf(tl->icon_pixbuf2, tl->options.icon2); +} + +static void tl_timeout_changed(t_tl *tl) { if (tl->timeout_handle) { @@ -307,6 +323,11 @@ tl->switched_on = launch_me(tl, TRUE); + tl->icon_pixbuf1 = NULL; + tl->icon_pixbuf2 = NULL; + + tl_icon1_changed (tl); + tl_icon2_changed (tl); tl_timeout_changed (tl); return tl; @@ -394,6 +415,16 @@ tl->timeout_handle = 0; } + if (tl->icon_pixbuf1) { + g_object_unref (tl->icon_pixbuf1); + tl->icon_pixbuf1 = 0; + } + + if (tl->icon_pixbuf2) { + g_object_unref (tl->icon_pixbuf2); + tl->icon_pixbuf2 = 0; + } + g_free(tl); } @@ -724,6 +755,8 @@ update_state(tl); } */ + tl_icon1_changed (tl); + tl_icon2_changed (tl); tl_timeout_changed (tl); } @@ -1026,12 +1059,14 @@ if (value) { if (tl->options.icon1) g_free(tl->options.icon1); tl->options.icon1 = (char *)value; + tl_icon1_changed (tl); } } else if (xmlStrEqual(node->name, (const xmlChar *)"IconOn")) { value = MYDATA(node); if (value) { if (tl->options.icon2) g_free(tl->options.icon2); tl->options.icon2 = (char *)value; + tl_icon2_changed (tl); } } else if (xmlStrEqual(node->name, (const xmlChar *)"Tooltip")) { value = MYDATA(node);