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.
This commit is contained in:
Enrico Tröger 2009-04-27 01:11:58 +02:00 committed by Christian Dywan
parent d328d2afab
commit ba7e8846ee
4 changed files with 27 additions and 17 deletions

View file

@ -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,

View file

@ -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

View file

@ -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",

View file

@ -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);
}
}