From 9e997e4c90f599a3f819dd4f02d1b3ae0f1d71a8 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 11 Nov 2008 00:51:28 +0100 Subject: [PATCH] Update location icon even if it's not in the history --- midori/midori-browser.c | 2 ++ midori/midori-locationaction.c | 34 ++++++++++++++++++++++++++++++++-- midori/midori-locationaction.h | 4 ++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 7a4bc986..e0a7e7ed 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2910,6 +2910,8 @@ gtk_notebook_switch_page_cb (GtkWidget* notebook, uri = midori_view_get_display_uri (MIDORI_VIEW (view)); action = _action_by_name (browser, "Location"); midori_location_action_set_uri (MIDORI_LOCATION_ACTION (action), uri); + midori_location_action_set_icon (MIDORI_LOCATION_ACTION (action), + midori_view_get_icon (MIDORI_VIEW (view))); title = midori_view_get_display_title (MIDORI_VIEW (view)); window_title = g_strconcat (title, " - ", diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 76641497..57220740 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -611,7 +611,7 @@ midori_location_action_item_iter (MidoriLocationAction* location_action, g_return_val_if_fail (uri != NULL, FALSE); found = FALSE; - model = location_action->model; // filter_model + model = location_action->model; if (gtk_tree_model_get_iter_first (model, iter)) { tmpuri = NULL; @@ -860,6 +860,7 @@ midori_location_action_set_text (MidoriLocationAction* location_action, GdkPixbuf* icon; g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action)); + g_return_if_fail (text != NULL); proxies = gtk_action_get_proxies (GTK_ACTION (location_action)); if (!proxies) @@ -875,7 +876,7 @@ midori_location_action_set_text (MidoriLocationAction* location_action, gtk_entry_set_text (GTK_ENTRY (entry), text); if (midori_location_action_item_iter (location_action, text, &iter)) { - model = location_action->model; // filter_model + model = location_action->model; gtk_tree_model_get (model, &iter, FAVICON_COL, &icon, -1); gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_PRIMARY, icon); @@ -900,6 +901,35 @@ midori_location_action_set_uri (MidoriLocationAction* location_action, midori_location_action_set_text (location_action, uri); } +void +midori_location_action_set_icon (MidoriLocationAction* location_action, + GdkPixbuf* icon) +{ + GSList* proxies; + GtkWidget* alignment; + GtkWidget* location_entry; + GtkWidget* entry; + + g_return_if_fail (MIDORI_IS_LOCATION_ACTION (location_action)); + g_return_if_fail (icon && GDK_IS_PIXBUF (icon)); + + proxies = gtk_action_get_proxies (GTK_ACTION (location_action)); + if (!proxies) + return; + + do + if (GTK_IS_TOOL_ITEM (proxies->data)) + { + alignment = gtk_bin_get_child (GTK_BIN (proxies->data)); + location_entry = gtk_bin_get_child (GTK_BIN (alignment)); + entry = gtk_bin_get_child (GTK_BIN (location_entry)); + + gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (entry), + GTK_ICON_ENTRY_PRIMARY, icon); + } + while ((proxies = g_slist_next (proxies))); +} + /** * midori_location_action_prepend_item: * @location_action: a #MidoriLocationAction diff --git a/midori/midori-locationaction.h b/midori/midori-locationaction.h index a95301c9..5d2d1d23 100644 --- a/midori/midori-locationaction.h +++ b/midori/midori-locationaction.h @@ -51,6 +51,10 @@ void midori_location_action_set_uri (MidoriLocationAction* location_action, const gchar* uri); +void +midori_location_action_set_icon (MidoriLocationAction* location_action, + GdkPixbuf* icon); + void midori_location_action_add_uri (MidoriLocationAction* location_action, const gchar* uri); -- 2.39.5