From ba7e8846ee6cf586d2b66cad019751fa5b42e4f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Mon, 27 Apr 2009 01:11:58 +0200 Subject: [PATCH] Do not display any icon if there's no news feed available Work around a bug that made unsetting the secondary icon in the location entry impossible and do not set an icon if there is no news feed instead of an 'information' icon. --- midori/gtkiconentry.c | 24 ++++++++++++++++++------ midori/gtkiconentry.h | 6 +++++- midori/midori-browser.c | 6 ++---- midori/midori-locationaction.c | 8 ++------ 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/midori/gtkiconentry.c b/midori/gtkiconentry.c index 51740ab0..bda44ca4 100644 --- a/midori/gtkiconentry.c +++ b/midori/gtkiconentry.c @@ -28,12 +28,20 @@ gtk_icon_entry_set_icon_from_pixbuf (GtkEntry* entry, GdkPixbuf* pixbuf) { /* Without this ugly hack pixbuf icons don't work */ - if (pixbuf) - { - gtk_widget_hide (GTK_WIDGET (entry)); - gtk_entry_set_icon_from_pixbuf (entry, position, pixbuf); - gtk_widget_show (GTK_WIDGET (entry)); - } + gtk_widget_hide (GTK_WIDGET (entry)); + gtk_entry_set_icon_from_pixbuf (entry, position, pixbuf); + gtk_widget_show (GTK_WIDGET (entry)); +} + +void +gtk_icon_entry_set_icon_from_stock (GtkEntry* entry, + GtkEntryIconPosition position, + const gchar* stock_id) +{ + if (stock_id) + gtk_entry_set_icon_from_stock(entry, position, stock_id); + else + gtk_icon_entry_set_icon_from_pixbuf(entry, position, NULL); } #else @@ -1266,6 +1274,10 @@ gtk_icon_entry_set_icon_from_stock (GtkIconEntry *entry, { GdkPixbuf *pixbuf; + /* FIXME: Due to a bug in GtkIconEntry we need to set a non-NULL icon */ + if (! stock_id) + stock_id = GTK_STOCK_INFO; + pixbuf = gtk_widget_render_icon (GTK_WIDGET (entry), stock_id, GTK_ICON_SIZE_MENU, diff --git a/midori/gtkiconentry.h b/midori/gtkiconentry.h index 61f8075b..8f910cff 100644 --- a/midori/gtkiconentry.h +++ b/midori/gtkiconentry.h @@ -38,11 +38,15 @@ G_BEGIN_DECLS #define GTK_ICON_ENTRY GTK_ENTRY #define GTK_TYPE_ICON_ENTRY GTK_TYPE_ENTRY #define gtk_icon_entry_new gtk_entry_new - #define gtk_icon_entry_set_icon_from_stock gtk_entry_set_icon_from_stock void gtk_icon_entry_set_icon_from_pixbuf (GtkEntry* entry, GtkEntryIconPosition position, GdkPixbuf* pixbuf); + void + gtk_icon_entry_set_icon_from_stock (GtkEntry* entry, + GtkEntryIconPosition position, + const gchar* stock_id); + #define gtk_icon_entry_set_icon_highlight gtk_entry_set_icon_activatable #else diff --git a/midori/midori-browser.c b/midori/midori-browser.c index bee98397..cb04bb3c 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -312,7 +312,7 @@ _midori_browser_update_interface (MidoriBrowser* browser) MIDORI_LOCATION_ACTION (action), STOCK_NEWS_FEED); else midori_location_action_set_secondary_icon ( - MIDORI_LOCATION_ACTION (action), GTK_STOCK_INFO); + MIDORI_LOCATION_ACTION (action), NULL); } static void @@ -420,7 +420,7 @@ midori_view_notify_load_status_cb (GtkWidget* view, midori_location_action_set_uri ( MIDORI_LOCATION_ACTION (action), uri); midori_location_action_set_secondary_icon ( - MIDORI_LOCATION_ACTION (action), GTK_STOCK_INFO); + MIDORI_LOCATION_ACTION (action), NULL); g_object_notify (G_OBJECT (browser), "uri"); } @@ -4003,8 +4003,6 @@ midori_browser_init (MidoriBrowser* browser) "label", _("_Location..."), "stock-id", GTK_STOCK_JUMP_TO, "tooltip", _("Open a particular location"), - /* FIXME: Due to a bug in GtkIconEntry we need to set an initial icon */ - "secondary-icon", STOCK_NEWS_FEED, NULL); g_object_connect (action, "signal::activate", diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 54cdaeda..a24ec972 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -1311,12 +1311,8 @@ midori_location_action_set_secondary_icon (MidoriLocationAction* location_action entry = gtk_bin_get_child (GTK_BIN (alignment)); child = gtk_bin_get_child (GTK_BIN (entry)); - if (stock_id) - gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (child), - GTK_ICON_ENTRY_SECONDARY, stock_id); - else - gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (child), - GTK_ICON_ENTRY_SECONDARY, NULL); + gtk_icon_entry_set_icon_from_stock (GTK_ICON_ENTRY (child), + GTK_ICON_ENTRY_SECONDARY, stock_id); } }