[gnome-music] Support tags removal
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Support tags removal
- Date: Mon, 12 May 2014 08:45:42 +0000 (UTC)
commit 81ce102ae26790cf0b2afe30580fdf6ded7c9e8f
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Tue Oct 8 12:43:30 2013 +0200
Support tags removal
gnomemusic/searchbar.py | 48 ++++++++++++++++++++++++++--------------------
gnomemusic/toolbar.py | 1 +
2 files changed, 28 insertions(+), 21 deletions(-)
---
diff --git a/gnomemusic/searchbar.py b/gnomemusic/searchbar.py
index fda7981..400b06f 100644
--- a/gnomemusic/searchbar.py
+++ b/gnomemusic/searchbar.py
@@ -68,40 +68,41 @@ class FilterView():
class DropDown(Gd.Revealer):
- searchbar = None
-
def __init__(self):
Gd.Revealer.__init__(self, halign=Gtk.Align.CENTER, valign=Gtk.Align.START)
self._grid = Gtk.Grid(orientation=Gtk.Orientation.HORIZONTAL)
- sourcesManager = BaseManager('source', "Sources")
+ frame = Gtk.Frame(shadow_type=Gtk.ShadowType.IN, opacity=0.9)
+ frame.get_style_context().add_class('documents-dropdown')
+ frame.add(self._grid)
+ frame.show_all()
+
+ self.add(frame)
+
+ def initialize_filters(self, searchbar):
+ sourcesManager = BaseManager('source', "Sources", searchbar._search_entry)
sourcesFilter = FilterView(sourcesManager, self)
self._grid.add(sourcesFilter.view)
- searchFieldsManager = BaseManager('search', "Search By")
+ searchFieldsManager = BaseManager('search', "Search By", searchbar._search_entry)
searchFieldsFilter = FilterView(searchFieldsManager, self)
self._grid.add(searchFieldsFilter.view)
self._grid.show_all()
- frame = Gtk.Frame(shadow_type=Gtk.ShadowType.IN, opacity=0.9)
- frame.get_style_context().add_class('documents-dropdown')
- frame.add(self._grid)
- frame.show_all()
-
- self.add(frame)
-
def do_select(self, manager, id):
manager.set_active(id)
- self.searchbar._search_entry.add_tag(manager.tag)
+
class BaseManager:
- def __init__(self, id, label):
+ def __init__(self, id, label, entry):
self.id = id
self.label = label
+ self.entry = entry
self.tag = Gd.TaggedEntryTag()
+ self.tag.manager = self
def fill_in_values(self, model):
self.values = []
@@ -132,7 +133,17 @@ class BaseManager:
if selected_value != []:
selected_value = selected_value[0]
self.selected_id = selected_value[BaseModelColumns.ID]
- self.tag.set_label(selected_value[BaseModelColumns.NAME])
+
+ # If selected values has non-empty HEADING_TEXT then it is a default value
+ # No need to set the tag there
+ if selected_value[BaseModelColumns.HEADING_TEXT] == "":
+ self.entry.add_tag(self.tag)
+ self.tag.set_label(selected_value[BaseModelColumns.NAME])
+ else:
+ self.entry.remove_tag(self.tag)
+
+ def reset_to_default(self):
+ self.set_active(self.values[0][BaseModelColumns.ID])
class Searchbar(Gd.Revealer):
@@ -144,7 +155,6 @@ class Searchbar(Gd.Revealer):
self.stack_switcher = stack_switcher
self._search_button = search_button
self.dropdown = dropdown
- self.dropdown.searchbar = self
self._searchContainer = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, halign=Gtk.Align.CENTER)
self._searchContainer.get_style_context().add_class('linked')
@@ -163,7 +173,6 @@ class Searchbar(Gd.Revealer):
self._dropDownButton.show_all()
self._searchContainer.add(self._dropDownButton)
- self._search_entry.connect("tag-clicked", self._search_entry_tag_clicked)
self._search_entry.connect("tag-button-clicked", self._search_entry_tag_button_clicked)
self._searchContainer.show_all()
@@ -184,11 +193,8 @@ class Searchbar(Gd.Revealer):
def _drop_down_button_toggled(self, *args):
self.dropdown.set_reveal_child(self._dropDownButton.get_active())
- def _search_entry_tag_clicked(self, *args):
- print("search_entry_tag_clicked")
-
- def _search_entry_tag_button_clicked(self, *args):
- print("search_entry_tag_button_clicked")
+ def _search_entry_tag_button_clicked(self, entry, tag):
+ tag.manager.reset_to_default()
def set_view_filter(self, model, itr, user_data):
if self._search_entry.get_property("visible"):
diff --git a/gnomemusic/toolbar.py b/gnomemusic/toolbar.py
index f9c2fcd..d3dc718 100644
--- a/gnomemusic/toolbar.py
+++ b/gnomemusic/toolbar.py
@@ -65,6 +65,7 @@ class Toolbar(GObject.GObject):
self._search_button = self._ui.get_object('search-button')
self.dropdown = DropDown()
self.searchbar = Searchbar(self._stack_switcher, self._search_button, self.dropdown)
+ self.dropdown.initialize_filters(self.searchbar)
self._select_button = self._ui.get_object('select-button')
self._cancel_button = self._ui.get_object('done-button')
self._back_button = self._ui.get_object('back-button')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]