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



commit 57a8546d85228189d23925a0bc523df9449af9c9
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 4 14:39:27 2016 +0100

    selection-controller: Make it a final class

 src/photos-selection-controller.c |   65 ++++++++++++++++++-------------------
 src/photos-selection-controller.h |   31 +----------------
 2 files changed, 34 insertions(+), 62 deletions(-)
---
diff --git a/src/photos-selection-controller.c b/src/photos-selection-controller.c
index 59acef9..2953163 100644
--- a/src/photos-selection-controller.c
+++ b/src/photos-selection-controller.c
@@ -34,14 +34,23 @@
 #include "photos-selection-controller.h"
 
 
-struct _PhotosSelectionControllerPrivate
+struct _PhotosSelectionController
 {
+  GObject parent_instance;
   GList *selection;
   PhotosBaseManager *item_mngr;
   gboolean is_frozen;
   gboolean selection_mode;
 };
 
+struct _PhotosSelectionControllerClass
+{
+  GObjectClass parent_class;
+
+  void (*selection_changed)      (PhotosSelectionController *self);
+  void (*selection_mode_changed) (PhotosSelectionController *self);
+};
+
 enum
 {
   SELECTION_CHANGED,
@@ -52,26 +61,25 @@ enum
 static guint signals[LAST_SIGNAL] = { 0 };
 
 
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosSelectionController, photos_selection_controller, G_TYPE_OBJECT);
+G_DEFINE_TYPE (PhotosSelectionController, photos_selection_controller, G_TYPE_OBJECT);
 
 
 static void
 photos_selection_controller_object_removed (PhotosBaseManager *manager, GObject *object, gpointer user_data)
 {
   PhotosSelectionController *self = PHOTOS_SELECTION_CONTROLLER (user_data);
-  PhotosSelectionControllerPrivate *priv = self->priv;
   GList *l;
   gboolean changed = FALSE;
   const gchar *id;
 
   id = photos_filterable_get_id (PHOTOS_FILTERABLE (object));
-  l = g_list_find_custom (priv->selection, (gconstpointer) id, (GCompareFunc) g_strcmp0);
+  l = g_list_find_custom (self->selection, (gconstpointer) id, (GCompareFunc) g_strcmp0);
   while (l != NULL)
     {
       changed = TRUE;
       g_free (l->data);
-      priv->selection = g_list_delete_link (priv->selection, l);
-      l = g_list_find_custom (priv->selection, (gconstpointer) id, (GCompareFunc) g_strcmp0);
+      self->selection = g_list_delete_link (self->selection, l);
+      l = g_list_find_custom (self->selection, (gconstpointer) id, (GCompareFunc) g_strcmp0);
     }
 
   if (changed)
@@ -103,13 +111,12 @@ static void
 photos_selection_controller_finalize (GObject *object)
 {
   PhotosSelectionController *self = PHOTOS_SELECTION_CONTROLLER (object);
-  PhotosSelectionControllerPrivate *priv = self->priv;
 
-  if (priv->selection != NULL)
-    g_list_free_full (priv->selection, g_free);
+  if (self->selection != NULL)
+    g_list_free_full (self->selection, g_free);
 
-  if (priv->item_mngr != NULL)
-    g_object_remove_weak_pointer (G_OBJECT (priv->item_mngr), (gpointer *) &priv->item_mngr);
+  if (self->item_mngr != NULL)
+    g_object_remove_weak_pointer (G_OBJECT (self->item_mngr), (gpointer *) &self->item_mngr);
 
   G_OBJECT_CLASS (photos_selection_controller_parent_class)->finalize (object);
 }
@@ -118,19 +125,15 @@ photos_selection_controller_finalize (GObject *object)
 static void
 photos_selection_controller_init (PhotosSelectionController *self)
 {
-  PhotosSelectionControllerPrivate *priv;
   GApplication *app;
   PhotosSearchContextState *state;
 
-  self->priv = photos_selection_controller_get_instance_private (self);
-  priv = self->priv;
-
   app = g_application_get_default ();
   state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
 
-  priv->item_mngr = state->item_mngr;
-  g_object_add_weak_pointer (G_OBJECT (priv->item_mngr), (gpointer *) &priv->item_mngr);
-  g_signal_connect_object (priv->item_mngr,
+  self->item_mngr = state->item_mngr;
+  g_object_add_weak_pointer (G_OBJECT (self->item_mngr), (gpointer *) &self->item_mngr);
+  g_signal_connect_object (self->item_mngr,
                            "object-removed",
                            G_CALLBACK (photos_selection_controller_object_removed),
                            self,
@@ -181,39 +184,37 @@ photos_selection_controller_dup_singleton (void)
 void
 photos_selection_controller_freeze_selection (PhotosSelectionController *self, gboolean freeze)
 {
-  self->priv->is_frozen = freeze;
+  self->is_frozen = freeze;
 }
 
 
 GList *
 photos_selection_controller_get_selection (PhotosSelectionController *self)
 {
-  return self->priv->selection;
+  return self->selection;
 }
 
 
 gboolean
 photos_selection_controller_get_selection_mode (PhotosSelectionController *self)
 {
-  return self->priv->selection_mode;
+  return self->selection_mode;
 }
 
 
 void
 photos_selection_controller_set_selection (PhotosSelectionController *self, GList *selection)
 {
-  PhotosSelectionControllerPrivate *priv = self->priv;
-
-  if (priv->is_frozen)
+  if (self->is_frozen)
     return;
 
-  if (priv->selection == NULL && selection == NULL)
+  if (self->selection == NULL && selection == NULL)
     return;
 
-  g_list_free_full (priv->selection, g_free);
-  priv->selection = NULL;
+  g_list_free_full (self->selection, g_free);
+  self->selection = NULL;
 
-  priv->selection = g_list_copy_deep (selection, (GCopyFunc) g_strdup, NULL);
+  self->selection = g_list_copy_deep (selection, (GCopyFunc) g_strdup, NULL);
   g_signal_emit (self, signals[SELECTION_CHANGED], 0);
 }
 
@@ -221,11 +222,9 @@ photos_selection_controller_set_selection (PhotosSelectionController *self, GLis
 void
 photos_selection_controller_set_selection_mode (PhotosSelectionController *self, gboolean mode)
 {
-  PhotosSelectionControllerPrivate *priv = self->priv;
-
-  if (priv->selection_mode == mode)
+  if (self->selection_mode == mode)
     return;
 
-  priv->selection_mode = mode;
-  g_signal_emit (self, signals[SELECTION_MODE_CHANGED], 0, priv->selection_mode);
+  self->selection_mode = mode;
+  g_signal_emit (self, signals[SELECTION_MODE_CHANGED], 0, self->selection_mode);
 }
diff --git a/src/photos-selection-controller.h b/src/photos-selection-controller.h
index a920f53..c3fc90e 100644
--- a/src/photos-selection-controller.h
+++ b/src/photos-selection-controller.h
@@ -35,39 +35,12 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
    PHOTOS_TYPE_SELECTION_CONTROLLER, PhotosSelectionController))
 
-#define PHOTOS_SELECTION_CONTROLLER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), \
-   PHOTOS_TYPE_SELECTION_CONTROLLER, PhotosSelectionControllerClass))
-
 #define PHOTOS_IS_SELECTION_CONTROLLER(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
    PHOTOS_TYPE_SELECTION_CONTROLLER))
 
-#define PHOTOS_IS_SELECTION_CONTROLLER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
-   PHOTOS_TYPE_SELECTION_CONTROLLER))
-
-#define PHOTOS_SELECTION_CONTROLLER_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-   PHOTOS_TYPE_SELECTION_CONTROLLER, PhotosSelectionControllerClass))
-
-typedef struct _PhotosSelectionController        PhotosSelectionController;
-typedef struct _PhotosSelectionControllerClass   PhotosSelectionControllerClass;
-typedef struct _PhotosSelectionControllerPrivate PhotosSelectionControllerPrivate;
-
-struct _PhotosSelectionController
-{
-  GObject parent_instance;
-  PhotosSelectionControllerPrivate *priv;
-};
-
-struct _PhotosSelectionControllerClass
-{
-  GObjectClass parent_class;
-
-  void (*selection_changed)      (PhotosSelectionController *self);
-  void (*selection_mode_changed) (PhotosSelectionController *self);
-};
+typedef struct _PhotosSelectionController      PhotosSelectionController;
+typedef struct _PhotosSelectionControllerClass PhotosSelectionControllerClass;
 
 GType                       photos_selection_controller_get_type           (void) G_GNUC_CONST;
 


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