Commit 743cf317 authored by Marinus Schraal's avatar Marinus Schraal

searchbar: Add FilterView.ui

parent 71a28e1b
......@@ -15,30 +15,10 @@
<property name="visible">True</property>
<child>
<object class="FilterView" id="_source_filter">
<property name="activate-on-single-click">True</property>
<property name="enable-search">False</property>
<property name="headers-visible">False</property>
<property name="visible">True</property>
<signal name="row-activated" handler="_on_row_activated"/>
<child internal-child="selection">
<object class="GtkTreeSelection">
<property name="mode">none</property>
</object>
</child>
</object>
</child>
<child>
<object class="FilterView" id="_search_filter">
<property name="activate-on-single-click">True</property>
<property name="enable-search">False</property>
<property name="headers-visible">False</property>
<property name="visible">True</property>
<signal name="row-activated" handler="_on_row_activated"/>
<child internal-child="selection">
<object class="GtkTreeSelection">
<property name="mode">none</property>
</object>
</child>
</object>
</child>
</object>
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="FilterView" parent="GtkTreeView">
<property name="activate-on-single-click">True</property>
<property name="enable-search">False</property>
<property name="headers-visible">False</property>
<property name="visible">True</property>
<signal name="row-activated" handler="_on_row_activated"/>
<child internal-child="selection">
<object class="GtkTreeSelection">
<property name="mode">none</property>
</object>
</child>
</template>
</interface>
......@@ -13,6 +13,7 @@
<file preprocess="xml-stripblanks">DiscBox.ui</file>
<file preprocess="xml-stripblanks">DropDown.ui</file>
<file preprocess="xml-stripblanks">EmptyView.ui</file>
<file preprocess="xml-stripblanks">FilterView.ui</file>
<file preprocess="xml-stripblanks">PlayerToolbar.ui</file>
<file preprocess="xml-stripblanks">Searchbar.ui</file>
<file preprocess="xml-stripblanks">SelectionBarMenuButton.ui</file>
......
......@@ -149,6 +149,7 @@ class SourceManager(BaseManager):
grilo.search_source = src
@Gtk.Template(resource_path="/org/gnome/Music/FilterView.ui")
class FilterView(Gtk.TreeView):
"""TreeView for search entry items
......@@ -232,6 +233,15 @@ class FilterView(Gtk.TreeView):
if additional_func:
additional_func(col, cell, model, _iter)
@Gtk.Template.Callback()
@log
def _on_row_activated(self, filterview, path, col):
model = filterview.get_model()
id_ = model[model.get_iter(path)][BaseModelColumns.ID]
self.emit('selection-changed', self.props.manager, id_)
self.props.manager.entry.emit('changed')
@Gtk.Template(resource_path="/org/gnome/Music/DropDown.ui")
class DropDown(Gtk.Revealer):
......@@ -282,27 +292,13 @@ class DropDown(Gtk.Revealer):
@log
def _on_selection_changed(self, klass, manager, id_):
manager.active = id_
if manager == self._source_manager:
self._search_filter.props.sensitive = self._is_tracker(id_)
self.search_manager.active = (
'search_all' if id_ != 'grl-tracker-source' else '')
@Gtk.Template.Callback()
@log
def _on_row_activated(self, filterview, path, col):
model = filterview.get_model()
id_ = model[model.get_iter(path)][BaseModelColumns.ID]
manager = filterview.props.manager
manager.active = id_
if manager == self._source_manager:
is_tracker = self._is_tracker(id_)
self._search_filter.props.sensitive = is_tracker
self.search_manager.props.active = (
'search_all' if not is_tracker else '')
manager.entry.emit('changed')
@log
def _is_tracker(self, grilo_id):
return grilo_id == "grl-tracker-source"
......
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