[gnome-photos] fetch-collections-job: Make it a final class



commit 634c5739b13e8929a145bda7114bbe63011ff587
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Mar 21 21:33:56 2015 +0100

    fetch-collections-job: Make it a final class

 src/photos-fetch-collections-job.c |   50 ++++++++++++++++-------------------
 src/photos-fetch-collections-job.h |   28 +------------------
 2 files changed, 25 insertions(+), 53 deletions(-)
---
diff --git a/src/photos-fetch-collections-job.c b/src/photos-fetch-collections-job.c
index cd4ed32..1f882a4 100644
--- a/src/photos-fetch-collections-job.c
+++ b/src/photos-fetch-collections-job.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2013, 2014 Red Hat, Inc.
+ * Copyright © 2013, 2014, 2015 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
@@ -36,8 +36,9 @@
 #include "photos-tracker-queue.h"
 
 
-struct _PhotosFetchCollectionsJobPrivate
+struct _PhotosFetchCollectionsJob
 {
+  GObject parent_instance;
   GList *collections;
   PhotosFetchCollectionsJobCallback callback;
   PhotosTrackerQueue *queue;
@@ -45,6 +46,11 @@ struct _PhotosFetchCollectionsJobPrivate
   gpointer user_data;
 };
 
+struct _PhotosFetchCollectionsJobClass
+{
+  GObjectClass parent_class;
+};
+
 enum
 {
   PROP_0,
@@ -52,18 +58,16 @@ enum
 };
 
 
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosFetchCollectionsJob, photos_fetch_collections_job, G_TYPE_OBJECT);
+G_DEFINE_TYPE (PhotosFetchCollectionsJob, photos_fetch_collections_job, G_TYPE_OBJECT);
 
 
 static void
 photos_fetch_collections_job_emit_callback (PhotosFetchCollectionsJob *self)
 {
-  PhotosFetchCollectionsJobPrivate *priv = self->priv;
-
-  if (priv->callback == NULL)
+  if (self->callback == NULL)
     return;
 
-  (*priv->callback) (priv->collections, priv->user_data);
+  (*self->callback) (self->collections, self->user_data);
 }
 
 
