[gnome-photos/wip/favorites: 15/15] main-toolbar: Desensitize it if there is no content



commit 0e70c5cf498598996d043d7d052ce58f6bbb8e95
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Dec 14 11:55:58 2012 +0530

    main-toolbar: Desensitize it if there is no content

 src/photos-main-toolbar.c |   60 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-main-toolbar.c b/src/photos-main-toolbar.c
index 05ce98c..7f8369b 100644
--- a/src/photos-main-toolbar.c
+++ b/src/photos-main-toolbar.c
@@ -35,8 +35,10 @@
 #include "photos-item-manager.h"
 #include "photos-main-toolbar.h"
 #include "photos-mode-controller.h"
+#include "photos-offset-overview-controller.h"
 #include "photos-selection-controller.h"
 #include "photos-source-manager.h"
+#include "photos-tracker-change-monitor.h"
 
 
 struct _PhotosMainToolbarPrivate
@@ -49,8 +51,11 @@ struct _PhotosMainToolbarPrivate
   PhotosBaseManager *item_mngr;
   PhotosBaseManager *src_mngr;
   PhotosModeController *mode_cntrlr;
+  PhotosOffsetController *offset_cntrlr;
   PhotosSelectionController *sel_cntrlr;
+  PhotosTrackerChangeMonitor *monitor;
   gulong collection_id;
+  gulong no_results_change_id;
   gulong search_source_id;
   gulong selection_changed_id;
   gulong selection_mode_id;
@@ -100,6 +105,46 @@ photos_main_toolbar_add_modes (PhotosMainToolbar *self, PhotosWindowMode window_
 
 
 static void
+photos_main_toolbar_enable (PhotosMainToolbar *self)
+{
+  PhotosMainToolbarPrivate *priv = self->priv;
+
+  if (priv->no_results_change_id != 0)
+    {
+      g_signal_handler_disconnect (priv->monitor, priv->no_results_change_id);
+      priv->no_results_change_id = 0;
+    }
+
+  gtk_widget_set_sensitive (priv->widget, TRUE);
+}
+
+
+static void
+photos_main_toolbar_changes_pending (PhotosMainToolbar *self, GHashTable *changes)
+{
+  photos_main_toolbar_enable (self);
+}
+
+
+static void
+photos_main_toolbar_count_changed (PhotosMainToolbar *self, gint count)
+{
+  PhotosMainToolbarPrivate *priv = self->priv;
+
+  if (count == 0)
+    {
+      priv->no_results_change_id = g_signal_connect_swapped (priv->monitor,
+                                                             "changes-pending",
+                                                             G_CALLBACK (photos_main_toolbar_changes_pending),
+                                                             self);
+      gtk_widget_set_sensitive (priv->widget, FALSE);
+    }
+  else
+    photos_main_toolbar_enable (self);
+}
+
+
+static void
 photos_main_toolbar_set_toolbar_title (PhotosMainToolbar *self)
 {
   PhotosMainToolbarPrivate *priv = self->priv;
@@ -419,11 +464,19 @@ photos_main_toolbar_dispose (GObject *object)
   PhotosMainToolbar *self = PHOTOS_MAIN_TOOLBAR (object);
   PhotosMainToolbarPrivate *priv = self->priv;
 
+  if (priv->no_results_change_id != 0)
+    {
+      g_signal_handler_disconnect (priv->monitor, priv->no_results_change_id);
+      priv->no_results_change_id = 0;
+    }
+
   g_clear_object (&priv->col_mngr);
   g_clear_object (&priv->item_mngr);
   g_clear_object (&priv->src_mngr);
   g_clear_object (&priv->mode_cntrlr);
+  g_clear_object (&priv->offset_cntrlr);
   g_clear_object (&priv->sel_cntrlr);
+  g_clear_object (&priv->monitor);
 
   G_OBJECT_CLASS (photos_main_toolbar_parent_class)->dispose (object);
 }
@@ -475,12 +528,19 @@ photos_main_toolbar_init (PhotosMainToolbar *self)
                                                    G_CALLBACK (photos_main_toolbar_reset_toolbar_mode),
                                                    self);
 
+  priv->offset_cntrlr = photos_offset_overview_controller_new ();
+  g_signal_connect_swapped (priv->offset_cntrlr,
+                            "count-changed",
+                            G_CALLBACK (photos_main_toolbar_count_changed),
+                            self);
+
   priv->sel_cntrlr = photos_selection_controller_new ();
   priv->selection_mode_id = g_signal_connect_swapped (priv->sel_cntrlr,
                                                       "selection-mode-changed",
                                                       G_CALLBACK (photos_main_toolbar_reset_toolbar_mode),
                                                       self);
 
+  priv->monitor = photos_tracker_change_monitor_new ();
   photos_main_toolbar_reset_toolbar_mode (self);
 
   g_signal_connect (priv->widget, "destroy", G_CALLBACK (photos_main_toolbar_destroy), self);



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