e9fed67
From 4f6953de531316e0385aaace9ae5f2400e4451c8 Mon Sep 17 00:00:00 2001
e9fed67
From: Hans de Goede <hdegoede@redhat.com>
e9fed67
Date: Sun, 10 Jun 2012 14:50:54 +0200
e9fed67
Subject: [PATCH] cheese-thumb-view: Don't set columns to 5000 in horizontal
e9fed67
 mode
e9fed67
e9fed67
Rather then assuming 5000 will be enough, just set the number of columns to
e9fed67
the number of thumbnails we have.
e9fed67
e9fed67
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
e9fed67
---
e9fed67
 src/cheese-window.vala            |    4 ++--
e9fed67
 src/thumbview/cheese-thumb-view.c |   21 ++++++++++++++++++++-
e9fed67
 src/thumbview/cheese-thumb-view.h |    1 +
e9fed67
 src/vapi/cheese-thumbview.vapi    |    1 +
e9fed67
 4 files changed, 24 insertions(+), 3 deletions(-)
e9fed67
e9fed67
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
e9fed67
index 12ef2e0..0ab0d2d 100644
e9fed67
--- a/src/cheese-window.vala
e9fed67
+++ b/src/cheese-window.vala
e9fed67
@@ -837,7 +837,7 @@ public class Cheese.MainWindow : Gtk.Window
e9fed67
 
e9fed67
     if (is_wide_mode)
e9fed67
     {
e9fed67
-      thumb_view.set_columns (1);
e9fed67
+      thumb_view.set_vertical (true);
e9fed67
       thumb_nav.set_vertical (true);
e9fed67
       if (thumbnails_bottom.get_child () != null)
e9fed67
       {
e9fed67
@@ -850,7 +850,7 @@ public class Cheese.MainWindow : Gtk.Window
e9fed67
     }
e9fed67
     else
e9fed67
     {
e9fed67
-      thumb_view.set_columns (5000);
e9fed67
+      thumb_view.set_vertical (false);
e9fed67
       thumb_nav.set_vertical (false);
e9fed67
       if (thumbnails_right.get_child () != null)
e9fed67
       {
e9fed67
diff --git a/src/thumbview/cheese-thumb-view.c b/src/thumbview/cheese-thumb-view.c
e9fed67
index 49bc31a..243d325 100644
e9fed67
--- a/src/thumbview/cheese-thumb-view.c
e9fed67
+++ b/src/thumbview/cheese-thumb-view.c
e9fed67
@@ -51,6 +51,7 @@ typedef struct
e9fed67
   GFileMonitor   *video_file_monitor;
e9fed67
   GnomeDesktopThumbnailFactory *factory;
e9fed67
   gboolean multiplex_thumbnail_generator;
e9fed67
+  gboolean vertical;
e9fed67
   guint n_items;
e9fed67
   guint idle_id;
e9fed67
   GQueue *thumbnails;
e9fed67
@@ -601,7 +602,10 @@ cheese_thumb_view_row_inserted_cb (GtkTreeModel    *tree_model,
e9fed67
   CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
e9fed67
 
e9fed67
   priv->n_items++;
e9fed67
-  gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, -1);
e9fed67
+  if (!priv->vertical)
e9fed67
+    gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), priv->n_items);
e9fed67
+  else
e9fed67
+    gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, -1);
e9fed67
 }
e9fed67
 
e9fed67
 static void
e9fed67
@@ -616,6 +620,8 @@ cheese_thumb_view_row_deleted_cb (GtkTreeModel    *tree_model,
e9fed67
     gtk_widget_set_size_request (GTK_WIDGET (thumb_view),
e9fed67
                                  THUMB_VIEW_MINIMUM_WIDTH,
e9fed67
                                  THUMB_VIEW_MINIMUM_HEIGHT);
e9fed67
+  else if (!priv->vertical)
e9fed67
+    gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), priv->n_items);
e9fed67
 }
e9fed67
 
e9fed67
 static void
e9fed67
@@ -684,6 +690,7 @@ cheese_thumb_view_constructed (GObject *object)
e9fed67
                                         THUMBNAIL_BASENAME_URL_COLUMN, GTK_SORT_ASCENDING);
e9fed67
                                         
e9fed67
   cheese_thumb_view_fill (thumb_view);
e9fed67
+  cheese_thumb_view_set_vertical (thumb_view, FALSE);
e9fed67
 }
e9fed67
 
e9fed67
 GtkWidget *
e9fed67
@@ -696,6 +703,18 @@ cheese_thumb_view_new ()
e9fed67
 }
e9fed67
 
e9fed67
 void
e9fed67
+cheese_thumb_view_set_vertical (CheeseThumbView *thumb_view, gboolean vertical)
e9fed67
+{
e9fed67
+  CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
e9fed67
+
e9fed67
+  priv->vertical = vertical;
e9fed67
+  if (!priv->vertical && priv->n_items)
e9fed67
+    gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), priv->n_items);
e9fed67
+  else
e9fed67
+    gtk_icon_view_set_columns(GTK_ICON_VIEW (thumb_view), 1);
e9fed67
+}
e9fed67
+
e9fed67
+void
e9fed67
 cheese_thumb_view_start_monitoring_photo_path (CheeseThumbView *thumb_view, const char *path_photos)
e9fed67
 {
e9fed67
   CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);
e9fed67
diff --git a/src/thumbview/cheese-thumb-view.h b/src/thumbview/cheese-thumb-view.h
e9fed67
index 140a283..b2ca2b3 100644
e9fed67
--- a/src/thumbview/cheese-thumb-view.h
e9fed67
+++ b/src/thumbview/cheese-thumb-view.h
e9fed67
@@ -54,6 +54,7 @@ GList *cheese_thumb_view_get_selected_images_list (CheeseThumbView *thumb_view);
e9fed67
 char * cheese_thumb_view_get_selected_image (CheeseThumbView *thumb_view);
e9fed67
 guint  cheese_thumb_view_get_n_selected (CheeseThumbView *thumbview);
e9fed67
 void   cheese_thumb_view_remove_item (CheeseThumbView *thumb_view, GFile *file);
e9fed67
+void   cheese_thumb_view_set_vertical (CheeseThumbView *thumb_view, gboolean vertical);
e9fed67
 void cheese_thumb_view_start_monitoring_photo_path (CheeseThumbView *thumbview, const char *path_photos);
e9fed67
 void cheese_thumb_view_start_monitoring_video_path (CheeseThumbView *thumbview, const char *path_videos);
e9fed67
 
e9fed67
diff --git a/src/vapi/cheese-thumbview.vapi b/src/vapi/cheese-thumbview.vapi
e9fed67
index 669b724..61b323e 100644
e9fed67
--- a/src/vapi/cheese-thumbview.vapi
e9fed67
+++ b/src/vapi/cheese-thumbview.vapi
e9fed67
@@ -9,6 +9,7 @@ namespace Cheese
e9fed67
     public List<GLib.File> get_selected_images_list ();
e9fed67
     public int             get_n_selected ();
e9fed67
     public void            remove_item (GLib.File file);
e9fed67
+    public void            set_vertical (bool vertical);
e9fed67
     public void            start_monitoring_photo_path (string path_photos);
e9fed67
     public void            start_monitoring_video_path (string path_videos);
e9fed67
   }
e9fed67
-- 
e9fed67
1.7.10.2
e9fed67