9cdfad3
From 2a16851e43cac594bf8983221411e19aa00082cd Mon Sep 17 00:00:00 2001
9cdfad3
From: Matthias Clasen <mclasen@redhat.com>
9cdfad3
Date: Tue, 9 Feb 2010 15:46:59 +0000
9cdfad3
Subject: [PATCH] Update sensitivity of "move all to trash"
9cdfad3
9cdfad3
https://bugzilla.gnome.org/show_bug.cgi?id=592663
9cdfad3
---
9cdfad3
 src/cheese-ui.h     |    7 +++++--
9cdfad3
 src/cheese-window.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
9cdfad3
 2 files changed, 53 insertions(+), 2 deletions(-)
9cdfad3
9cdfad3
diff --git a/src/cheese-ui.h b/src/cheese-ui.h
9cdfad3
index 0068b73..c9c76bb 100644
9cdfad3
--- a/src/cheese-ui.h
9cdfad3
+++ b/src/cheese-ui.h
9cdfad3
@@ -79,12 +79,15 @@ const GtkActionEntry action_entries_file[] = {
9cdfad3
    G_CALLBACK (cheese_cmd_file_save_as)},
9cdfad3
   {"MoveToTrash", "user-trash",      N_("Move to _Trash"), "Delete",        NULL,
9cdfad3
    G_CALLBACK (cheese_cmd_file_move_to_trash)},
9cdfad3
-  {"RemoveAll",    NULL,             N_("Move All to Trash"), NULL, NULL,
9cdfad3
-   G_CALLBACK (cheese_cmd_file_move_all_to_trash)},
9cdfad3
   {"Delete",      NULL,              N_("Delete"),         "<shift>Delete", NULL,
9cdfad3
    G_CALLBACK (cheese_cmd_file_delete)},
9cdfad3
 };
9cdfad3
 
9cdfad3
+static const GtkActionEntry action_entries_trash[] = {
9cdfad3
+  {"RemoveAll",    NULL,             N_("Move All to Trash"), NULL, NULL,
9cdfad3
+   G_CALLBACK (cheese_cmd_file_move_all_to_trash)},
9cdfad3
+};
9cdfad3
+
9cdfad3
 G_END_DECLS
9cdfad3
 
9cdfad3
 #endif /* __CHEESE_UI_H__ */
9cdfad3
diff --git a/src/cheese-window.c b/src/cheese-window.c
9cdfad3
index e4d06fa..e1c672e 100644
9cdfad3
--- a/src/cheese-window.c
9cdfad3
+++ b/src/cheese-window.c
9cdfad3
@@ -164,6 +164,7 @@ typedef struct
cd9a709
   GtkActionGroup *actions_burst;
cd9a709
   GtkActionGroup *actions_fullscreen;
cd9a709
   GtkActionGroup *actions_wide_mode;
cd9a709
+  GtkActionGroup *actions_trash;
cd9a709
 
cd9a709
   GtkUIManager *ui_manager;
cd9a709
 
9cdfad3
@@ -479,6 +480,40 @@ cheese_window_selection_changed_cb (GtkIconView  *iconview,
cd9a709
   }
cd9a709
 }
cd9a709
 
cd9a709
+static void
cd9a709
+cheese_window_thumbnails_changed (GtkTreeModel *model,
cd9a709
+                                  CheeseWindow *cheese_window)
cd9a709
+{
9cdfad3
+  CheeseWindowPrivate *priv = CHEESE_WINDOW_GET_PRIVATE (cheese_window);
cd9a709
+  GtkTreeIter iter;
cd9a709
+
cd9a709
+  if (gtk_tree_model_get_iter_first (model, &iter))
cd9a709
+  {
9cdfad3
+    gtk_action_group_set_sensitive (priv->actions_trash, TRUE);
cd9a709
+  }
cd9a709
+  else
cd9a709
+  {
9cdfad3
+    gtk_action_group_set_sensitive (priv->actions_trash, FALSE);
cd9a709
+  }
cd9a709
+}
cd9a709
+
cd9a709
+static void
cd9a709
+cheese_window_thumbnail_inserted (GtkTreeModel *model,
cd9a709
+                                  GtkTreePath  *path,
cd9a709
+                                  GtkTreeIter  *iter,
cd9a709
+                                  CheeseWindow *cheese_window)
cd9a709
+{
cd9a709
+  cheese_window_thumbnails_changed (model, cheese_window);
cd9a709
+}
cd9a709
+
cd9a709
+static void
cd9a709
+cheese_window_thumbnail_deleted (GtkTreeModel *model,
cd9a709
+                                 GtkTreePath  *path,
cd9a709
+                                 CheeseWindow *cheese_window)
cd9a709
+{
cd9a709
+  cheese_window_thumbnails_changed (model, cheese_window);
cd9a709
+}
cd9a709
+
cd9a709
 static gboolean
cd9a709
 cheese_window_button_press_event_cb (GtkWidget *iconview, GdkEventButton *event,
cd9a709
                                      CheeseWindow *cheese_window)
9cdfad3
@@ -1085,6 +1120,11 @@ setup_menubar_and_actions (CheeseWindow *cheese_window)
9cdfad3
                                                        G_N_ELEMENTS (action_entries_file));
9cdfad3
   gtk_action_group_set_sensitive (priv->actions_file, FALSE);
cd9a709
 
9cdfad3
+  priv->actions_trash = cheese_window_action_group_new (cheese_window,
9cdfad3
+                                                        "ActionsTrash",
9cdfad3
+                                                        action_entries_trash,
9cdfad3
+                                                        G_N_ELEMENTS (action_entries_trash));
cd9a709
+
9cdfad3
   priv->actions_photo = cheese_window_action_group_new (cheese_window,
9cdfad3
                                                         "ActionsPhoto",
9cdfad3
                                                         action_entries_photo,
9cdfad3
@@ -1253,6 +1293,13 @@ cheese_window_init (CheeseWindow *cheese_window)
9cdfad3
   g_signal_connect (priv->thumb_view, "button_press_event",
cd9a709
                     G_CALLBACK (cheese_window_button_press_event_cb), cheese_window);
9cdfad3
 
9cdfad3
+  g_signal_connect (gtk_icon_view_get_model (GTK_ICON_VIEW (priv->thumb_view)), "row-inserted",
cd9a709
+                    G_CALLBACK (cheese_window_thumbnail_inserted), cheese_window);
9cdfad3
+  g_signal_connect (gtk_icon_view_get_model (GTK_ICON_VIEW (priv->thumb_view)), "row-deleted",
cd9a709
+                    G_CALLBACK (cheese_window_thumbnail_deleted), cheese_window);
cd9a709
+
9cdfad3
+  cheese_window_thumbnails_changed (gtk_icon_view_get_model (GTK_ICON_VIEW (priv->thumb_view)), cheese_window);
9cdfad3
+
9cdfad3
   cheese_window_set_mode (cheese_window, CAMERA_MODE_PHOTO);
cd9a709
 }
cd9a709
 
9cdfad3
@@ -1331,6 +1378,7 @@ cheese_window_finalize (GObject *object)
9cdfad3
   g_object_unref (priv->actions_video);
9cdfad3
   g_object_unref (priv->actions_burst);
9cdfad3
   g_object_unref (priv->actions_fullscreen);
9cdfad3
+  g_object_unref (priv->actions_trash);
9cdfad3
 
9cdfad3
   if (G_OBJECT_CLASS (cheese_window_parent_class)->finalize)
9cdfad3
     G_OBJECT_CLASS (cheese_window_parent_class)->finalize (object);
9cdfad3
-- 
9cdfad3
1.6.6
9cdfad3