[gnome-photos] view-container: Make it a final class



commit d67dc6ff9ec80ee16ff777f897f94122fde63273
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Feb 5 13:59:38 2016 +0100

    view-container: Make it a final class

 src/photos-view-container.c |  172 ++++++++++++++++++++-----------------------
 src/photos-view-container.h |   28 +-------
 2 files changed, 82 insertions(+), 118 deletions(-)
---
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index f692095..6cdbc20 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013, 2014, 2015 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014, 2015, 2016 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
@@ -46,8 +46,9 @@
 #include "photos-view-model.h"
 
 
-struct _PhotosViewContainerPrivate
+struct _PhotosViewContainer
 {
+  GtkStack parent_instance;
   GdMainView *view;
   GtkListStore *model;
   GtkTreePath *current_path;
@@ -64,6 +65,11 @@ struct _PhotosViewContainerPrivate
   gchar *name;
 };
 
+struct _PhotosViewContainerClass
+{
+  GtkStackClass parent_class;
+};
+
 enum
 {
   PROP_0,
@@ -72,24 +78,21 @@ enum
 };
 
 
-G_DEFINE_TYPE_WITH_PRIVATE (PhotosViewContainer, photos_view_container, GTK_TYPE_STACK);
+G_DEFINE_TYPE (PhotosViewContainer, photos_view_container, GTK_TYPE_STACK);
 
 
 static void
 photos_view_container_edge_reached (PhotosViewContainer *self, GtkPositionType pos)
 {
   if (pos == GTK_POS_BOTTOM)
-    photos_offset_controller_increase_offset (self->priv->offset_cntrlr);
+    photos_offset_controller_increase_offset (self->offset_cntrlr);
 }
 
 
 static void
 photos_view_container_connect_view (PhotosViewContainer *self)
 {
-  g_signal_connect_swapped (self->priv->view,
-                            "edge-reached",
-                            G_CALLBACK (photos_view_container_edge_reached),
-                            self);
+  g_signal_connect_swapped (self->view, "edge-reached", G_CALLBACK (photos_view_container_edge_reached), 
self);
 }
 
 
@@ -106,35 +109,30 @@ photos_view_container_count_changed (PhotosViewContainer *self, gint count)
 static void
 photos_view_container_disconnect_view (PhotosViewContainer *self)
 {
-  PhotosViewContainerPrivate *priv = self->priv;
-
-  g_signal_handlers_disconnect_by_func (priv->view, photos_view_container_edge_reached, self);
+  g_signal_handlers_disconnect_by_func (self->view, photos_view_container_edge_reached, self);
 }
 
 
 static void
 photos_view_container_item_activated (PhotosViewContainer *self, const gchar * id, const GtkTreePath *path)
 {
-  PhotosViewContainerPrivate *priv = self->priv;
   GObject *object;
 
-  priv->current_path = gtk_tree_path_copy (path);
-  object = photos_base_manager_get_object_by_id (priv->item_mngr, id);
+  self->current_path = gtk_tree_path_copy (path);
+  object = photos_base_manager_get_object_by_id (self->item_mngr, id);
 
   if (!photos_base_item_is_collection (PHOTOS_BASE_ITEM (object)) &&
-      photos_remote_display_manager_is_active (priv->remote_mngr))
-    photos_remote_display_manager_render (priv->remote_mngr, PHOTOS_BASE_ITEM (object));
+      photos_remote_display_manager_is_active (self->remote_mngr))
+    photos_remote_display_manager_render (self->remote_mngr, PHOTOS_BASE_ITEM (object));
   else
-    photos_base_manager_set_active_object (priv->item_mngr, object);
+    photos_base_manager_set_active_object (self->item_mngr, object);
 }
 
 
 static void
 photos_view_container_set_error (PhotosViewContainer *self, const gchar *primary, const gchar *secondary)
 {
-  PhotosViewContainerPrivate *priv = self->priv;
-
-  photos_error_box_update (PHOTOS_ERROR_BOX (priv->error_box), primary, secondary);
+  photos_error_box_update (PHOTOS_ERROR_BOX (self->error_box), primary, secondary);
   gtk_stack_set_visible_child_name (GTK_STACK (self), "error");
 }
 
