[gnome-photos] embed, view-container: Add a method to activate the first item



commit 3077861aac9f91b881fea6dc6e4ca3d2ef073812
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jun 28 10:48:27 2016 +0200

    embed, view-container: Add a method to activate the first item
    
    This keeps the code in sync with gnome-documents.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768130

 src/photos-embed.c          |   16 +---------------
 src/photos-view-container.c |   18 ++++++++++++++++++
 src/photos-view-container.h |    2 ++
 3 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/src/photos-embed.c b/src/photos-embed.c
index f440832..d128095 100644
--- a/src/photos-embed.c
+++ b/src/photos-embed.c
@@ -48,7 +48,6 @@
 #include "photos-tracker-overview-controller.h"
 #include "photos-utils.h"
 #include "photos-view-container.h"
-#include "photos-view-model.h"
 
 
 typedef struct _PhotosEmbedSearchState PhotosEmbedSearchState;
@@ -176,25 +175,12 @@ photos_embed_get_view_container_from_mode (PhotosEmbed *self, PhotosWindowMode m
 static void
 photos_embed_activate_result (PhotosEmbed *self)
 {
-  GtkTreeIter iter;
-  GtkListStore *store;
   GtkWidget *view_container;
   PhotosWindowMode mode;
 
   mode = photos_mode_controller_get_window_mode (self->mode_cntrlr);
   view_container = photos_embed_get_view_container_from_mode (self, mode);
-  store = photos_view_container_get_model (PHOTOS_VIEW_CONTAINER (view_container));
-
-  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
-    {
-      GObject *item;
-      gchar *id;
-
-      gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, PHOTOS_VIEW_MODEL_URN, &id, -1);
-      item = photos_base_manager_get_object_by_id (self->item_mngr, id);
-      photos_base_manager_set_active_object (self->item_mngr, item);
-      g_free (id);
-    }
+  photos_view_container_activate_result (PHOTOS_VIEW_CONTAINER (view_container));
 }
 
 
diff --git a/src/photos-view-container.c b/src/photos-view-container.c
index 238b126..866f482 100644
--- a/src/photos-view-container.c
+++ b/src/photos-view-container.c
@@ -479,6 +479,24 @@ photos_view_container_new (PhotosWindowMode mode, const gchar *name)
 }
 
 
+void
+photos_view_container_activate_result (PhotosViewContainer *self)
+{
+  GtkTreeIter iter;
+
+  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->model), &iter))
+    {
+      GObject *item;
+      gchar *id;
+
+      gtk_tree_model_get (GTK_TREE_MODEL (self->model), &iter, PHOTOS_VIEW_MODEL_URN, &id, -1);
+      item = photos_base_manager_get_object_by_id (self->item_mngr, id);
+      photos_base_manager_set_active_object (self->item_mngr, item);
+      g_free (id);
+    }
+}
+
+
 GtkTreePath *
 photos_view_container_get_current_path (PhotosViewContainer *self)
 {
diff --git a/src/photos-view-container.h b/src/photos-view-container.h
index fedab39..2b475d7 100644
--- a/src/photos-view-container.h
+++ b/src/photos-view-container.h
@@ -48,6 +48,8 @@ GType                  photos_view_container_get_type               (void) G_GNU
 
 GtkWidget             *photos_view_container_new                    (PhotosWindowMode mode, const gchar 
*name);
 
+void                   photos_view_container_activate_result        (PhotosViewContainer *self);
+
 GtkTreePath           *photos_view_container_get_current_path       (PhotosViewContainer *self);
 
 GtkListStore          *photos_view_container_get_model              (PhotosViewContainer *self);


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