[gnome-photos/wip/search: 6/27] base-manager: Support titles



commit e4be441dffdf75e97c244c0f7002638f7f2ee84b
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jan 23 11:38:50 2014 +0100

    base-manager: Support titles
    
    ... add them to PhotosSearchTypeManager and PhotosSourceManager.

 src/photos-base-manager.c        |   55 +++++++++++++++++++++++++++++++++++++-
 src/photos-base-manager.h        |    4 ++-
 src/photos-search-type-manager.c |    5 +++-
 src/photos-source-manager.c      |    2 +-
 4 files changed, 62 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index 8598745..65fba9a 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.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
@@ -35,6 +35,13 @@ struct _PhotosBaseManagerPrivate
 {
   GHashTable *objects;
   GObject *active_object;
+  gchar *title;
+};
+
+enum
+{
+  PROP_0,
+  PROP_TITLE
 };
 
 enum
@@ -143,6 +150,35 @@ photos_base_manager_dispose (GObject *object)
 
 
 static void
+photos_base_manager_finalize (GObject *object)
+{
+  PhotosBaseManager *self = PHOTOS_BASE_MANAGER (object);
+
+  g_free (self->priv->title);
+
+  G_OBJECT_CLASS (photos_base_manager_parent_class)->finalize (object);
+}
+
+
+static void
+photos_base_manager_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+  PhotosBaseManager *self = PHOTOS_BASE_MANAGER (object);
+
+  switch (prop_id)
+    {
+    case PROP_TITLE:
+      self->priv->title = g_value_dup_string (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
 photos_base_manager_init (PhotosBaseManager *self)
 {
   PhotosBaseManagerPrivate *priv;
@@ -160,8 +196,18 @@ photos_base_manager_class_init (PhotosBaseManagerClass *class)
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
   object_class->dispose = photos_base_manager_dispose;
+  object_class->finalize = photos_base_manager_finalize;
+  object_class->set_property = photos_base_manager_set_property;
   class->set_active_object = photos_base_manager_default_set_active_object;
 
+  g_object_class_install_property (object_class,
+                                   PROP_TITLE,
+                                   g_param_spec_string ("title",
+                                                        "Title",
+                                                        "The name of this manager",
+                                                        NULL,
+                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
   signals[ACTIVE_CHANGED] = g_signal_new ("active-changed",
                                           G_TYPE_FROM_CLASS (class),
                                           G_SIGNAL_RUN_LAST,
@@ -299,6 +345,13 @@ photos_base_manager_get_objects_count (PhotosBaseManager *self)
 }
 
 
+const gchar *
+photos_base_manager_get_title (PhotosBaseManager *self)
+{
+  return self->priv->title;
+}
+
+
 void
 photos_base_manager_process_new_objects (PhotosBaseManager *self, GHashTable *new_objects)
 {
diff --git a/src/photos-base-manager.h b/src/photos-base-manager.h
index 0f239ff..1987cec 100644
--- a/src/photos-base-manager.h
+++ b/src/photos-base-manager.h
@@ -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
@@ -91,6 +91,8 @@ GHashTable         *photos_base_manager_get_objects              (PhotosBaseMana
 
 guint               photos_base_manager_get_objects_count        (PhotosBaseManager *self);
 
+const gchar        *photos_base_manager_get_title                (PhotosBaseManager *self);
+
 void                photos_base_manager_process_new_objects      (PhotosBaseManager *self, GHashTable 
*new_objects);
 
 void                photos_base_manager_remove_object            (PhotosBaseManager *self, GObject *object);
diff --git a/src/photos-search-type-manager.c b/src/photos-search-type-manager.c
index ce44ea0..9e8127f 100644
--- a/src/photos-search-type-manager.c
+++ b/src/photos-search-type-manager.c
@@ -118,7 +118,10 @@ photos_search_type_manager_class_init (PhotosSearchTypeManagerClass *class)
 PhotosBaseManager *
 photos_search_type_manager_dup_singleton (void)
 {
-  return g_object_new (PHOTOS_TYPE_SEARCH_TYPE_MANAGER, NULL);
+  /* Translators: "Type" refers to a search filter. eg., All, Albums,
+   * Favorites and Photos.
+   */
+  return g_object_new (PHOTOS_TYPE_SEARCH_TYPE_MANAGER, "title", C_("Search Filter", "Type"), NULL);
 }
 
 
diff --git a/src/photos-source-manager.c b/src/photos-source-manager.c
index a9a39f0..a897a1b 100644
--- a/src/photos-source-manager.c
+++ b/src/photos-source-manager.c
@@ -166,7 +166,7 @@ photos_source_manager_class_init (PhotosSourceManagerClass *class)
 PhotosBaseManager *
 photos_source_manager_dup_singleton (void)
 {
-  return g_object_new (PHOTOS_TYPE_SOURCE_MANAGER, NULL);
+  return g_object_new (PHOTOS_TYPE_SOURCE_MANAGER, "title", _("Sources"), NULL);
 }
 
 


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