You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1385 lines
42 KiB

From e2d3f71a37a7e587b0af2a9818377ec1ac098e79 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <debarshir@gnome.org>
Date: Tue, 20 Apr 2021 23:00:28 +0200
Subject: [PATCH] background: Drop the unused build dependency on Grilo
The code that uses Grilo to fetch the user's Flickr photos isn't
actually used by the Background panel, to the extent that the final
binary doesn't even link against Grilo. Getting rid of this unused code
will ensure that distributors aren't needlessly pulling in this
dependency.
This patch has been customized for RHEL 9 to skip the .gitlab-ci.yml
file, which isn't part of the 'ninja dist' generated tarball.
https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1345
---
build-aux/flatpak/org.gnome.Settings.json | 17 -
panels/background/bg-pictures-source.c | 855 ------------------
panels/background/bg-pictures-source.h | 46 -
panels/background/cc-background-chooser.c | 1 -
panels/background/cc-background-grilo-miner.c | 315 -------
panels/background/cc-background-grilo-miner.h | 31 -
panels/background/cc-background-panel.c | 2 -
panels/background/meson.build | 4 -
8 files changed, 1271 deletions(-)
delete mode 100644 panels/background/bg-pictures-source.c
delete mode 100644 panels/background/bg-pictures-source.h
delete mode 100644 panels/background/cc-background-grilo-miner.c
delete mode 100644 panels/background/cc-background-grilo-miner.h
diff --git a/build-aux/flatpak/org.gnome.Settings.json b/build-aux/flatpak/org.gnome.Settings.json
index 3e19894b0484..b64b4c2fdbc5 100644
--- a/build-aux/flatpak/org.gnome.Settings.json
+++ b/build-aux/flatpak/org.gnome.Settings.json
@@ -485,23 +485,6 @@
}
]
},
- {
- "name" : "grilo",
- "buildsystem" : "meson",
- "config-opts" : [
- "-Denable-grl-pls=false",
- "-Denable-gtk-doc=false",
- "-Denable-introspection=false",
- "-Denable-test-ui=false",
- "-Denable-vala=false"
- ],
- "sources" : [
- {
- "type" : "git",
- "url" : "https://gitlab.gnome.org/GNOME/grilo.git"
- }
- ]
- },
{
"name" : "openldap",
"buildsystem" : "autotools",
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
deleted file mode 100644
index 3a3027b1391e..000000000000
--- a/panels/background/bg-pictures-source.c
+++ /dev/null
@@ -1,855 +0,0 @@
-/* bg-pictures-source.c */
-/*
- * Copyright (C) 2010 Intel, Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Thomas Wood <thomas.wood@intel.com>
- *
- */
-
-#include <config.h>
-
-#include "bg-pictures-source.h"
-
-#include "cc-background-grilo-miner.h"
-#include "cc-background-item.h"
-
-#include <string.h>
-#include <cairo-gobject.h>
-#include <gio/gio.h>
-#include <grilo.h>
-#include <libgnome-desktop/gnome-desktop-thumbnail.h>
-#include <gdesktop-enums.h>
-
-#define ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_NAME "," \
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," \
- G_FILE_ATTRIBUTE_TIME_MODIFIED
-
-struct _BgPicturesSource
-{
- BgSource parent_instance;
-
- GCancellable *cancellable;
-
- CcBackgroundGriloMiner *grl_miner;
-
- GFileMonitor *picture_dir_monitor;
- GFileMonitor *cache_dir_monitor;
-
- GHashTable *known_items;
-};
-
-G_DEFINE_TYPE (BgPicturesSource, bg_pictures_source, BG_TYPE_SOURCE)
-
-const char * const content_types[] = {
- "image/png",
- "image/jp2",
- "image/jpeg",
- "image/bmp",
- "image/svg+xml",
- "image/x-portable-anymap",
- NULL
-};
-
-const char * const screenshot_types[] = {
- "image/png",
- NULL
-};
-
-static char *bg_pictures_source_get_unique_filename (const char *uri);
-
-static void picture_opened_for_read (GObject *source_object, GAsyncResult *res, gpointer user_data);
-
-static void
-bg_pictures_source_dispose (GObject *object)
-{
- BgPicturesSource *source = BG_PICTURES_SOURCE (object);
-
- if (source->cancellable)
- {
- g_cancellable_cancel (source->cancellable);
- g_clear_object (&source->cancellable);
- }
-
- g_clear_object (&source->grl_miner);
-
- G_OBJECT_CLASS (bg_pictures_source_parent_class)->dispose (object);
-}
-
-static void
-bg_pictures_source_finalize (GObject *object)
-{
- BgPicturesSource *bg_source = BG_PICTURES_SOURCE (object);
-
- g_clear_pointer (&bg_source->known_items, g_hash_table_destroy);
-
- g_clear_object (&bg_source->picture_dir_monitor);
- g_clear_object (&bg_source->cache_dir_monitor);
-
- G_OBJECT_CLASS (bg_pictures_source_parent_class)->finalize (object);
-}
-
-static void
-bg_pictures_source_class_init (BgPicturesSourceClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = bg_pictures_source_dispose;
- object_class->finalize = bg_pictures_source_finalize;
-}
-
-static void
-remove_placeholder (BgPicturesSource *bg_source,
- CcBackgroundItem *item)
-{
- GListStore *store;
- guint i;
-
- store = bg_source_get_liststore (BG_SOURCE (bg_source));
-
- for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (store)); i++)
- {
- g_autoptr(CcBackgroundItem) item_n = NULL;
-
- item_n = g_list_model_get_item (G_LIST_MODEL (store), i);
-
- if (item_n == item)
- {
- g_list_store_remove (store, i);
- break;
- }
- }
-}
-
-static gboolean
-picture_needs_rotation (GdkPixbuf *pixbuf)
-{
- const gchar *str;
-
- str = gdk_pixbuf_get_option (pixbuf, "orientation");
- if (str == NULL)
- return FALSE;
-
- if (*str == '5' || *str == '6' || *str == '7' || *str == '8')
- return TRUE;
-
- return FALSE;
-}
-
-static GdkPixbuf *
-swap_rotated_pixbuf (GdkPixbuf *pixbuf)
-{
- GdkPixbuf *tmp_pixbuf;
-
- tmp_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
- if (tmp_pixbuf == NULL)
- return pixbuf;
-
- g_object_unref (pixbuf);
- return tmp_pixbuf;
-}
-
-static int
-sort_func (gconstpointer a,
- gconstpointer b,
- gpointer user_data)
-{
- CcBackgroundItem *item_a;
- CcBackgroundItem *item_b;
- guint64 modified_a;
- guint64 modified_b;
- int retval;
-
- item_a = (CcBackgroundItem *) a;
- item_b = (CcBackgroundItem *) b;
- modified_a = cc_background_item_get_modified (item_a);
- modified_b = cc_background_item_get_modified (item_b);
-
- retval = modified_b - modified_a;
-
- return retval;
-}
-
-static void
-picture_scaled (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- BgPicturesSource *bg_source;
- CcBackgroundItem *item;
- g_autoptr(GError) error = NULL;
- g_autoptr(GdkPixbuf) pixbuf = NULL;
- const char *software;
- const char *uri;
- GListStore *store;
- cairo_surface_t *surface = NULL;
- int scale_factor;
- gboolean rotation_applied;
-
- item = g_object_get_data (source_object, "item");
- pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
- if (pixbuf == NULL)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- {
- g_warning ("Failed to load image: %s", error->message);
- remove_placeholder (BG_PICTURES_SOURCE (user_data), item);
- }
-
- return;
- }
-
- /* since we were not cancelled, we can now cast user_data
- * back to BgPicturesSource.
- */
- bg_source = BG_PICTURES_SOURCE (user_data);
- store = bg_source_get_liststore (BG_SOURCE (bg_source));
- uri = cc_background_item_get_uri (item);
- if (uri == NULL)
- uri = cc_background_item_get_source_url (item);
-
- /* Ignore screenshots */
- software = gdk_pixbuf_get_option (pixbuf, "tEXt::Software");
- if (software != NULL &&
- g_str_equal (software, "gnome-screenshot"))
- {
- g_debug ("Ignored URL '%s' as it's a screenshot from gnome-screenshot", uri);
- remove_placeholder (BG_PICTURES_SOURCE (user_data), item);
- return;
- }
-
- /* Process embedded orientation */
- rotation_applied = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "rotation-applied"));
-
- if (!rotation_applied && picture_needs_rotation (pixbuf))
- {
- /* the width and height of pixbuf we requested are wrong for EXIF
- * orientations 5, 6, 7 and 8. the file has to be reloaded. */
- g_autoptr(GFile) file = NULL;
-
- file = g_file_new_for_uri (uri);
- g_object_set_data (G_OBJECT (item), "needs-rotation", GINT_TO_POINTER (TRUE));
- g_object_set_data_full (G_OBJECT (file), "item", g_object_ref (item), g_object_unref);
- g_file_read_async (G_FILE (file), G_PRIORITY_DEFAULT,
- bg_source->cancellable,
- picture_opened_for_read, bg_source);
- return;
- }
-
- pixbuf = swap_rotated_pixbuf (pixbuf);
-
- scale_factor = bg_source_get_scale_factor (BG_SOURCE (bg_source));
- surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale_factor, NULL);
- cc_background_item_load (item, NULL);
-
- /* insert the item into the liststore */
- g_list_store_insert_sorted (store, item, sort_func, bg_source);
-
- g_hash_table_insert (bg_source->known_items,
- bg_pictures_source_get_unique_filename (uri),
- GINT_TO_POINTER (TRUE));
-
- g_clear_pointer (&surface, cairo_surface_destroy);
-}
-
-static void
-picture_opened_for_read (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- BgPicturesSource *bg_source;
- CcBackgroundItem *item;
- g_autoptr(GFileInputStream) stream = NULL;
- g_autoptr(GError) error = NULL;
- gint thumbnail_height;
- gint thumbnail_width;
- gboolean needs_rotation;
-
- item = g_object_get_data (source_object, "item");
- stream = g_file_read_finish (G_FILE (source_object), res, &error);
- if (stream == NULL)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- {
- g_autofree gchar *filename = g_file_get_path (G_FILE (source_object));
- g_warning ("Failed to load picture '%s': %s", filename, error->message);
- remove_placeholder (BG_PICTURES_SOURCE (user_data), item);
- }
-
- return;
- }
-
- /* since we were not cancelled, we can now cast user_data
- * back to BgPicturesSource.
- */
- bg_source = BG_PICTURES_SOURCE (user_data);
-
- needs_rotation = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "needs-rotation"));
- if (needs_rotation)
- {
- /* swap width and height for EXIF orientations that need it */
- thumbnail_width = bg_source_get_thumbnail_height (BG_SOURCE (bg_source));
- thumbnail_height = bg_source_get_thumbnail_width (BG_SOURCE (bg_source));
- g_object_set_data (G_OBJECT (item), "rotation-applied", GINT_TO_POINTER (TRUE));
- }
- else
- {
- thumbnail_width = bg_source_get_thumbnail_width (BG_SOURCE (bg_source));
- thumbnail_height = bg_source_get_thumbnail_height (BG_SOURCE (bg_source));
- }
-
- g_object_set_data_full (G_OBJECT (stream), "item", g_object_ref (item), g_object_unref);
- gdk_pixbuf_new_from_stream_at_scale_async (G_INPUT_STREAM (stream),
- thumbnail_width, thumbnail_height,
- TRUE,
- bg_source->cancellable,
- picture_scaled, bg_source);
-}
-
-static void
-picture_copied_for_read (GObject *source_object,
- GAsyncResult *res,
- gpointer user_data)
-{
- BgPicturesSource *bg_source;
- CcBackgroundItem *item;
- g_autoptr(GError) error = NULL;
- GFile *thumbnail_file = G_FILE (source_object);
- GFile *native_file;
-
- if (!g_file_copy_finish (thumbnail_file, res, &error))
- {
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- return;
- else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
- {
- g_autofree gchar *uri = NULL;
-
- uri = g_file_get_uri (thumbnail_file);
- g_warning ("Failed to download '%s': %s", uri, error->message);
- return;
- }
- }
-
- bg_source = BG_PICTURES_SOURCE (user_data);
-
- native_file = g_object_get_data (G_OBJECT (thumbnail_file), "native-file");
- item = g_object_get_data (G_OBJECT (thumbnail_file), "item");
- g_object_set_data_full (G_OBJECT (native_file), "item", g_object_ref (item), g_object_unref);
- g_file_read_async (native_file,
- G_PRIORITY_DEFAULT,
- bg_source->cancellable,
- picture_opened_for_read,
- bg_source);
-}
-
-static gboolean
-in_content_types (const char *content_type)
-{
- guint i;
- for (i = 0; content_types[i]; i++)
- if (g_str_equal (content_types[i], content_type))
- return TRUE;
- return FALSE;
-}
-
-static GFile *
-bg_pictures_source_get_cache_file (void)
-{
- g_autofree gchar *path = NULL;
- GFile *file;
-
- path = bg_pictures_source_get_cache_path ();
- file = g_file_new_for_path (path);
-
- return file;
-}
-
-static gboolean
-add_single_file (BgPicturesSource *bg_source,
- GFile *file,
- const gchar *content_type,
- guint64 mtime)
-{
- g_autoptr(CcBackgroundItem) item = NULL;
- CcBackgroundItemFlags flags = 0;
- g_autofree gchar *source_uri = NULL;
- g_autofree gchar *uri = NULL;
- gboolean needs_download;
- gboolean retval = FALSE;
- const gchar *pictures_path;
- g_autoptr(GFile) pictures_dir = NULL;
- g_autoptr(GFile) cache_dir = NULL;
- GrlMedia *media;
-
- /* find png and jpeg files */
- if (!content_type)
- goto out;
- if (!in_content_types (content_type))
- goto out;
-
- /* create a new CcBackgroundItem */
- uri = g_file_get_uri (file);
-
- pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
- if (pictures_path == NULL)
- pictures_path = g_get_home_dir ();
- pictures_dir = g_file_new_for_path (pictures_path);
- cache_dir = bg_pictures_source_get_cache_file ();
- needs_download = !g_file_has_parent (file, pictures_dir) &&
- !g_file_has_parent (file, cache_dir);
-
- if (!needs_download)
- {
- source_uri = g_strdup (uri);
- flags |= CC_BACKGROUND_ITEM_HAS_URI;
- }
- else
- {
- source_uri = g_steal_pointer (&uri);
- }
-
- item = cc_background_item_new (uri);
- flags |= CC_BACKGROUND_ITEM_HAS_SHADING | CC_BACKGROUND_ITEM_HAS_PLACEMENT;
- g_object_set (G_OBJECT (item),
- "flags", flags,
- "shading", G_DESKTOP_BACKGROUND_SHADING_SOLID,
- "placement", G_DESKTOP_BACKGROUND_STYLE_ZOOM,
- "modified", mtime,
- "needs-download", needs_download,
- "source-url", source_uri,
- NULL);
-
- media = g_object_get_data (G_OBJECT (file), "grl-media");
- if (media == NULL)
- {
- g_object_set_data_full (G_OBJECT (file), "item", g_object_ref (item), g_object_unref);
- g_file_read_async (file, G_PRIORITY_DEFAULT,
- bg_source->cancellable,
- picture_opened_for_read, bg_source);
- }
- else
- {
- g_autoptr(GFile) native_file = NULL;
- g_autoptr(GFile) thumbnail_file = NULL;
- g_autofree gchar *native_dir = NULL;
- g_autofree gchar *native_path = NULL;
- const gchar *title;
- const gchar *thumbnail_uri;
-
- title = grl_media_get_title (media);
- g_object_set (G_OBJECT (item), "name", title, NULL);
-
- thumbnail_uri = grl_media_get_thumbnail (media);
- thumbnail_file = g_file_new_for_uri (thumbnail_uri);
-
- native_path = gnome_desktop_thumbnail_path_for_uri (source_uri, GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
- native_file = g_file_new_for_path (native_path);
-
- native_dir = g_path_get_dirname (native_path);
- g_mkdir_with_parents (native_dir, USER_DIR_MODE);
-
- g_object_set_data_full (G_OBJECT (thumbnail_file), "item", g_object_ref (item), g_object_unref);
- g_object_set_data_full (G_OBJECT (thumbnail_file),
- "native-file",
- g_object_ref (native_file),
- g_object_unref);
- g_file_copy_async (thumbnail_file,
- native_file,
- G_FILE_COPY_ALL_METADATA,
- G_PRIORITY_DEFAULT,
- bg_source->cancellable,
- NULL,
- NULL,
- picture_copied_for_read,
- bg_source);
- }
-
- retval = TRUE;
-
- out:
- return retval;
-}
-
-static gboolean
-add_single_file_from_info (BgPicturesSource *bg_source,
- GFile *file,
- GFileInfo *info)
-{
- const gchar *content_type;
- guint64 mtime;
-
- content_type = g_file_info_get_content_type (info);
- mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
- return add_single_file (bg_source, file, content_type, mtime);
-}
-
-static gboolean
-add_single_file_from_media (BgPicturesSource *bg_source,
- GFile *file,
- GrlMedia *media)
-{
- GDateTime *mtime;
- const gchar *content_type;
- gint64 mtime_unix;
-
- content_type = grl_media_get_mime (media);
-
- /* only GRL_METADATA_KEY_CREATION_DATE is implemented in the Flickr
- * plugin, GRL_METADATA_KEY_MODIFICATION_DATE is not
- */
- mtime = grl_media_get_creation_date (media);
- if (!mtime)
- mtime = grl_media_get_modification_date (media);
- if (mtime)
- mtime_unix = g_date_time_to_unix (mtime);
- else
- mtime_unix = g_get_real_time () / G_USEC_PER_SEC;
-
- return add_single_file (bg_source, file, content_type, (guint64) mtime_unix);
-}
-
-gboolean
-bg_pictures_source_add (BgPicturesSource *bg_source,
- const char *uri,
- GtkTreeRowReference **ret_row_ref)
-{
- g_autoptr(GFile) file = NULL;
- GFileInfo *info;
- gboolean retval;
-
- file = g_file_new_for_uri (uri);
- info = g_file_query_info (file, ATTRIBUTES, G_FILE_QUERY_INFO_NONE, NULL, NULL);
- if (info == NULL)
- return FALSE;
-
- retval = add_single_file_from_info (bg_source, file, info);
-
- return retval;
-}
-
-gboolean
-bg_pictures_source_remove (BgPicturesSource *bg_source,
- const char *uri)
-{
- GListStore *store;
- gboolean retval;
- guint i;
-
- retval = FALSE;
- store = bg_source_get_liststore (BG_SOURCE (bg_source));
-
- for (i = 0; i < g_list_model_get_n_items (G_LIST_MODEL (store)); i++)
- {
- g_autoptr(CcBackgroundItem) tmp_item = NULL;
- const char *tmp_uri;
-
- tmp_item = g_list_model_get_item (G_LIST_MODEL (store), i);
- tmp_uri = cc_background_item_get_uri (tmp_item);
- if (g_str_equal (tmp_uri, uri))
- {
- char *uuid;
- uuid = bg_pictures_source_get_unique_filename (uri);
- g_hash_table_insert (bg_source->known_items,
- uuid, NULL);
-
- g_list_store_remove (store, i);
- retval = TRUE;
- break;
- }
- }
- return retval;
-}
-
-static int
-file_sort_func (gconstpointer a,
- gconstpointer b)
-{
- GFileInfo *file_a = G_FILE_INFO (a);
- GFileInfo *file_b = G_FILE_INFO (b);
- guint64 modified_a, modified_b;
-
- modified_a = g_file_info_get_attribute_uint64 (file_a, G_FILE_ATTRIBUTE_TIME_MODIFIED);
-
- modified_b = g_file_info_get_attribute_uint64 (file_b, G_FILE_ATTRIBUTE_TIME_MODIFIED);
-
- return modified_b - modified_a;
-}
-
-static void
-file_info_async_ready (GObject *source,
- GAsyncResult *res,
- gpointer user_data)
-{
- BgPicturesSource *bg_source;
- GList *files, *l;
- g_autoptr(GError) err = NULL;
- GFile *parent;
-
- files = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (source),
- res,
- &err);
- if (err)
- {
- if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Could not get pictures file information: %s", err->message);
-
- g_list_foreach (files, (GFunc) g_object_unref, NULL);
- g_list_free (files);
- return;
- }
-
- bg_source = BG_PICTURES_SOURCE (user_data);
-
- parent = g_file_enumerator_get_container (G_FILE_ENUMERATOR (source));
-
- files = g_list_sort (files, file_sort_func);
-
- /* iterate over the available files */
- for (l = files; l; l = g_list_next (l))
- {
- GFileInfo *info = l->data;
- g_autoptr(GFile) file = NULL;
-
- file = g_file_get_child (parent, g_file_info_get_name (info));
-
- add_single_file_from_info (bg_source, file, info);
- }
-
- g_list_foreach (files, (GFunc) g_object_unref, NULL);
- g_list_free (files);
-}
-
-static void
-dir_enum_async_ready (GObject *s,
- GAsyncResult *res,
- gpointer user_data)
-{
- BgPicturesSource *source = (BgPicturesSource *) user_data;
- g_autoptr(GFileEnumerator) enumerator = NULL;
- g_autoptr(GError) err = NULL;
-
- enumerator = g_file_enumerate_children_finish (G_FILE (s), res, &err);
-
- if (err)
- {
- if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Could not fill pictures source: %s", err->message);
- return;
- }
-
- /* get the files */
- g_file_enumerator_next_files_async (enumerator,
- G_MAXINT,
- G_PRIORITY_LOW,
- source->cancellable,
- file_info_async_ready,
- user_data);
-}
-
-char *
-bg_pictures_source_get_cache_path (void)
-{
- return g_build_filename (g_get_user_cache_dir (),
- "gnome-control-center",
- "backgrounds",
- NULL);
-}
-
-static char *
-bg_pictures_source_get_unique_filename (const char *uri)
-{
- g_autoptr(GChecksum) csum = NULL;
- char *ret;
-
- csum = g_checksum_new (G_CHECKSUM_SHA256);
- g_checksum_update (csum, (guchar *) uri, -1);
- ret = g_strdup (g_checksum_get_string (csum));
-
- return ret;
-}
-
-char *
-bg_pictures_source_get_unique_path (const char *uri)
-{
- g_autoptr(GFile) parent = NULL;
- g_autoptr(GFile) file = NULL;
- g_autofree gchar *cache_path = NULL;
- g_autofree gchar *filename = NULL;
-
- cache_path = bg_pictures_source_get_cache_path ();
- parent = g_file_new_for_path (cache_path);
-
- filename = bg_pictures_source_get_unique_filename (uri);
- file = g_file_get_child (parent, filename);
-
- return g_file_get_path (file);
-}
-
-gboolean
-bg_pictures_source_is_known (BgPicturesSource *bg_source,
- const char *uri)
-{
- g_autofree gchar *uuid = NULL;
-
- uuid = bg_pictures_source_get_unique_filename (uri);
-
- return GPOINTER_TO_INT (g_hash_table_lookup (bg_source->known_items, uuid));
-}
-
-static void
-file_info_ready (GObject *object,
- GAsyncResult *res,
- gpointer user_data)
-{
- GFileInfo *info;
- GError *error = NULL;
- GFile *file = G_FILE (object);
-
- info = g_file_query_info_finish (file, res, &error);
-
- if (!info)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Problem looking up file info: %s", error->message);
- g_clear_error (&error);
- return;
- }
-
- add_single_file_from_info (BG_PICTURES_SOURCE (user_data), file, info);
-}
-
-static void
-file_added (GFile *file,
- BgPicturesSource *self)
-{
- g_autofree gchar *uri = NULL;
- uri = g_file_get_uri (file);
-
- if (!bg_pictures_source_is_known (self, uri))
- {
- g_file_query_info_async (file,
- ATTRIBUTES,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_LOW,
- NULL,
- file_info_ready,
- self);
- }
-}
-
-static void
-files_changed_cb (BgPicturesSource *self,
- GFile *file,
- GFile *other_file,
- GFileMonitorEvent event_type)
-{
- g_autofree gchar *uri = NULL;
-
- switch (event_type)
- {
- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
- file_added (file, self);
- break;
-
- case G_FILE_MONITOR_EVENT_DELETED:
- uri = g_file_get_uri (file);
- bg_pictures_source_remove (self, uri);
- break;
-
- default:
- return;
- }
-}
-
-static GFileMonitor *
-monitor_path (BgPicturesSource *self,
- const char *path)
-{
- GFileMonitor *monitor;
- g_autoptr(GFile) dir = NULL;
-
- g_mkdir_with_parents (path, USER_DIR_MODE);
-
- dir = g_file_new_for_path (path);
- g_file_enumerate_children_async (dir,
- ATTRIBUTES,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_LOW, self->cancellable,
- dir_enum_async_ready, self);
-
- monitor = g_file_monitor_directory (dir,
- G_FILE_MONITOR_NONE,
- self->cancellable,
- NULL);
-
- if (monitor)
- g_signal_connect_object (monitor,
- "changed",
- G_CALLBACK (files_changed_cb),
- self, G_CONNECT_SWAPPED);
-
- return monitor;
-}
-
-static void
-media_found_cb (BgPicturesSource *self, GrlMedia *media)
-{
- g_autoptr(GFile) file = NULL;
- const gchar *uri;
-
- uri = grl_media_get_url (media);
- file = g_file_new_for_uri (uri);
- g_object_set_data_full (G_OBJECT (file), "grl-media", g_object_ref (media), g_object_unref);
- add_single_file_from_media (self, file, media);
-}
-
-static void
-bg_pictures_source_init (BgPicturesSource *self)
-{
- const gchar *pictures_path;
- g_autofree gchar *cache_path = NULL;
-
- self->cancellable = g_cancellable_new ();
- self->known_items = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- NULL);
-
- pictures_path = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
- if (pictures_path == NULL)
- pictures_path = g_get_home_dir ();
-
- self->picture_dir_monitor = monitor_path (self, pictures_path);
-
- cache_path = bg_pictures_source_get_cache_path ();
- self->cache_dir_monitor = monitor_path (self, cache_path);
-
- self->grl_miner = cc_background_grilo_miner_new ();
- g_signal_connect_object (self->grl_miner, "media-found", G_CALLBACK (media_found_cb), self, G_CONNECT_SWAPPED);
- cc_background_grilo_miner_start (self->grl_miner);
-}
-
-BgPicturesSource *
-bg_pictures_source_new (GtkWidget *widget)
-{
- return g_object_new (BG_TYPE_PICTURES_SOURCE, "widget", widget, NULL);
-}
-
-const char * const *
-bg_pictures_get_support_content_types (void)
-{
- return content_types;
-}
diff --git a/panels/background/bg-pictures-source.h b/panels/background/bg-pictures-source.h
deleted file mode 100644
index f62cbe532e26..000000000000
--- a/panels/background/bg-pictures-source.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* bg-pictures-source.h */
-/*
- * Copyright (C) 2010 Intel, Inc
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * Author: Thomas Wood <thomas.wood@intel.com>
- *
- */
-
-#pragma once
-
-#include <gtk/gtk.h>
-#include "bg-source.h"
-#include "cc-background-item.h"
-
-G_BEGIN_DECLS
-
-#define BG_TYPE_PICTURES_SOURCE (bg_pictures_source_get_type ())
-G_DECLARE_FINAL_TYPE (BgPicturesSource, bg_pictures_source, BG, PICTURES_SOURCE, BgSource)
-
-BgPicturesSource *bg_pictures_source_new (GtkWidget *widget);
-char *bg_pictures_source_get_cache_path (void);
-char *bg_pictures_source_get_unique_path(const char *uri);
-gboolean bg_pictures_source_add (BgPicturesSource *bg_source,
- const char *uri,
- GtkTreeRowReference **ret_row_ref);
-gboolean bg_pictures_source_remove (BgPicturesSource *bg_source,
- const char *uri);
-gboolean bg_pictures_source_is_known (BgPicturesSource *bg_source,
- const char *uri);
-
-const char * const * bg_pictures_get_support_content_types (void);
-
-G_END_DECLS
diff --git a/panels/background/cc-background-chooser.c b/panels/background/cc-background-chooser.c
index 6c8f56136271..04fd85c477aa 100644
--- a/panels/background/cc-background-chooser.c
+++ b/panels/background/cc-background-chooser.c
@@ -25,7 +25,6 @@
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#include "bg-colors-source.h"
-#include "bg-pictures-source.h"
#include "bg-recent-source.h"
#include "bg-wallpapers-source.h"
#include "cc-background-chooser.h"
diff --git a/panels/background/cc-background-grilo-miner.c b/panels/background/cc-background-grilo-miner.c
deleted file mode 100644
index 85c09daf6928..000000000000
--- a/panels/background/cc-background-grilo-miner.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-#include <gio/gio.h>
-#include <grilo.h>
-
-#define GOA_API_IS_SUBJECT_TO_CHANGE
-#include <goa/goa.h>
-
-#include "bg-pictures-source.h"
-#include "cc-background-grilo-miner.h"
-
-struct _CcBackgroundGriloMiner
-{
- GObject parent_instance;
-
- GCancellable *cancellable;
- GList *accounts;
-};
-
-G_DEFINE_TYPE (CcBackgroundGriloMiner, cc_background_grilo_miner, G_TYPE_OBJECT)
-
-enum
-{
- MEDIA_FOUND,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-#define REMOTE_ITEM_COUNT 50
-
-static gchar *
-get_grilo_id (GoaObject *goa_object)
-{
- GoaAccount *account;
-
- account = goa_object_peek_account (goa_object);
- return g_strdup_printf ("grl-flickr-%s", goa_account_get_id (account));
-}
-
-static void
-is_online_data_cached (GObject *object,
- GAsyncResult *res,
- gpointer user_data)
-{
- CcBackgroundGriloMiner *self;
- GError *error = NULL;
- GFileInfo *info = NULL;
- GFile *cache_file = G_FILE (object);
- GrlMedia *media;
- const gchar *uri;
-
- info = g_file_query_info_finish (cache_file, res, &error);
- if (info == NULL)
- {
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- goto out;
- }
-
- self = CC_BACKGROUND_GRILO_MINER (user_data);
-
- media = g_object_get_data (G_OBJECT (cache_file), "grl-media");
- uri = grl_media_get_url (media);
-
- if (info != NULL)
- {
- g_debug ("Ignored URL '%s' as it is already in the cache", uri);
- goto out;
- }
-
- g_signal_emit (self, signals[MEDIA_FOUND], 0, media);
-
- out:
- g_clear_object (&info);
- g_clear_error (&error);
-}
-
-static void
-searched_online_source (GrlSource *source,
- guint operation_id,
- GrlMedia *media,
- guint remaining,
- gpointer user_data,
- const GError *error)
-{
- CcBackgroundGriloMiner *self = CC_BACKGROUND_GRILO_MINER (user_data);
- g_autoptr(GFile) cache_file = NULL;
- const gchar *uri;
- g_autofree gchar *cache_path = NULL;
-
- if (error != NULL)
- {
- const gchar *source_id;
-
- source_id = grl_source_get_id (source);
- g_warning ("Error searching %s: %s", source_id, error->message);
- grl_operation_cancel (operation_id);
- remaining = 0;
- goto out;
- }
-
- uri = grl_media_get_url (media);
- cache_path = bg_pictures_source_get_unique_path (uri);
- cache_file = g_file_new_for_path (cache_path);
- g_object_set_data_full (G_OBJECT (cache_file), "grl-media", media, g_object_unref);
- g_file_query_info_async (cache_file,
- G_FILE_ATTRIBUTE_STANDARD_TYPE,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT,
- self->cancellable,
- is_online_data_cached,
- self);
-
- out:
- if (remaining == 0)
- g_object_unref (self);
-}
-
-static void
-query_online_source (CcBackgroundGriloMiner *self, GrlSource *source)
-{
- const GList *keys;
- GrlCaps *caps;
- GrlOperationOptions *options;
-
- keys = grl_source_supported_keys (source);
- caps = grl_source_get_caps (source, GRL_OP_BROWSE);
- options = grl_operation_options_new (caps);
- grl_operation_options_set_count (options, REMOTE_ITEM_COUNT);
- grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FAST_ONLY);
- grl_operation_options_set_type_filter (options, GRL_TYPE_FILTER_IMAGE);
-
- grl_source_search (source, NULL, keys, options, searched_online_source, g_object_ref (self));
- g_object_unref (options);
-}
-
-static void
-add_online_source_cb (CcBackgroundGriloMiner *self,
- GrlSource *source)
-{
- GList *l;
- gboolean found = FALSE;
- const gchar *source_id;
-
- source_id = grl_source_get_id (source);
- for (l = self->accounts; l != NULL && !found; l = l->next)
- {
- GoaObject *goa_object = GOA_OBJECT (l->data);
- g_autofree gchar *account_id = NULL;
-
- account_id = get_grilo_id (goa_object);
- if (g_strcmp0 (source_id, account_id) == 0)
- {
- query_online_source (self, source);
- found = TRUE;
- }
- }
-}
-
-static void
-client_async_ready (GObject *source,
- GAsyncResult *res,
- gpointer user_data)
-{
- CcBackgroundGriloMiner *self;
- g_autoptr(GError) error = NULL;
- GList *accounts = NULL;
- GList *photo_accounts = NULL;
- GList *l;
- GoaClient *client = NULL;
- GrlRegistry *registry;
-
- client = goa_client_new_finish (res, &error);
- if (client == NULL)
- {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Failed to create GoaClient: %s", error->message);
- goto out;
- }
-
- self = CC_BACKGROUND_GRILO_MINER (user_data);
-
- accounts = goa_client_get_accounts (client);
- for (l = accounts; l != NULL; l = l->next)
- {
- GoaObject *goa_object = GOA_OBJECT (l->data);
- GoaAccount *account;
- GoaPhotos *photos;
- const gchar *provider_type;
-
- account = goa_object_peek_account (goa_object);
- provider_type = goa_account_get_provider_type (account);
-
- photos = goa_object_peek_photos (goa_object);
- if (photos != NULL && g_strcmp0 (provider_type, "flickr") == 0)
- photo_accounts = g_list_prepend (photo_accounts, g_object_ref (goa_object));
- }
-
- if (photo_accounts == NULL)
- goto out;
-
- registry = grl_registry_get_default ();
-
- for (l = photo_accounts; l != NULL; l = l->next)
- {
- GoaObject *goa_object = GOA_OBJECT (l->data);
- GrlSource *source;
- g_autofree gchar *account_id = NULL;
-
- account_id = get_grilo_id (goa_object);
- source = grl_registry_lookup_source (registry, account_id);
- if (source != NULL)
- query_online_source (self, source);
- }
-
- self->accounts = photo_accounts;
- photo_accounts = NULL;
-
- g_signal_connect_object (registry, "source-added", G_CALLBACK (add_online_source_cb), self, G_CONNECT_SWAPPED);
-
- out:
- g_list_free_full (photo_accounts, g_object_unref);
- g_list_free_full (accounts, g_object_unref);
- g_clear_object (&client);
-}
-
-static void
-setup_online_accounts (CcBackgroundGriloMiner *self)
-{
- goa_client_new (self->cancellable, client_async_ready, self);
-}
-
-static void
-cc_background_grilo_miner_dispose (GObject *object)
-{
- CcBackgroundGriloMiner *self = CC_BACKGROUND_GRILO_MINER (object);
-
- if (self->cancellable)
- {
- g_cancellable_cancel (self->cancellable);
- g_clear_object (&self->cancellable);
- }
-
- if (self->accounts)
- {
- g_list_free_full (self->accounts, g_object_unref);
- self->accounts = NULL;
- }
-
- G_OBJECT_CLASS (cc_background_grilo_miner_parent_class)->dispose (object);
-}
-
-static void
-cc_background_grilo_miner_init (CcBackgroundGriloMiner *self)
-{
- self->cancellable = g_cancellable_new ();
-}
-
-static void
-cc_background_grilo_miner_class_init (CcBackgroundGriloMinerClass *klass)
-{
- g_autoptr(GError) error = NULL;
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GrlRegistry *registry;
-
- object_class->dispose = cc_background_grilo_miner_dispose;
-
- signals[MEDIA_FOUND] = g_signal_new ("media-found",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0, /* class_offset */
- NULL, /* accumulator */
- NULL, /* accu_data */
- g_cclosure_marshal_VOID__OBJECT,
- G_TYPE_NONE,
- 1,
- GRL_TYPE_MEDIA);
-
- grl_init (NULL, NULL);
- registry = grl_registry_get_default ();
-
- error = NULL;
- if (!grl_registry_load_all_plugins (registry, FALSE, &error) ||
- !grl_registry_activate_plugin_by_id (registry, "grl-flickr", &error))
- g_warning ("%s", error->message);
-}
-
-CcBackgroundGriloMiner *
-cc_background_grilo_miner_new (void)
-{
- return g_object_new (CC_TYPE_BACKGROUND_GRILO_MINER, NULL);
-}
-
-void
-cc_background_grilo_miner_start (CcBackgroundGriloMiner *self)
-{
- setup_online_accounts (self);
-}
diff --git a/panels/background/cc-background-grilo-miner.h b/panels/background/cc-background-grilo-miner.h
deleted file mode 100644
index b018129aeba5..000000000000
--- a/panels/background/cc-background-grilo-miner.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2014 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define CC_TYPE_BACKGROUND_GRILO_MINER (cc_background_grilo_miner_get_type ())
-G_DECLARE_FINAL_TYPE (CcBackgroundGriloMiner, cc_background_grilo_miner, CC, BACKGROUND_GRILO_MINER, GObject);
-
-CcBackgroundGriloMiner *cc_background_grilo_miner_new (void);
-
-void cc_background_grilo_miner_start (CcBackgroundGriloMiner *self);
-
-G_END_DECLS
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index 29dedf1653ad..3e50f506b514 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -35,8 +35,6 @@
#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"
diff --git a/panels/background/meson.build b/panels/background/meson.build
index e9fa398d4ceb..eb5e9ec84625 100644
--- a/panels/background/meson.build
+++ b/panels/background/meson.build
@@ -76,12 +76,10 @@ common_sources += gnome.compile_resources(
sources = common_sources + files(
'bg-colors-source.c',
- 'bg-pictures-source.c',
'bg-recent-source.c',
'bg-source.c',
'bg-wallpapers-source.c',
'cc-background-chooser.c',
- 'cc-background-grilo-miner.c',
'cc-background-item.c',
'cc-background-panel.c',
'cc-background-preview.c',
@@ -91,10 +89,8 @@ sources = common_sources + files(
deps = common_deps + [
gdk_pixbuf_dep,
gnome_desktop_dep,
- goa_dep,
libxml_dep,
dependency('cairo-gobject'),
- dependency('grilo-0.3', version: '>= 0.3.0')
]
cflags += [
--
2.30.2