Started work on trying to conform to hildon style guidelines
authorKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Tue, 5 Jan 2010 08:08:09 +0000 (09:08 +0100)
committerKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Wed, 6 Jan 2010 13:56:42 +0000 (14:56 +0100)
jamaui/colors.py [new file with mode: 0644]
jamaui/playerwindow.py
jamaui/playlists.py

diff --git a/jamaui/colors.py b/jamaui/colors.py
new file mode 100644 (file)
index 0000000..c17dbc9
--- /dev/null
@@ -0,0 +1,56 @@
+# hildon colors
+
+import gtk
+import hildon
+
+# See the Fremantle Master Layout Guide for more information:
+# http://tinyurl.com/fremantle-master-layout-guide
+
+logical_font_names = (
+    'SystemFont',
+    'EmpSystemFont',
+    'SmallSystemFont', # Used for secondary text in buttons/TreeViews
+    'EmpSmallSystemFont',
+    'LargeSystemFont', # Used for empty TreeView text
+    'X-LargeSystemFont',
+    'XX-LargeSystemFont',
+    'XXX-LargeSystemFont',
+    'HomeSystemFont',
+)
+
+logical_color_names = (
+    'ButtonTextColor',
+    'ButtonTextPressedColor',
+    'ButtonTextDisabledColor',
+    'ActiveTextColor', # Used for Button values, etc..
+    'SecondaryTextColor', # Used for additional/secondary information
+)
+
+def get_font_desc(logicalfontname):
+    settings = gtk.settings_get_default()
+    font_style = gtk.rc_get_style_by_paths(settings, logicalfontname, \
+                                               None, None)
+    font_desc = font_style.font_desc
+    return font_desc
+
+def get_color(logicalcolorname):
+    settings = gtk.settings_get_default()
+    color_style = gtk.rc_get_style_by_paths(settings, 'GtkButton', \
+                                                'osso-logical-colors', gtk.Button)
+    return color_style.lookup_color(logicalcolorname)
+
+def font(name):
+    return get_font_desc(name).to_string()
+
+
+def color(name):
+    return get_color('SecondaryTextColor').to_string()
+
+import sys
+current_module = sys.modules[__name__]
+
+for fnt in logical_font_names:
+    setattr(current_module, fnt, font(fnt))
+
+for clr in logical_color_names:
+    setattr(current_module, clr, color(clr))
index 2bb6598..c9b965b 100644 (file)
@@ -35,6 +35,7 @@ import cgi
 
 from songposition import SongPosition
 from listbox import ListDialog
+import colors
 log = logging.getLogger(__name__)
 
 class PlayerWindow(hildon.StackableWindow):
@@ -169,6 +170,7 @@ class PlayerWindow(hildon.StackableWindow):
     def add_stock_button(self, btns, stock, cb):
         btn = hildon.GtkButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
         btn.set_relief(gtk.RELIEF_NONE)
+        btn.set_focus_on_click(False)
         sz = gtk.ICON_SIZE_BUTTON
         btn.set_image(gtk.image_new_from_stock(stock, sz))
         btn.connect('clicked', cb)
@@ -199,14 +201,15 @@ class PlayerWindow(hildon.StackableWindow):
             self.playbtn.set_data('state', 'play')
 
     def set_labels(self, track, artist, album, playlist_pos, playlist_size):
+
         if self.playlist.radio_mode:
             ppstr = '<span size="small">Radio: %s</span>'%(cgi.escape(self.playlist.radio_name))
         else:
-            ppstr = '<span size="small">Track %s of %s</span>'%(int(playlist_pos)+1, playlist_size)
+            ppstr = '<span font_desc="%s" foreground="%s">Track %s of %s</span>'%(colors.SmallSystemFont, colors.SecondaryTextColor, int(playlist_pos)+1, playlist_size)
         self.playlist_pos.set_markup(ppstr)
-        self.track.set_markup('<span size="x-large">%s</span>'%(cgi.escape(track)))
-        self.artist.set_markup('<span size="large">%s</span>'%(cgi.escape(artist)))
-        self.album.set_markup('<span foreground="#aaaaaa">%s</span>'%(cgi.escape(album)))
+        self.track.set_markup('<span font_desc="%s">%s</span>'%(colors.LargeSystemFont, cgi.escape(track)))
+        self.artist.set_markup('%s'%(cgi.escape(artist)))
+        self.album.set_markup('<span foreground="%s">%s</span>'%(colors.SecondaryTextColor, cgi.escape(album)))
 
     def show_banner(self, message, timeout = 2000):
         banner = hildon.hildon_banner_show_information(self, '', message)
index 714ec55..ece1527 100644 (file)
@@ -113,6 +113,7 @@ class PlaylistsWindow(hildon.StackableWindow):
         col = gtk.TreeViewColumn('Info')
         self.treeview.append_column(col)
         cell = gtk.CellRendererText()
+        cell.set_property('xalign', 1.0)
         col.pack_start(cell, True)
         col.add_attribute(cell, 'text', self.COL_INFO)