[Xfce4-commits] <midori:master> Implement Ask for destination folder

Christian Dywan noreply at xfce.org
Sun Sep 20 21:26:01 CEST 2009


Updating branch refs/heads/master
         to 72ba3a700b9729850c9e95677f451a9a9dd3f529 (commit)
       from 59c43d08e005c46d0e1aa80019fcd57757923d78 (commit)

commit 72ba3a700b9729850c9e95677f451a9a9dd3f529
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Sep 20 21:04:15 2009 +0200

    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.

 midori/midori-preferences.c |    1 -
 midori/midori-view.c        |   32 ++++++++++++++++++++++----------
 midori/midori-websettings.c |    4 +++-
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index 6acddeb..34bfa79 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 c949122..9b92712 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 1324e68..9ef8b40 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));



More information about the Xfce4-commits mailing list