[gnome-music/search] Display search field
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/search] Display search field
- Date: Sat, 22 Jun 2013 00:55:14 +0000 (UTC)
commit 879e4ff587bff93637fe9c0641951dafd0e1994c
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Sat Jun 22 02:54:54 2013 +0200
Display search field
configure.ac | 2 +-
src/searchbar.js | 111 ++++++++++--------------------------------------------
src/toolbar.js | 4 +-
src/view.js | 7 +++
src/window.js | 10 ++++-
5 files changed, 38 insertions(+), 96 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2af9e80..f0cb6c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT([disable-static])
-LIBGD_INIT([header-bar main-toolbar main-view stack revealer gir])
+LIBGD_INIT([header-bar main-toolbar main-view stack gir tagged-entry])
PKG_PROG_PKG_CONFIG([0.22])
diff --git a/src/searchbar.js b/src/searchbar.js
index 3203f5d..fa175a0 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -22,111 +22,40 @@ const Lang = imports.lang;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Gd = imports.gi.Gd;
+const Signals = imports.signals;
const Searchbar = new Lang.Class({
Name: "Searchbar",
-
- actor: function() { return this._eventbox; },
-
- _eventbox: null,
-
- _search_entry: null,
-
- _init: function() {
- this._setup_ui();
- },
-
- _setup_ui: function() {
- this._eventbox = new Gtk.EventBox();
- //this._eventbox.margin_top = 5;
- //this._eventbox.margin_bottom = 5;
-
- let container = new Gd.MarginContainer();
- //container.min_margin = 64;
- //container.max_margin = 128;
- this._eventbox.add (container);
-
- let box = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing : 0});
- container.add(box);
-
- this._search_entry = new Gd.TaggedEntry();
- this._search_entry.hexpand = true;
- this._search_entry.key_press_event.connect (on_search_entry_key_pressed);
- this._search_entry.changed.connect (on_search_entry_changed);
- this._search_entry.tag_clicked.connect (on_search_entry_tag_clicked);
- box.add (this._search_entry);
-
- this._eventbox.show_all();
- },
-
- _on_search_entry_key_pressed: function(e) {
- let keyval = e.keyval;
-
- if(keyval == Gdk.Key.Escape) {
- //App.app.search_mode = false;
- return true;
- }
-
- return false;
- },
-
- _on_search_entry_changed: function() {
- debug("2");
- },
-
- _on_search_entry_tag_clicked: function() {
- debug("3");
- },
-
- show: function() {
- this.actor.show();
- },
-
- hide: function() {
- this.actor.hide();
- },
-
- grab_focus: function() {
- this._search_entry.grab_focus();
- },
-
-});
-
-const Dropdown = new Lang.Class({
- Name: 'Dropdown',
_init: function() {
- this._sourceView = new Manager.BaseView(Application.sourceManager);
- this._typeView = new Manager.BaseView(Application.searchTypeManager);
- this._matchView = new Manager.BaseView(Application.searchMatchManager);
- // TODO: this is out for now, but should we move it somewhere
- // else?
- // this._categoryView = new Manager.BaseView(Application.searchCategoryManager);
-
- this._sourceView.connect('item-activated',
- Lang.bind(this, this._onItemActivated));
- this._typeView.connect('item-activated',
- Lang.bind(this, this._onItemActivated));
- this._matchView.connect('item-activated',
- Lang.bind(this, this._onItemActivated));
-
let frame = new Gtk.Frame({ shadow_type: Gtk.ShadowType.IN,
opacity: 0.9 });
frame.get_style_context().add_class('documents-dropdown');
- this.widget = new Gd.Revealer({ halign: Gtk.Align.CENTER,
- valign: Gtk.Align.START });
- this.widget.add(frame);
-
this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL });
frame.add(this._grid);
- this._grid.add(this._sourceView.widget);
- this._grid.add(this._typeView.widget);
- this._grid.add(this._matchView.widget);
- //this._grid.add(this._categoryView.widget);
+ this._searchEntry = new Gd.TaggedEntry();
+ 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();
},
+
+ _onItemActivated: function() {
+ this.emit('item-activated');
+ },
+
+ show: function() {
+ this.widget.reveal_child = true;
+ },
+
+ hide: function() {
+ this.widget.reveal_child = false;
+ }
});
+Signals.addSignalMethods(Searchbar.prototype);
diff --git a/src/toolbar.js b/src/toolbar.js
index 01bf21a..fca41ee 100644
--- a/src/toolbar.js
+++ b/src/toolbar.js
@@ -30,8 +30,6 @@ const Signals = imports.signals;
const Gettext = imports.gettext;
const _ = imports.gettext.gettext;
-const Searchbar = imports.searchbar;
-
const ToolbarState = {
SINGLE: 0,
ALBUMS: 1,
@@ -106,7 +104,7 @@ const Toolbar = new Lang.Class({
},
_addSearchButton: function() {
- this._searchButton = new Gd.HeaderSimpleButton({ symbolic_icon_name: 'folder-saved-search-symbolic',
+ this._searchButton = new Gd.HeaderToggleButton({ symbolic_icon_name: 'folder-saved-search-symbolic',
label: _("Search") });
this.pack_end(this._searchButton);
this._searchButton.show();
diff --git a/src/view.js b/src/view.js
index 5c26220..acc2fdd 100644
--- a/src/view.js
+++ b/src/view.js
@@ -107,6 +107,13 @@ 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._searchBar.show()
+ } else {
+ this.header_bar._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 715836e..b7005fb 100644
--- a/src/window.js
+++ b/src/window.js
@@ -29,6 +29,7 @@ const Gettext = imports.gettext;
const _ = imports.gettext.gettext;
const Toolbar = imports.toolbar;
+const Searchbar = imports.searchbar;
const Views = imports.view;
const Player = imports.player;
const Query = imports.query;
@@ -69,8 +70,15 @@ const MainWindow = new Lang.Class({
});
this.toolbar.set_stack(this._stack);
+ this.toolbar._searchBar = new Searchbar.Searchbar();
+
+ 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.toolbar._searchBar.widget);
+
this._box.pack_start(this.toolbar, false, false, 0);
- this._box.pack_start(this._stack, true, true, 0);
+ this._box.pack_start(this._stackOverlay, true, true, 0);
this._box.pack_start(this.player.eventBox, false, false, 0);
this.add(this._box);
let count = -1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]