[gnome-photos] search-controller: Make it a final class



commit 3fd91030911d571887ba3eba835746f98a9edfb3
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 4 14:51:19 2016 +0100

    search-controller: Make it a final class

 src/photos-search-controller.c |   36 +++++++++++++++++++-----------------
 src/photos-search-controller.h |   31 ++-----------------------------
 2 files changed, 21 insertions(+), 46 deletions(-)
---
diff --git a/src/photos-search-controller.c b/src/photos-search-controller.c
index 6c07d87..22a6b59 100644
--- a/src/photos-search-controller.c
+++ b/src/photos-search-controller.c
@@ -31,11 +31,20 @@
 #include "photos-search-controller.h"
 
 
-struct _PhotosSearchControllerPrivate
+struct _PhotosSearchController
 {
+  GObject parent_instance;
   gchar *str;
 };
 
+struct _PhotosSearchControllerClass
+{
+  GObjectClass parent_class;
+
+  /* signals */
+  void (*search_string_changed) (PhotosSearchController *self, const gchar *str);
+};
+
 enum
 {
   SEARCH_STRING_CHANGED,
@@ -45,7 +54,7 @@ enum
 static guint signals[LAST_SIGNAL] = { 0 };
 
 
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosSearchController, photos_search_controller, G_TYPE_OBJECT);
+G_DEFINE_TYPE (PhotosSearchController, photos_search_controller, G_TYPE_OBJECT);
 
 
 static void
@@ -53,7 +62,7 @@ photos_search_controller_finalize (GObject *object)
 {
   PhotosSearchController *self = PHOTOS_SEARCH_CONTROLLER (object);
 
-  g_free (self->priv->str);
+  g_free (self->str);
 
   G_OBJECT_CLASS (photos_search_controller_parent_class)->finalize (object);
 }
@@ -62,12 +71,7 @@ photos_search_controller_finalize (GObject *object)
 static void
 photos_search_controller_init (PhotosSearchController *self)
 {
-  PhotosSearchControllerPrivate *priv;
-
-  self->priv = photos_search_controller_get_instance_private (self);
-  priv = self->priv;
-
-  priv->str = g_strdup ("");
+  self->str = g_strdup ("");
 }
 
 
@@ -102,7 +106,7 @@ photos_search_controller_new (void)
 const gchar *
 photos_search_controller_get_string (PhotosSearchController *self)
 {
-  return self->priv->str;
+  return self->str;
 }
 
 
@@ -113,7 +117,7 @@ photos_search_controller_get_terms (PhotosSearchController *self)
   gchar *str;
   gchar **terms;
 
-  escaped_str = tracker_sparql_escape_string (self->priv->str);
+  escaped_str = tracker_sparql_escape_string (self->str);
   str = g_utf8_casefold (escaped_str, -1);
   /* TODO: find out what str.replace(/ + /g, ' ') does */
   terms = g_strsplit (str, " ", -1);
@@ -126,12 +130,10 @@ photos_search_controller_get_terms (PhotosSearchController *self)
 void
 photos_search_controller_set_string (PhotosSearchController *self, const gchar *str)
 {
-  PhotosSearchControllerPrivate *priv = self->priv;
-
-  if (g_strcmp0 (priv->str, str) == 0)
+  if (g_strcmp0 (self->str, str) == 0)
     return;
 
-  g_free (priv->str);
-  priv->str = g_strdup (str);
-  g_signal_emit (self, signals[SEARCH_STRING_CHANGED], 0, priv->str);
+  g_free (self->str);
+  self->str = g_strdup (str);
+  g_signal_emit (self, signals[SEARCH_STRING_CHANGED], 0, self->str);
 }
diff --git a/src/photos-search-controller.h b/src/photos-search-controller.h
index a562f12..b0b060c 100644
--- a/src/photos-search-controller.h
+++ b/src/photos-search-controller.h
@@ -35,39 +35,12 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
    PHOTOS_TYPE_SEARCH_CONTROLLER, PhotosSearchController))
 
-#define PHOTOS_SEARCH_CONTROLLER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), \
-   PHOTOS_TYPE_SEARCH_CONTROLLER, PhotosSearchControllerClass))
-
 #define PHOTOS_IS_SEARCH_CONTROLLER(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
    PHOTOS_TYPE_SEARCH_CONTROLLER))
 
-#define PHOTOS_IS_SEARCH_CONTROLLER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
-   PHOTOS_TYPE_SEARCH_CONTROLLER))
-
-#define PHOTOS_SEARCH_CONTROLLER_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-   PHOTOS_TYPE_SEARCH_CONTROLLER, PhotosSearchControllerClass))
-
-typedef struct _PhotosSearchController        PhotosSearchController;
-typedef struct _PhotosSearchControllerClass   PhotosSearchControllerClass;
-typedef struct _PhotosSearchControllerPrivate PhotosSearchControllerPrivate;
-
-struct _PhotosSearchController
-{
-  GObject parent_instance;
-  PhotosSearchControllerPrivate *priv;
-};
-
-struct _PhotosSearchControllerClass
-{
-  GObjectClass parent_class;
-
-  /* signals */
-  void (*search_string_changed) (PhotosSearchController *self, const gchar *str);
-};
+typedef struct _PhotosSearchController      PhotosSearchController;
+typedef struct _PhotosSearchControllerClass PhotosSearchControllerClass;
 
 GType                      photos_search_controller_get_type       (void) G_GNUC_CONST;
 


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