[gnome-photos] camera-cache: Make it a final class



commit 5b0e68041809bb9176f1140d34324c87cad18a10
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Mar 4 15:18:34 2016 +0100

    camera-cache: Make it a final class

 src/photos-camera-cache.c |   39 ++++++++++++++++++---------------------
 src/photos-camera-cache.h |   28 ++--------------------------
 2 files changed, 20 insertions(+), 47 deletions(-)
---
diff --git a/src/photos-camera-cache.c b/src/photos-camera-cache.c
index 1d16bf1..14d1dc8 100644
--- a/src/photos-camera-cache.c
+++ b/src/photos-camera-cache.c
@@ -29,15 +29,21 @@
 #include "photos-tracker-queue.h"
 
 
-struct _PhotosCameraCachePrivate
+struct _PhotosCameraCache
 {
+  GObject parent_instance;
   GError *queue_error;
   GHashTable *cache;
   PhotosTrackerQueue *queue;
 };
 
+struct _PhotosCameraCacheClass
+{
+  GObjectClass parent_class;
+};
+
 
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosCameraCache, photos_camera_cache, G_TYPE_OBJECT);
+G_DEFINE_TYPE (PhotosCameraCache, photos_camera_cache, G_TYPE_OBJECT);
 
 
 static void
@@ -45,7 +51,6 @@ photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpoi
 {
   GTask *task = G_TASK (user_data);
   PhotosCameraCache *self;
-  PhotosCameraCachePrivate *priv;
   TrackerSparqlCursor *cursor = TRACKER_SPARQL_CURSOR (source_object);
   GError *error;
   const gchar *manufacturer;
@@ -54,7 +59,6 @@ photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpoi
   gpointer key;
 
   self = PHOTOS_CAMERA_CACHE (g_task_get_source_object (task));
-  priv = self->priv;
 
   error = NULL;
   tracker_sparql_cursor_next_finish (cursor, res, &error);
@@ -77,7 +81,7 @@ photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpoi
     camera = g_strconcat (manufacturer, " ", model, NULL);
 
   key = g_task_get_task_data (task);
-  g_hash_table_insert (priv->cache, key, camera);
+  g_hash_table_insert (self->cache, key, camera);
 
   g_task_return_pointer (task, g_strdup (camera), g_free);
 
@@ -131,7 +135,7 @@ photos_camera_cache_dispose (GObject *object)
 {
   PhotosCameraCache *self = PHOTOS_CAMERA_CACHE (object);
 
-  g_clear_object (&self->priv->queue);
+  g_clear_object (&self->queue);
 
   G_OBJECT_CLASS (photos_camera_cache_parent_class)->dispose (object);
 }
@@ -141,10 +145,9 @@ static void
 photos_camera_cache_finalize (GObject *object)
 {
   PhotosCameraCache *self = PHOTOS_CAMERA_CACHE (object);
-  PhotosCameraCachePrivate *priv = self->priv;
 
-  g_clear_error (&priv->queue_error);
-  g_hash_table_unref (priv->cache);
+  g_clear_error (&self->queue_error);
+  g_hash_table_unref (self->cache);
 
   G_OBJECT_CLASS (photos_camera_cache_parent_class)->finalize (object);
 }
@@ -153,13 +156,8 @@ photos_camera_cache_finalize (GObject *object)
 static void
 photos_camera_cache_init (PhotosCameraCache *self)
 {
-  PhotosCameraCachePrivate *priv;
-
-  self->priv = photos_camera_cache_get_instance_private (self);
-  priv = self->priv;
-
-  priv->cache = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
-  priv->queue = photos_tracker_queue_dup_singleton (NULL, &priv->queue_error);
+  self->cache = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
+  self->queue = photos_tracker_queue_dup_singleton (NULL, &self->queue_error);
 }
 
 
@@ -188,7 +186,6 @@ photos_camera_cache_get_camera_async (PhotosCameraCache *self,
                                       GAsyncReadyCallback callback,
                                       gpointer user_data)
 {
-  PhotosCameraCachePrivate *priv = self->priv;
   GApplication *app;
   GTask *task;
   PhotosQuery *query;
@@ -199,16 +196,16 @@ photos_camera_cache_get_camera_async (PhotosCameraCache *self,
   g_task_set_source_tag (task, photos_camera_cache_get_camera_async);
   g_task_set_task_data (task, GUINT_TO_POINTER (id), NULL);
 
-  camera = g_hash_table_lookup (priv->cache, GUINT_TO_POINTER (id));
+  camera = g_hash_table_lookup (self->cache, GUINT_TO_POINTER (id));
   if (camera != NULL)
     {
       g_task_return_pointer (task, g_strdup (camera), g_free);
       goto out;
     }
 
-  if (G_UNLIKELY (priv->queue == NULL))
+  if (G_UNLIKELY (self->queue == NULL))
     {
-      g_task_return_error (task, g_error_copy (priv->queue_error));
+      g_task_return_error (task, g_error_copy (self->queue_error));
       goto out;
     }
 
@@ -216,7 +213,7 @@ photos_camera_cache_get_camera_async (PhotosCameraCache *self,
   state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
 
   query = photos_query_builder_equipment_query (state, id);
-  photos_tracker_queue_select (priv->queue,
+  photos_tracker_queue_select (self->queue,
                                query->sparql,
                                cancellable,
                                photos_camera_cache_equipment_query_executed,
diff --git a/src/photos-camera-cache.h b/src/photos-camera-cache.h
index d5d9fd8..93f1115 100644
--- a/src/photos-camera-cache.h
+++ b/src/photos-camera-cache.h
@@ -32,36 +32,12 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
    PHOTOS_TYPE_CAMERA_CACHE, PhotosCameraCache))
 
-#define PHOTOS_CAMERA_CACHE_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), \
-   PHOTOS_TYPE_CAMERA_CACHE, PhotosCameraCacheClass))
-
 #define PHOTOS_IS_CAMERA_CACHE(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
    PHOTOS_TYPE_CAMERA_CACHE))
 
-#define PHOTOS_IS_CAMERA_CACHE_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
-   PHOTOS_TYPE_CAMERA_CACHE))
-
-#define PHOTOS_CAMERA_CACHE_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-   PHOTOS_TYPE_CAMERA_CACHE, PhotosCameraCacheClass))
-
-typedef struct _PhotosCameraCache        PhotosCameraCache;
-typedef struct _PhotosCameraCacheClass   PhotosCameraCacheClass;
-typedef struct _PhotosCameraCachePrivate PhotosCameraCachePrivate;
-
-struct _PhotosCameraCache
-{
-  GObject parent_instance;
-  PhotosCameraCachePrivate *priv;
-};
-
-struct _PhotosCameraCacheClass
-{
-  GObjectClass parent_class;
-};
+typedef struct _PhotosCameraCache      PhotosCameraCache;
+typedef struct _PhotosCameraCacheClass PhotosCameraCacheClass;
 
 GType                  photos_camera_cache_get_type               (void) G_GNUC_CONST;
 


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