Implement Ask for destination folder

The option determines whether 'Save image' and 'Save link destination'
in the context menu prompt for a location or not.
This commit is contained in:
Christian Dywan 2009-09-20 21:04:15 +02:00
parent 59c43d08e0
commit 72ba3a700b
3 changed files with 25 additions and 12 deletions

View file

@ -429,7 +429,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
button = katze_property_proxy (settings, "download-folder", "folder"); button = katze_property_proxy (settings, "download-folder", "folder");
FILLED_ADD (button, 1, 2, 0, 1); FILLED_ADD (button, 1, 2, 0, 1);
label = katze_property_proxy (settings, "ask-for-destination-folder", NULL); label = katze_property_proxy (settings, "ask-for-destination-folder", NULL);
gtk_widget_set_sensitive (label, FALSE);
INDENTED_ADD (label, 0, 1, 1, 2); INDENTED_ADD (label, 0, 1, 1, 2);
button = katze_property_proxy (settings, "notify-transfer-completed", NULL); button = katze_property_proxy (settings, "notify-transfer-completed", NULL);
/* FIXME: Disable the option if notifications presumably cannot be sent /* FIXME: Disable the option if notifications presumably cannot be sent

View file

@ -82,6 +82,7 @@ struct _MidoriView
gboolean speed_dial_in_new_tabs; gboolean speed_dial_in_new_tabs;
gchar* download_manager; gchar* download_manager;
gchar* news_aggregator; gchar* news_aggregator;
gboolean ask_for_destination_folder;
gboolean middle_click_opens_selection; gboolean middle_click_opens_selection;
gboolean open_tabs_in_the_background; gboolean open_tabs_in_the_background;
gboolean close_buttons_on_tabs; gboolean close_buttons_on_tabs;
@ -1202,8 +1203,10 @@ midori_web_view_menu_save_activate_cb (GtkWidget* widget,
WebKitDownload* download = webkit_download_new (request); WebKitDownload* download = webkit_download_new (request);
gboolean handled; gboolean handled;
g_object_unref (request); g_object_unref (request);
g_object_set_data (G_OBJECT (download), "save-as-download", 0); if (view->ask_for_destination_folder)
g_object_set_data (G_OBJECT (download), "save-as-download", (void*)0xdeadbeef);
g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled); g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
if (!view->ask_for_destination_folder)
webkit_download_start (download); webkit_download_start (download);
} }
@ -1247,8 +1250,10 @@ midori_web_view_menu_image_save_activate_cb (GtkWidget* widget,
WebKitDownload* download = webkit_download_new (request); WebKitDownload* download = webkit_download_new (request);
gboolean handled; gboolean handled;
g_object_unref (request); g_object_unref (request);
g_object_set_data (G_OBJECT (download), "save-as-download", 0); if (view->ask_for_destination_folder)
g_object_set_data (G_OBJECT (download), "save-as-download", (void*)0xdeadbeef);
g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled); g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
if (!view->ask_for_destination_folder)
webkit_download_start (download); webkit_download_start (download);
g_free (uri); g_free (uri);
} }
@ -1274,8 +1279,10 @@ midori_web_view_menu_video_save_activate_cb (GtkWidget* widget,
WebKitDownload* download = webkit_download_new (request); WebKitDownload* download = webkit_download_new (request);
gboolean handled; gboolean handled;
g_object_unref (request); g_object_unref (request);
g_object_set_data (G_OBJECT (download), "save-as-download", 0); if (view->ask_for_destination_folder)
g_object_set_data (G_OBJECT (download), "save-as-download", (void*)0xdeadbeef);
g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled); g_signal_emit (view, signals[DOWNLOAD_REQUESTED], 0, download, &handled);
if (!view->ask_for_destination_folder)
webkit_download_start (download); webkit_download_start (download);
g_free (uri); g_free (uri);
} }
@ -1495,9 +1502,9 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
midori_view_insert_menu_item (menu_shell, -1, midori_view_insert_menu_item (menu_shell, -1,
_("_Copy Link destination"), NULL, _("_Copy Link destination"), NULL,
G_CALLBACK (midori_web_view_menu_link_copy_activate_cb), widget); G_CALLBACK (midori_web_view_menu_link_copy_activate_cb), widget);
/* FIXME */
midori_view_insert_menu_item (menu_shell, -1, midori_view_insert_menu_item (menu_shell, -1,
FALSE ? _("_Save Link destination") : _("_Download Link destination"), NULL, view->ask_for_destination_folder ? _("_Save Link destination")
: _("_Download Link destination"), NULL,
G_CALLBACK (midori_web_view_menu_save_activate_cb), widget); G_CALLBACK (midori_web_view_menu_save_activate_cb), widget);
if (view->download_manager && *view->download_manager) if (view->download_manager && *view->download_manager)
midori_view_insert_menu_item (menu_shell, -1, midori_view_insert_menu_item (menu_shell, -1,
@ -1521,9 +1528,9 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
midori_view_insert_menu_item (menu_shell, -1, midori_view_insert_menu_item (menu_shell, -1,
_("Copy Image _Address"), NULL, _("Copy Image _Address"), NULL,
G_CALLBACK (midori_web_view_menu_image_copy_activate_cb), widget); G_CALLBACK (midori_web_view_menu_image_copy_activate_cb), widget);
/* FIXME */
midori_view_insert_menu_item (menu_shell, -1, midori_view_insert_menu_item (menu_shell, -1,
FALSE ? _("Save I_mage") : _("Download I_mage"), GTK_STOCK_SAVE, view->ask_for_destination_folder ? _("Save I_mage")
: _("Download I_mage"), GTK_STOCK_SAVE,
G_CALLBACK (midori_web_view_menu_image_save_activate_cb), widget); G_CALLBACK (midori_web_view_menu_image_save_activate_cb), widget);
} }
@ -2200,6 +2207,7 @@ _midori_view_update_settings (MidoriView* view)
"zoom-text-and-images", &zoom_text_and_images, "zoom-text-and-images", &zoom_text_and_images,
"close-buttons-on-tabs", &view->close_buttons_on_tabs, "close-buttons-on-tabs", &view->close_buttons_on_tabs,
"open-new-pages-in", &view->open_new_pages_in, "open-new-pages-in", &view->open_new_pages_in,
"ask-for-destination-folder", &view->ask_for_destination_folder,
"middle-click-opens-selection", &view->middle_click_opens_selection, "middle-click-opens-selection", &view->middle_click_opens_selection,
"open-tabs-in-the-background", &view->open_tabs_in_the_background, "open-tabs-in-the-background", &view->open_tabs_in_the_background,
"find-while-typing", &view->find_while_typing, "find-while-typing", &view->find_while_typing,
@ -2250,6 +2258,10 @@ midori_view_settings_notify_cb (MidoriWebSettings* settings,
{ {
view->open_new_pages_in = g_value_get_enum (&value); view->open_new_pages_in = g_value_get_enum (&value);
} }
else if (name == g_intern_string ("ask-for-destination-folder"))
{
view->ask_for_destination_folder = g_value_get_boolean (&value);
}
else if (name == g_intern_string ("middle-click-opens-selection")) else if (name == g_intern_string ("middle-click-opens-selection"))
{ {
view->middle_click_opens_selection = g_value_get_boolean (&value); view->middle_click_opens_selection = g_value_get_boolean (&value);

View file

@ -635,6 +635,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
* *
* Whether to ask for the destination folder when downloading a file. * Whether to ask for the destination folder when downloading a file.
* *
* Note: Only since 0.2.0 is this value actually used.
*
* Since: 0.1.7 * Since: 0.1.7
*/ */
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
@ -644,7 +646,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
_("Ask for the destination folder"), _("Ask for the destination folder"),
_("Whether to ask for the destination folder when downloading a file"), _("Whether to ask for the destination folder when downloading a file"),
FALSE, FALSE,
#if WEBKIT_CHECK_VERSION (1, 1, 3) #if WEBKIT_CHECK_VERSION (1, 1, 15)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#else #else
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));