@@ -149,18 +147,16 @@ photos_view_container_query_error (PhotosViewContainer *self, const gchar *prima
 static void
 photos_view_container_query_status_changed (PhotosViewContainer *self, gboolean query_status)
 {
-  PhotosViewContainerPrivate *priv = self->priv;
-
   if (!query_status)
     {
-      gd_main_view_set_model (priv->view, GTK_TREE_MODEL (priv->model));
-      photos_selection_controller_freeze_selection (priv->sel_cntrlr, FALSE);
+      gd_main_view_set_model (self->view, GTK_TREE_MODEL (self->model));
+      photos_selection_controller_freeze_selection (self->sel_cntrlr, FALSE);
       /* TODO: update selection */
     }
   else
     {
-      photos_selection_controller_freeze_selection (priv->sel_cntrlr, TRUE);
-      gd_main_view_set_model (priv->view, NULL);
+      photos_selection_controller_freeze_selection (self->sel_cntrlr, TRUE);
+      gd_main_view_set_model (self->view, NULL);
     }
 }
 
@@ -168,37 +164,34 @@ photos_view_container_query_status_changed (PhotosViewContainer *self, gboolean
 static void
 photos_view_container_select_all (PhotosViewContainer *self)
 {
-  PhotosViewContainerPrivate *priv = self->priv;
-
-  photos_selection_controller_set_selection_mode (priv->sel_cntrlr, TRUE);
-  gd_main_view_select_all (priv->view);
+  photos_selection_controller_set_selection_mode (self->sel_cntrlr, TRUE);
+  gd_main_view_select_all (self->view);
 }
 
 
 static void
 photos_view_container_selection_mode_changed (PhotosViewContainer *self, gboolean mode)
 {
-  gd_main_view_set_selection_mode (self->priv->view, mode);
+  gd_main_view_set_selection_mode (self->view, mode);
 }
 
 
 static void
 photos_view_container_selection_mode_request (PhotosViewContainer *self)
 {
-  photos_selection_controller_set_selection_mode (self->priv->sel_cntrlr, TRUE);
+  photos_selection_controller_set_selection_mode (self->sel_cntrlr, TRUE);
 }
 
 
 static void
 photos_view_container_view_selection_changed (PhotosViewContainer *self)
 {
-  PhotosViewContainerPrivate *priv = self->priv;
   GList *selected_urns;
   GList *selection;
 
-  selection = gd_main_view_get_selection (priv->view);
-  selected_urns = photos_utils_get_urns_from_paths (selection, GTK_TREE_MODEL (priv->model));
-  photos_selection_controller_set_selection (priv->sel_cntrlr, selected_urns);
+  selection = gd_main_view_get_selection (self->view);
+  selected_urns = photos_utils_get_urns_from_paths (selection, GTK_TREE_MODEL (self->model));
+  photos_selection_controller_set_selection (self->sel_cntrlr, selected_urns);
 
   g_list_free_full (selected_urns, g_free);
   g_list_free_full (selection, (GDestroyNotify) gtk_tree_path_free);
@@ -224,7 +217,6 @@ static void
 photos_view_container_constructed (GObject *object)
 {
   PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (object);
-  PhotosViewContainerPrivate *priv = self->priv;
   AtkObject *accessible;
   GAction *action;
   GApplication *app;
@@ -241,80 +233,80 @@ photos_view_container_constructed (GObject *object)
 
   accessible = gtk_widget_get_accessible (GTK_WIDGET (self));
   if (accessible != NULL)
-    atk_object_set_name (accessible, priv->name);
+    atk_object_set_name (accessible, self->name);
 
-  priv->model = photos_view_model_new (priv->mode);
+  self->model = photos_view_model_new (self->mode);
 
   grid = gtk_grid_new ();
   gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL);
   gtk_stack_add_named (GTK_STACK (self), grid, "view");
 
-  priv->no_results = photos_empty_results_box_new (priv->mode);
-  gtk_stack_add_named (GTK_STACK (self), priv->no_results, "no-results");
+  self->no_results = photos_empty_results_box_new (self->mode);
+  gtk_stack_add_named (GTK_STACK (self), self->no_results, "no-results");
 
-  priv->error_box = photos_error_box_new ();
-  gtk_stack_add_named (GTK_STACK (self), priv->error_box, "error");
+  self->error_box = photos_error_box_new ();
+  gtk_stack_add_named (GTK_STACK (self), self->error_box, "error");
 
-  priv->view = gd_main_view_new (GD_MAIN_VIEW_ICON);
-  generic_view = gd_main_view_get_generic_view (priv->view);
+  self->view = gd_main_view_new (GD_MAIN_VIEW_ICON);
+  generic_view = gd_main_view_get_generic_view (self->view);
   size = photos_utils_get_icon_size_unscaled ();
   gtk_icon_view_set_item_width (GTK_ICON_VIEW (generic_view), size + 24);
-  gtk_container_add (GTK_CONTAINER (grid), GTK_WIDGET (priv->view));
+  gtk_container_add (GTK_CONTAINER (grid), GTK_WIDGET (self->view));
 
   gtk_widget_show_all (GTK_WIDGET (self));
 
   gtk_stack_set_visible_child_full (GTK_STACK (self), "view", GTK_STACK_TRANSITION_TYPE_NONE);
 
-  g_signal_connect_swapped (priv->view, "item-activated", G_CALLBACK (photos_view_container_item_activated), 
self);
-  g_signal_connect_swapped (priv->view,
+  g_signal_connect_swapped (self->view, "item-activated", G_CALLBACK (photos_view_container_item_activated), 
self);
+  g_signal_connect_swapped (self->view,
                             "selection-mode-request",
                             G_CALLBACK (photos_view_container_selection_mode_request),
                             self);
-  g_signal_connect_swapped (priv->view,
+  g_signal_connect_swapped (self->view,
                             "view-selection-changed",
                             G_CALLBACK (photos_view_container_view_selection_changed),
                             self);
 
-  priv->item_mngr = g_object_ref (state->item_mngr);
+  self->item_mngr = g_object_ref (state->item_mngr);
 
-  priv->sel_cntrlr = photos_selection_controller_dup_singleton ();
-  g_signal_connect_object (priv->sel_cntrlr,
+  self->sel_cntrlr = photos_selection_controller_dup_singleton ();
+  g_signal_connect_object (self->sel_cntrlr,
                            "selection-mode-changed",
                            G_CALLBACK (photos_view_container_selection_mode_changed),
                            self,
                            G_CONNECT_SWAPPED);
   photos_view_container_selection_mode_changed (self,
-                                                photos_selection_controller_get_selection_mode 
(priv->sel_cntrlr));
+                                                photos_selection_controller_get_selection_mode 
(self->sel_cntrlr));
 
-  priv->mode_cntrlr = g_object_ref (state->mode_cntrlr);
-  g_signal_connect_object (priv->mode_cntrlr,
+  self->mode_cntrlr = g_object_ref (state->mode_cntrlr);
+  g_signal_connect_object (self->mode_cntrlr,
                            "window-mode-changed",
                            G_CALLBACK (photos_view_container_window_mode_changed),
                            self,
                            G_CONNECT_SWAPPED);
 
-  priv->remote_mngr = photos_remote_display_manager_dup_singleton ();
+  self->remote_mngr = photos_remote_display_manager_dup_singleton ();
 
-  switch (priv->mode)
+  switch (self->mode)
     {
     case PHOTOS_WINDOW_MODE_COLLECTIONS:
-      priv->trk_cntrlr = photos_tracker_collections_controller_dup_singleton ();
-      priv->offset_cntrlr = photos_offset_collections_controller_dup_singleton ();
+      self->trk_cntrlr = photos_tracker_collections_controller_dup_singleton ();
+      self->offset_cntrlr = photos_offset_collections_controller_dup_singleton ();
       break;
 
     case PHOTOS_WINDOW_MODE_FAVORITES:
-      priv->trk_cntrlr = photos_tracker_favorites_controller_dup_singleton ();
-      priv->offset_cntrlr = photos_offset_favorites_controller_dup_singleton ();
+      self->trk_cntrlr = photos_tracker_favorites_controller_dup_singleton ();
+      self->offset_cntrlr = photos_offset_favorites_controller_dup_singleton ();
       break;
 
     case PHOTOS_WINDOW_MODE_OVERVIEW:
-      priv->trk_cntrlr = photos_tracker_overview_controller_dup_singleton ();
-      priv->offset_cntrlr = photos_offset_overview_controller_dup_singleton ();
+      self->trk_cntrlr = photos_tracker_overview_controller_dup_singleton ();
+      self->offset_cntrlr = photos_offset_overview_controller_dup_singleton ();
       break;
 
     case PHOTOS_WINDOW_MODE_SEARCH:
-      priv->trk_cntrlr = photos_tracker_search_controller_dup_singleton ();
-      priv->offset_cntrlr = photos_offset_search_controller_dup_singleton ();
+      self->trk_cntrlr = photos_tracker_search_controller_dup_singleton ();
+      self->offset_cntrlr = photos_offset_search_controller_dup_singleton ();
       break;
 
     case PHOTOS_WINDOW_MODE_NONE:
@@ -336,28 +328,28 @@ photos_view_container_constructed (GObject *object)
   g_signal_connect_object (action,
                            "activate",
                            G_CALLBACK (gd_main_view_unselect_all),
-                           priv->view,
+                           self->view,
                            G_CONNECT_SWAPPED);
 
-  g_signal_connect_object (priv->offset_cntrlr,
+  g_signal_connect_object (self->offset_cntrlr,
                            "count-changed",
                            G_CALLBACK (photos_view_container_count_changed),
                            self,
                            G_CONNECT_SWAPPED);
 
-  g_signal_connect_object (priv->trk_cntrlr,
+  g_signal_connect_object (self->trk_cntrlr,
                            "query-error",
                            G_CALLBACK (photos_view_container_query_error),
                            self,
                            G_CONNECT_SWAPPED);
-  g_signal_connect_object (priv->trk_cntrlr,
+  g_signal_connect_object (self->trk_cntrlr,
                            "query-status-changed",
                            G_CALLBACK (photos_view_container_query_status_changed),
                            self,
                            G_CONNECT_SWAPPED);
-  photos_tracker_controller_start (priv->trk_cntrlr);
+  photos_tracker_controller_start (self->trk_cntrlr);
 
-  status = photos_tracker_controller_get_query_status (priv->trk_cntrlr);
+  status = photos_tracker_controller_get_query_status (self->trk_cntrlr);
   photos_view_container_query_status_changed (self, status);
 }
 
@@ -366,21 +358,20 @@ static void
 photos_view_container_dispose (GObject *object)
 {
   PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (object);
-  PhotosViewContainerPrivate *priv = self->priv;
 
-  if (!priv->disposed)
+  if (!self->disposed)
     {
       photos_view_container_disconnect_view (self);
-      priv->disposed = TRUE;
+      self->disposed = TRUE;
     }
 
-  g_clear_object (&priv->model);
-  g_clear_object (&priv->item_mngr);
-  g_clear_object (&priv->mode_cntrlr);
-  g_clear_object (&priv->offset_cntrlr);
-  g_clear_object (&priv->remote_mngr);
-  g_clear_object (&priv->sel_cntrlr);
-  g_clear_object (&priv->trk_cntrlr);
+  g_clear_object (&self->model);
+  g_clear_object (&self->item_mngr);
+  g_clear_object (&self->mode_cntrlr);
+  g_clear_object (&self->offset_cntrlr);
+  g_clear_object (&self->remote_mngr);
+  g_clear_object (&self->sel_cntrlr);
+  g_clear_object (&self->trk_cntrlr);
 
   G_OBJECT_CLASS (photos_view_container_parent_class)->dispose (object);
 }
@@ -390,10 +381,9 @@ static void
 photos_view_container_finalize (GObject *object)
 {
   PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (object);
-  PhotosViewContainerPrivate *priv = self->priv;
 
-  g_clear_pointer (&priv->current_path, (GDestroyNotify) gtk_tree_path_free);
-  g_free (priv->name);
+  g_clear_pointer (&self->current_path, (GDestroyNotify) gtk_tree_path_free);
+  g_free (self->name);
 
   G_OBJECT_CLASS (photos_view_container_parent_class)->finalize (object);
 }
@@ -407,7 +397,7 @@ photos_view_container_get_property (GObject *object, guint prop_id, GValue *valu
   switch (prop_id)
     {
     case PROP_NAME:
-      g_value_set_string (value, self->priv->name);
+      g_value_set_string (value, self->name);
       break;
 
     default:
@@ -421,16 +411,15 @@ static void
 photos_view_container_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
   PhotosViewContainer *self = PHOTOS_VIEW_CONTAINER (object);
-  PhotosViewContainerPrivate *priv = self->priv;
 
   switch (prop_id)
     {
     case PROP_MODE:
-      priv->mode = (PhotosWindowMode) g_value_get_enum (value);
+      self->mode = (PhotosWindowMode) g_value_get_enum (value);
       break;
 
     case PROP_NAME:
-      priv->name = g_value_dup_string (value);
+      self->name = g_value_dup_string (value);
       break;
 
     default:
@@ -443,7 +432,6 @@ photos_view_container_set_property (GObject *object, guint prop_id, const GValue
 static void
 photos_view_container_init (PhotosViewContainer *self)
 {
-  self->priv = photos_view_container_get_instance_private (self);
 }
 
 
@@ -492,19 +480,19 @@ photos_view_container_new (PhotosWindowMode mode, const gchar *name)
 GtkTreePath *
 photos_view_container_get_current_path (PhotosViewContainer *self)
 {
-  return self->priv->current_path;
+  return self->current_path;
 }
 
 
 GtkListStore *
 photos_view_container_get_model (PhotosViewContainer *self)
 {
-  return self->priv->model;
+  return self->model;
 }
 
 
 const gchar *
 photos_view_container_get_name (PhotosViewContainer *self)
 {
-  return self->priv->name;
+  return self->name;
 }
diff --git a/src/photos-view-container.h b/src/photos-view-container.h
index 9f87ff7..2991717 100644
--- a/src/photos-view-container.h
+++ b/src/photos-view-container.h
@@ -37,36 +37,12 @@ G_BEGIN_DECLS
   (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
    PHOTOS_TYPE_VIEW_CONTAINER, PhotosViewContainer))
 
-#define PHOTOS_VIEW_CONTAINER_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), \
-   PHOTOS_TYPE_VIEW_CONTAINER, PhotosViewContainerClass))
-
 #define PHOTOS_IS_VIEW_CONTAINER(obj) \
   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
    PHOTOS_TYPE_VIEW_CONTAINER))
 
-#define PHOTOS_IS_VIEW_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), \
-   PHOTOS_TYPE_VIEW_CONTAINER))
-
-#define PHOTOS_VIEW_CONTAINER_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), \
-   PHOTOS_TYPE_VIEW_CONTAINER, PhotosViewContainerClass))
-
-typedef struct _PhotosViewContainer        PhotosViewContainer;
-typedef struct _PhotosViewContainerClass   PhotosViewContainerClass;
-typedef struct _PhotosViewContainerPrivate PhotosViewContainerPrivate;
-
-struct _PhotosViewContainer
-{
-  GtkStack parent_instance;
-  PhotosViewContainerPrivate *priv;
-};
-
-struct _PhotosViewContainerClass
-{
-  GtkStackClass parent_class;
-};
+typedef struct _PhotosViewContainer      PhotosViewContainer;
+typedef struct _PhotosViewContainerClass PhotosViewContainerClass;
 
 GType                  photos_view_container_get_type               (void) G_GNUC_CONST;
 


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