@@ -71,7 +75,6 @@ static void
 photos_fetch_collections_job_cursor_next (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   PhotosFetchCollectionsJob *self = PHOTOS_FETCH_COLLECTIONS_JOB (user_data);
-  PhotosFetchCollectionsJobPrivate *priv = self->priv;
   TrackerSparqlCursor *cursor = TRACKER_SPARQL_CURSOR (source_object);
   GError *error;
   gboolean valid;
@@ -89,7 +92,7 @@ photos_fetch_collections_job_cursor_next (GObject *source_object, GAsyncResult *
     goto end;
 
   urn = g_strdup (tracker_sparql_cursor_get_string (cursor, 0, NULL));
-  priv->collections = g_list_prepend (priv->collections, urn);
+  self->collections = g_list_prepend (self->collections, urn);
 
   tracker_sparql_cursor_next_async (cursor,
                                     NULL,
@@ -98,7 +101,7 @@ photos_fetch_collections_job_cursor_next (GObject *source_object, GAsyncResult *
   return;
 
  end:
-  priv->collections = g_list_reverse (priv->collections);
+  self->collections = g_list_reverse (self->collections);
   photos_fetch_collections_job_emit_callback (self);
   tracker_sparql_cursor_close (cursor);
   g_object_unref (self);
@@ -136,7 +139,7 @@ photos_fetch_collections_job_dispose (GObject *object)
 {
   PhotosFetchCollectionsJob *self = PHOTOS_FETCH_COLLECTIONS_JOB (object);
 
-  g_clear_object (&self->priv->queue);
+  g_clear_object (&self->queue);
 
   G_OBJECT_CLASS (photos_fetch_collections_job_parent_class)->dispose (object);
 }
@@ -146,10 +149,9 @@ static void
 photos_fetch_collections_job_finalize (GObject *object)
 {
   PhotosFetchCollectionsJob *self = PHOTOS_FETCH_COLLECTIONS_JOB (object);
-  PhotosFetchCollectionsJobPrivate *priv = self->priv;
 
-  g_list_free_full (priv->collections, g_free);
-  g_free (priv->urn);
+  g_list_free_full (self->collections, g_free);
+  g_free (self->urn);
 
   G_OBJECT_CLASS (photos_fetch_collections_job_parent_class)->finalize (object);
 }
@@ -163,7 +165,7 @@ photos_fetch_collections_job_set_property (GObject *object, guint prop_id, const
   switch (prop_id)
     {
     case PROP_URN:
-      self->priv->urn = g_value_dup_string (value);
+      self->urn = g_value_dup_string (value);
       break;
 
     default:
@@ -176,12 +178,7 @@ photos_fetch_collections_job_set_property (GObject *object, guint prop_id, const
 static void
 photos_fetch_collections_job_init (PhotosFetchCollectionsJob *self)
 {
-  PhotosFetchCollectionsJobPrivate *priv = self->priv;
-
-  self->priv = photos_fetch_collections_job_get_instance_private (self);
-  priv = self->priv;
-
-  priv->queue = photos_tracker_queue_dup_singleton (NULL, NULL);
+  self->queue = photos_tracker_queue_dup_singleton (NULL, NULL);
 }
 
 
@@ -216,26 +213,25 @@ photos_fetch_collections_job_run (PhotosFetchCollectionsJob *self,
                                   PhotosFetchCollectionsJobCallback callback,
                                   gpointer user_data)
 {
-  PhotosFetchCollectionsJobPrivate *priv = self->priv;
   GApplication *app;
   PhotosQuery *query;
   PhotosSearchContextState *state;
 
-  if (G_UNLIKELY (priv->queue == NULL))
+  if (G_UNLIKELY (self->queue == NULL))
     {
       if (callback != NULL)
         (*callback) (NULL, user_data);
       return;
     }
 
-  priv->callback = callback;
-  priv->user_data = user_data;
+  self->callback = callback;
+  self->user_data = user_data;
 
   app = g_application_get_default ();
   state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app));
 
-  query = photos_query_builder_fetch_collections_query (state, priv->urn);
-  photos_tracker_queue_select (priv->queue,
+  query = photos_query_builder_fetch_collections_query (state, self->urn);
+  photos_tracker_queue_select (self->queue,
                                query->sparql,
                                NULL,
                                photos_fetch_collections_job_query_executed,
diff --git a/src/photos-fetch-collections-job.h b/src/photos-fetch-collections-job.h
index 47d9494..de88b8e 100644
--- a/src/photos-fetch-collections-job.h
+++ b/src/photos-fetch-collections-job.h
@@ -35,38 +35,14 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
    PHOTOS_TYPE_FETCH_COLLECTIONS_JOB, PhotosFetchCollectionsJob))
 
-#define PHOTOS_FETCH_COLLECTIONS_JOB_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), \
-   PHOTOS_TYPE_FETCH_COLLECTIONS_JOB, PhotosFetchCollectionsJobClass))
-
 #define PHOTOS_IS_FETCH_COLLECTIONS_JOB(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
    PHOTOS_TYPE_FETCH_COLLECTIONS_JOB))
 
-#define PHOTOS_IS_FETCH_COLLECTIONS_JOB_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
-   PHOTOS_TYPE_FETCH_COLLECTIONS_JOB))
-
-#define PHOTOS_FETCH_COLLECTIONS_JOB_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-   PHOTOS_TYPE_FETCH_COLLECTIONS_JOB, PhotosFetchCollectionsJobClass))
-
 typedef void (*PhotosFetchCollectionsJobCallback) (GList *, gpointer);
 
-typedef struct _PhotosFetchCollectionsJob        PhotosFetchCollectionsJob;
-typedef struct _PhotosFetchCollectionsJobClass   PhotosFetchCollectionsJobClass;
-typedef struct _PhotosFetchCollectionsJobPrivate PhotosFetchCollectionsJobPrivate;
-
-struct _PhotosFetchCollectionsJob
-{
-  GObject parent_instance;
-  PhotosFetchCollectionsJobPrivate *priv;
-};
-
-struct _PhotosFetchCollectionsJobClass
-{
-  GObjectClass parent_class;
-};
+typedef struct _PhotosFetchCollectionsJob      PhotosFetchCollectionsJob;
+typedef struct _PhotosFetchCollectionsJobClass PhotosFetchCollectionsJobClass;
 
 GType                      photos_fetch_collections_job_get_type    (void) G_GNUC_CONST;
 


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