aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-tab.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-04-25 19:40:41 +0800
committerChristian Persch <chpe@src.gnome.org>2006-04-25 19:40:41 +0800
commit7c7d6f9dba8d66386213172d5e7c1e05577ebc49 (patch)
tree4177eedaa4c3c65dcdee5e1ff483ba74783d2b58 /src/ephy-tab.c
parent72987fc9b47a86b9eb271b214bf0675ed5589850 (diff)
downloadgsoc2013-epiphany-7c7d6f9dba8d66386213172d5e7c1e05577ebc49.tar.gz
gsoc2013-epiphany-7c7d6f9dba8d66386213172d5e7c1e05577ebc49.tar.zst
gsoc2013-epiphany-7c7d6f9dba8d66386213172d5e7c1e05577ebc49.zip
Make sure each tab has its own unique ID, so accel paths don't conflict
2006-04-25 Christian Persch <chpe@cvs.gnome.org> * src/ephy-tab.c: (ephy_tab_finalize), (ephy_tab_init), (ephy_tab_get_zoom), (_ephy_tab_get_id): * src/ephy-tab.h: * src/ephy-tabs-menu.c: (notebook_page_added_cb), (sync_active_tab): Make sure each tab has its own unique ID, so accel paths don't conflict between windows. Fixes bug #339548.
Diffstat (limited to 'src/ephy-tab.c')
-rw-r--r--src/ephy-tab.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 0b4a904dc..a793c167a 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -78,6 +78,8 @@
struct _EphyTabPrivate
{
+ guint id;
+
char *status_message;
char *link_message;
char *address;
@@ -146,7 +148,15 @@ typedef struct
char *features;
} PopupInfo;
-static GObjectClass *parent_class = NULL;
+static GObjectClass *parent_class;
+
+/* We need to assign unique IDs to tabs, otherwise accels get confused in the
+ * tabs menu (bug #339548). We could use a serial #, but the ID is used in the
+ * action name which is stored in a GQuark and so we should use them sparingly.
+ */
+
+static GArray *tabs_id_array = NULL;
+static guint n_tabs = 0;
/* internal functions, accessible only from this file */
static void ephy_tab_set_load_status (EphyTab *tab,
@@ -821,6 +831,7 @@ ephy_tab_finalize (GObject *object)
{
EphyTab *tab = EPHY_TAB (object);
EphyTabPrivate *priv = tab->priv;
+ guint id = priv->id;
if (priv->icon != NULL)
{
@@ -844,6 +855,14 @@ ephy_tab_finalize (GObject *object)
#endif
LOG ("EphyTab finalized %p", tab);
+
+ /* Remove the ID */
+ g_array_index (tabs_id_array, gpointer, id) = NULL;
+ if (--n_tabs == 0)
+ {
+ g_array_free (tabs_id_array, TRUE);
+ tabs_id_array = NULL;
+ }
}
static gboolean
@@ -2039,11 +2058,41 @@ ephy_tab_init (EphyTab *tab)
EphyTabPrivate *priv;
GObject *embed;
EphyFaviconCache *cache;
+ guint id;
LOG ("EphyTab initialising %p", tab);
priv = tab->priv = EPHY_TAB_GET_PRIVATE (tab);
+ /* Make tab ID */
+ ++n_tabs;
+
+ if (tabs_id_array == NULL)
+ {
+ tabs_id_array = g_array_sized_new (FALSE /* zero-terminate */,
+ TRUE /* clear */,
+ sizeof (gpointer),
+ 64 /* initial size */);
+ }
+
+ for (id = 0; id < tabs_id_array->len; ++id)
+ {
+ if (g_array_index (tabs_id_array, gpointer, id) == NULL) break;
+ }
+
+ priv->id = id;
+
+ /* Grow array if necessary */
+ if (id >= tabs_id_array->len)
+ {
+ g_array_append_val (tabs_id_array, tab);
+ g_assert (g_array_index (tabs_id_array, gpointer, id) == tab);
+ }
+ else
+ {
+ g_array_index (tabs_id_array, gpointer, id) = tab;
+ }
+
tab->priv->total_requests = 0;
tab->priv->cur_requests = 0;
tab->priv->width = -1;
@@ -2466,3 +2515,12 @@ ephy_tab_get_zoom (EphyTab *tab)
return tab->priv->zoom;
}
+
+/* private */
+guint
+_ephy_tab_get_id (EphyTab *tab)
+{
+ g_return_val_if_fail (EPHY_IS_TAB (tab), (guint) -1);
+
+ return tab->priv->id;
+}