]> spindle.queued.net Git - midori/commitdiff
Implement Ask for destination folder
authorChristian Dywan <christian@twotoasts.de>
Sun, 20 Sep 2009 19:04:15 +0000 (21:04 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 20 Sep 2009 19:23:52 +0000 (21:23 +0200)
The option determines whether 'Save image' and 'Save link destination'
in the context menu prompt for a location or not.

midori/midori-preferences.c
midori/midori-view.c
midori/midori-websettings.c

index 6acddebe102d358668b05d24a0f021bb1f566852..34bfa793eda447355de47702f1848584547717c1 100644 (file)
@@ -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
index c9491222a766d79a0f5f6b7c04648d4472c39290..9b9271204e8172d66c453bd49f6de9de8543e14c 100644 (file)
@@ -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);
index 1324e68270361507b0cf5197ea3fd7e8cc37ad1b..9ef8b402e44e55f1fc9983666fef31d163c0b697 100644 (file)
@@ -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));