[gnome-clocks/wip/vala] Update the select button sensitivity



commit f8c7e20de7a715244070f95f23f57df052676024
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Feb 17 11:53:22 2013 +0100

    Update the select button sensitivity

 src/alarm.vala   |   16 ++++++++++++----
 src/widgets.vala |    4 ++++
 src/world.vala   |   16 ++++++++++++----
 3 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index d4f9f4f..8996be5 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -441,6 +441,10 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
         content_view = new ContentView (empty_view, icon_view);
         add (content_view);
 
+        content_view.notify["is-empty"].connect (() => {
+            update_toolbar ();
+        });
+
         standalone = new StandalonePanel ();
         add (standalone);
 
@@ -537,10 +541,14 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
                     activate_new ();
                 });
                 var select_button = toolbar.add_button ("object-select-symbolic", null, false);
-                select_button.clicked.connect (() => {
-                    icon_view.mode = IconView.Mode.SELECTION;
-                    update_toolbar ();
-                });
+                if (content_view.is_empty) {
+                    select_button.sensitive = false;
+                } else {
+                    select_button.clicked.connect (() => {
+                        icon_view.mode = IconView.Mode.SELECTION;
+                        update_toolbar ();
+                    });
+                }
             }
         } else if (visible_child == standalone) {
             toolbar.mode = Toolbar.Mode.STANDALONE;
diff --git a/src/widgets.vala b/src/widgets.vala
index c5408d8..3b65a37 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -308,6 +308,8 @@ public class IconView : Gtk.IconView {
 public class ContentView : Gtk.Bin {
     private const int SELECTION_TOOLBAR_WIDTH = 300;
 
+    public bool is_empty { get; private set; default = true; }
+
     private Gtk.Widget empty_page;
     private Gtk.Overlay overlay;
     private Gtk.ScrolledWindow scrolled_window;
@@ -381,11 +383,13 @@ public class ContentView : Gtk.Bin {
             if (child != scrolled_window) {
                 remove (child);
                 add (scrolled_window);
+                is_empty = false;
             }
         } else {
             if (child != empty_page) {
                 remove (child);
                 add (empty_page);
+                is_empty = true;
             }
         }
         show_all ();
diff --git a/src/world.vala b/src/world.vala
index 2d29a3b..a87fff4 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -281,6 +281,10 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
         content_view.delete_selected.connect (() => {
         });
 
+        content_view.notify["is-empty"].connect (() => {
+            update_toolbar ();
+        });
+
         standalone = new StandalonePanel ();
         add (standalone);
 
@@ -358,10 +362,14 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
                     activate_new ();
                 });
                 var select_button = toolbar.add_button ("object-select-symbolic", null, false);
-                select_button.clicked.connect (() => {
-                    icon_view.mode = IconView.Mode.SELECTION;
-                    update_toolbar ();
-                });
+                if (content_view.is_empty) {
+                    select_button.sensitive = false;
+                } else {
+                    select_button.clicked.connect (() => {
+                        icon_view.mode = IconView.Mode.SELECTION;
+                        update_toolbar ();
+                    });
+                }
             }
         } else if (visible_child == standalone) {
             toolbar.mode = Toolbar.Mode.STANDALONE;


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