Save non-text as single file, checkbox otherwise
Fixes: https://bugs.launchpad.net/midori/+bug/1025894
This commit is contained in:
parent
3259ab1be2
commit
3d14faf9be
2 changed files with 24 additions and 8 deletions
|
@ -1104,6 +1104,8 @@ midori_browser_save_uri (MidoriBrowser* browser,
|
||||||
GtkWidget* dialog;
|
GtkWidget* dialog;
|
||||||
const gchar* title = midori_view_get_display_title (view);
|
const gchar* title = midori_view_get_display_title (view);
|
||||||
gchar* filename;
|
gchar* filename;
|
||||||
|
gboolean file_only;
|
||||||
|
GtkWidget* checkbox;
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
if (!gtk_widget_get_visible (GTK_WIDGET (browser)))
|
||||||
return;
|
return;
|
||||||
|
@ -1111,6 +1113,15 @@ midori_browser_save_uri (MidoriBrowser* browser,
|
||||||
dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
|
dialog = sokoke_file_chooser_dialog_new (_("Save file as"),
|
||||||
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
GTK_WINDOW (browser), GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
|
||||||
|
if (midori_view_can_view_source (view))
|
||||||
|
{
|
||||||
|
file_only = FALSE;
|
||||||
|
checkbox = gtk_check_button_new_with_mnemonic (_("Save associated _resources"));
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
|
||||||
|
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), checkbox);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
file_only = TRUE;
|
||||||
if (last_dir && *last_dir)
|
if (last_dir && *last_dir)
|
||||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), last_dir);
|
||||||
else
|
else
|
||||||
|
@ -1122,7 +1133,7 @@ midori_browser_save_uri (MidoriBrowser* browser,
|
||||||
|
|
||||||
if (uri == NULL)
|
if (uri == NULL)
|
||||||
uri = midori_view_get_display_uri (view);
|
uri = midori_view_get_display_uri (view);
|
||||||
if (!g_str_equal (title, uri))
|
if (!file_only && !g_str_equal (title, uri))
|
||||||
filename = midori_browser_fixup_filename (g_strdup (title));
|
filename = midori_browser_fixup_filename (g_strdup (title));
|
||||||
else
|
else
|
||||||
filename = midori_browser_get_filename_suggestion_for_uri (view, uri);
|
filename = midori_browser_get_filename_suggestion_for_uri (view, uri);
|
||||||
|
@ -1131,14 +1142,20 @@ midori_browser_save_uri (MidoriBrowser* browser,
|
||||||
|
|
||||||
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
|
||||||
{
|
{
|
||||||
gchar* fullname;
|
|
||||||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||||
fullname = g_strconcat (filename, ".html", NULL);
|
file_only = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox));
|
||||||
|
if (!file_only && !g_str_equal (title, uri))
|
||||||
|
{
|
||||||
|
gchar* fullname = g_strconcat (filename, ".html", NULL);
|
||||||
midori_view_save_source (view, uri, fullname);
|
midori_view_save_source (view, uri, fullname);
|
||||||
|
g_free (fullname);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
midori_view_save_source (view, uri, filename);
|
||||||
|
if (!file_only)
|
||||||
|
midori_browser_save_resources (view, filename);
|
||||||
katze_assign (last_dir,
|
katze_assign (last_dir,
|
||||||
gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));
|
gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog)));
|
||||||
midori_browser_save_resources (view, filename);
|
|
||||||
g_free (fullname);
|
|
||||||
}
|
}
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5448,10 +5448,9 @@ const gchar*
|
||||||
midori_view_fallback_extension (MidoriView* view,
|
midori_view_fallback_extension (MidoriView* view,
|
||||||
const gchar* extension)
|
const gchar* extension)
|
||||||
{
|
{
|
||||||
if (!view->mime_type)
|
|
||||||
extension = "";
|
|
||||||
if (extension && *extension)
|
if (extension && *extension)
|
||||||
return extension;
|
return extension;
|
||||||
|
g_return_val_if_fail (view->mime_type != NULL, "");
|
||||||
if (strstr (view->mime_type, "css"))
|
if (strstr (view->mime_type, "css"))
|
||||||
return ".css";
|
return ".css";
|
||||||
if (strstr (view->mime_type, "javascript"))
|
if (strstr (view->mime_type, "javascript"))
|
||||||
|
|
Loading…
Reference in a new issue