[gnome-documents/wip/rishi/split-view: 10/15] mainToolbar: Create the selection menu only once during construction



commit 0a2f7cef91c1fdfd9e48801907fff09e7a4e99a0
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Oct 6 14:34:28 2014 +0200

    mainToolbar: Create the selection menu only once during construction
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686461

 src/mainToolbar.js |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 836913b..4835f8f 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -99,13 +99,18 @@ const OverviewToolbar = new Lang.Class({
         this._collBackButton = null;
         this._collectionId = 0;
         this._selectionChangedId = 0;
-        this._selectionMenu = null;
         this._viewGridButton = null;
         this._viewListButton = null;
         this._viewSettingsId = 0;
 
         this.parent();
 
+        let builder = new Gtk.Builder();
+        builder.add_from_resource('/org/gnome/documents/selection-menu.ui');
+        let selectionMenu = builder.get_object('selection-menu');
+        this._selectionMenu = new Gtk.MenuButton({ menu_model: selectionMenu });
+        this._selectionMenu.get_style_context().add_class('selection-menu');
+
         // setup listeners to mode changes that affect the toolbar layout
         this._selectionModeId = Application.selectionController.connect('selection-mode-changed',
             Lang.bind(this, this._resetToolbarMode));
@@ -177,7 +182,7 @@ const OverviewToolbar = new Lang.Class({
                 primary = label;
         }
 
-        if (this._selectionMenu) {
+        if (selectionMode) {
             if (primary) {
                 this._selectionMenu.set_label(primary);
                 this._selectionMenu.get_child().use_markup = true;
@@ -189,12 +194,6 @@ const OverviewToolbar = new Lang.Class({
 
     _populateForSelectionMode: function() {
         this.toolbar.get_style_context().add_class('selection-mode');
-
-        let builder = new Gtk.Builder();
-        builder.add_from_resource('/org/gnome/documents/selection-menu.ui');
-        let selectionMenu = builder.get_object('selection-menu');
-        this._selectionMenu = new Gtk.MenuButton({ menu_model: selectionMenu });
-        this._selectionMenu.get_style_context().add_class('selection-menu');
         this.toolbar.set_custom_title(this._selectionMenu);
 
         let selectionButton = new Gtk.Button({ label: _("Cancel") });
@@ -257,7 +256,6 @@ const OverviewToolbar = new Lang.Class({
 
     _clearStateData: function() {
         this._collBackButton = null;
-        this._selectionMenu = null;
         this._viewGridButton = null;
         this._viewListButton = null;
         this.toolbar.set_custom_title(null);


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