[gitg] Do not double reload



commit a98454abf0f0d4ef1de62ce7b4218a609a4d1568
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Thu Jul 10 22:17:30 2014 +0200

    Do not double reload

 gitg/commit/gitg-commit.vala       |    2 +-
 gitg/gitg-window.vala              |    1 -
 gitg/history/gitg-history.vala     |   46 +++++++++++++++++++++++++----------
 libgitg-ext/gitg-ext-activity.vala |    8 ------
 4 files changed, 34 insertions(+), 23 deletions(-)
---
diff --git a/gitg/commit/gitg-commit.vala b/gitg/commit/gitg-commit.vala
index c53811d..ca8ad59 100644
--- a/gitg/commit/gitg-commit.vala
+++ b/gitg/commit/gitg-commit.vala
@@ -347,7 +347,7 @@ namespace GitgCommit
                        return citem;
                }
 
-               public void reload()
+               private void reload()
                {
                        var repository = application.repository;
 
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 1c62f28..7ed045a 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -337,7 +337,6 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                                                           null);
 
                        notify_property("repository");
-                       d_activities.current.reload();
                }
                catch {}
        }
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index fe4dd91..779773a 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -49,14 +49,26 @@ namespace GitgHistory
                        owned get { return "/org/gnome/gitg/Activities/History"; }
                }
 
+               private Gitg.Repository d_repository;
+
                [Notify]
                public Gitg.Repository repository
                {
+                       get
+                       {
+                               return d_repository;
+                       }
+
                        set
                        {
-                               if (value != null)
+                               if (d_repository != value)
                                {
-                                       reload();
+                                       d_repository = value;
+
+                                       if (value != null)
+                                       {
+                                               reload();
+                                       }
                                }
                        }
                }
@@ -99,12 +111,6 @@ namespace GitgHistory
 
                        update_sort_mode();
 
-                       application.bind_property("repository", d_navigation_model,
-                                                 "repository", BindingFlags.DEFAULT);
-
-                       application.bind_property("repository", d_commit_list_model,
-                                                 "repository", BindingFlags.DEFAULT);
-
                        application.bind_property("repository", this,
                                                  "repository", BindingFlags.DEFAULT);
                }
@@ -213,17 +219,31 @@ namespace GitgHistory
                        d_main.navigation_view.select_first();
                }
 
-               public void reload()
+               private void reload()
                {
                        double vadj = d_main.navigation_view.get_vadjustment().get_value();
 
-                       d_navigation_model.reload();
-                       d_main.navigation_view.expand_all();
-                       d_main.navigation_view.select();
 
-                       d_main.navigation_view.size_allocate.connect((a) => {
+
+                       // Clears the commit model
+                       d_commit_list_model.repository = repository;
+
+                       // Reloads branches, tags, etc.
+                       d_navigation_model.repository = repository;
+
+                       ulong sid = 0;
+
+                       sid = d_main.navigation_view.size_allocate.connect((a) => {
                                d_main.navigation_view.get_vadjustment().set_value(vadj);
+
+                               if (sid != 0)
+                               {
+                                       d_main.navigation_view.disconnect(sid);
+                               }
                        });
+
+                       d_main.navigation_view.expand_all();
+                       d_main.navigation_view.select();
                }
 
                private void build_ui()
diff --git a/libgitg-ext/gitg-ext-activity.vala b/libgitg-ext/gitg-ext-activity.vala
index ef94979..ffe68c2 100644
--- a/libgitg-ext/gitg-ext-activity.vala
+++ b/libgitg-ext/gitg-ext-activity.vala
@@ -30,14 +30,6 @@ namespace GitgExt
 public interface Activity : Object, UIElement
 {
        /**
-        * Method called to reload the activity.
-        *
-        */
-       public virtual void reload()
-       {
-       }
-
-       /**
         * Whether the activity is the default for the specified action.
         *
         * @param action the action.


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