[gnome-documents] sidebar: use a view signal to switch page



commit 9febc04b8eb338b6275b2c7b5fcdf3594a383ffa
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Sep 2 18:21:27 2011 -0400

    sidebar: use a view signal to switch page
    
    This way we avoid an useless refresh if we click on the same source in
    the sidebar.

 src/sidebar.js |    8 +++-----
 src/sources.js |    1 +
 2 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/src/sidebar.js b/src/sidebar.js
index e5e1874..b9ce9f7 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -153,15 +153,13 @@ function Sidebar() {
 
 Sidebar.prototype = {
     _init: function() {
-        this._sourceManager = Global.sourceManager;
-        this._sourceManager.connect('active-source-changed',
-                                    Lang.bind(this, this._onSourceFilterChanged));
-
         this.widget = new Gtk.Notebook({ show_tabs: false });
         this.widget.get_style_context().add_class(Gtk.STYLE_CLASS_SIDEBAR);
 
         this._sourceView = new Sources.SourceView();
         this.widget.insert_page(this._sourceView.widget, null, _SIDEBAR_SOURCES_PAGE);
+        this._sourceView.connect('source-clicked',
+                                 Lang.bind(this, this._onSourceClicked));
 
         this._sidebarView = new SidebarMainPage();
         this.widget.insert_page(this._sidebarView.widget, null, _SIDEBAR_MAIN_PAGE);
@@ -172,7 +170,7 @@ Sidebar.prototype = {
         this.widget.show_all();
     },
 
-    _onSourceFilterChanged: function(sourcePage, id, name) {
+    _onSourceClicked: function() {
         this.widget.set_current_page(_SIDEBAR_MAIN_PAGE);
     },
 
diff --git a/src/sources.js b/src/sources.js
index 1061963..629ff35 100644
--- a/src/sources.js
+++ b/src/sources.js
@@ -289,6 +289,7 @@ SourceView.prototype = {
                 let id = this._model.model.get_value(iter, SourceModelColumns.ID);
 
                 this._sourceManager.setActiveSourceId(id);
+                this.emit('source-clicked');
             }));
 
         let col = new Gtk.TreeViewColumn();



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