[Sugar-devel] [sugar] Show summary information in the activities list view - v2

godiard at sugarlabs.org godiard at sugarlabs.org
Thu Sep 20 11:34:27 EDT 2012


From: Gonzalo Odiard <godiard at gmail.com>

The listview and the favoritesview are sorted by the localized activity name
instead of installation time. The installation time is not used anymore
and was removed. The search is done now in the title and in the summary fields.
The version column is moved at the right.

A pending issue is the space between columns, probably should be set in the theme.

Signed-off-by: Gonzalo Odiard <gonzalo at laptop.org>
---
 src/jarabe/desktop/activitieslist.py  | 36 +++++++++++++++++------------------
 src/jarabe/desktop/favoriteslayout.py |  9 +++++----
 src/jarabe/desktop/favoritesview.py   |  4 ----
 3 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/src/jarabe/desktop/activitieslist.py b/src/jarabe/desktop/activitieslist.py
index b111164..1dd4e75 100644
--- a/src/jarabe/desktop/activitieslist.py
+++ b/src/jarabe/desktop/activitieslist.py
@@ -26,7 +26,6 @@ from gi.repository import GConf
 from gi.repository import Gtk
 from gi.repository import Gdk
 
-from sugar3 import util
 from sugar3.graphics import style
 from sugar3.graphics.icon import Icon, CellRendererIcon
 from sugar3.graphics.xocolor import XoColor
@@ -79,29 +78,28 @@ class ActivitiesTreeView(Gtk.TreeView):
         self.append_column(column)
 
         cell_text = Gtk.CellRendererText()
-        cell_text.props.ellipsize = Pango.EllipsizeMode.MIDDLE
-        cell_text.props.ellipsize_set = True
 
         column = Gtk.TreeViewColumn()
         column.props.sizing = Gtk.TreeViewColumnSizing.GROW_ONLY
-        column.props.expand = True
         column.set_sort_column_id(ListModel.COLUMN_TITLE)
         column.pack_start(cell_text, True)
         column.add_attribute(cell_text, 'markup', ListModel.COLUMN_TITLE)
         self.append_column(column)
 
         cell_text = Gtk.CellRendererText()
-        cell_text.props.xalign = 1
+        cell_text.props.xalign = 0
+        cell_text.props.wrap_width = int(Gdk.Screen.width() / 3)
+        cell_text.props.wrap_mode = Pango.WrapMode.WORD
 
         column = Gtk.TreeViewColumn()
-        column.set_alignment(1)
         column.props.sizing = Gtk.TreeViewColumnSizing.GROW_ONLY
         column.props.resizable = True
         column.props.reorderable = True
         column.props.expand = True
-        column.set_sort_column_id(ListModel.COLUMN_VERSION)
+        column.props.max_width = int(Gdk.Screen.width() / 3)
+        column.set_sort_column_id(ListModel.COLUMN_SUMMARY)
         column.pack_start(cell_text, True)
-        column.add_attribute(cell_text, 'text', ListModel.COLUMN_VERSION_TEXT)
+        column.add_attribute(cell_text, 'text', ListModel.COLUMN_SUMMARY)
         self.append_column(column)
 
         cell_text = Gtk.CellRendererText()
@@ -112,10 +110,9 @@ class ActivitiesTreeView(Gtk.TreeView):
         column.props.sizing = Gtk.TreeViewColumnSizing.GROW_ONLY
         column.props.resizable = True
         column.props.reorderable = True
-        column.props.expand = True
-        column.set_sort_column_id(ListModel.COLUMN_DATE)
+        column.set_sort_column_id(ListModel.COLUMN_VERSION)
         column.pack_start(cell_text, True)
-        column.add_attribute(cell_text, 'text', ListModel.COLUMN_DATE_TEXT)
+        column.add_attribute(cell_text, 'text', ListModel.COLUMN_VERSION_TEXT)
         self.append_column(column)
 
         self.set_search_column(ListModel.COLUMN_TITLE)
@@ -160,7 +157,10 @@ class ActivitiesTreeView(Gtk.TreeView):
 
     def __model_visible_cb(self, model, tree_iter, data):
         title = model[tree_iter][ListModel.COLUMN_TITLE]
-        return title is not None and title.lower().find(self._query) > -1
+        summary = model[tree_iter][ListModel.COLUMN_SUMMARY]
+        return title is not None and title.lower().find(self._query) > -1 \
+                or summary is not None and \
+                summary.lower().find(self._query) > -1
 
 
 class ListModel(Gtk.TreeModelSort):
@@ -172,13 +172,13 @@ class ListModel(Gtk.TreeModelSort):
     COLUMN_TITLE = 3
     COLUMN_VERSION = 4
     COLUMN_VERSION_TEXT = 5
-    COLUMN_DATE = 6
-    COLUMN_DATE_TEXT = 7
+    COLUMN_SUMMARY = 6
 
     def __init__(self):
-        self._model = Gtk.ListStore(str, bool, str, str, str, str, int, str)
+        self._model = Gtk.ListStore(str, bool, str, str, str, str, str)
         self._model_filter = self._model.filter_new()
         Gtk.TreeModelSort.__init__(self, model=self._model_filter)
+        self.set_sort_column_id(ListModel.COLUMN_TITLE, Gtk.SortType.ASCENDING)
 
         GObject.idle_add(self.__connect_to_bundle_registry_cb)
 
@@ -216,7 +216,6 @@ class ListModel(Gtk.TreeModelSort):
         if activity_info.get_bundle_id() == 'org.laptop.JournalActivity':
             return
 
-        timestamp = activity_info.get_installation_time()
         version = activity_info.get_activity_version()
 
         registry = bundleregistry.get_registry()
@@ -232,14 +231,15 @@ class ListModel(Gtk.TreeModelSort):
                     '<span style="italic" weight="light">%s</span>' % \
                             (activity_info.get_name(), tags)
 
+        summary = activity_info.get_summary()
+
         self._model.append([activity_info.get_bundle_id(),
                             favorite,
                             activity_info.get_icon(),
                             title,
                             version,
                             _('Version %s') % version,
-                            int(timestamp),
-                            util.timestamp_to_elapsed_string(timestamp)])
+                            summary])
 
     def set_visible_func(self, func):
         self._model_filter.set_visible_func(func)
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
index a367ab6..979cfa4 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -387,11 +387,12 @@ class RingLayout(ViewLayout):
             child.size_allocate(child_allocation)
 
     def compare_activities(self, icon_a, icon_b):
-        if hasattr(icon_a, 'installation_time') and \
-                hasattr(icon_b, 'installation_time'):
-            return int(icon_b.installation_time - icon_a.installation_time)
-        else:
+        if icon_a.get_activity_name() == icon_b.get_activity_name():
             return 0
+        if icon_a.get_activity_name() > icon_b.get_activity_name():
+            return 1
+        else:
+            return -1
 
 
 _SUNFLOWER_CONSTANT = style.STANDARD_ICON_SIZE * .75
diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py
index b73d016..5dea6a6 100644
--- a/src/jarabe/desktop/favoritesview.py
+++ b/src/jarabe/desktop/favoritesview.py
@@ -494,10 +494,6 @@ class ActivityIcon(EventIcon):
     def get_activity_name(self):
         return self._activity_info.get_name()
 
-    def _get_installation_time(self):
-        return self._activity_info.get_installation_time()
-    installation_time = property(_get_installation_time, None)
-
     def _get_fixed_position(self):
         registry = bundleregistry.get_registry()
         return registry.get_bundle_position(self.bundle_id, self.version)
-- 
1.7.11.4



More information about the Sugar-devel mailing list