[gitg] Allow searchable inavailability



commit afda626f23217c58662b917582f3d8b1f4de19f9
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Fri Aug 7 13:07:05 2015 +0200

    Allow searchable inavailability

 gitg/gitg-dash-view.vala             |   23 ++++++++++++++---------
 gitg/gitg-window.vala                |   25 ++++++++++++++++++-------
 gitg/history/gitg-history.vala       |    7 ++++++-
 libgitg-ext/gitg-ext-searchable.vala |    1 +
 libgitg-ext/gitg-ext-selectable.vala |    2 +-
 5 files changed, 40 insertions(+), 18 deletions(-)
---
diff --git a/gitg/gitg-dash-view.vala b/gitg/gitg-dash-view.vala
index 1d882c0..df76d24 100644
--- a/gitg/gitg-dash-view.vala
+++ b/gitg/gitg-dash-view.vala
@@ -87,7 +87,12 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
                get { return d_repository_list_box.get_children().length() != 0; }
        }
 
-       public bool selectable_enabled
+       public bool selectable_available
+       {
+               get { return has_repositories; }
+       }
+
+       public bool search_available
        {
                get { return has_repositories; }
        }
@@ -229,15 +234,15 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
                              BindingFlags.SYNC_CREATE |
                              BindingFlags.INVERT_BOOLEAN);
 
-               d_repository_list_box.add.connect(() => {
-                       notify_property("has-repositories");
-                       notify_property("selectable-enabled");
-               });
+               d_repository_list_box.add.connect(update_availability);
+               d_repository_list_box.remove.connect(update_availability);
+       }
 
-               d_repository_list_box.remove.connect(() => {
-                       notify_property("has-repositories");
-                       notify_property("selectable-enabled");
-               });
+       private void update_availability()
+       {
+               notify_property("has-repositories");
+               notify_property("selectable-available");
+               notify_property("search-available");
        }
 
        public RepositoryListBox.Row? add_repository(Repository repository)
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 3e098de..674ea00 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -34,7 +34,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
        private Gtk.Widget? d_select_actions;
 
        private Binding? d_selectable_mode_binding;
-       private Binding? d_selectable_enabled_binding;
+       private Binding? d_selectable_available_binding;
+       private Binding? d_searchable_available_binding;
        private GitgExt.SelectionMode d_selectable_mode;
 
        private UIElements<GitgExt.Activity> d_activities;
@@ -522,16 +523,25 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
 
                var searchable = current as GitgExt.Searchable;
 
+               d_searchable_available_binding = null;
+
                if (searchable != null)
                {
                        d_search_button.visible = true;
                        d_search_entry.text = searchable.search_text;
                        d_search_button.active = searchable.search_visible;
+
+                       d_searchable_available_binding = searchable.bind_property("search-available",
+                                                                                 d_search_button,
+                                                                                 "sensitive",
+                                                                                 BindingFlags.DEFAULT |
+                                                                                 BindingFlags.SYNC_CREATE);
                }
                else
                {
                        d_search_button.visible = false;
                        d_search_button.active = false;
+                       d_search_button.sensitive = false;
                        d_search_entry.text = "";
                }
 
@@ -539,7 +549,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                d_select_button.visible = (selectable != null);
 
                d_selectable_mode_binding = null;
-               d_selectable_enabled_binding = null;
+               d_selectable_available_binding = null;
 
                if (selectable != null)
                {
@@ -548,15 +558,16 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                                                                             "selectable-mode",
                                                                             BindingFlags.DEFAULT);
 
-                       d_selectable_enabled_binding = selectable.bind_property("selectable-enabled",
-                                                                               d_select_button,
-                                                                               "sensitive",
-                                                                               BindingFlags.DEFAULT |
-                                                                               BindingFlags.SYNC_CREATE);
+                       d_selectable_available_binding = selectable.bind_property("selectable-available",
+                                                                                d_select_button,
+                                                                                "sensitive",
+                                                                                BindingFlags.DEFAULT |
+                                                                                BindingFlags.SYNC_CREATE);
                }
                else
                {
                        d_select_button.active = false;
+                       d_select_button.sensitive = false;
                }
        }
 
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 5325951..474b76c 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -802,7 +802,12 @@ namespace GitgHistory
                        get; set;
                }
 
-               public bool selectable_enabled
+               public bool selectable_available
+               {
+                       get { return true; }
+               }
+
+               public bool search_available
                {
                        get { return true; }
                }
diff --git a/libgitg-ext/gitg-ext-searchable.vala b/libgitg-ext/gitg-ext-searchable.vala
index 505278d..ae26be1 100644
--- a/libgitg-ext/gitg-ext-searchable.vala
+++ b/libgitg-ext/gitg-ext-searchable.vala
@@ -31,6 +31,7 @@ public interface Searchable : Object, Activity
        public abstract string search_text { owned get; set; }
        public abstract bool search_visible { get; set; }
        public abstract bool search_enabled { get; set; }
+       public abstract bool search_available { get; }
        public abstract Gtk.Entry? search_entry { set; }
 }
 
diff --git a/libgitg-ext/gitg-ext-selectable.vala b/libgitg-ext/gitg-ext-selectable.vala
index ad01206..14044e8 100644
--- a/libgitg-ext/gitg-ext-selectable.vala
+++ b/libgitg-ext/gitg-ext-selectable.vala
@@ -35,7 +35,7 @@ public enum SelectionMode
 public interface Selectable : Object, Activity
 {
        public abstract SelectionMode selectable_mode { get; set; }
-       public abstract bool selectable_enabled { get; }
+       public abstract bool selectable_available { get; }
 
        public abstract Gtk.Widget? action_widget { owned get; }
 


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