aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXan Lopez <xlopez@igalia.com>2011-07-04 23:17:02 +0800
committerXan Lopez <xlopez@igalia.com>2011-07-05 19:16:57 +0800
commitc1ecf8245ba6071c1fee3c5ccdacf247953decb2 (patch)
treeabdb74309e75639e1139c81d8d67a2fe75dd39fd /src
parent1ff0d93c8d6a5c61d3f1d0cead7f3a0a19892f9d (diff)
downloadgsoc2013-epiphany-c1ecf8245ba6071c1fee3c5ccdacf247953decb2.tar
gsoc2013-epiphany-c1ecf8245ba6071c1fee3c5ccdacf247953decb2.tar.gz
gsoc2013-epiphany-c1ecf8245ba6071c1fee3c5ccdacf247953decb2.tar.bz2
gsoc2013-epiphany-c1ecf8245ba6071c1fee3c5ccdacf247953decb2.tar.lz
gsoc2013-epiphany-c1ecf8245ba6071c1fee3c5ccdacf247953decb2.tar.xz
gsoc2013-epiphany-c1ecf8245ba6071c1fee3c5ccdacf247953decb2.tar.zst
gsoc2013-epiphany-c1ecf8245ba6071c1fee3c5ccdacf247953decb2.zip
window-commands: make get_suggested_title a separate function
We'll reuse it in the future.
Diffstat (limited to 'src')
-rw-r--r--src/window-commands.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/src/window-commands.c b/src/window-commands.c
index a67ad6d39..32043c910 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -321,33 +321,15 @@ window_cmd_file_open (GtkAction *action,
gtk_widget_show (GTK_WIDGET (dialog));
}
-void
-window_cmd_file_save_as (GtkAction *action,
- EphyWindow *window)
+static char *
+get_suggested_filename (EphyWebView *view)
{
- EphyEmbed *embed;
- EphyFileChooser *dialog;
-
- /* These all are needed in order to get the suggested filename */
char *suggested_filename;
const char *mimetype;
- EphyWebView *view;
WebKitWebFrame *frame;
WebKitWebDataSource *data_source;
WebKitWebResource *web_resource;
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
-
- dialog = ephy_file_chooser_new (_("Save"),
- GTK_WIDGET (window),
- GTK_FILE_CHOOSER_ACTION_SAVE,
- EPHY_PREFS_STATE_SAVE_DIR,
- EPHY_FILE_FILTER_ALL);
-
- gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
-
- view = ephy_embed_get_web_view (embed);
frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view));
data_source = webkit_web_frame_get_data_source (frame);
web_resource = webkit_web_data_source_get_main_resource (data_source);
@@ -356,7 +338,7 @@ window_cmd_file_save_as (GtkAction *action,
if ((g_ascii_strncasecmp (mimetype, "text/html", 9)) == 0)
{
/* Web Title will be used as suggested filename*/
- suggested_filename = g_strconcat(ephy_web_view_get_title (view), ".html",NULL);
+ suggested_filename = g_strconcat (ephy_web_view_get_title (view), ".html", NULL);
}
else
{
@@ -365,6 +347,32 @@ window_cmd_file_save_as (GtkAction *action,
soup_uri_free (soup_uri);
}
+ return suggested_filename;
+}
+
+void
+window_cmd_file_save_as (GtkAction *action,
+ EphyWindow *window)
+{
+ EphyEmbed *embed;
+ EphyFileChooser *dialog;
+ char *suggested_filename;
+ EphyWebView *view;
+
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ dialog = ephy_file_chooser_new (_("Save"),
+ GTK_WIDGET (window),
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ EPHY_PREFS_STATE_SAVE_DIR,
+ EPHY_FILE_FILTER_ALL);
+
+ gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ view = ephy_embed_get_web_view (embed);
+ suggested_filename = get_suggested_filename (view);
+
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename);
g_free (suggested_filename);