From: Christian Dywan Date: Sun, 20 Sep 2009 19:04:15 +0000 (+0200) Subject: Implement Ask for destination folder X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72ba3a700b9729850c9e95677f451a9a9dd3f529;p=midori 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. --- diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index 6acddebe..34bfa793 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -429,7 +429,6 @@ midori_preferences_set_settings (MidoriPreferences* preferences, button = katze_property_proxy (settings, "download-folder", "folder"); FILLED_ADD (button, 1, 2, 0, 1); label = katze_property_proxy (settings, "ask-for-destination-folder", NULL); - gtk_widget_set_sensitive (label, FALSE); INDENTED_ADD (label, 0, 1, 1, 2); button = katze_property_proxy (settings, "notify-transfer-completed", NULL); /* FIXME: Disable the option if notifications presumably cannot be sent diff --git a/midori/midori-view.c b/midori/midori-view.c index c9491222..9b927120 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -82,6 +82,7 @@ struct _MidoriView gboolean speed_dial_in_new_tabs; gchar* download_manager; gchar* news_aggregator; + gboolean ask_for_destination_folder; gboolean middle_click_opens_selection; gboolean open_tabs_in_the_background; gboolean close_buttons_on_tabs; @@ -1202,9 +1203,11 @@ midori_web_view_menu_save_activate_cb (GtkWidget* widget, WebKitDownload* download = webkit_download_new (request); gboolean handled; 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); - webkit_download_start (download); + if (!view->ask_for_destination_folder) + webkit_download_start (download); } static void @@ -1247,9 +1250,11 @@ midori_web_view_menu_image_save_activate_cb (GtkWidget* widget, WebKitDownload* download = webkit_download_new (request); gboolean handled; 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); - webkit_download_start (download); + if (!view->ask_for_destination_folder) + webkit_download_start (download); g_free (uri); } @@ -1274,9 +1279,11 @@ midori_web_view_menu_video_save_activate_cb (GtkWidget* widget, WebKitDownload* download = webkit_download_new (request); gboolean handled; 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); - webkit_download_start (download); + if (!view->ask_for_destination_folder) + webkit_download_start (download); g_free (uri); } @@ -1495,9 +1502,9 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view, midori_view_insert_menu_item (menu_shell, -1, _("_Copy Link destination"), NULL, G_CALLBACK (midori_web_view_menu_link_copy_activate_cb), widget); - /* FIXME */ 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); if (view->download_manager && *view->download_manager) 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, _("Copy Image _Address"), NULL, G_CALLBACK (midori_web_view_menu_image_copy_activate_cb), widget); - /* FIXME */ 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); } @@ -2200,6 +2207,7 @@ _midori_view_update_settings (MidoriView* view) "zoom-text-and-images", &zoom_text_and_images, "close-buttons-on-tabs", &view->close_buttons_on_tabs, "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, "open-tabs-in-the-background", &view->open_tabs_in_the_background, "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); } + 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")) { view->middle_click_opens_selection = g_value_get_boolean (&value); diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c index 1324e682..9ef8b402 100644 --- a/midori/midori-websettings.c +++ b/midori/midori-websettings.c @@ -635,6 +635,8 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class) * * 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 */ g_object_class_install_property (gobject_class, @@ -644,7 +646,7 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class) _("Ask for the destination folder"), _("Whether to ask for the destination folder when downloading a file"), FALSE, - #if WEBKIT_CHECK_VERSION (1, 1, 3) + #if WEBKIT_CHECK_VERSION (1, 1, 15) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); #else G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));