391d18a8c3e65d8fcbfbccf0d15f0deece192ccb
[jamaendo] / jamaui / colors.py
1 # hildon colors
2
3 import gtk
4 try:
5     import hildon
6     _using_helldon = False
7 except:
8     import helldon as hildon
9     _using_helldon = True
10
11 # See the Fremantle Master Layout Guide for more information:
12 # http://tinyurl.com/fremantle-master-layout-guide
13
14 logical_font_names = (
15     'SystemFont',
16     'EmpSystemFont',
17     'SmallSystemFont', # Used for secondary text in buttons/TreeViews
18     'EmpSmallSystemFont',
19     'LargeSystemFont', # Used for empty TreeView text
20     'X-LargeSystemFont',
21     'XX-LargeSystemFont',
22     'XXX-LargeSystemFont',
23     'HomeSystemFont',
24 )
25
26 logical_color_names = (
27     'ButtonTextColor',
28     'ButtonTextPressedColor',
29     'ButtonTextDisabledColor',
30     'ActiveTextColor', # Used for Button values, etc..
31     'SecondaryTextColor', # Used for additional/secondary information
32 )
33
34 def get_font_desc(logicalfontname):
35     settings = gtk.settings_get_default()
36     font_style = gtk.rc_get_style_by_paths(settings, logicalfontname, \
37                                                None, None)
38     if not font_style:
39         font_style = gtk.rc_get_style_by_paths(settings,
40                                                'GtkButton', 'GtkButton', gtk.Button)
41
42     font_desc = font_style.font_desc
43     return font_desc
44
45 def get_color(logicalcolorname):
46     settings = gtk.settings_get_default()
47     color_style = gtk.rc_get_style_by_paths(settings, 'GtkButton', \
48                                                 'osso-logical-colors', gtk.Button)
49
50     if not color_style:
51         font_style = gtk.rc_get_style_by_paths(settings,
52                                                'GtkButton', 'GtkButton', gtk.Button)
53     return color_style.lookup_color(logicalcolorname)
54
55 if _using_helldon:
56     def font(name):
57         return "normal"
58 else:
59     def font(name):
60         return get_font_desc(name).to_string()
61
62 if _using_helldon:
63     def color(name):
64         return "#333333"
65 else:
66     def color(name):
67         return get_color('SecondaryTextColor').to_string()
68
69 import sys
70 current_module = sys.modules[__name__]
71
72 for fnt in logical_font_names:
73     setattr(current_module, fnt, lambda: font(fnt))
74
75 for clr in logical_color_names:
76     setattr(current_module, clr, lambda: color(clr))