From 5aee0deca12e14554ce0fa0d4b02613e99ba77a9 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Wed, 2 Dec 2009 17:01:24 -0500 Subject: Remove redundant parameters in location-set API EphyLocationEntry, EphyLocationAction and EphyToolbar take an @adress and @typed_address parameter, while both are useful we only end up using one so we can easily decide which one to use in ephy-window.c instead of carrying both around until ephy-location-entry.c Bonus: make ephy_location_entry_set_location accept NULL as @address safely. Bug #603651 --- src/ephy-location-action.c | 20 ++++++-------------- src/ephy-location-action.h | 3 +-- src/ephy-lockdown.c | 2 +- src/ephy-toolbar.c | 11 ++++------- src/ephy-toolbar.h | 3 +-- src/ephy-window.c | 11 +++++++---- 6 files changed, 20 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 580aa905b..598f9ff8c 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -50,7 +50,6 @@ struct _EphyLocationActionPrivate GtkWidget *proxy; GList *actions; char *address; - char *typed_address; EphyNode *smart_bmks; EphyBookmarks *bookmarks; GdkPixbuf *icon; @@ -224,7 +223,7 @@ user_changed_cb (GtkWidget *proxy, EphyLocationAction *action) LOG ("user_changed_cb, new address %s", address); g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), proxy); - ephy_location_action_set_address (action, address, NULL); + ephy_location_action_set_address (action, address); g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy); } @@ -247,8 +246,7 @@ sync_address (GtkAction *gaction, LOG ("sync_address %s", action->priv->address); g_signal_handlers_block_by_func (proxy, G_CALLBACK (user_changed_cb), action); - ephy_location_entry_set_location (lentry, priv->address, - priv->typed_address); + ephy_location_entry_set_location (lentry, priv->address); g_signal_handlers_unblock_by_func (proxy, G_CALLBACK (user_changed_cb), action); } @@ -579,7 +577,7 @@ ephy_location_action_set_property (GObject *object, switch (prop_id) { case PROP_ADDRESS: - ephy_location_action_set_address (action, g_value_get_string (value), NULL); + ephy_location_action_set_address (action, g_value_get_string (value)); break; case PROP_EDITABLE: priv->editable = g_value_get_boolean (value); @@ -935,7 +933,6 @@ ephy_location_action_finalize (GObject *object) g_list_free (priv->actions); g_free (priv->address); - g_free (priv->typed_address); g_free (priv->lock_stock_id); g_free (priv->lock_tooltip); @@ -961,15 +958,13 @@ ephy_location_action_get_address (EphyLocationAction *action) /** * ephy_location_action_set_address: * @action: an #EphyLocationAction - * @address: the current address - * @typed_address: address typed by the user + * @address: new address * - * Sets the @address and @typed_address in @action. + * Sets @address as the address of @action. **/ void ephy_location_action_set_address (EphyLocationAction *action, - const char *address, - const char *typed_address) + const char *address) { EphyLocationActionPrivate *priv; @@ -982,8 +977,5 @@ ephy_location_action_set_address (EphyLocationAction *action, g_free (priv->address); priv->address = g_strdup (address); - g_free (priv->typed_address); - priv->typed_address = g_strdup (typed_address); - g_object_notify (G_OBJECT (action), "address"); } diff --git a/src/ephy-location-action.h b/src/ephy-location-action.h index 2fa69a602..e94931a3a 100644 --- a/src/ephy-location-action.h +++ b/src/ephy-location-action.h @@ -60,8 +60,7 @@ GType ephy_location_action_get_type (void); const char *ephy_location_action_get_address (EphyLocationAction *action); void ephy_location_action_set_address (EphyLocationAction *action, - const char *address, - const char *typed_address); + const char *address); G_END_DECLS diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c index f11d7b086..bb3a03524 100644 --- a/src/ephy-lockdown.c +++ b/src/ephy-lockdown.c @@ -105,7 +105,7 @@ update_location_editable (EphyWindow *window, if (embed != NULL) { address = ephy_web_view_get_location (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), TRUE); - ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address, NULL); + ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address); ephy_web_view_set_typed_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed), NULL); g_free (address); } diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c index b562ebbda..83c34e931 100644 --- a/src/ephy-toolbar.c +++ b/src/ephy-toolbar.c @@ -475,16 +475,13 @@ ephy_toolbar_get_location (EphyToolbar *toolbar) /** * ephy_toolbar_set_location: * @toolbar: an #EphyToolbar widget - * @address: current @toolbar address - * @typed_address: address currently typed by the user + * @address: new address * - * Calls ephy_location_action_set_address in the internal #EphyLocationAction - * with @address and @typed_address. + * Sets the internal #EphyLocationAction address to @address. **/ void ephy_toolbar_set_location (EphyToolbar *toolbar, - const char *address, - const char *typed_address) + const char *address) { EphyToolbarPrivate *priv = toolbar->priv; EphyLocationAction *action = EPHY_LOCATION_ACTION (priv->actions[LOCATION_ACTION]); @@ -492,7 +489,7 @@ ephy_toolbar_set_location (EphyToolbar *toolbar, if (priv->updating_address) return; priv->updating_address = TRUE; - ephy_location_action_set_address (action, address, typed_address); + ephy_location_action_set_address (action, address); priv->updating_address = FALSE; } diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h index 13a3d7d5a..060a3ad5a 100644 --- a/src/ephy-toolbar.h +++ b/src/ephy-toolbar.h @@ -81,8 +81,7 @@ void ephy_toolbar_activate_location (EphyToolbar *toolbar); const char *ephy_toolbar_get_location (EphyToolbar *toolbar); void ephy_toolbar_set_location (EphyToolbar *toolbar, - const char *address, - const char *typed_address); + const char *address); void ephy_toolbar_set_navigation_actions (EphyToolbar *toolbar, gboolean back, diff --git a/src/ephy-window.c b/src/ephy-window.c index aa10f2ab1..0f2ceed43 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -1547,12 +1547,15 @@ sync_tab_address (EphyWebView *view, EphyWindow *window) { EphyWindowPrivate *priv = window->priv; + const char *address; + const char *typed_address; if (priv->closing) return; - ephy_toolbar_set_location (priv->toolbar, - ephy_web_view_get_address (view), - ephy_web_view_get_typed_address (view)); + address = ephy_web_view_get_address (view); + typed_address = ephy_web_view_get_typed_address (view); + + ephy_toolbar_set_location (priv->toolbar, typed_address ? typed_address : address); ephy_find_toolbar_request_close (priv->find_toolbar); } @@ -2922,7 +2925,7 @@ embed_modal_alert_cb (EphyEmbed *embed, /* make sure the location entry shows the real URL of the tab's page */ address = ephy_web_view_get_address (EPHY_GET_EPHY_WEB_VIEW_FROM_EMBED (embed)); - ephy_toolbar_set_location (priv->toolbar, address, NULL); + ephy_toolbar_set_location (priv->toolbar, address); /* don't suppress alert */ return FALSE; -- cgit v1.2.3