[gnome-music/wip/merge: 337/343] view: Set static properties of renderers in Songs view only once



commit d092071d45a501334f4fc114ac8cc51eb9b21816
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Wed Jul 24 12:06:52 2013 +0800

    view: Set static properties of renderers in Songs view only once
    
    We repeatedly set the static properties of renderers, such as xalign,
    everytime the data function of renderers are called. We could just set them
    during construction.

 gnomemusic/view.py |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index 5452c57..e4d68d5 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -333,15 +333,26 @@ class Songs(ViewContainer):
                                          "icon_name", 8)
         list_widget.insert_column(column_now_playing, 0)
 
-        title_renderer = Gtk.CellRendererText(xpad=0)
+        title_renderer = Gtk.CellRendererText(
+            xpad=0,
+            xalign=0.0,
+            yalign=0.5,
+            height=48,
+            ellipsize=Pango.EllipsizeMode.END
+        )
         list_widget.add_renderer(title_renderer,
                                  self._on_list_widget_title_render, None)
 
-        star_renderer = Gtk.CellRendererPixbuf(xpad=32)
+        star_renderer = Gtk.CellRendererPixbuf(
+            xpad=32
+        )
         list_widget.add_renderer(star_renderer,
                                  self._on_list_widget_star_render, None)
 
-        duration_renderer = Gd.StyledTextRenderer(xpad=32)
+        duration_renderer = Gd.StyledTextRenderer(
+            xpad=32,
+            xalign=1.0
+        )
         duration_renderer.add_class('dim-label')
         list_widget.add_renderer(duration_renderer,
                                  self._on_list_widget_duration_render, None)
@@ -364,10 +375,6 @@ class Songs(ViewContainer):
 
     def _on_list_widget_title_render(self, col, cell, model, itr, data):
         item = model.get_value(itr, 5)
-        cell.set_property("xalign", 0.0)
-        cell.set_property("yalign", 0.5)
-        cell.set_property("height", 48)
-        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
         cell.set_property("text", albumArtCache.get_media_title(item))
 
     def _on_list_widget_star_render(self, col, cell, model, itr, data):
@@ -383,19 +390,16 @@ class Songs(ViewContainer):
             seconds = item.get_duration()
             minutes = seconds // 60
             seconds %= 60
-            cell.set_property("xalign", 1.0)
             cell.set_property("text", "%i:%02i" % (minutes, seconds))
 
     def _on_list_widget_artist_render(self, col, cell, model, itr, data):
         item = model.get_value(itr, 5)
         if item:
-            cell.set_property("ellipsize", Pango.EllipsizeMode.END)
             cell.set_property("text", item.get_string(Grl.METADATA_KEY_ARTIST))
 
     def _on_list_widget_type_render(self, coll, cell, model, itr, data):
         item = model.get_value(itr, 5)
         if item:
-            cell.set_property("ellipsize", Pango.EllipsizeMode.END)
             cell.set_property("text", item.get_string(Grl.METADATA_KEY_ALBUM))
 
     def populate(self):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]