[epiphany] ephy-tabs-menu: show favicons instead of radiobuttons in the tabs menu.
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-tabs-menu: show favicons instead of radiobuttons in the tabs menu.
- Date: Fri, 19 Feb 2010 07:04:18 +0000 (UTC)
commit 2df12ad5882cf78c10df47d927566a69afc3af4f
Author: Olivier Tilloy <olivier tilloy net>
Date: Sun Feb 14 19:48:51 2010 +0100
ephy-tabs-menu: show favicons instead of radiobuttons in the tabs menu.
Bug #405505
Signed-off-by: Xan Lopez <xan gnome org>
src/ephy-tabs-menu.c | 75 +++++++++++++++++++------------------------------
1 files changed, 29 insertions(+), 46 deletions(-)
---
diff --git a/src/ephy-tabs-menu.c b/src/ephy-tabs-menu.c
index 0d48752..db76129 100644
--- a/src/ephy-tabs-menu.c
+++ b/src/ephy-tabs-menu.c
@@ -147,17 +147,12 @@ free_tab_id (GtkAction *action)
}
static void
-tab_action_activate_cb (GtkToggleAction *action,
+tab_action_activate_cb (GtkAction *action,
EphyTabsMenu *menu)
{
EphyTabsMenuPrivate *priv = menu->priv;
EphyEmbed *embed;
- if (gtk_toggle_action_get_active (action) == FALSE)
- {
- return;
- }
-
embed = g_object_get_data (G_OBJECT (action), DATA_KEY);
g_return_if_fail (embed != NULL);
@@ -182,6 +177,24 @@ sync_tab_title (EphyWebView *view,
}
static void
+sync_tab_icon (EphyWebView *view,
+ GParamSpec *pspec,
+ GtkWidget *proxy)
+{
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ GdkPixbuf *pixbuf;
+ GtkWidget *image;
+
+ pixbuf = ephy_web_view_get_icon (view);
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ gtk_widget_show (image);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (proxy), TRUE);
+ }
+}
+
+static void
notebook_page_added_cb (EphyNotebook *notebook,
EphyEmbed *embed,
guint position,
@@ -190,16 +203,12 @@ notebook_page_added_cb (EphyNotebook *notebook,
EphyTabsMenuPrivate *priv = menu->priv;
GtkAction *action;
char verb[ACTION_VERB_FORMAT_LENGTH];
- GSList *group;
LOG ("tab_added_cb embed=%p", embed);
g_snprintf (verb, sizeof (verb), ACTION_VERB_FORMAT, allocate_tab_id ());
-
- action = g_object_new (GTK_TYPE_RADIO_ACTION,
- "name", verb,
- "tooltip", _("Switch to this tab"),
- NULL);
+
+ action = gtk_action_new (verb, NULL, _("Switch to this tab"), NULL);
sync_tab_title (ephy_embed_get_web_view (embed), NULL, action);
/* make sure the action is alive when handling the signal, see bug #169833 */
@@ -208,15 +217,6 @@ notebook_page_added_cb (EphyNotebook *notebook,
gtk_action_group_add_action_with_accel (priv->action_group, action, NULL);
- group = gtk_radio_action_get_group (GTK_RADIO_ACTION (priv->anchor_action));
- gtk_radio_action_set_group (GTK_RADIO_ACTION (action), group);
-
- /* set this here too, since tab-added comes after notify::active-child */
- if (ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (priv->window)) == embed)
- {
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- }
-
g_object_set_data (G_OBJECT (embed), DATA_KEY, action);
g_object_set_data (G_OBJECT (action), DATA_KEY, embed);
@@ -276,36 +276,22 @@ connect_proxy_cb (GtkActionGroup *action_group,
if (GTK_IS_MENU_ITEM (proxy))
{
GtkLabel *label;
+ EphyEmbed *embed;
+ EphyWebView *view;
label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));
gtk_label_set_use_underline (label, FALSE);
gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars (label, LABEL_WIDTH_CHARS);
- }
-}
-
-static void
-sync_active_tab (EphyWindow *window,
- GParamSpec *pspec,
- EphyTabsMenu *menu)
-{
- EphyEmbed *embed;
- GtkAction *action;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- if (embed == NULL) return;
+ embed = g_object_get_data (G_OBJECT (action), DATA_KEY);
+ view = ephy_embed_get_web_view (embed);
- LOG ("active tab is embed %p", embed);
-
- action = g_object_get_data (G_OBJECT (embed), DATA_KEY);
- /* happens initially, since the ::active-child comes before
- * the ::tab-added signal
- */
- /* FIXME that's not true with gtk+ 2.9 anymore */
- if (action == NULL) return;
-
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ sync_tab_icon (view, NULL, proxy);
+ g_signal_connect_object (view, "notify::icon",
+ G_CALLBACK (sync_tab_icon), proxy, 0);
+ }
}
static void
@@ -332,9 +318,6 @@ ephy_tabs_menu_set_window (EphyTabsMenu *menu,
g_signal_connect (priv->action_group, "connect-proxy",
G_CALLBACK (connect_proxy_cb), NULL);
- g_signal_connect (window, "notify::active-child",
- G_CALLBACK (sync_active_tab), menu);
-
notebook = ephy_window_get_notebook (window);
g_signal_connect_object (notebook, "page-added",
G_CALLBACK (notebook_page_added_cb), menu, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]