Commit da3e75ec authored by Christian Persch's avatar Christian Persch Committed by Christian Persch

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.
parent b48d4a6f
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.
2005-02-10 Christian Persch <chpe@cvs.gnome.org> 2005-02-10 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-window.c: (ephy_window_dispose), * src/ephy-window.c: (ephy_window_dispose),
......
/* /*
* Copyright (C) 2000-2003 Marco Pesenti Gritti * 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 Crispin Flowerday
* Copyright (C) 2004 Adam Hooper * Copyright (C) 2004 Adam Hooper
* *
...@@ -57,7 +57,6 @@ ...@@ -57,7 +57,6 @@
#include <gtk/gtkmain.h> #include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h> #include <gtk/gtkmenu.h>
#include <gtk/gtkuimanager.h> #include <gtk/gtkuimanager.h>
#include <gtk/gtkradioaction.h>
#include <gtk/gtkclipboard.h> #include <gtk/gtkclipboard.h>
#include <string.h> #include <string.h>
...@@ -80,7 +79,6 @@ struct _EphyTabPrivate ...@@ -80,7 +79,6 @@ struct _EphyTabPrivate
int total_requests; int total_requests;
int width; int width;
int height; int height;
GtkToggleAction *action;
float zoom; float zoom;
gboolean setting_zoom; gboolean setting_zoom;
EphyEmbedSecurityLevel security_level; EphyEmbedSecurityLevel security_level;
...@@ -120,8 +118,6 @@ typedef struct ...@@ -120,8 +118,6 @@ typedef struct
static GObjectClass *parent_class = NULL; static GObjectClass *parent_class = NULL;
static gulong tab_id = 0;
/* internal functions, accessible only from this file */ /* internal functions, accessible only from this file */
static void ephy_tab_set_icon_address (EphyTab *tab, static void ephy_tab_set_icon_address (EphyTab *tab,
const char *location); const char *location);
...@@ -137,7 +133,7 @@ static void ephy_tab_set_security_level (EphyTab *tab, ...@@ -137,7 +133,7 @@ static void ephy_tab_set_security_level (EphyTab *tab,
EphyEmbedSecurityLevel level); EphyEmbedSecurityLevel level);
static void ephy_tab_set_title (EphyTab *tab, static void ephy_tab_set_title (EphyTab *tab,
EphyEmbed *embed, EphyEmbed *embed,
const char *new_title); char *new_title);
static void ephy_tab_set_zoom (EphyTab *tab, static void ephy_tab_set_zoom (EphyTab *tab,
float zoom); float zoom);
static guint popup_blocker_n_hidden (EphyTab *tab); static guint popup_blocker_n_hidden (EphyTab *tab);
...@@ -327,23 +323,6 @@ ephy_tab_get_window (EphyTab *tab) ...@@ -327,23 +323,6 @@ ephy_tab_get_window (EphyTab *tab)
return EPHY_WINDOW (toplevel); return EPHY_WINDOW (toplevel);
} }
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 static void
ephy_tab_class_init (EphyTabClass *class) ephy_tab_class_init (EphyTabClass *class)
{ {
...@@ -761,11 +740,6 @@ ephy_tab_finalize (GObject *object) ...@@ -761,11 +740,6 @@ ephy_tab_finalize (GObject *object)
g_idle_remove_by_data (tab); 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->title);
g_free (tab->priv->address); g_free (tab->priv->address);
g_free (tab->priv->icon_address); g_free (tab->priv->icon_address);
...@@ -1167,8 +1141,6 @@ ephy_tab_title_cb (EphyEmbed *embed, EphyTab *tab) ...@@ -1167,8 +1141,6 @@ ephy_tab_title_cb (EphyEmbed *embed, EphyTab *tab)
title = ephy_embed_get_title (embed); title = ephy_embed_get_title (embed);
ephy_tab_set_title (tab, embed, title); ephy_tab_set_title (tab, embed, title);
g_free (title);
} }
static int static int
...@@ -1280,13 +1252,13 @@ build_progress_from_requests (EphyTab *tab, EphyEmbedNetState state) ...@@ -1280,13 +1252,13 @@ build_progress_from_requests (EphyTab *tab, EphyEmbedNetState state)
static void static void
ensure_page_info (EphyTab *tab, EphyEmbed *embed, const char *address) 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) tab->priv->address_expire == EPHY_TAB_ADDRESS_EXPIRE_NOW)
{ {
ephy_tab_set_location (tab, address, 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); ephy_tab_set_title (tab, embed, NULL);
} }
...@@ -1600,7 +1572,6 @@ ephy_tab_init (EphyTab *tab) ...@@ -1600,7 +1572,6 @@ ephy_tab_init (EphyTab *tab)
{ {
GObject *embed; GObject *embed;
EphyFaviconCache *cache; EphyFaviconCache *cache;
char *id;
LOG ("EphyTab initialising %p", tab); LOG ("EphyTab initialising %p", tab);
...@@ -1616,6 +1587,7 @@ ephy_tab_init (EphyTab *tab) ...@@ -1616,6 +1587,7 @@ ephy_tab_init (EphyTab *tab)
tab->priv->document_type = EPHY_EMBED_DOCUMENT_HTML; tab->priv->document_type = EPHY_EMBED_DOCUMENT_HTML;
tab->priv->zoom = 1.0; tab->priv->zoom = 1.0;
tab->priv->address_expire = EPHY_TAB_ADDRESS_EXPIRE_NOW; tab->priv->address_expire = EPHY_TAB_ADDRESS_EXPIRE_NOW;
tab->priv->title = g_strdup ("");
embed = ephy_embed_factory_new_object (EPHY_TYPE_EMBED); embed = ephy_embed_factory_new_object (EPHY_TYPE_EMBED);
g_assert (embed != NULL); g_assert (embed != NULL);
...@@ -1623,18 +1595,6 @@ ephy_tab_init (EphyTab *tab) ...@@ -1623,18 +1595,6 @@ ephy_tab_init (EphyTab *tab)
gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (embed)); gtk_container_add (GTK_CONTAINER (tab), GTK_WIDGET (embed));
gtk_widget_show (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_signal_connect_object (embed, "link_message",
G_CALLBACK (ephy_tab_link_message_cb), G_CALLBACK (ephy_tab_link_message_cb),
tab, 0); tab, 0);
...@@ -1803,30 +1763,27 @@ ephy_tab_get_status_message (EphyTab *tab) ...@@ -1803,30 +1763,27 @@ ephy_tab_get_status_message (EphyTab *tab)
} }
} }
#define MAX_LABEL_LENGTH 32
static void 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; if (title == NULL || title[0] == '\0')
g_return_if_fail (EPHY_IS_TAB (tab));
g_free (tab->priv->title);
if (new_title == NULL || new_title[0] == '\0')
{ {
GnomeVFSURI *uri = NULL; GnomeVFSURI *uri = NULL;
char *address; char *address;
g_free (title);
title = NULL;
address = ephy_embed_get_location (embed, TRUE); address = ephy_embed_get_location (embed, TRUE);
if (address) if (address != NULL)
{ {
uri = gnome_vfs_uri_new (address); uri = gnome_vfs_uri_new (address);
} }
if (uri) if (uri != NULL)
{ {
title = gnome_vfs_uri_to_string (uri, title = gnome_vfs_uri_to_string (uri,
GNOME_VFS_URI_HIDE_USER_NAME | GNOME_VFS_URI_HIDE_USER_NAME |
...@@ -1835,31 +1792,29 @@ ephy_tab_set_title (EphyTab *tab, EphyEmbed *embed, const char *new_title) ...@@ -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_TOPLEVEL_METHOD |
GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER); GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER);
gnome_vfs_uri_unref (uri); 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') if (title == NULL || title[0] == '\0')
{ {
g_free (title); g_free (title);
title = g_strdup (_("Blank page")); title = g_strdup (_("Blank page"));
} }
g_free (address);
}
else
{
title = g_strdup (new_title);
} }
g_free (tab->priv->title);
tab->priv->title = title; tab->priv->title = title;
g_object_set (G_OBJECT (tab->priv->action),
"label", title,
NULL);
g_object_notify (G_OBJECT (tab), "title"); g_object_notify (G_OBJECT (tab), "title");
} }
...@@ -1874,7 +1829,7 @@ ephy_tab_set_title (EphyTab *tab, EphyEmbed *embed, const char *new_title) ...@@ -1874,7 +1829,7 @@ ephy_tab_set_title (EphyTab *tab, EphyEmbed *embed, const char *new_title)
const char * const char *
ephy_tab_get_title (EphyTab *tab) 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; return tab->priv->title;
} }
...@@ -1984,23 +1939,3 @@ ephy_tab_get_zoom (EphyTab *tab) ...@@ -1984,23 +1939,3 @@ ephy_tab_get_zoom (EphyTab *tab)
return tab->priv->zoom; 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);
}
/* /*
* Copyright (C) 2000-2003 Marco Pesenti Gritti * 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 * 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 * it under the terms of the GNU General Public License as published by
...@@ -66,16 +66,10 @@ struct _EphyTabClass ...@@ -66,16 +66,10 @@ struct _EphyTabClass
GtkBinClass parent_class; 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); GType ephy_tab_get_type (void);
EphyTab *ephy_tab_new (void); EphyTab *ephy_tab_new (void);
GObject *ephy_tab_get_action (EphyTab *tab);
EphyEmbed *ephy_tab_get_embed (EphyTab *tab); EphyEmbed *ephy_tab_get_embed (EphyTab *tab);
EphyTab *ephy_tab_for_embed (EphyEmbed *embed); EphyTab *ephy_tab_for_embed (EphyEmbed *embed);
......
...@@ -27,10 +27,12 @@ ...@@ -27,10 +27,12 @@
#include "ephy-shell.h" #include "ephy-shell.h"
#include "ephy-debug.h" #include "ephy-debug.h"
#include <glib/gi18n.h>
#include <gtk/gtklabel.h> #include <gtk/gtklabel.h>
#include <gtk/gtkmenuitem.h> #include <gtk/gtkmenuitem.h>
#include <gtk/gtkaccelmap.h> #include <gtk/gtkaccelmap.h>
#include <gtk/gtkaction.h> #include <gtk/gtkaction.h>
#include <gtk/gtktoggleaction.h>
#include <gtk/gtkradioaction.h> #include <gtk/gtkradioaction.h>
#include <gtk/gtkuimanager.h> #include <gtk/gtkuimanager.h>
#include <string.h> #include <string.h>
...@@ -38,6 +40,11 @@ ...@@ -38,6 +40,11 @@
#include <libxml/entities.h> #include <libxml/entities.h>
#define LABEL_WIDTH_CHARS 32 #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)) #define EPHY_TABS_MENU_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TABS_MENU, EphyTabsMenuPrivate))
...@@ -45,81 +52,154 @@ struct _EphyTabsMenuPrivate ...@@ -45,81 +52,154 @@ struct _EphyTabsMenuPrivate
{ {
EphyWindow *window; EphyWindow *window;
GtkActionGroup *action_group; GtkActionGroup *action_group;
GtkAction *anchor_action;
guint ui_id; guint ui_id;
guint num;
}; };
static void ephy_tabs_menu_class_init (EphyTabsMenuClass *klass);
static void ephy_tabs_menu_init (EphyTabsMenu *menu);
enum enum
{ {
PROP_0, PROP_0,
PROP_WINDOW PROP_WINDOW
}; };
static void ephy_tabs_menu_class_init (EphyTabsMenuClass *klass);
static void ephy_tabs_menu_init (EphyTabsMenu *menu);
GType GType
ephy_tabs_menu_get_type (void) ephy_tabs_menu_get_type (void)
{ {
static GType type = 0; static GType type = 0;
if (G_UNLIKELY (type == 0)) if (G_UNLIKELY (type == 0))
{ {
static const GTypeInfo our_info = static const GTypeInfo our_info =
{ {
sizeof (EphyTabsMenuClass), sizeof (EphyTabsMenuClass),
NULL, /* base_init */ NULL, /* base_init */
NULL, /* base_finalize */ NULL, /* base_finalize */
(GClassInitFunc) ephy_tabs_menu_class_init, (GClassInitFunc) ephy_tabs_menu_class_init,
NULL, NULL,
NULL, /* class_data */ NULL, /* class_data */
sizeof (EphyTab), sizeof (EphyTab),
0, /* n_preallocs */ 0, /* n_preallocs */
(GInstanceInitFunc) ephy_tabs_menu_init (GInstanceInitFunc) ephy_tabs_menu_init
}; };
type = g_type_register_static (G_TYPE_OBJECT, type = g_type_register_static (G_TYPE_OBJECT,
"EphyTabsMenu", "EphyTabsMenu",
&our_info, 0); &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 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; 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), g_signal_connect (action, "activate",
"<Actions>/TabsActions/%s", gtk_action_get_name (action)); G_CALLBACK (tab_action_activate_cb), menu);
gtk_action_set_accel_path (action, accel_path);
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); ephy_tabs_menu_update (menu);
} }
static void 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; 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)); g_signal_handlers_disconnect_by_func
gtk_action_group_remove_action (menu->priv->action_group, action); (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); ephy_tabs_menu_update (menu);
} }
static void 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); ephy_tabs_menu_update (menu);
} }
...@@ -142,26 +222,59 @@ connect_proxy_cb (GtkActionGroup *action_group, ...@@ -142,26 +222,59 @@ connect_proxy_cb (GtkActionGroup *action_group,
} }
static void 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; GtkWidget *notebook;
GtkUIManager *manager; GtkUIManager *manager;
menu->priv->window = window; priv->window = window;
manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window)); manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
menu->priv->action_group = gtk_action_group_new ("TabsActions"); priv->action_group = gtk_action_group_new ("TabsActions");
gtk_ui_manager_insert_action_group (manager, menu->priv->action_group, -1); gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
g_object_unref (menu->priv->action_group); 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_CALLBACK (connect_proxy_cb), NULL);
g_signal_connect (window, "notify::active-tab",
G_CALLBACK (sync_active_tab), menu);
notebook = ephy_window_get_notebook (window); notebook = ephy_window_get_notebook (window);
g_signal_connect_object (notebook, "tab_added", 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_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_signal_connect_object (notebook, "tabs_reordered",
G_CALLBACK (tabs_reordered_cb), menu, 0); G_CALLBACK (tabs_reordered_cb), menu, 0);
} }
...@@ -172,31 +285,24 @@ ephy_tabs_menu_set_property (GObject *object, ...@@ -172,31 +285,24 @@ ephy_tabs_menu_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
EphyTabsMenu *m = EPHY_TABS_MENU (object); EphyTabsMenu *menu = EPHY_TABS_MENU (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_WINDOW: case PROP_WINDOW:
ephy_tabs_menu_set_window ephy_tabs_menu_set_window (menu, g_value_get_object (value));
(m, EPHY_WINDOW (g_value_get_object (value))); break;
break; }
}
} }
stati