From efdde3ff63b9f0c3c3ff8c418c451be494360601 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Mon, 1 Aug 2005 19:28:53 +0000 Subject: Now that the tab's address is always correct (isn't the typed address 2005-08-01 Christian Persch * src/ephy-location-action.c: (get_location_cb): * src/ephy-session.c: (write_tab): * src/ephy-tab.c: * src/ephy-window.c: (modal_alert_cb): * src/prefs-dialog.c: (set_homepage_entry), (prefs_homepage_current_button_clicked_cb): * src/window-commands.c: (window_cmd_file_send_to), (window_cmd_file_bookmark_page), (window_cmd_view_page_source): Now that the tab's address is always correct (isn't the typed address anymore), always use ephy_tab_get_address instead of ephy_embed_get_location, since the former also gets the right address when the page loading but still blank. Should fix bug #147840. --- src/ephy-location-action.c | 10 ++++++---- src/ephy-session.c | 9 +++------ src/ephy-tab.c | 4 ++-- src/ephy-window.c | 5 ++--- src/prefs-dialog.c | 14 ++++++-------- src/window-commands.c | 34 ++++++++++++++-------------------- 6 files changed, 33 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 773743bea..4cce221cf 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -282,11 +282,13 @@ static char * get_location_cb (EphyLocationEntry *entry, EphyLocationAction *action) { - EphyEmbed *embed; - - embed = ephy_window_get_active_embed (action->priv->window); + EphyLocationActionPrivate *priv = action->priv; + EphyTab *tab; - return ephy_embed_get_location (embed, TRUE); + tab = ephy_window_get_active_tab (priv->window); + g_return_val_if_fail (tab != NULL, NULL); + + return g_strdup (ephy_tab_get_address (tab)); } static char * diff --git a/src/ephy-session.c b/src/ephy-session.c index 1b7a5ef21..4591b4962 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -517,17 +517,14 @@ static int write_tab (xmlTextWriterPtr writer, EphyTab *tab) { - EphyEmbed *embed; - char *location; + const char *address; int ret; ret = xmlTextWriterStartElement (writer, (xmlChar *) "embed"); if (ret < 0) return ret; - embed = ephy_tab_get_embed (tab); - location = ephy_embed_get_location (embed, TRUE); - ret = xmlTextWriterWriteAttribute (writer, (xmlChar *) "url", (xmlChar *) location); - g_free (location); + address = ephy_tab_get_address (tab); + ret = xmlTextWriterWriteAttribute (writer, (xmlChar *) "url", (xmlChar *) address); if (ret < 0) return ret; ret = xmlTextWriterEndElement (writer); /* embed */ diff --git a/src/ephy-tab.c b/src/ephy-tab.c index ae2f2dbbf..b843dd2cd 100644 --- a/src/ephy-tab.c +++ b/src/ephy-tab.c @@ -2248,7 +2248,7 @@ ephy_tab_set_title (EphyTab *tab, * * Returns the title of the web page loaded in @tab. * - * Return value: @tab's loaded web page's title + * Return value: @tab's loaded web page's title. Will never be %NULL. **/ const char * ephy_tab_get_title (EphyTab *tab) @@ -2283,7 +2283,7 @@ ephy_tab_get_title (EphyTab *tab) * * Returns the address of the currently loaded page. * - * Return value: @tab's address + * Return value: @tab's address. Will never be %NULL. **/ const char * ephy_tab_get_address (EphyTab *tab) diff --git a/src/ephy-window.c b/src/ephy-window.c index 949077ca3..7da565a2e 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2035,7 +2035,7 @@ modal_alert_cb (EphyEmbed *embed, { EphyWindowPrivate *priv = window->priv; EphyTab *tab; - char *address; + const char *address; tab = ephy_tab_for_embed (embed); g_return_val_if_fail (tab != NULL, FALSE); @@ -2051,9 +2051,8 @@ modal_alert_cb (EphyEmbed *embed, gtk_window_present (GTK_WINDOW (window)); /* make sure the location entry shows the real URL of the tab's page */ - address = ephy_embed_get_location (embed, TRUE); + address = ephy_tab_get_address (tab); ephy_toolbar_set_location (priv->toolbar, address, NULL); - g_free (address); /* don't suppress alert */ return FALSE; diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index ea2526169..42b71f257 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -1280,12 +1280,12 @@ prefs_clear_cache_button_clicked_cb (GtkWidget *button, static void set_homepage_entry (EphyDialog *dialog, - char *new_location) + const char *new_location) { GValue value = { 0, }; g_value_init (&value, G_TYPE_STRING); - g_value_take_string (&value, new_location); + g_value_set_string (&value, new_location); ephy_dialog_set_value (dialog, properties[HOMEPAGE_ENTRY_PROP].id, &value); g_value_unset (&value); } @@ -1296,8 +1296,7 @@ prefs_homepage_current_button_clicked_cb (GtkWidget *button, { EphySession *session; EphyWindow *window; - EphyEmbed *embed; - char *location; + EphyTab *tab; session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ())); window = ephy_session_get_active_window (session); @@ -1305,11 +1304,10 @@ prefs_homepage_current_button_clicked_cb (GtkWidget *button, /* can't do anything in this case */ if (window == NULL) return; - embed = ephy_window_get_active_embed (window); - g_return_if_fail (embed != NULL); + tab = ephy_window_get_active_tab (window); + g_return_if_fail (tab != NULL); - location = ephy_embed_get_location (embed, TRUE); - set_homepage_entry (dialog, location); + set_homepage_entry (dialog, ephy_tab_get_address (tab)); } void diff --git a/src/window-commands.c b/src/window-commands.c index 5f012e0a8..ba490736d 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -129,10 +129,8 @@ window_cmd_file_send_to (GtkAction *action, { EphyTab *tab; EphyEmbed *embed; - char *url; - char *embed_location; - char *location; - char *title; + const char *address; + char *url, *location, *title; tab = ephy_window_get_active_tab (window); g_return_if_fail (tab != NULL); @@ -140,9 +138,8 @@ window_cmd_file_send_to (GtkAction *action, embed = ephy_window_get_active_embed (window); g_return_if_fail (embed != NULL); - embed_location = ephy_embed_get_location (embed, TRUE); - location = gnome_vfs_escape_string (embed_location); - g_free (embed_location); + address = ephy_tab_get_address (tab); + location = gnome_vfs_escape_string (address); title = ephy_embed_get_title (embed); if (title != NULL) @@ -291,9 +288,8 @@ window_cmd_file_bookmark_page (GtkAction *action, EphyEmbed *embed; EphyBookmarks *bookmarks; GtkWidget *new_bookmark; - char *location; - const char *icon; - char *title = NULL; + const char *location, *icon; + char *title; tab = ephy_window_get_active_tab (window); g_return_if_fail (tab != NULL); @@ -301,7 +297,7 @@ window_cmd_file_bookmark_page (GtkAction *action, embed = ephy_window_get_active_embed (window); g_return_if_fail (embed != NULL); - location = ephy_embed_get_location (embed, TRUE); + location = ephy_tab_get_address (tab); title = ephy_embed_get_title (embed); if (title == NULL) @@ -325,7 +321,6 @@ window_cmd_file_bookmark_page (GtkAction *action, } g_free (title); - g_free (location); } static void @@ -676,19 +671,21 @@ void window_cmd_view_page_source (GtkAction *action, EphyWindow *window) { + EphyTab *tab; EphyEmbed *embed; - char *address; - char *scheme; + const char *address; guint32 user_time; + tab = ephy_window_get_active_tab (window); + g_return_if_fail (tab != NULL); + embed = ephy_window_get_active_embed (window); g_return_if_fail (embed != NULL); - address = ephy_embed_get_location (embed, TRUE); - scheme = gnome_vfs_get_uri_scheme (address); + address = ephy_tab_get_address (tab); user_time = gtk_get_current_event_time (); - if (strcmp (scheme, "file") == 0) + if (g_str_has_prefix (address, "file://")) { ephy_file_launch_handler ("text/plain", address, user_time); } @@ -696,9 +693,6 @@ window_cmd_view_page_source (GtkAction *action, { save_temp_source (embed, user_time); } - - g_free (scheme); - g_free (address); } void -- cgit v1.2.3