aboutsummaryrefslogtreecommitdiffstats
path: root/src/toolbar.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-11-01 22:48:55 +0800
committerChristian Persch <chpe@src.gnome.org>2004-11-01 22:48:55 +0800
commit748a94321a69d4220b97d75cc5e64aa15a2112c7 (patch)
tree26d0d208de9f4206e6c9d1baf3ad7a1ef26e0fc0 /src/toolbar.c
parent57730e8161a159fdb5a38b9dd0d19dda3bdde8e5 (diff)
downloadgsoc2013-epiphany-748a94321a69d4220b97d75cc5e64aa15a2112c7.tar
gsoc2013-epiphany-748a94321a69d4220b97d75cc5e64aa15a2112c7.tar.gz
gsoc2013-epiphany-748a94321a69d4220b97d75cc5e64aa15a2112c7.tar.bz2
gsoc2013-epiphany-748a94321a69d4220b97d75cc5e64aa15a2112c7.tar.lz
gsoc2013-epiphany-748a94321a69d4220b97d75cc5e64aa15a2112c7.tar.xz
gsoc2013-epiphany-748a94321a69d4220b97d75cc5e64aa15a2112c7.tar.zst
gsoc2013-epiphany-748a94321a69d4220b97d75cc5e64aa15a2112c7.zip
Don't deactivate the toolbar when another item in the same toolbar gains
2004-11-01 Christian Persch <chpe@cvs.gnome.org> * lib/widgets/ephy-location-entry.c: (ephy_location_entry_init), (ephy_location_entry_activate): * src/ephy-location-action.c: (ephy_location_action_class_init): * src/ephy-window.c: (ephy_window_init): * src/toolbar.c: (toolbar_class_init), (toolbar_finalize), (maybe_finish_activation_cb), (toolbar_activate_location), (toolbar_update_zoom), (toolbar_new): * src/toolbar.h: Don't deactivate the toolbar when another item in the same toolbar gains focus. Fixes bug #155650.
Diffstat (limited to 'src/toolbar.c')
-rwxr-xr-xsrc/toolbar.c98
1 files changed, 88 insertions, 10 deletions
diff --git a/src/toolbar.c b/src/toolbar.c
index 67f7edb4f..2b8ffd3b7 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -63,6 +63,14 @@ enum
PROP_WINDOW
};
+enum
+{
+ ACTIVATION_FINISHED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
static GObjectClass *parent_class = NULL;
#define CONF_LOCKDOWN_DISABLE_ARBITRARY_URL "/apps/epiphany/lockdown/disable_arbitrary_url"
@@ -76,6 +84,7 @@ struct ToolbarPrivate
gboolean updating_address;
GtkWidget *spinner;
guint disable_arbitrary_url_notifier_id;
+ gulong set_focus_handler;
};
GType
@@ -250,6 +259,16 @@ toolbar_class_init (ToolbarClass *klass)
widget_class->realize = toolbar_realize;
widget_class->unrealize = toolbar_unrealize;
+ signals[ACTIVATION_FINISHED] =
+ g_signal_new ("activation-finished",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (ToolbarClass, activation_finished),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
g_object_class_install_property (object_class,
PROP_WINDOW,
g_param_spec_object ("window",
@@ -454,6 +473,12 @@ toolbar_finalize (GObject *object)
Toolbar *t = EPHY_TOOLBAR (object);
EggEditableToolbar *eggtoolbar = EGG_EDITABLE_TOOLBAR (object);
+ if (t->priv->set_focus_handler != 0)
+ {
+ g_signal_handler_disconnect (t->priv->window,
+ t->priv->set_focus_handler);
+ }
+
eel_gconf_notification_remove
(t->priv->disable_arbitrary_url_notifier_id);
@@ -470,26 +495,70 @@ toolbar_finalize (GObject *object)
LOG ("Toolbar finalized")
}
-Toolbar *
-toolbar_new (EphyWindow *window)
+static void
+maybe_finish_activation_cb (EphyWindow *window,
+ GtkWidget *widget,
+ Toolbar *toolbar)
{
- return EPHY_TOOLBAR (g_object_new (EPHY_TYPE_TOOLBAR,
- "window", window,
- "ui-manager", ephy_window_get_ui_manager (window),
- NULL));
+ GtkWidget *wtoolbar = GTK_WIDGET (toolbar);
+
+ while (widget != NULL && widget != wtoolbar)
+ {
+ widget = widget->parent;
+ }
+
+ /* if widget == toolbar, the new focus widget is in the toolbar, so we
+ * don't deactivate.
+ */
+ if (widget != wtoolbar)
+ {
+ g_signal_handler_disconnect (window,
+ toolbar->priv->set_focus_handler);
+ toolbar->priv->set_focus_handler = 0;
+
+ g_signal_emit (toolbar, signals[ACTIVATION_FINISHED], 0);
+ }
}
void
-toolbar_activate_location (Toolbar *t)
+toolbar_activate_location (Toolbar *toolbar)
{
GtkActionGroup *action_group;
GtkAction *action;
+ GSList *proxies;
+ GtkWidget *entry = NULL;
+ gboolean visible;
- action_group = t->priv->action_group;
+ action_group = toolbar->priv->action_group;
action = gtk_action_group_get_action (action_group, "Location");
- gtk_action_activate (action);
-}
+ proxies = gtk_action_get_proxies (action);
+
+ if (proxies != NULL && EPHY_IS_LOCATION_ENTRY (proxies->data))
+ {
+ entry = GTK_WIDGET (proxies->data);
+ }
+
+ if (entry == NULL)
+ {
+ /* happens when the user has removed the location entry from
+ * the toolbars.
+ */
+ return;
+ }
+
+ ephy_location_entry_activate (EPHY_LOCATION_ENTRY (entry));
+
+ g_object_get (G_OBJECT (toolbar), "visible", &visible, NULL);
+ if (visible == FALSE)
+ {
+ gtk_widget_show (GTK_WIDGET (toolbar));
+ toolbar->priv->set_focus_handler =
+ g_signal_connect (toolbar->priv->window, "set-focus",
+ G_CALLBACK (maybe_finish_activation_cb),
+ toolbar);
+ }
+}
void
toolbar_spinner_start (Toolbar *t)
@@ -572,3 +641,12 @@ toolbar_update_zoom (Toolbar *t, float zoom)
action = gtk_action_group_get_action (action_group, "Zoom");
g_object_set (action, "zoom", zoom, NULL);
}
+
+Toolbar *
+toolbar_new (EphyWindow *window)
+{
+ return EPHY_TOOLBAR (g_object_new (EPHY_TYPE_TOOLBAR,
+ "window", window,
+ "ui-manager", ephy_window_get_ui_manager (window),
+ NULL));
+}