diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-02-11 06:37:15 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-02-11 06:37:15 +0800 |
commit | da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d (patch) | |
tree | dcadd2684a1160fe078833c86c1a8f9d74aaaeb6 /src | |
parent | b48d4a6f2f65afa8b982e09929c67dbfe438d54b (diff) | |
download | gsoc2013-epiphany-da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d.tar gsoc2013-epiphany-da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d.tar.gz gsoc2013-epiphany-da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d.tar.bz2 gsoc2013-epiphany-da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d.tar.lz gsoc2013-epiphany-da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d.tar.xz gsoc2013-epiphany-da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d.tar.zst gsoc2013-epiphany-da3e75ecba1dbc62ee1f6c9e1970f4c140fbef0d.zip |
Remove ephy_tab_get_action(). Adapts the tabs menu accordingly.
2005-02-10 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-tab.c: (ephy_tab_finalize), (ephy_tab_title_cb),
(ensure_page_info), (ephy_tab_init), (ephy_tab_set_title),
(ephy_tab_get_title), (ephy_tab_get_zoom):
* src/ephy-tab.h:
* src/ephy-tabs-menu.c: (ephy_tabs_menu_get_type),
(tab_action_activate_cb), (sync_tab_title), (tab_added_cb),
(tab_removed_cb), (tabs_reordered_cb), (sync_active_tab),
(ephy_tabs_menu_set_window), (ephy_tabs_menu_set_property),
(ephy_tabs_menu_get_property), (ephy_tabs_menu_class_init),
(ephy_tabs_menu_clean), (tab_set_action_accelerator),
(ephy_tabs_menu_update):
* src/ephy-window.c: (ephy_window_set_active_tab),
(ephy_window_get_active_embed):
Remove ephy_tab_get_action(). Adapts the tabs menu accordingly.
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-tab.c | 115 | ||||
-rw-r--r-- | src/ephy-tab.h | 8 | ||||
-rw-r--r-- | src/ephy-tabs-menu.c | 286 | ||||
-rw-r--r-- | src/ephy-window.c | 13 |
4 files changed, 222 insertions, 200 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c index b4de9b701..f7dfe6cad 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2003 Marco Pesenti Gritti - * Copyright (C) 2003, 2004 Christian Persch + * Copyright (C) 2003, 2004, 2005 Christian Persch * Copyright (C) 2004 Crispin Flowerday * Copyright (C) 2004 Adam Hooper * @@ -57,7 +57,6 @@ #include <gtk/gtkmain.h> #include <gtk/gtkmenu.h> #include <gtk/gtkuimanager.h> -#include <gtk/gtkradioaction.h> #include <gtk/gtkclipboard.h> #include <string.h> @@ -80,7 +79,6 @@ struct _EphyTabPrivate int total_requests; int width; int height; - GtkToggleAction *action; float zoom; gboolean setting_zoom; EphyEmbedSecurityLevel security_level; @@ -120,8 +118,6 @@ typedef struct static GObjectClass *parent_class = NULL; -static gulong tab_id = 0; - /* internal functions, accessible only from this file */ static void ephy_tab_set_icon_address (EphyTab *tab, const char *location); @@ -137,7 +133,7 @@ static void ephy_tab_set_security_level (EphyTab *tab, EphyEmbedSecurityLevel level); static void ephy_tab_set_title (EphyTab *tab, EphyEmbed *embed, - const char *new_title); + char *new_title); static void ephy_tab_set_zoom (EphyTab *tab, float zoom); static guint popup_blocker_n_hidden (EphyTab *tab); @@ -328,23 +324,6 @@ ephy_tab_get_window (EphyTab *tab) } static void -ephy_tab_action_activate_cb (GtkAction *action, EphyTab *tab) -{ - EphyWindow *window; - - g_return_if_fail (EPHY_IS_TAB (tab)); - - window = ephy_tab_get_window (tab); - g_return_if_fail (window != NULL); - - if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) && - ephy_window_get_active_tab (window) != tab) - { - ephy_window_jump_to_tab (window, tab); - } -} - -static void ephy_tab_class_init (EphyTabClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); @@ -761,11 +740,6 @@ ephy_tab_finalize (GObject *object) g_idle_remove_by_data (tab); - if (tab->priv->action != NULL) - { - g_object_unref (tab->priv->action); - } - g_free (tab->priv->title); g_free (tab->priv->address); g_free (tab->priv->icon_address); @@ -1167,8 +1141,6 @@ ephy_tab_title_cb (EphyEmbed *embed, EphyTab *tab) title = ephy_embed_get_title (embed); ephy_tab_set_title (tab, embed, title); - - g_free (title); } static int @@ -1280,13 +1252,13 @@ build_progress_from_requests (EphyTab *tab, EphyEmbedNetState state) static void ensure_page_info (EphyTab *tab, EphyEmbed *embed, const char *address) { - if ((tab->priv->address == NULL || *tab->priv->address == '\0') && + if ((tab->priv->address == NULL || tab->priv->address[0] == '\0') && tab->priv->address_expire == EPHY_TAB_ADDRESS_EXPIRE_NOW) { ephy_tab_set_location (tab, address, EPHY_TAB_ADDRESS_EXPIRE_NOW); } - if (tab->priv->title == NULL) + if (tab->priv->title == NULL || tab->priv->title[0] == '\0') { ephy_tab_set_title (tab, embed, NULL); } @@ -1600,7 +1572,6 @@ ephy_tab_init (EphyTab *tab) { GObject *embed; EphyFaviconCache *cache; - char *id; LOG ("EphyTab initialising %p", tab); @@ -1616,6 +1587,7 @@ ephy_tab_init (EphyTab *tab) tab->priv->document_type = EPHY_EMBED_DOCUMENT_HTML; tab->priv->zoom = 1.0; tab->priv->address_expire = EPHY_TAB_ADDRESS_EXPIRE_NOW; + tab->priv->title = g_strdup (""); embed = ephy_embed_factory_new_object (EPHY_TYPE_EMBED); g_assert (embed != NULL); @@ -1623,18 +1595,6 @@ ephy_tab_init (EphyTab *tab) gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (embed)); gtk_widget_show (GTK_WIDGET (embed)); - id = g_strdup_printf ("Tab%lu", tab_id++); - - tab->priv->action = g_object_new (GTK_TYPE_TOGGLE_ACTION, - "name", id, - "label", _("Blank page"), - "draw_as_radio", TRUE, - NULL); - - g_free (id); - g_signal_connect (tab->priv->action, "activate", - G_CALLBACK (ephy_tab_action_activate_cb), tab); - g_signal_connect_object (embed, "link_message", G_CALLBACK (ephy_tab_link_message_cb), tab, 0); @@ -1803,30 +1763,27 @@ ephy_tab_get_status_message (EphyTab *tab) } } -#define MAX_LABEL_LENGTH 32 - static void -ephy_tab_set_title (EphyTab *tab, EphyEmbed *embed, const char *new_title) +ephy_tab_set_title (EphyTab *tab, + EphyEmbed *embed, + char *title) { - char *title = NULL; - - g_return_if_fail (EPHY_IS_TAB (tab)); - - g_free (tab->priv->title); - - if (new_title == NULL || new_title[0] == '\0') + if (title == NULL || title[0] == '\0') { GnomeVFSURI *uri = NULL; char *address; + g_free (title); + title = NULL; + address = ephy_embed_get_location (embed, TRUE); - if (address) + if (address != NULL) { uri = gnome_vfs_uri_new (address); } - if (uri) + if (uri != NULL) { title = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_USER_NAME | @@ -1835,31 +1792,29 @@ ephy_tab_set_title (EphyTab *tab, EphyEmbed *embed, const char *new_title) GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD | GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER); gnome_vfs_uri_unref (uri); + g_free (address); } - else if (address != NULL && strncmp (address, "about:blank", 11) != 0) + else if (address != NULL && + strncmp (address, "about:blank", 11) != 0) { - title = g_strdup (address); + title = address; + } + else + { + g_free (address); } + /* Fallback */ if (title == NULL || title[0] == '\0') { g_free (title); title = g_strdup (_("Blank page")); } - - g_free (address); - } - else - { - title = g_strdup (new_title); } + g_free (tab->priv->title); tab->priv->title = title; - g_object_set (G_OBJECT (tab->priv->action), - "label", title, - NULL); - g_object_notify (G_OBJECT (tab), "title"); } @@ -1874,7 +1829,7 @@ ephy_tab_set_title (EphyTab *tab, EphyEmbed *embed, const char *new_title) const char * ephy_tab_get_title (EphyTab *tab) { - g_return_val_if_fail (EPHY_IS_TAB (tab), ""); + g_return_val_if_fail (EPHY_IS_TAB (tab), NULL); return tab->priv->title; } @@ -1984,23 +1939,3 @@ ephy_tab_get_zoom (EphyTab *tab) return tab->priv->zoom; } - -/** - * ephy_tab_get_action: - * @tab: an #EphyTab - * - * DO NOT USE - * - * Returns the #GtkToggleAction represented by the labelled tab displayed at the - * top of @tab's #EphyWindow when multiple tabs are loaded. Activating this - * action will switch the window to display @tab. - * - * Return value: @tab's #GtkToggleAction - **/ -GObject * -ephy_tab_get_action (EphyTab *tab) -{ - g_return_val_if_fail (EPHY_IS_TAB (tab), NULL); - - return G_OBJECT (tab->priv->action); -} diff --git a/src/ephy-tab.h b/src/ephy-tab.h index 474030400..f341f6887 100644 --- a/src/ephy-tab.h +++ b/src/ephy-tab.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2003 Marco Pesenti Gritti - * Copyright (C) 2003 Christian Persch + * Copyright (C) 2003, 2004, 2005 Christian Persch * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,16 +66,10 @@ struct _EphyTabClass GtkBinClass parent_class; }; -GType ephy_tab_address_expire_get_type (void); - -GType ephy_tab_navigation_flags_get_type (void); - GType ephy_tab_get_type (void); EphyTab *ephy_tab_new (void); -GObject *ephy_tab_get_action (EphyTab *tab); - EphyEmbed *ephy_tab_get_embed (EphyTab *tab); EphyTab *ephy_tab_for_embed (EphyEmbed *embed); diff --git a/src/ephy-tabs-menu.c b/src/ephy-tabs-menu.c index 212a9e6e0..46740b362 100644 --- a/src/ephy-tabs-menu.c +++ b/src/ephy-tabs-menu.c @@ -27,10 +27,12 @@ #include "ephy-shell.h" #include "ephy-debug.h" +#include <glib/gi18n.h> #include <gtk/gtklabel.h> #include <gtk/gtkmenuitem.h> #include <gtk/gtkaccelmap.h> #include <gtk/gtkaction.h> +#include <gtk/gtktoggleaction.h> #include <gtk/gtkradioaction.h> #include <gtk/gtkuimanager.h> #include <string.h> @@ -38,6 +40,11 @@ #include <libxml/entities.h> #define LABEL_WIDTH_CHARS 32 +#define ACTION_VERB_FORMAT "JmpTab%x" +#define ACTION_VERB_FORMAT_LENGTH strlen (ACTION_VERB_FORMAT) + 14 + 1 +#define ACCEL_PATH_FORMAT "<Actions>/TabsActions/%s" +#define ACCEL_PATH_FORMAT_LENGTH strlen (ACCEL_PATH_FORMAT) -2 + ACTION_VERB_FORMAT_LENGTH +#define DATA_KEY "EphyTabsMenu::Action" #define EPHY_TABS_MENU_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TABS_MENU, EphyTabsMenuPrivate)) @@ -45,81 +52,154 @@ struct _EphyTabsMenuPrivate { EphyWindow *window; GtkActionGroup *action_group; + GtkAction *anchor_action; guint ui_id; + guint num; }; -static void ephy_tabs_menu_class_init (EphyTabsMenuClass *klass); -static void ephy_tabs_menu_init (EphyTabsMenu *menu); - enum { PROP_0, PROP_WINDOW }; +static void ephy_tabs_menu_class_init (EphyTabsMenuClass *klass); +static void ephy_tabs_menu_init (EphyTabsMenu *menu); + GType ephy_tabs_menu_get_type (void) { - static GType type = 0; - - if (G_UNLIKELY (type == 0)) - { - static const GTypeInfo our_info = - { - sizeof (EphyTabsMenuClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) ephy_tabs_menu_class_init, - NULL, - NULL, /* class_data */ - sizeof (EphyTab), - 0, /* n_preallocs */ - (GInstanceInitFunc) ephy_tabs_menu_init - }; - - type = g_type_register_static (G_TYPE_OBJECT, + static GType type = 0; + + if (G_UNLIKELY (type == 0)) + { + static const GTypeInfo our_info = + { + sizeof (EphyTabsMenuClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) ephy_tabs_menu_class_init, + NULL, + NULL, /* class_data */ + sizeof (EphyTab), + 0, /* n_preallocs */ + (GInstanceInitFunc) ephy_tabs_menu_init + }; + + type = g_type_register_static (G_TYPE_OBJECT, "EphyTabsMenu", &our_info, 0); - } + } + + return type; +} + +static void +tab_action_activate_cb (GtkToggleAction *action, + EphyTabsMenu *menu) +{ + EphyTabsMenuPrivate *priv = menu->priv; + EphyTab *tab; - return type; + if (gtk_toggle_action_get_active (action) == FALSE) + { + return; + } + + tab = g_object_get_data (G_OBJECT (action), DATA_KEY); + g_return_if_fail (tab != NULL); + + LOG ("tab_action_activate_cb tab=%p", tab); + + if (ephy_window_get_active_tab (priv->window) != tab) + { + ephy_window_jump_to_tab (priv->window, tab); + } +} + +static void +sync_tab_title (EphyTab *tab, + GParamSpec *pspec, + GtkAction *action) +{ + const char *title; + + title = ephy_tab_get_title (tab); + + g_object_set (action, "label", title, NULL); } static void -tab_added_cb (EphyNotebook *notebook, EphyTab *tab, EphyTabsMenu *menu) +tab_added_cb (EphyNotebook *notebook, + EphyTab *tab, + EphyTabsMenu *menu) { + EphyTabsMenuPrivate *priv = menu->priv; GtkAction *action; - char accel_path[40]; + char verb[ACTION_VERB_FORMAT_LENGTH]; + GSList *group; - g_return_if_fail (EPHY_IS_TAB (tab)); + LOG ("tab_added_cb tab=%p", tab); - action = GTK_ACTION (ephy_tab_get_action (tab)); + g_snprintf (verb, sizeof (verb), ACTION_VERB_FORMAT, priv->num++); + + action = g_object_new (GTK_TYPE_RADIO_ACTION, + "name", verb, + "tooltip", _("Switch to this tab"), + NULL); - g_snprintf (accel_path, sizeof (accel_path), - "<Actions>/TabsActions/%s", gtk_action_get_name (action)); - gtk_action_set_accel_path (action, accel_path); + g_signal_connect (action, "activate", + G_CALLBACK (tab_action_activate_cb), menu); + + sync_tab_title (tab, NULL, action); + g_signal_connect (tab, "notify::title", + G_CALLBACK (sync_tab_title), action); - gtk_action_group_add_action (menu->priv->action_group, action); + 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); + + g_object_set_data (G_OBJECT (tab), DATA_KEY, action); + g_object_set_data (G_OBJECT (action), DATA_KEY, tab); + g_object_unref (action); ephy_tabs_menu_update (menu); } static void -tab_removed_cb (EphyNotebook *notebook, EphyTab *tab, EphyTabsMenu *menu) +tab_removed_cb (EphyNotebook *notebook, + EphyTab *tab, + EphyTabsMenu *menu) { + EphyTabsMenuPrivate *priv = menu->priv; GtkAction *action; - - g_return_if_fail (EPHY_IS_TAB (tab)); + + g_return_if_fail (EPHY_IS_TAB (tab)); + + LOG ("tab_removed_cb tab=%p", tab); + + action = g_object_get_data (G_OBJECT (tab), DATA_KEY); + g_return_if_fail (action != NULL); - action = GTK_ACTION (ephy_tab_get_action (tab)); - gtk_action_group_remove_action (menu->priv->action_group, action); + g_signal_handlers_disconnect_by_func + (tab, G_CALLBACK (sync_tab_title), action); + + g_signal_handlers_disconnect_by_func + (action, G_CALLBACK (tab_action_activate_cb), tab); + + g_object_set_data (G_OBJECT (tab), DATA_KEY, NULL); + gtk_action_group_remove_action (priv->action_group, action); ephy_tabs_menu_update (menu); } static void -tabs_reordered_cb (EphyNotebook *notebook, EphyTabsMenu *menu) +tabs_reordered_cb (EphyNotebook *notebook, + EphyTabsMenu *menu) { + LOG ("tabs_reordered_cb"); + ephy_tabs_menu_update (menu); } @@ -142,26 +222,59 @@ connect_proxy_cb (GtkActionGroup *action_group, } static void -ephy_tabs_menu_set_window (EphyTabsMenu *menu, EphyWindow *window) +sync_active_tab (EphyWindow *window, + GParamSpec *pspec, + EphyTabsMenu *menu) +{ + EphyTab *tab; + GtkAction *action; + + tab = ephy_window_get_active_tab (window); + g_return_if_fail (tab != NULL); + if (tab == NULL) return; + + LOG ("active tab is tab %p", tab); + + action = g_object_get_data (G_OBJECT (tab), DATA_KEY); + /* happens initially, since the ::active-tab comes before + * the ::tab-added signal + */ + if (action == NULL) return; + + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); +} + +static void +ephy_tabs_menu_set_window (EphyTabsMenu *menu, + EphyWindow *window) { + EphyTabsMenuPrivate *priv = menu->priv; GtkWidget *notebook; GtkUIManager *manager; - menu->priv->window = window; + priv->window = window; manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window)); - menu->priv->action_group = gtk_action_group_new ("TabsActions"); - gtk_ui_manager_insert_action_group (manager, menu->priv->action_group, -1); - g_object_unref (menu->priv->action_group); + priv->action_group = gtk_action_group_new ("TabsActions"); + gtk_ui_manager_insert_action_group (manager, priv->action_group, -1); + g_object_unref (priv->action_group); - g_signal_connect (menu->priv->action_group, "connect-proxy", + priv->anchor_action = g_object_new (GTK_TYPE_RADIO_ACTION, + "name", "TabsMenuAnchorAction", + NULL); + gtk_action_group_add_action (priv->action_group, priv->anchor_action); + + g_signal_connect (priv->action_group, "connect-proxy", G_CALLBACK (connect_proxy_cb), NULL); + g_signal_connect (window, "notify::active-tab", + G_CALLBACK (sync_active_tab), menu); + notebook = ephy_window_get_notebook (window); g_signal_connect_object (notebook, "tab_added", - G_CALLBACK (tab_added_cb), menu, 0); + G_CALLBACK (tab_added_cb), menu, 0); g_signal_connect_object (notebook, "tab_removed", - G_CALLBACK (tab_removed_cb), menu, 0); + G_CALLBACK (tab_removed_cb), menu, 0); g_signal_connect_object (notebook, "tabs_reordered", G_CALLBACK (tabs_reordered_cb), menu, 0); } @@ -172,31 +285,24 @@ ephy_tabs_menu_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - EphyTabsMenu *m = EPHY_TABS_MENU (object); - - switch (prop_id) - { - case PROP_WINDOW: - ephy_tabs_menu_set_window - (m, EPHY_WINDOW (g_value_get_object (value))); - break; - } + EphyTabsMenu *menu = EPHY_TABS_MENU (object); + + switch (prop_id) + { + case PROP_WINDOW: + ephy_tabs_menu_set_window (menu, g_value_get_object (value)); + break; + } } static void ephy_tabs_menu_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { - EphyTabsMenu *m = EPHY_TABS_MENU (object); - - switch (prop_id) - { - case PROP_WINDOW: - g_value_set_object (value, m->priv->window); - break; - } + /* no readable properties */ + g_return_if_reached (); } static void @@ -208,15 +314,15 @@ ephy_tabs_menu_class_init (EphyTabsMenuClass *klass) object_class->get_property = ephy_tabs_menu_get_property; g_object_class_install_property (object_class, - PROP_WINDOW, - g_param_spec_object ("window", - "Window", - "Parent window", - EPHY_TYPE_WINDOW, - G_PARAM_READWRITE | + PROP_WINDOW, + g_param_spec_object ("window", + "Window", + "Parent window", + EPHY_TYPE_WINDOW, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_type_class_add_private (object_class, sizeof(EphyTabsMenuPrivate)); + g_type_class_add_private (object_class, sizeof (EphyTabsMenuPrivate)); } static void @@ -231,7 +337,7 @@ ephy_tabs_menu_clean (EphyTabsMenu *menu) EphyTabsMenuPrivate *p = menu->priv; GtkUIManager *manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (p->window)); - if (p->ui_id > 0) + if (p->ui_id != 0) { gtk_ui_manager_remove_ui (manager, p->ui_id); gtk_ui_manager_ensure_update (manager); @@ -252,19 +358,18 @@ tab_set_action_accelerator (GtkActionGroup *action_group, GtkAction *action, guint tab_number) { - const char *action_name, *action_group_name; - char *accel_path; + const char *verb; + char accel_path[ACCEL_PATH_FORMAT_LENGTH]; char accel[7]; gint accel_number; guint accel_key; GdkModifierType accel_mods; - action_name = gtk_action_get_name (action); - action_group_name = gtk_action_group_get_name (action_group); + verb = gtk_action_get_name (action); /* set the accel path for the menu item */ - accel_path = g_strconcat ("<Actions>/", action_group_name, "/", - action_name, NULL); + g_snprintf (accel_path, sizeof (accel_path), + ACCEL_PATH_FORMAT, verb); gtk_action_set_accel_path (action, accel_path); /* Only the first ten tabs get accelerators starting from 1 through 0 */ @@ -287,19 +392,17 @@ tab_set_action_accelerator (GtkActionGroup *action_group, { gtk_accel_map_change_entry (accel_path, 0, 0, TRUE); } - - g_free (accel_path); } void ephy_tabs_menu_update (EphyTabsMenu *menu) { EphyTabsMenuPrivate *p = menu->priv; - GtkUIManager *manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (p->window)); - EphyTab *tab; + GtkUIManager *manager; GtkAction *action; - guint i = 0; GList *tabs = NULL, *l; + guint i = 0; + const char *verb; LOG ("Rebuilding open tabs menu"); @@ -311,25 +414,22 @@ ephy_tabs_menu_update (EphyTabsMenu *menu) if (g_list_length (tabs) == 0) return; + manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (p->window)); p->ui_id = gtk_ui_manager_new_merge_id (manager); for (l = tabs; l != NULL; l = l->next) { - const char *action_name; - char *name; - - tab = (EphyTab *) l->data; - action = GTK_ACTION (ephy_tab_get_action (tab)); - action_name = gtk_action_get_name (action); - name = g_strdup_printf ("%sMenu", action_name); + action = g_object_get_data (G_OBJECT (l->data), DATA_KEY); + g_return_if_fail (action != NULL); + + verb = gtk_action_get_name (action); tab_set_action_accelerator (p->action_group, action, i++); gtk_ui_manager_add_ui (manager, p->ui_id, "/menubar/TabsMenu/TabsOpen", - name, action_name, + verb, verb, GTK_UI_MANAGER_MENUITEM, FALSE); - g_free (name); } g_list_free (tabs); diff --git a/src/ephy-window.c b/src/ephy-window.c index 6ea4fbe27..77953976c 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -1816,7 +1816,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) { EphyTab *old_tab; EphyEmbed *embed; - GtkToggleAction *action; g_return_if_fail (EPHY_IS_WINDOW (window)); g_return_if_fail (gtk_widget_get_toplevel (GTK_WIDGET (new_tab)) == GTK_WIDGET (window)); @@ -1825,7 +1824,7 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) if (old_tab == new_tab) return; - if (old_tab) + if (old_tab != NULL) { g_signal_handlers_disconnect_by_func (G_OBJECT (old_tab), G_CALLBACK (sync_tab_address), @@ -1868,14 +1867,11 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) g_signal_handlers_disconnect_by_func (G_OBJECT (embed), G_CALLBACK (tab_context_menu_cb), window); - - action = GTK_TOGGLE_ACTION (ephy_tab_get_action (old_tab)); - gtk_toggle_action_set_active (action, FALSE); } window->priv->active_tab = new_tab; - if (new_tab) + if (new_tab != NULL) { sync_tab_address (new_tab, NULL, window); sync_tab_document_type (new_tab, NULL, window); @@ -1944,9 +1940,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab) G_CALLBACK (tab_context_menu_cb), window, G_CONNECT_AFTER); - action = GTK_TOGGLE_ACTION (ephy_tab_get_action (new_tab)); - gtk_toggle_action_set_active (action, TRUE); - g_object_notify (G_OBJECT (window), "active-tab"); } } @@ -3096,7 +3089,7 @@ ephy_window_get_active_embed (EphyWindow *window) g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL); tab = ephy_window_get_active_tab (window); - g_return_val_if_fail (EPHY_IS_TAB (tab), NULL); + if (tab == NULL) return NULL; return ephy_tab_get_embed (tab); } |