[gnome-music/wip/gbsneto/flowbox: 6/7] searchbar: turn into a GtkSearchBar subclass
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/gbsneto/flowbox: 6/7] searchbar: turn into a GtkSearchBar subclass
- Date: Sun, 14 Aug 2016 00:07:25 +0000 (UTC)
commit 33918603b53bb0ee16039fac871ccf7009e6527f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Aug 11 17:54:34 2016 -0300
searchbar: turn into a GtkSearchBar subclass
Gtk already ships a widget that is ideal to use
on search. GNOME Music, however, uses a toolbar
and add the search widgets as toolbar items, which
causes various flaws on the UI - the major one
being not looking like a searchbar anymore.
This patch makes the searchbar a GtkSearchBar subclass
and adapts the code to treat it as such.
https://bugzilla.gnome.org/show_bug.cgi?id=769772
gnomemusic/searchbar.py | 17 ++++-------------
gnomemusic/window.py | 10 ++++++++--
2 files changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/gnomemusic/searchbar.py b/gnomemusic/searchbar.py
index ef4f499..897f63e 100644
--- a/gnomemusic/searchbar.py
+++ b/gnomemusic/searchbar.py
@@ -243,7 +243,7 @@ class DropDown(Gtk.Revealer):
self.searchFieldsFilter.view.set_sensitive(id == 'grl-tracker-source')
-class Searchbar(Gtk.Revealer):
+class Searchbar(Gtk.SearchBar):
def __repr__(self):
return '<Searchbar>'
@@ -275,16 +275,7 @@ class Searchbar(Gtk.Revealer):
self._search_entry.connect("tag-button-clicked", self._search_entry_tag_button_clicked)
self._searchContainer.show_all()
- toolbar = Gtk.Toolbar()
- toolbar.get_style_context().add_class("search-bar")
- toolbar.show()
- self.add(toolbar)
-
- item = Gtk.ToolItem()
- item.set_expand(True)
- item.show()
- toolbar.insert(item, 0)
- item.add(self._searchContainer)
+ self.add(self._searchContainer)
@log
def _drop_down_button_toggled(self, *args):
@@ -323,7 +314,7 @@ class Searchbar(Gtk.Revealer):
@log
def show_bar(self, show, clear=True):
- self.set_reveal_child(show)
+ self.set_search_mode(show)
self._search_button.set_active(show)
if show:
@@ -336,4 +327,4 @@ class Searchbar(Gtk.Revealer):
@log
def toggle_bar(self):
- self.show_bar(not self.get_child_revealed())
+ self.show_bar(not self.get_search_mode())
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 8de1240..d556e19 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -193,6 +193,11 @@ class Window(Gtk.ApplicationWindow):
transition_duration=100,
visible=True,
can_focus=False)
+
+ # Add the 'background' styleclass so it properly hides the
+ # bottom line of the searchbar
+ self._stack.get_style_context().add_class('background')
+
self._overlay = Gtk.Overlay(child=self._stack)
self._overlay.add_overlay(self.toolbar.dropdown)
self.set_titlebar(self.toolbar.header_bar)
@@ -392,13 +397,14 @@ class Window(Gtk.ApplicationWindow):
# Open search bar when typing printable chars if it not opened
# Make sure we skip unprintable chars and don't grab space press
# (this is used for play/pause)
- if not self.toolbar.searchbar.get_reveal_child() and not event.keyval == Gdk.KEY_space:
+ if (not self.toolbar.searchbar.get_search_mode()
+ and not event.keyval == Gdk.KEY_space):
if (event_and_modifiers == Gdk.ModifierType.SHIFT_MASK or
event_and_modifiers == 0) and \
GLib.unichar_isprint(chr(Gdk.keyval_to_unicode(event.keyval))):
self.toolbar.searchbar.show_bar(True)
else:
- if not self.toolbar.searchbar.get_reveal_child():
+ if not self.toolbar.searchbar.get_search_mode():
if event.keyval == Gdk.KEY_space and self.player.actionbar.get_visible():
if self.get_focus() != self.player.playBtn:
self.player.play_pause()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]