[Sugar-devel] [PATCH] Implement filter in favorites view - v2
godiard at sugarlabs.org
godiard at sugarlabs.org
Thu Aug 18 13:46:46 EDT 2011
From: Gonzalo Odiard <godiard at gmail.com>
The icons of non selected activities are painted in light gray
like in the neighborhood view. The user can interact with them
because are not disabled, the filter only highligt the selected activities.
Signed-of-by: Gonzalo Odiard <gonzalo at laptop.org>
---
src/jarabe/desktop/favoritesview.py | 18 +++++++++++++++---
src/jarabe/desktop/homebox.py | 22 +++++++++-------------
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py
index b609b1b..2ae44c6 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -110,6 +110,16 @@ class FavoritesView(hippo.Canvas):
favorites_settings.changed.connect(self.__settings_changed_cb)
self._set_layout(favorites_settings.layout)
+ def set_filter(self, query):
+ for icon in self._box.get_children():
+ if icon not in [self._my_icon, self._current_activity]:
+ activity_name = icon._activity_info.get_name().lower()
+ if activity_name.find(query) > -1:
+ icon.props.xo_color = icon.icon_color
+ else:
+ icon.props.xo_color = XoColor('#D5D5D5,%s' %
+ style.COLOR_TRANSPARENT.get_svg())
+
def __settings_changed_cb(self, **kwargs):
favorites_settings = get_settings()
self._set_layout(favorites_settings.layout)
@@ -362,6 +372,7 @@ class ActivityIcon(CanvasIcon):
self._journal_entries = []
self._hovering = False
self._resume_mode = True
+ self.icon_color = None
self.connect('hovering-changed', self.__hovering_changed_event_cb)
self.connect('button-release-event', self.__button_release_event_cb)
@@ -414,11 +425,12 @@ class ActivityIcon(CanvasIcon):
def _update(self):
self.palette = None
if not self._resume_mode or not self._journal_entries:
- xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
+ self.icon_color = XoColor('%s,%s' %
+ (style.COLOR_BUTTON_GREY.get_svg(),
style.COLOR_TRANSPARENT.get_svg()))
else:
- xo_color = misc.get_icon_color(self._journal_entries[0])
- self.props.xo_color = xo_color
+ self.icon_color = misc.get_icon_color(self._journal_entries[0])
+ self.props.xo_color = self.icon_color
def create_palette(self):
palette = FavoritePalette(self._activity_info, self._journal_entries)
diff --git a/src/jarabe/desktop/homebox.py b/src/jarabe/desktop/homebox.py
index 661326e..2ee6ae7 100644
--- a/src/jarabe/desktop/homebox.py
+++ b/src/jarabe/desktop/homebox.py
@@ -55,6 +55,7 @@ class HomeBox(gtk.VBox):
self._toolbar.show()
self._set_view(_FAVORITES_VIEW)
+ self._query = ''
def show_software_updates_alert(self):
alert = Alert()
@@ -103,8 +104,9 @@ class HomeBox(gtk.VBox):
panel.set_section_view_auto_close()
def __toolbar_query_changed_cb(self, toolbar, query):
- query = query.lower()
- self._list_view.set_filter(query)
+ self._query = query.lower()
+ self._list_view.set_filter(self._query)
+ self._favorites_view.set_filter(self._query)
def __toolbar_view_changed_cb(self, toolbar, view):
self._set_view(view)
@@ -145,6 +147,9 @@ class HomeBox(gtk.VBox):
def set_resume_mode(self, resume_mode):
self._favorites_view.set_resume_mode(resume_mode)
+ if resume_mode and self._query != '':
+ self._list_view.set_filter(self._query)
+ self._favorites_view.set_filter(self._query)
class HomeToolbar(gtk.Toolbar):
@@ -177,7 +182,6 @@ class HomeToolbar(gtk.Toolbar):
self.search_entry.connect('activate', self.__entry_activated_cb)
self.search_entry.connect('changed', self.__entry_changed_cb)
tool_item.add(self.search_entry)
- self.search_entry.set_sensitive(False)
self.search_entry.show()
self._add_separator(expand=True)
@@ -201,14 +205,8 @@ class HomeToolbar(gtk.Toolbar):
def __view_button_toggled_cb(self, button, view):
if button.props.active:
- if view == _FAVORITES_VIEW:
- self.search_entry.set_text('')
- self.search_entry.set_sensitive(False)
- self.emit('view-changed', view)
- else:
- self.search_entry.set_sensitive(True)
- self.search_entry.grab_focus()
- self.emit('view-changed', view)
+ self.search_entry.grab_focus()
+ self.emit('view-changed', view)
def _add_separator(self, expand=False):
separator = gtk.SeparatorToolItem()
@@ -228,8 +226,6 @@ class HomeToolbar(gtk.Toolbar):
if self._query != new_query:
self._query = new_query
- if self._query is not '':
- self._list_button.props.active = True
self.emit('query-changed', self._query)
def __entry_changed_cb(self, entry):
--
1.7.4.4
More information about the Sugar-devel
mailing list