[gnome-photos] base-item, filterable, search-match, search-type, source: Add get_id
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] base-item, filterable, search-match, search-type, source: Add get_id
- Date: Mon, 10 Feb 2014 13:34:47 +0000 (UTC)
commit 93c74a1103140f07374bf65719df7973bdacdd68
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Feb 7 15:46:13 2014 +0100
base-item, filterable, search-match, search-type, source: Add get_id
Better than having to use g_object_get to get the "id".
src/photos-application.c | 7 ++++---
src/photos-base-item.c | 29 +++++++++++++++++++++--------
src/photos-base-item.h | 2 --
src/photos-base-manager.c | 24 ++++++++++--------------
src/photos-base-view.c | 6 +++---
src/photos-collection-icon-watcher.c | 3 ++-
src/photos-dlna-renderer.c | 9 +++++----
src/photos-embed.c | 12 +++++-------
src/photos-fetch-collection-state-job.c | 6 ++++--
src/photos-filterable.c | 10 +++++++++-
src/photos-filterable.h | 5 ++++-
src/photos-organize-collection-model.c | 5 +++--
src/photos-overview-searchbar.c | 12 +++++-------
src/photos-remote-display-manager.c | 5 ++++-
src/photos-search-match-manager.c | 5 ++---
src/photos-search-match.c | 9 +++++++++
src/photos-search-type-manager.c | 5 ++---
src/photos-search-type.c | 11 ++++++++++-
src/photos-selection-controller.c | 10 ++++------
src/photos-source-manager.c | 11 +++++------
src/photos-source.c | 11 ++++++++++-
src/photos-tracker-controller.c | 8 +++-----
src/photos-view-model.c | 5 +++--
23 files changed, 127 insertions(+), 83 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 9cab009..f54a9b2 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 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
@@ -37,6 +37,7 @@
#include "photos-base-item.h"
#include "photos-camera-cache.h"
#include "photos-dlna-renderers-dialog.h"
+#include "photos-filterable.h"
#include "photos-gom-miner.h"
#include "photos-item-manager.h"
#include "photos-main-window.h"
@@ -198,7 +199,7 @@ photos_application_properties (PhotosApplication *self)
if (item == NULL)
return;
- id = photos_base_item_get_id (item);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (item));
dialog = photos_properties_dialog_new (GTK_WINDOW (priv->main_window), id);
gtk_widget_show_all (dialog);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
@@ -291,7 +292,7 @@ photos_application_remote_display_current (PhotosApplication *self)
if (item == NULL)
return;
- urn = photos_base_item_get_id (item);
+ urn = photos_filterable_get_id (PHOTOS_FILTERABLE (item));
dialog = photos_dlna_renderers_dialog_new (GTK_WINDOW (priv->main_window), urn);
gtk_widget_show_all (dialog);
}
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 8c06c6f..7a767d4 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -36,6 +36,7 @@
#include "photos-base-item.h"
#include "photos-collection-icon-watcher.h"
#include "photos-delete-item-job.h"
+#include "photos-filterable.h"
#include "photos-icons.h"
#include "photos-print-operation.h"
#include "photos-query.h"
@@ -99,8 +100,12 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
+static void photos_base_item_filterable_iface_init (PhotosFilterableInterface *iface);
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosBaseItem, photos_base_item, G_TYPE_OBJECT);
+
+G_DEFINE_TYPE_WITH_CODE (PhotosBaseItem, photos_base_item, G_TYPE_OBJECT,
+ G_ADD_PRIVATE (PhotosBaseItem)
+ G_IMPLEMENT_INTERFACE (PHOTOS_TYPE_FILTERABLE,
photos_base_item_filterable_iface_init));
static GThreadPool *create_thumbnail_pool;
@@ -338,6 +343,14 @@ photos_base_item_download_in_thread_func (GTask *task,
}
+static const gchar *
+photos_base_item_get_id (PhotosFilterable *filterable)
+{
+ PhotosBaseItem *self = PHOTOS_BASE_ITEM (filterable);
+ return self->priv->id;
+}
+
+
static void
photos_base_item_icon_updated (PhotosBaseItem *self, GIcon *icon)
{
@@ -958,6 +971,13 @@ photos_base_item_class_init (PhotosBaseItemClass *class)
}
+static void
+photos_base_item_filterable_iface_init (PhotosFilterableInterface *iface)
+{
+ iface->get_id = photos_base_item_get_id;
+}
+
+
gboolean
photos_base_item_can_trash (PhotosBaseItem *self)
{
@@ -1088,13 +1108,6 @@ photos_base_item_get_icon (PhotosBaseItem *self)
const gchar *
-photos_base_item_get_id (PhotosBaseItem *self)
-{
- return self->priv->id;
-}
-
-
-const gchar *
photos_base_item_get_identifier (PhotosBaseItem *self)
{
return self->priv->identifier;
diff --git a/src/photos-base-item.h b/src/photos-base-item.h
index f9325a2..9e799c4 100644
--- a/src/photos-base-item.h
+++ b/src/photos-base-item.h
@@ -119,8 +119,6 @@ gint64 photos_base_item_get_height (PhotosBaseItem *self);
GdkPixbuf *photos_base_item_get_icon (PhotosBaseItem *self);
-const gchar *photos_base_item_get_id (PhotosBaseItem *self);
-
const gchar *photos_base_item_get_identifier (PhotosBaseItem *self);
gdouble photos_base_item_get_iso_speed (PhotosBaseItem *self);
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index eb6b468..0911205 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -224,17 +224,14 @@ void
photos_base_manager_add_object (PhotosBaseManager *self, GObject *object)
{
GObject *old_object;
- gchar *id;
+ const gchar *id;
- g_object_get (object, "id", &id, NULL);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
old_object = photos_base_manager_get_object_by_id (self, id);
if (old_object != NULL)
- {
- g_free (id);
- return;
- }
+ return;
- g_hash_table_insert (self->priv->objects, (gpointer) id, g_object_ref (object));
+ g_hash_table_insert (self->priv->objects, g_strdup (id), g_object_ref (object));
g_signal_emit (self, signals[OBJECT_ADDED], 0, object);
}
@@ -275,14 +272,15 @@ photos_base_manager_get_all_filter (PhotosBaseManager *self)
for (i = 0, l = values; l != NULL; l = l->next)
{
- gchar *id;
+ PhotosFilterable *filterable = PHOTOS_FILTERABLE (l->data);
+ const gchar *id;
- g_object_get (l->data, "id", &id, NULL);
+ id = photos_filterable_get_id (filterable);
if (g_strcmp0 (id, "all") != 0)
{
gchar *str;
- str = photos_filterable_get_filter (PHOTOS_FILTERABLE (l->data));
+ str = photos_filterable_get_filter (filterable);
if (g_strcmp0 (str, blank) == 0)
g_free (str);
else
@@ -291,7 +289,6 @@ photos_base_manager_get_all_filter (PhotosBaseManager *self)
i++;
}
}
- g_free (id);
}
length = g_strv_length (strv);
@@ -403,11 +400,10 @@ photos_base_manager_process_new_objects (PhotosBaseManager *self, GHashTable *ne
void
photos_base_manager_remove_object (PhotosBaseManager *self, GObject *object)
{
- gchar *id;
+ const gchar *id;
- g_object_get (object, "id", &id, NULL);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
photos_base_manager_remove_object_by_id (self, id);
- g_free (id);
}
diff --git a/src/photos-base-view.c b/src/photos-base-view.c
index 7fa7eb3..4c1637b 100644
--- a/src/photos-base-view.c
+++ b/src/photos-base-view.c
@@ -27,6 +27,7 @@
#include "photos-base-view.h"
#include "photos-base-model.h"
+#include "photos-filterable.h"
struct _PhotosBaseViewPrivate
@@ -105,18 +106,17 @@ photos_base_view_renderer_radio_cell_func (PhotosBaseView *self,
PhotosBaseViewPrivate *priv = self->priv;
GObject *object;
gboolean active;
- gchar *active_id = NULL;
+ const gchar *active_id = NULL;
gchar *id;
gtk_tree_model_get (GTK_TREE_MODEL (priv->model), iter, PHOTOS_BASE_MODEL_ID, &id, -1);
object = photos_base_manager_get_active_object (priv->mngr);
if (object != NULL)
- g_object_get (object, "id", &active_id, NULL);
+ active_id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
active = g_strcmp0 (id, active_id) == 0;
gtk_cell_renderer_toggle_set_active (GTK_CELL_RENDERER_TOGGLE (cell), active);
- g_free (active_id);
g_free (id);
}
diff --git a/src/photos-collection-icon-watcher.c b/src/photos-collection-icon-watcher.c
index 08e64e3..fa3b7db 100644
--- a/src/photos-collection-icon-watcher.c
+++ b/src/photos-collection-icon-watcher.c
@@ -30,6 +30,7 @@
#include <tracker-sparql.h>
#include "photos-collection-icon-watcher.h"
+#include "photos-filterable.h"
#include "photos-item-manager.h"
#include "photos-query.h"
#include "photos-query-builder.h"
@@ -309,7 +310,7 @@ photos_collection_icon_watcher_start (PhotosCollectionIconWatcher *self)
if (priv->collection == NULL)
return;
- id = photos_base_item_get_id (priv->collection);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (priv->collection));
query = photos_query_builder_collection_icon_query (id);
photos_tracker_queue_select (priv->queue,
query->sparql,
diff --git a/src/photos-dlna-renderer.c b/src/photos-dlna-renderer.c
index ff31ecc..a96d3fd 100644
--- a/src/photos-dlna-renderer.c
+++ b/src/photos-dlna-renderer.c
@@ -1,7 +1,7 @@
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2013 Intel Corporation. All rights reserved.
- * Copyright © 2013 Red Hat, Inc.
+ * Copyright © 2013, 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
@@ -25,6 +25,7 @@
#include "photos-dleyna-renderer-device.h"
#include "photos-dleyna-renderer-push-host.h"
#include "photos-dlna-renderer.h"
+#include "photos-filterable.h"
#include "photos-mpris-player.h"
@@ -502,10 +503,10 @@ photos_dlna_renderer_match_by_item_value (gpointer key,
gpointer value,
gpointer user_data)
{
- PhotosBaseItem *a = PHOTOS_BASE_ITEM (value);
- PhotosBaseItem *b = PHOTOS_BASE_ITEM (user_data);
+ PhotosFilterable *a = PHOTOS_FILTERABLE (value);
+ PhotosFilterable *b = PHOTOS_FILTERABLE (user_data);
- return g_strcmp0 (photos_base_item_get_id (a), photos_base_item_get_id (b)) == 0;
+ return g_strcmp0 (photos_filterable_get_id (a), photos_filterable_get_id (b)) == 0;
}
diff --git a/src/photos-embed.c b/src/photos-embed.c
index 3e98bdf..f2daeef 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -32,6 +32,7 @@
#include "photos-application.h"
#include "photos-collection-manager.h"
#include "photos-embed.h"
+#include "photos-filterable.h"
#include "photos-indexing-notification.h"
#include "photos-item-manager.h"
#include "photos-mode-controller.h"
@@ -498,9 +499,9 @@ photos_embed_search_changed (PhotosEmbed *self)
PhotosEmbedPrivate *priv = self->priv;
GObject *object;
PhotosWindowMode mode;
+ const gchar *search_type_id;
+ const gchar *source_id;
const gchar *str;
- gchar *search_type_id;
- gchar *source_id;
/* Whenever a search constraint is specified we want to switch to
* the search mode, and when all constraints have been lifted we
@@ -523,10 +524,10 @@ photos_embed_search_changed (PhotosEmbed *self)
return;
object = photos_base_manager_get_active_object (priv->src_mngr);
- g_object_get (object, "id", &source_id, NULL);
+ source_id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
object = photos_base_manager_get_active_object (priv->srch_mngr);
- g_object_get (object, "id", &search_type_id, NULL);
+ search_type_id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
str = photos_search_controller_get_string (priv->srch_cntrlr);
@@ -538,9 +539,6 @@ photos_embed_search_changed (PhotosEmbed *self)
mode = PHOTOS_WINDOW_MODE_SEARCH;
photos_mode_controller_set_window_mode (priv->mode_cntrlr, mode);
-
- g_free (search_type_id);
- g_free (source_id);
}
diff --git a/src/photos-fetch-collection-state-job.c b/src/photos-fetch-collection-state-job.c
index 42ce5fb..811bcdc 100644
--- a/src/photos-fetch-collection-state-job.c
+++ b/src/photos-fetch-collection-state-job.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2013 Red Hat, Inc.
+ * Copyright © 2013, 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
@@ -31,6 +31,7 @@
#include "photos-collection-manager.h"
#include "photos-fetch-collection-state-job.h"
#include "photos-fetch-collections-job.h"
+#include "photos-filterable.h"
#include "photos-item-manager.h"
#include "photos-query.h"
#include "photos-query-builder.h"
@@ -117,7 +118,8 @@ photos_fetch_collection_state_job_emit_callback (PhotosFetchCollectionStateJob *
{
item_idx = (gchar *) keys->data;
item = PHOTOS_BASE_ITEM (photos_base_manager_get_object_by_id (priv->item_mngr, item_idx));
- if (g_strcmp0 (photos_base_item_get_id (item), photos_base_item_get_id (collection)) == 0)
+ if (g_strcmp0 (photos_filterable_get_id (PHOTOS_FILTERABLE (item)),
+ photos_filterable_get_id (PHOTOS_FILTERABLE (collection))) == 0)
hidden = TRUE;
}
g_list_free (keys);
diff --git a/src/photos-filterable.c b/src/photos-filterable.c
index 57ef1c6..3e16e3a 100644
--- a/src/photos-filterable.c
+++ b/src/photos-filterable.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 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
@@ -47,6 +47,14 @@ photos_filterable_get_filter (PhotosFilterable *iface)
}
+const gchar *
+photos_filterable_get_id (PhotosFilterable *self)
+{
+ g_return_val_if_fail (PHOTOS_IS_FILTERABLE (self), NULL);
+ return PHOTOS_FILTERABLE_GET_INTERFACE (self)->get_id (self);
+}
+
+
gchar *
photos_filterable_get_where (PhotosFilterable *iface)
{
diff --git a/src/photos-filterable.h b/src/photos-filterable.h
index 3669151..ef05a93 100644
--- a/src/photos-filterable.h
+++ b/src/photos-filterable.h
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 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
@@ -51,6 +51,7 @@ struct _PhotosFilterableInterface
GTypeInterface parent_iface;
gchar *(*get_filter) (PhotosFilterable *self);
+ const gchar *(*get_id) (PhotosFilterable *self);
gchar *(*get_where) (PhotosFilterable *self);
};
@@ -58,6 +59,8 @@ GType photos_filterable_get_type (void) G_GNUC_CONST;
gchar *photos_filterable_get_filter (PhotosFilterable *iface);
+const gchar *photos_filterable_get_id (PhotosFilterable *self);
+
gchar *photos_filterable_get_where (PhotosFilterable *iface);
G_END_DECLS
diff --git a/src/photos-organize-collection-model.c b/src/photos-organize-collection-model.c
index be269ef..ec7433a 100644
--- a/src/photos-organize-collection-model.c
+++ b/src/photos-organize-collection-model.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 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
@@ -28,6 +28,7 @@
#include "photos-base-item.h"
#include "photos-collection-manager.h"
#include "photos-fetch-collection-state-job.h"
+#include "photos-filterable.h"
#include "photos-organize-collection-model.h"
@@ -54,7 +55,7 @@ photos_organize_collection_model_foreach (GtkTreeModel *model,
gchar *id;
gtk_tree_model_get (GTK_TREE_MODEL (self), iter, PHOTOS_ORGANIZE_MODEL_ID, &id, -1);
- if (g_strcmp0 (photos_base_item_get_id (collection), id) == 0)
+ if (g_strcmp0 (photos_filterable_get_id (PHOTOS_FILTERABLE (collection)), id) == 0)
{
self->priv->coll_path = gtk_tree_path_copy (path);
ret_val = TRUE;
diff --git a/src/photos-overview-searchbar.c b/src/photos-overview-searchbar.c
index 83bfd89..78dd9c5 100644
--- a/src/photos-overview-searchbar.c
+++ b/src/photos-overview-searchbar.c
@@ -30,6 +30,7 @@
#include "photos-application.h"
#include "photos-collection-manager.h"
+#include "photos-filterable.h"
#include "photos-overview-searchbar.h"
#include "photos-search-controller.h"
#include "photos-search-match-manager.h"
@@ -72,11 +73,11 @@ photos_overview_searchbar_active_changed (PhotosOverviewSearchbar *self,
{
PhotosOverviewSearchbarPrivate *priv = self->priv;
GObject *object;
- gchar *id;
+ const gchar *id;
gchar *name;
object = photos_base_manager_get_active_object (mngr);
- g_object_get (object, "id", &id, NULL);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
g_object_get (object, "name", &name, NULL);
if (g_strcmp0 (id, "all") == 0)
@@ -88,7 +89,6 @@ photos_overview_searchbar_active_changed (PhotosOverviewSearchbar *self,
}
g_free (name);
- g_free (id);
}
@@ -97,20 +97,18 @@ photos_overview_searchbar_collection_active_changed (PhotosOverviewSearchbar *se
{
PhotosOverviewSearchbarPrivate *priv = self->priv;
PhotosSearchType *search_type;
+ const gchar *id;
const gchar *str;
- gchar *id;
search_type = PHOTOS_SEARCH_TYPE (photos_base_manager_get_active_object (priv->srch_typ_mngr));
str = photos_search_controller_get_string (priv->srch_cntrlr);
- g_object_get (search_type, "id", &id, NULL);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (search_type));
if (g_strcmp0 (str, "") != 0 || g_strcmp0 (id, "all") != 0)
{
photos_base_manager_set_active_object_by_id (priv->srch_typ_mngr, "all");
gtk_entry_set_text (GTK_ENTRY (priv->search_entry), "");
}
-
- g_free (id);
}
diff --git a/src/photos-remote-display-manager.c b/src/photos-remote-display-manager.c
index fef30b4..32db26e 100644
--- a/src/photos-remote-display-manager.c
+++ b/src/photos-remote-display-manager.c
@@ -1,6 +1,7 @@
/*
* Photos - access, organize and share your photos on GNOME
* Copyright © 2013 Intel Corporation. All rights reserved.
+ * Copyright © 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
@@ -25,6 +26,8 @@
#include <gio/gio.h>
#include "photos-dlna-renderers-manager.h"
+#include "photos-filterable.h"
+
typedef struct {
PhotosRemoteDisplayManager *manager;
@@ -177,7 +180,7 @@ photos_remote_display_manager_share_cb (GObject *source_object,
if (error != NULL)
{
g_warning ("Unable to remotely display item '%s': %s",
- share->item != NULL ? photos_base_item_get_id (share->item) : "(none)",
+ share->item != NULL ? photos_filterable_get_id (PHOTOS_FILTERABLE (share->item)) : "(none)",
error->message);
g_signal_emit (share->manager, signals[SHARE_ERROR], 0, share->renderer, share->item, error);
g_error_free (error);
diff --git a/src/photos-search-match-manager.c b/src/photos-search-match-manager.c
index cb0c475..1f0c9f1 100644
--- a/src/photos-search-match-manager.c
+++ b/src/photos-search-match-manager.c
@@ -72,14 +72,14 @@ photos_search_match_manager_get_filter (PhotosBaseManager *mngr, gint flags)
for (i = 0; terms[i] != NULL; i++)
{
GHashTableIter iter;
- gchar *id;
+ const gchar *id;
g_hash_table_iter_init (&iter, objects);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &search_match))
photos_search_match_set_filter_term (search_match, terms[i]);
search_match = PHOTOS_SEARCH_MATCH (photos_base_manager_get_active_object (PHOTOS_BASE_MANAGER
(self)));
- g_object_get (search_match, "id", &id, NULL);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (search_match));
if (g_strcmp0 (id, PHOTOS_SEARCH_MATCH_STOCK_ALL) == 0)
filter = photos_base_manager_get_all_filter (PHOTOS_BASE_MANAGER (self));
else
@@ -87,7 +87,6 @@ photos_search_match_manager_get_filter (PhotosBaseManager *mngr, gint flags)
filters[i] = filter;
filter = NULL;
- g_free (id);
}
filter = g_strjoinv (" && ", filters);
diff --git a/src/photos-search-match.c b/src/photos-search-match.c
index d414b20..f62f67d 100644
--- a/src/photos-search-match.c
+++ b/src/photos-search-match.c
@@ -64,6 +64,14 @@ photos_search_match_get_filter (PhotosFilterable *iface)
}
+static const gchar *
+photos_search_match_get_id (PhotosFilterable *filterable)
+{
+ PhotosSearchMatch *self = PHOTOS_SEARCH_MATCH (filterable);
+ return self->priv->id;
+}
+
+
static void
photos_search_match_finalize (GObject *object)
{
@@ -180,6 +188,7 @@ static void
photos_filterable_interface_init (PhotosFilterableInterface *iface)
{
iface->get_filter = photos_search_match_get_filter;
+ iface->get_id = photos_search_match_get_id;
}
diff --git a/src/photos-search-type-manager.c b/src/photos-search-type-manager.c
index a4e3492..440ea14 100644
--- a/src/photos-search-type-manager.c
+++ b/src/photos-search-type-manager.c
@@ -41,8 +41,8 @@ static gchar *
photos_search_type_manager_get_filter (PhotosBaseManager *mngr, gint flags)
{
GObject *search_type;
+ const gchar *id;
gchar *filter;
- gchar *id;
if (flags & PHOTOS_QUERY_FLAGS_COLLECTIONS)
search_type = photos_base_manager_get_object_by_id (mngr, PHOTOS_SEARCH_TYPE_STOCK_COLLECTIONS);
@@ -55,13 +55,12 @@ photos_search_type_manager_get_filter (PhotosBaseManager *mngr, gint flags)
else
search_type = photos_base_manager_get_object_by_id (mngr, PHOTOS_SEARCH_TYPE_STOCK_ALL);
- g_object_get (search_type, "id", &id, NULL);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (search_type));
if (g_strcmp0 (id, PHOTOS_SEARCH_TYPE_STOCK_ALL) == 0)
filter = photos_base_manager_get_all_filter (mngr);
else
filter = photos_filterable_get_filter (PHOTOS_FILTERABLE (search_type));
- g_free (id);
return filter;
}
diff --git a/src/photos-search-type.c b/src/photos-search-type.c
index 8525a52..7a5be88 100644
--- a/src/photos-search-type.c
+++ b/src/photos-search-type.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 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
@@ -63,6 +63,14 @@ photos_search_type_get_filter (PhotosFilterable *iface)
}
+static const gchar *
+photos_search_type_get_id (PhotosFilterable *filterable)
+{
+ PhotosSearchType *self = PHOTOS_SEARCH_TYPE (filterable);
+ return self->priv->id;
+}
+
+
static gchar *
photos_search_type_get_where (PhotosFilterable *iface)
{
@@ -194,6 +202,7 @@ static void
photos_filterable_interface_init (PhotosFilterableInterface *iface)
{
iface->get_filter = photos_search_type_get_filter;
+ iface->get_id = photos_search_type_get_id;
iface->get_where = photos_search_type_get_where;
}
diff --git a/src/photos-selection-controller.c b/src/photos-selection-controller.c
index 3be0ad4..ebbd637 100644
--- a/src/photos-selection-controller.c
+++ b/src/photos-selection-controller.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012 Red Hat, Inc.
+ * Copyright © 2012, 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
@@ -27,6 +27,7 @@
#include <glib.h>
+#include "photos-filterable.h"
#include "photos-item-manager.h"
#include "photos-selection-controller.h"
@@ -59,10 +60,9 @@ photos_selection_controller_object_removed (PhotosBaseManager *manager, GObject
PhotosSelectionControllerPrivate *priv = self->priv;
GList *l;
gboolean changed = FALSE;
- gchar *id;
-
- g_object_get (object, "id", &id, NULL);
+ const gchar *id;
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
l = g_list_find_custom (priv->selection, (gconstpointer) id, (GCompareFunc) g_strcmp0);
while (l != NULL)
{
@@ -72,8 +72,6 @@ photos_selection_controller_object_removed (PhotosBaseManager *manager, GObject
l = g_list_find_custom (priv->selection, (gconstpointer) id, (GCompareFunc) g_strcmp0);
}
- g_free (id);
-
if (changed)
g_signal_emit (self, signals[SELECTION_CHANGED], 0);
}
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index 5b357e0..6ca8d7b 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -48,21 +48,20 @@ static gchar *
photos_source_manager_get_filter (PhotosBaseManager *mngr, gint flags)
{
GObject *source;
+ const gchar *id;
gchar *filter;
- gchar *id;
if (flags & PHOTOS_QUERY_FLAGS_SEARCH)
source = photos_base_manager_get_active_object (mngr);
else
source = photos_base_manager_get_object_by_id (mngr, PHOTOS_SOURCE_STOCK_ALL);
- g_object_get (source, "id", &id, NULL);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (source));
if (g_strcmp0 (id, PHOTOS_SOURCE_STOCK_ALL) == 0)
filter = photos_base_manager_get_all_filter (mngr);
else
filter = photos_filterable_get_filter (PHOTOS_FILTERABLE (source));
- g_free (id);
return filter;
}
@@ -83,7 +82,7 @@ photos_source_manager_refresh_accounts (PhotosSourceManager *self)
GoaAccount *account;
GoaObject *object = GOA_OBJECT (l->data);
PhotosSource *source;
- gchar *id;
+ const gchar *id;
account = goa_object_peek_account (object);
if (account == NULL)
@@ -96,8 +95,8 @@ photos_source_manager_refresh_accounts (PhotosSourceManager *self)
continue;
source = photos_source_new_from_goa_object (GOA_OBJECT (l->data));
- g_object_get (source, "id", &id, NULL);
- g_hash_table_insert (new_sources, id, g_object_ref (source));
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (source));
+ g_hash_table_insert (new_sources, g_strdup (id), g_object_ref (source));
g_object_unref (source);
}
diff --git a/src/photos-source.c b/src/photos-source.c
index 4d0d251..bbaf3d2 100644
--- a/src/photos-source.c
+++ b/src/photos-source.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013 Red Hat, Inc.
+ * Copyright © 2012, 2013, 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
@@ -89,6 +89,14 @@ photos_source_get_filter (PhotosFilterable *iface)
}
+static const gchar *
+photos_source_get_id (PhotosFilterable *filterable)
+{
+ PhotosSource *self = PHOTOS_SOURCE (filterable);
+ return self->priv->id;
+}
+
+
static void
photos_source_dispose (GObject *object)
{
@@ -249,6 +257,7 @@ static void
photos_filterable_interface_init (PhotosFilterableInterface *iface)
{
iface->get_filter = photos_source_get_filter;
+ iface->get_id = photos_source_get_id;
}
diff --git a/src/photos-tracker-controller.c b/src/photos-tracker-controller.c
index c1c3c9d..f13a713 100644
--- a/src/photos-tracker-controller.c
+++ b/src/photos-tracker-controller.c
@@ -29,6 +29,7 @@
#include <glib/gi18n.h>
#include "photos-enums.h"
+#include "photos-filterable.h"
#include "photos-item-manager.h"
#include "photos-marshalers.h"
#include "photos-mode-controller.h"
@@ -258,14 +259,11 @@ photos_tracker_controller_refresh_for_source (PhotosTrackerController *self)
if (priv->current_query->source != NULL)
{
- gchar *id;
-
- g_object_get (priv->current_query->source, "id", &id, NULL);
+ const gchar *id;
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (priv->current_query->source));
if (g_strcmp0 (id, PHOTOS_SOURCE_STOCK_ALL) == 0)
photos_tracker_controller_refresh_internal (self, PHOTOS_TRACKER_REFRESH_FLAGS_NONE);
-
- g_free (id);
}
priv->refresh_pending = FALSE;
diff --git a/src/photos-view-model.c b/src/photos-view-model.c
index 5a64684..d9ea4cc 100644
--- a/src/photos-view-model.c
+++ b/src/photos-view-model.c
@@ -27,6 +27,7 @@
#include "photos-collection-manager.h"
#include "photos-enums.h"
+#include "photos-filterable.h"
#include "photos-item-manager.h"
#include "photos-mode-controller.h"
#include "photos-offset-collections-controller.h"
@@ -75,7 +76,7 @@ photos_view_model_info_set (PhotosViewModel *self, PhotosBaseItem *item, GtkTree
{
gtk_list_store_set (GTK_LIST_STORE (self),
iter,
- PHOTOS_VIEW_MODEL_URN, photos_base_item_get_id (item),
+ PHOTOS_VIEW_MODEL_URN, photos_filterable_get_id (PHOTOS_FILTERABLE (item)),
PHOTOS_VIEW_MODEL_URI, photos_base_item_get_uri (item),
PHOTOS_VIEW_MODEL_NAME, photos_base_item_get_name (item),
PHOTOS_VIEW_MODEL_AUTHOR, photos_base_item_get_author (item),
@@ -177,7 +178,7 @@ photos_view_model_item_removed_foreach (GtkTreeModel *model,
gchar *value;
gint64 mtime;
- id = photos_base_item_get_id (item);
+ id = photos_filterable_get_id (PHOTOS_FILTERABLE (item));
gtk_tree_model_get (model, iter, PHOTOS_VIEW_MODEL_URN, &value, PHOTOS_VIEW_MODEL_MTIME, &mtime, -1);
if (g_strcmp0 (id, value) == 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]