diff options
-rw-r--r-- | src/window-commands.c | 50 |
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); |