[gnome-control-center/wip/jsparber/background: 16/41] background: set wallpaper and lockscreen



commit 7bc1fd8e64c3e6a0acfaf3e60689491ab6eeb071
Author: Julian Sparber <julian sparber net>
Date:   Thu Nov 23 20:08:47 2017 +0100

    background: set wallpaper and lockscreen
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788515

 panels/background/cc-background-grilo-miner.c | 315 --------------------------
 panels/background/cc-background-grilo-miner.h |  35 ---
 panels/background/cc-background-panel.c       | 127 +----------
 3 files changed, 8 insertions(+), 469 deletions(-)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 981c05e78..32c7d4098 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -36,9 +36,8 @@
 #include "cc-background-resources.h"
 #include "cc-background-xml.h"
 
-#include "bg-pictures-source.h"
-
 #define WP_PATH_ID "org.gnome.desktop.background"
+#define WP_LOCK_PATH_ID "org.gnome.desktop.screensaver"
 #define WP_URI_KEY "picture-uri"
 #define WP_OPTIONS_KEY "picture-options"
 #define WP_SHADING_KEY "color-shading-type"
@@ -52,6 +51,7 @@ struct _CcBackgroundPanel
   GtkBuilder *builder;
   GDBusConnection *connection;
   GSettings *settings;
+  GSettings *lock_settings;
 
   GnomeDesktopThumbnailFactory *thumb_factory;
 
@@ -87,6 +87,7 @@ cc_background_panel_dispose (GObject *object)
   panel->spinner = NULL;
 
   g_clear_object (&panel->settings);
+  g_clear_object (&panel->lock_settings);
 
   if (panel->copy_cancellable)
     {
@@ -508,56 +509,6 @@ create_save_dir (void)
   return TRUE;
 }
 
-static void
-copy_finished_cb (GObject      *source_object,
-                  GAsyncResult *result,
-                  gpointer      pointer)
-{
-  g_autoptr(GError) err = NULL;
-  g_autoptr(CcBackgroundPanel) panel = (CcBackgroundPanel *) pointer;
-  CcBackgroundItem *item;
-  CcBackgroundItem *current_background;
-  GSettings *settings;
-
-  if (!g_file_copy_finish (G_FILE (source_object), result, &err))
-    {
-      if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
-        return;
-      }
-      g_warning ("Failed to copy image to cache location: %s", err->message);
-    }
-  item = g_object_get_data (source_object, "item");
-  settings = g_object_get_data (source_object, "settings");
-  current_background = panel->current_background;
-
-  g_settings_apply (settings);
-
-  /* the panel may have been destroyed before the callback is run, so be sure
-   * to check the widgets are not NULL */
-
-  if (panel->spinner)
-    {
-      gtk_widget_destroy (GTK_WIDGET (panel->spinner));
-      panel->spinner = NULL;
-    }
-
-  if (current_background)
-    cc_background_item_load (current_background, NULL);
-
-  if (panel->builder)
-    {
-      g_autofree gchar *filename = NULL;
-
-      update_preview (panel, settings, item);
-      current_background = panel->current_background;
-
-      /* Save the source XML if there is one */
-      filename = get_save_path ("last-edited.xml");
-      if (create_save_dir ())
-        cc_background_xml_save (current_background, filename);
-    }
-}
-
 static void
 set_background (CcBackgroundPanel *panel,
                 GSettings         *settings,
@@ -582,73 +533,7 @@ set_background (CcBackgroundPanel *panel,
   else if (cc_background_item_get_source_url (item) != NULL &&
            cc_background_item_get_needs_download (item))
     {
-      g_autoptr(GFile) source = NULL;
-      g_autoptr(GFile) dest = NULL;
-      g_autofree gchar *cache_path = NULL;
-      g_autofree gchar *basename = NULL;
-      g_autofree gchar *display_name = NULL;
-      g_autofree gchar *dest_path = NULL;
-      g_autofree gchar *dest_uri = NULL;
-      g_autoptr(GdkPixbuf) pixbuf = NULL;
-
-      cache_path = bg_pictures_source_get_cache_path ();
-      if (g_mkdir_with_parents (cache_path, USER_DIR_MODE) < 0)
-        {
-          g_warning ("Failed to create directory '%s'", cache_path);
-          return;
-        }
-
-      dest_path = bg_pictures_source_get_unique_path (cc_background_item_get_source_url (item));
-      dest = g_file_new_for_path (dest_path);
-      source = g_file_new_for_uri (cc_background_item_get_source_url (item));
-      basename = g_file_get_basename (source);
-      display_name = g_filename_display_name (basename);
-      dest_path = g_file_get_path (dest);
-
-      /* create a blank image to use until the source image is ready */
-      pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
-      gdk_pixbuf_fill (pixbuf, 0x00000000);
-      gdk_pixbuf_save (pixbuf, dest_path, "png", NULL, NULL);
-
-      if (panel->copy_cancellable)
-        {
-          g_cancellable_cancel (panel->copy_cancellable);
-          g_cancellable_reset (panel->copy_cancellable);
-        }
-
-      if (panel->spinner)
-        {
-          gtk_widget_destroy (GTK_WIDGET (panel->spinner));
-          panel->spinner = NULL;
-        }
-
-      /* create a spinner while the file downloads */
-      panel->spinner = gtk_spinner_new ();
-      gtk_spinner_start (GTK_SPINNER (panel->spinner));
-      gtk_box_pack_start (GTK_BOX (WID ("bottom-hbox")), panel->spinner, FALSE,
-                          FALSE, 6);
-      gtk_widget_show (panel->spinner);
-
-      /* reference the panel in case it is removed before the copy is
-       * finished */
-      g_object_ref (panel);
-      g_object_set_data_full (G_OBJECT (source), "item", g_object_ref (item), g_object_unref);
-      g_object_set_data (G_OBJECT (source), "settings", settings);
-      g_file_copy_async (source, dest, G_FILE_COPY_OVERWRITE,
-                         G_PRIORITY_DEFAULT, panel->copy_cancellable,
-                         NULL, NULL,
-                         copy_finished_cb, panel);
-      dest_uri = g_file_get_uri (dest);
-
-      g_settings_set_string (settings, WP_URI_KEY, dest_uri);
-      g_object_set (G_OBJECT (item),
-                    "uri", dest_uri,
-                    "needs-download", FALSE,
-                    "name", display_name,
-                    NULL);
-
-      /* delay the updated drawing of the preview until the copy finishes */
-      save_settings = FALSE;
+      //do not handle
     }
   else
     {
@@ -710,6 +595,7 @@ on_background_select (GtkFlowBox      *box,
   item = cc_background_grid_item_get_ref (selected);
 
   set_background (panel, panel->settings, item);
+  set_background (panel, panel->lock_settings, item);
 }
 
 static void
@@ -852,6 +738,9 @@ cc_background_panel_init (CcBackgroundPanel *panel)
   panel->settings = g_settings_new (WP_PATH_ID);
   g_settings_delay (panel->settings);
 
+  panel->lock_settings = g_settings_new (WP_LOCK_PATH_ID);
+  g_settings_delay (panel->lock_settings);
+
   /* add the top level widget */
   widget = WID ("background-panel");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]