[gnome-music/search] Implement search



commit 918b75316b9855fe8c02e7af666735747d1a5ff1
Author: Shivani Poddar <shivani poddar92 gmail com>
Date:   Wed Jun 26 21:22:50 2013 +0530

    Implement search
    
    https://bugzilla.gnome.org/show_bug.cgi?id=701411

 src/searchbar.js |   33 +++++++--------------------------
 src/view.js      |    7 -------
 src/window.js    |    7 ++++---
 3 files changed, 11 insertions(+), 36 deletions(-)
---
diff --git a/src/searchbar.js b/src/searchbar.js
index 61668fa..b968308 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -26,31 +26,20 @@ const Signals = imports.signals;
 
 const Searchbar = new Lang.Class({
     Name: "Searchbar",
+    Extends: Gtk.SearchBar ,
 
     _init: function() {
+        this.parent({show_close_button: false});
         this.view = null;
-
-        let frame = new Gtk.Frame({ shadow_type: Gtk.ShadowType.IN,
-                                    opacity: 0.9 });
-        frame.get_style_context().add_class('documents-dropdown');
-
-        this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL });
-        frame.add(this._grid);
-
-        this._searchEntry = new Gd.TaggedEntry();
+        this._searchEntry = new Gtk.SearchEntry();
+        this.connect_entry(this._searchEntry);
         this._searchEntry.connect("changed", Lang.bind(this, this.search_entry_changed));
-        this._grid.add(this._searchEntry)
-
-        this.widget = new Gtk.Revealer({ halign: Gtk.Align.CENTER,
-                                         valign: Gtk.Align.START });
-        this.widget.add(frame);
-
-        this.hide();
-        this.widget.show_all();
+        this._searchEntry.show();
+        this.add(this._searchEntry);
     },
 
     setViewFilter: function(model, iter, user_data) {
-        if(this._searchEntry.visible){
+        if (this._searchEntry.visible){
             let search_string = this._searchEntry.text.toLowerCase();
             let media = model.get_value(iter, 5);
             let searchable_fields = [];
@@ -72,14 +61,6 @@ const Searchbar = new Lang.Class({
         this.emit('item-activated');
     },
 
-    show: function() {
-        this.widget.reveal_child = true;
-    },
-
-    hide: function() {
-        this.widget.reveal_child = false;
-    },
-
     search_entry_changed: function() {
         this.search_term = this._searchEntry.text;
         if (this.view) {
diff --git a/src/view.js b/src/view.js
index 5cfc607..9fefa6d 100644
--- a/src/view.js
+++ b/src/view.js
@@ -108,13 +108,6 @@ const ViewContainer = new Lang.Class({
                             Lang.bind(this, this._onItemActivated));
         this._cursor = null;
         this.header_bar = header_bar;
-        this.header_bar._searchButton.connect('toggled',Lang.bind(this,function (button) {
-            if (button.get_active()) {
-                this.header_bar.get_stack()._searchBar.show()
-            } else {
-                this.header_bar.get_stack()._searchBar.hide()
-            }
-        }));
         this.header_bar._selectButton.connect('toggled',Lang.bind(this,function (button) {
             if (button.get_active()) {
                 this.view.set_selection_mode(true);
diff --git a/src/window.js b/src/window.js
index d695469..fe80704 100644
--- a/src/window.js
+++ b/src/window.js
@@ -24,7 +24,7 @@ const Gd = imports.gi.Gd;
 const Gio = imports.gi.Gio;
 const GLib = imports.gi.GLib;
 const Tracker = imports.gi.Tracker;
-
+const GObject = imports.gi.GObject;
 const Gettext = imports.gettext;
 const _ = imports.gettext.gettext;
 
@@ -110,13 +110,14 @@ const MainWindow = new Lang.Class({
         });
         this._stack._searchBar = new Searchbar.Searchbar();
         this.toolbar.set_stack(this._stack);
+        this._stack._searchBar.show();
+        this.toolbar._searchButton.bind_property("active", this._stack._searchBar, "search-mode-enabled", 
GObject.BindingFlags.BIDIRECTIONAL);
 
         this._stackOverlay = new Gtk.Overlay({ visible: true });
         this._stackOverlay.get_style_context().add_class('documents-scrolledwin');
         this._stackOverlay.add(this._stack);
-        this._stackOverlay.add_overlay(this._stack._searchBar.widget);
-
         this._box.pack_start(this.toolbar, false, false, 0);
+        this._box.pack_start(this._stack._searchBar, false, false, 0);
         this._box.pack_start(this._stackOverlay, true, true, 0);
         this._box.pack_start(this.player.eventBox, false, false, 0);
         this.add(this._box);


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