Commit 4276c5ae authored by Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto Committed by Marinus Schraal

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
parent 2f9f122c
......@@ -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())
......@@ -458,13 +458,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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment