Show a dialog before downloading asking what to do
This commit is contained in:
parent
81717cc965
commit
42027c256b
1 changed files with 64 additions and 12 deletions
|
@ -1000,6 +1000,47 @@ midori_view_download_requested_cb (GtkWidget* view,
|
||||||
WebKitDownload* download,
|
WebKitDownload* download,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
|
GtkWidget* dialog;
|
||||||
|
gchar* mime_type;
|
||||||
|
gchar* description;
|
||||||
|
gchar* title;
|
||||||
|
GdkScreen* screen;
|
||||||
|
GtkIconTheme* icon_theme;
|
||||||
|
|
||||||
|
dialog = gtk_message_dialog_new (
|
||||||
|
NULL, 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
|
||||||
|
_("Open or download file"));
|
||||||
|
mime_type = katze_object_get_string (view, "mime-type");
|
||||||
|
description = g_content_type_get_description (mime_type);
|
||||||
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||||
|
_("File Type: %s ('%s')"), description, mime_type);
|
||||||
|
g_free (mime_type);
|
||||||
|
g_free (description);
|
||||||
|
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
|
||||||
|
/* i18n: A file open dialog title, ie. "Open http://fila.com/manual.tgz" */
|
||||||
|
title = g_strdup_printf (_("Open %s"),
|
||||||
|
webkit_download_get_suggested_filename (download));
|
||||||
|
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
||||||
|
g_free (title);
|
||||||
|
screen = gtk_widget_get_screen (dialog);
|
||||||
|
if (screen)
|
||||||
|
{
|
||||||
|
icon_theme = gtk_icon_theme_get_for_screen (screen);
|
||||||
|
if (gtk_icon_theme_has_icon (icon_theme, STOCK_TRANSFER))
|
||||||
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), STOCK_TRANSFER);
|
||||||
|
else
|
||||||
|
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN);
|
||||||
|
}
|
||||||
|
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
|
||||||
|
GTK_STOCK_SAVE, 1,
|
||||||
|
GTK_STOCK_CANCEL, 2,
|
||||||
|
GTK_STOCK_OPEN, 3,
|
||||||
|
NULL);
|
||||||
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), 3, FALSE);
|
||||||
|
switch (gtk_dialog_run (GTK_DIALOG (dialog)))
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
gtk_widget_destroy (dialog);
|
||||||
if (!webkit_download_get_destination_uri (download))
|
if (!webkit_download_get_destination_uri (download))
|
||||||
{
|
{
|
||||||
gchar* folder = katze_object_get_string (browser->settings,
|
gchar* folder = katze_object_get_string (browser->settings,
|
||||||
|
@ -1014,6 +1055,17 @@ midori_view_download_requested_cb (GtkWidget* view,
|
||||||
}
|
}
|
||||||
midori_browser_add_download_item (browser, download);
|
midori_browser_add_download_item (browser, download);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
case 2:
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
/* FIXME: Implement open */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_destroy (dialog);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue