[gnome-documents] toolbar: add a WindowToolbar subclass



commit 3010cdbe6b6e0afc09fe98cb3d3a094889e76254
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon May 14 12:02:19 2012 -0400

    toolbar: add a WindowToolbar subclass
    
    Add WindowToolbar, which encapsulates a searchbar and the regular
    toolbar.

 src/embed.js       |    2 +-
 src/mainToolbar.js |   26 +++++++++++++++++++++++---
 src/mainWindow.js  |   12 +++---------
 src/preview.js     |    2 +-
 4 files changed, 28 insertions(+), 14 deletions(-)
---
diff --git a/src/embed.js b/src/embed.js
index 4578073..d09aac7 100644
--- a/src/embed.js
+++ b/src/embed.js
@@ -68,7 +68,7 @@ ViewEmbed.prototype  = {
             Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL);
 
         // pack the toolbar
-        this._toolbar = new MainToolbar.MainToolbar();
+        this._toolbar = new MainToolbar.OverviewToolbar();
         this._contentsActor.add_actor(this._toolbar.actor);
         this._contentsLayout.set_fill(this._toolbar.actor, true, false);
 
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index cee3e31..56e0e03 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -34,6 +34,7 @@ const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Global = imports.global;
+const Searchbar = imports.searchbar;
 const Tweener = imports.util.tweener;
 const WindowMode = imports.windowMode;
 
@@ -55,7 +56,9 @@ MainToolbar.prototype = {
         this.layout = new Clutter.BoxLayout({ vertical: true });
         this.actor = new Clutter.Actor({ layout_manager: this.layout });
 
-        this.layout.pack(new GtkClutter.Actor({ contents: this.widget }),
+        this.toolbarActor = new GtkClutter.Actor({ contents: this.widget });
+
+        this.layout.pack(this.toolbarActor,
                          false, true, false,
                          Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
 
@@ -289,11 +292,11 @@ MainToolbar.prototype = {
     }
 };
 
-function FullscreenToolbar() {
+function PreviewToolbar() {
     this._init();
 };
 
-FullscreenToolbar.prototype = {
+PreviewToolbar.prototype = {
     __proto__: MainToolbar.prototype,
 
     _init: function() {
@@ -316,3 +319,20 @@ FullscreenToolbar.prototype = {
                            transition: 'easeOutQuad' });
     }
 };
+
+function OverviewToolbar() {
+    this._init();
+};
+
+OverviewToolbar.prototype = {
+    __proto__: MainToolbar.prototype,
+
+    _init: function() {
+        MainToolbar.prototype._init.call(this);
+
+        this.searchbar = new Searchbar.Searchbar();
+        this.layout.pack_start = true;
+        this.layout.pack(this.searchbar.actor, false, true, false,
+                         Clutter.BoxAlignment.CENTER, Clutter.BoxAlignment.START);
+    }
+};
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 3b9703b..aa0bc32 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -31,7 +31,6 @@ const Mainloop = imports.mainloop;
 const Config = imports.config;
 const Embed = imports.embed;
 const Global = imports.global;
-const Searchbar = imports.searchbar;
 const Selections = imports.selections;
 const Utils = imports.utils;
 const WindowMode = imports.windowMode;
@@ -103,11 +102,6 @@ MainWindow.prototype = {
 
         stage.add_actor(this._clutterBox);
 
-        // first child: searchbar filling the X axis
-        this._searchbar = new Searchbar.Searchbar();
-        this._clutterBox.add_actor(this._searchbar.actor);
-        this._clutterBoxLayout.set_fill(this._searchbar.actor, true, false);
-
         this._embed = new Embed.ViewEmbed();
         this._clutterBox.add_actor(this._embed.actor);
         this._clutterBoxLayout.set_expand(this._embed.actor, true);
@@ -160,7 +154,7 @@ MainWindow.prototype = {
 
     _onWindowModeChanged: function() {
         if (Global.modeController.getWindowMode() == WindowMode.WindowMode.PREVIEW)
-            this._searchbar.hide();
+            this._embed._toolbar.searchbar.hide();
     },
 
     _onFullscreenChanged: function(controller, fullscreen) {
@@ -209,11 +203,11 @@ MainWindow.prototype = {
         let keyval = event.get_keyval()[1];
 
         if (Utils.isSearchEvent(event)) {
-            this._searchbar.toggle();
+            this._embed._toolbar.searchbar.toggle();
             return true;
         }
 
-        if (this._searchbar.deliverEvent(event))
+        if (this._embed._toolbar.searchbar.deliverEvent(event))
             return true;
 
         if (Global.selectionController.getSelectionMode() &&
diff --git a/src/preview.js b/src/preview.js
index b699a53..1a90c83 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -202,7 +202,7 @@ PreviewEmbed.prototype = {
                                           factor: 0.95 }));
 
         // create toolbar
-        this._fsToolbar = new MainToolbar.FullscreenToolbar();
+        this._fsToolbar = new MainToolbar.PreviewToolbar();
         this._fsToolbar.setModel(model);
 
         this._layout.add(this._fsToolbar.actor,



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