diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-09-20 17:37:26 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-09-20 17:37:26 +0800 |
commit | 68616208eeeee369e62c9256fc9aba5dbe139e3e (patch) | |
tree | 279fbbbeb9bfb24372c9a3a9b6d169284c877e8d /src/toolbar.c | |
parent | f7c6e1db094b8f4da058aaec9b2faa9498326b59 (diff) | |
download | gsoc2013-epiphany-68616208eeeee369e62c9256fc9aba5dbe139e3e.tar gsoc2013-epiphany-68616208eeeee369e62c9256fc9aba5dbe139e3e.tar.gz gsoc2013-epiphany-68616208eeeee369e62c9256fc9aba5dbe139e3e.tar.bz2 gsoc2013-epiphany-68616208eeeee369e62c9256fc9aba5dbe139e3e.tar.lz gsoc2013-epiphany-68616208eeeee369e62c9256fc9aba5dbe139e3e.tar.xz gsoc2013-epiphany-68616208eeeee369e62c9256fc9aba5dbe139e3e.tar.zst gsoc2013-epiphany-68616208eeeee369e62c9256fc9aba5dbe139e3e.zip |
Remember the address in the location action, so we can restore it when we
2003-09-20 Christian Persch <chpe@cvs.gnome.org>
* lib/widgets/ephy-location-entry.c:
(ephy_location_entry_class_init),
(ephy_location_entry_activation_finished), (location_focus_out_cb),
(ephy_location_entry_init), (ephy_location_ignore_prefix),
(ephy_location_entry_activate_cb),
(ephy_location_entry_set_location),
(ephy_location_entry_get_location), (ephy_location_entry_activate),
(ephy_location_entry_editable_changed_cb),
(ephy_location_entry_clear_history):
* lib/widgets/ephy-location-entry.h:
* src/ephy-location-action.c: (location_url_activate_cb),
(user_changed_cb), (sync_address), (connect_proxy),
(disconnect_proxy), (ephy_location_action_set_property),
(ephy_location_action_get_property),
(ephy_location_action_activate), (ephy_location_action_class_init),
(ephy_location_action_init), (ephy_location_action_finalize),
(ephy_location_action_get_address),
(ephy_location_action_set_address), (clear_history),
(ephy_location_action_clear_history):
* src/ephy-location-action.h:
* src/toolbar.c: (toolbar_class_init), (toolbar_set_property),
(sync_user_input_cb), (toolbar_setup_actions),
(toolbar_set_window), (toolbar_init), (toolbar_finalize),
(toolbar_new), (toolbar_activate_location), (toolbar_set_location),
(toolbar_get_location), (toolbar_clear_location_history):
* src/toolbar.h:
* src/window-commands.c: (window_cmd_load_location):
Remember the address in the location action, so we can restore it when we
get a new proxy widget.
Do some misc cleanups on location entry, removing finished signal; move
activation from toolbar into location entry.
Diffstat (limited to 'src/toolbar.c')
-rwxr-xr-x | src/toolbar.c | 161 |
1 files changed, 61 insertions, 100 deletions
diff --git a/src/toolbar.c b/src/toolbar.c index 326a47f71..a1b4553f1 100755 --- a/src/toolbar.c +++ b/src/toolbar.c @@ -87,7 +87,7 @@ struct ToolbarPrivate GtkUIManager *ui_merge; GtkActionGroup *action_group; gboolean visibility; - gboolean can_set_location; + gboolean updating_address; GtkWidget *spinner; GtkWidget *favicon; GtkWidget *go; @@ -217,8 +217,8 @@ toolbar_class_init (ToolbarClass *klass) g_object_class_install_property (object_class, PROP_EPHY_WINDOW, - g_param_spec_object ("EphyWindow", - "EphyWindow", + g_param_spec_object ("window", + "Window", "Parent window", EPHY_TYPE_WINDOW, G_PARAM_READWRITE | @@ -238,8 +238,8 @@ toolbar_set_property (GObject *object, switch (prop_id) { case PROP_EPHY_WINDOW: - toolbar_set_window (t, g_value_get_object (value)); - break; + toolbar_set_window (t, g_value_get_object (value)); + break; } } @@ -260,6 +260,26 @@ toolbar_get_property (GObject *object, } static void +sync_user_input_cb (EphyLocationAction *action, GParamSpec *pspec, Toolbar *t) +{ + EphyTab *tab; + const char *address; + + LOG ("sync_user_input_cb") + + if (t->priv->updating_address) return; + + tab = ephy_window_get_active_tab (t->priv->window); + g_return_if_fail (EPHY_IS_TAB (tab)); + + address = ephy_location_action_get_address (action); + + t->priv->updating_address = TRUE; + ephy_tab_set_location (tab, address, TAB_ADDRESS_EXPIRE_CURRENT); + t->priv->updating_address = FALSE; +} + +static void toolbar_setup_actions (Toolbar *t) { GtkAction *action; @@ -324,6 +344,8 @@ toolbar_setup_actions (Toolbar *t) NULL); g_signal_connect (action, "go_location", G_CALLBACK (go_location_cb), t->priv->window); + g_signal_connect (action, "notify::address", + G_CALLBACK (sync_user_input_cb), t); gtk_action_group_add_action (t->priv->action_group, action); g_object_unref (action); @@ -430,36 +452,6 @@ update_toolbar_remove_flag (EphyToolbarsModel *model, gpointer data) } } -static GtkWidget * -get_location_entry (Toolbar *t) -{ - GtkAction *action; - GtkWidget *location; - - action = gtk_action_group_get_action - (t->priv->action_group, "Location"); - location = ephy_location_action_get_widget - (EPHY_LOCATION_ACTION (action)); - - return location; -} - -static void -location_user_changed_cb (GtkWidget *entry, Toolbar *t) -{ - EphyTab *tab; - char *address; - - tab = ephy_window_get_active_tab (t->priv->window); - g_return_if_fail (EPHY_IS_TAB (tab)); - - t->priv->can_set_location = FALSE; - address = ephy_location_entry_get_location (EPHY_LOCATION_ENTRY (entry)); - ephy_tab_set_location (tab, address, TAB_ADDRESS_EXPIRE_CURRENT); - g_free (address); - t->priv->can_set_location = TRUE; -} - static void init_normal_mode (Toolbar *t) { @@ -536,10 +528,6 @@ toolbar_set_window (Toolbar *t, EphyWindow *window) NULL); init_normal_mode (t); - - g_signal_connect_object (get_location_entry (t), "user_changed", - G_CALLBACK (location_user_changed_cb), - t, 0); } static void @@ -550,19 +538,13 @@ toolbar_init (Toolbar *t) t->priv->window = NULL; t->priv->ui_merge = NULL; t->priv->visibility = TRUE; - t->priv->can_set_location = TRUE; + t->priv->updating_address = FALSE; } static void toolbar_finalize (GObject *object) { - Toolbar *t; - ToolbarPrivate *p; - GtkUIManager *merge; - - t = EPHY_TOOLBAR (object); - p = t->priv; - merge = GTK_UI_MANAGER (t->priv->window->ui_merge); + Toolbar *t = EPHY_TOOLBAR (object); /* FIXME: why not at the end? */ G_OBJECT_CLASS (parent_class)->finalize (object); @@ -575,46 +557,21 @@ toolbar_finalize (GObject *object) Toolbar * toolbar_new (EphyWindow *window) { - Toolbar *t; - - t = EPHY_TOOLBAR (g_object_new (EPHY_TYPE_TOOLBAR, - "EphyWindow", window, - NULL)); - - return t; -} - -static void -location_finished_cb (GtkWidget *location, GtkWidget *toolbar) -{ - gtk_widget_hide (toolbar); - - g_signal_handlers_disconnect_by_func (G_OBJECT (location), - G_CALLBACK (location_finished_cb), - toolbar); + return EPHY_TOOLBAR (g_object_new (EPHY_TYPE_TOOLBAR, + "window", window, + NULL)); } void toolbar_activate_location (Toolbar *t) { - GtkWidget *location; - GtkWidget *location_tb; - - location = get_location_entry (t); - g_return_if_fail (location != NULL); - - location_tb = gtk_widget_get_ancestor (location, GTK_TYPE_TOOLBAR); - g_return_if_fail (location_tb != NULL); + GtkActionGroup *action_group; + GtkAction *action; - if (!GTK_WIDGET_VISIBLE (location_tb)) - { - g_signal_connect (location, "finished", - G_CALLBACK (location_finished_cb), location_tb); - gtk_widget_show (location_tb); - } + action_group = t->priv->action_group; + action = gtk_action_group_get_action (action_group, "Location"); - ephy_location_entry_activate - (EPHY_LOCATION_ENTRY(location)); + gtk_action_activate (action); } void @@ -641,19 +598,22 @@ toolbar_spinner_stop (Toolbar *t) void toolbar_set_location (Toolbar *t, - const char *alocation) + const char *address) { - GtkWidget *location; + GtkActionGroup *action_group; + GtkAction *action; - if (t->priv->can_set_location) - { - location = get_location_entry (t); - g_return_if_fail (location != NULL); + LOG ("toolbar set location %s", address) + LOG ("updating is %d", t->priv->updating_address) - ephy_location_entry_set_location - (EPHY_LOCATION_ENTRY (location), - alocation ? alocation : ""); - } + if (t->priv->updating_address) return; + + action_group = t->priv->action_group; + action = gtk_action_group_get_action (action_group, "Location"); + + t->priv->updating_address = TRUE; + ephy_location_action_set_address (EPHY_LOCATION_ACTION (action), address); + t->priv->updating_address = FALSE; } void @@ -671,27 +631,28 @@ toolbar_update_favicon (Toolbar *t) g_object_set (action, "icon", url, NULL); } -char * +const char * toolbar_get_location (Toolbar *t) { - GtkWidget *location; + GtkActionGroup *action_group; + GtkAction *action; - location = get_location_entry (t); - g_return_val_if_fail (location != NULL, NULL); + action_group = t->priv->action_group; + action = gtk_action_group_get_action (action_group, "Location"); - return ephy_location_entry_get_location - (EPHY_LOCATION_ENTRY (location)); + return ephy_location_action_get_address (EPHY_LOCATION_ACTION (action)); } void toolbar_clear_location_history (Toolbar *t) { - GtkWidget *location; + GtkActionGroup *action_group; + GtkAction *action; - location = get_location_entry (t), - g_return_if_fail (location != NULL); + action_group = t->priv->action_group; + action = gtk_action_group_get_action (action_group, "Location"); - ephy_location_entry_clear_history (EPHY_LOCATION_ENTRY (location)); + ephy_location_action_clear_history (EPHY_LOCATION_ACTION (action)); } void |