[gnome-photos/wip/rishi/empty-results: 2/2] source-manager: Nuke all sources when run with --empty-results
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/empty-results: 2/2] source-manager: Nuke all sources when run with --empty-results
- Date: Fri, 8 Dec 2017 13:51:38 +0000 (UTC)
commit 4bbf125b307962cdd820b3f6cfb45492cd53b09d
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Dec 8 14:47:00 2017 +0100
source-manager: Nuke all sources when run with --empty-results
src/photos-source-manager.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index 40946ef..a10ddcf 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <goa/goa.h>
+#include "photos-application.h"
#include "photos-filterable.h"
#include "photos-query.h"
#include "photos-source.h"
@@ -60,10 +61,18 @@ G_DEFINE_TYPE (PhotosSourceManager, photos_source_manager, PHOTOS_TYPE_BASE_MANA
static gchar *
photos_source_manager_get_filter (PhotosBaseManager *mngr, gint flags)
{
+ GApplication *app;
GObject *source;
const gchar *id;
gchar *filter;
+ app = g_application_get_default ();
+ if (photos_application_get_empty_results (PHOTOS_APPLICATION (app)))
+ {
+ filter = g_strdup ("(false)");
+ goto out;
+ }
+
if (flags & PHOTOS_QUERY_FLAGS_SEARCH)
source = photos_base_manager_get_active_object (mngr);
else
@@ -75,6 +84,7 @@ photos_source_manager_get_filter (PhotosBaseManager *mngr, gint flags)
else
filter = photos_filterable_get_filter (PHOTOS_FILTERABLE (source));
+ out:
return filter;
}
@@ -102,12 +112,17 @@ photos_source_manager_remove_object_by_id (PhotosBaseManager *mngr, const gchar
static void
photos_source_manager_refresh_accounts (PhotosSourceManager *self)
{
- GHashTable *new_sources;
- GList *accounts;
+ GApplication *app;
+ GHashTable *new_sources = NULL;
+ GList *accounts = NULL;
GList *l;
guint i;
guint n_items;
+ app = g_application_get_default ();
+ if (photos_application_get_empty_results (PHOTOS_APPLICATION (app)))
+ goto out;
+
accounts = goa_client_get_accounts (self->client);
new_sources = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
@@ -180,7 +195,8 @@ photos_source_manager_refresh_accounts (PhotosSourceManager *self)
g_clear_object (&source);
}
- g_hash_table_unref (new_sources);
+ out:
+ g_clear_pointer (&new_sources, (GDestroyNotify) g_hash_table_unref);
g_list_free_full (accounts, g_object_unref);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]