1 """ Stuff that works a bit differently depending on whether we're running in
2 a ROX or GNOME environment.
12 global get_app_info
, get_logo
, quit
, load_first_config
, save_config_path
13 get_app_info
= get_app_info_rox
14 get_logo
= get_logo_rox
16 load_first_config
= load_first_config_rox
17 save_config_path
= save_config_path_rox
21 global get_app_info
, get_logo
, quit
, load_first_config
, save_config_path
22 get_app_info
= get_app_info_gnome
23 get_logo
= get_logo_gnome
25 load_first_config
= load_first_config_gnome
26 save_config_path
= save_config_path_gnome
29 def get_app_info_rox():
31 from rox
import AppInfo
34 app_info
= AppInfo
.AppInfo(os
.path
.join(rox
.app_dir
, 'AppInfo.xml'))
35 _app_info
= (app_info
.getAuthors(),
36 app_info
.findElements('Version')[0].firstChild
.nodeValue
.split()[0])
40 def get_logo_rox(size
= 64):
42 return g
.gdk
.pixbuf_new_from_file_at_size( \
43 os
.path
.join(rox
.app_dir
, '.DirIcon'), size
, size
)
52 def load_first_config_rox(uri
, appname
, leafname
):
53 from rox
import basedir
54 return basedir
.load_first_config(uri
, appname
, leafname
)
57 def save_config_path_rox(uri
, appname
):
58 from rox
import basedir
59 return basedir
.save_config_path(uri
, appname
)
62 def get_app_info_gnome():
68 fp
= open(os
.path
.join(prefix
.share_dir
, 'AppInfo.xml'))
69 for l
in fp
.readlines():
71 version
= l
.split('>', 1)[1].split(' ', 1)[0]
74 elif '<Authors>' in l
:
75 authors
= l
.split('>', 1)[1].split('<', 1)[0]
79 _app_info
= (authors
, version
)
83 def get_logo_gnome(size
= 64):
85 return g
.gdk
.pixbuf_new_from_file_at_size( \
86 os
.path
.join(prefix
.icons_dir
, 'sysbars.svg'),
94 def _xdg_config_home():
95 return os
.path
.expanduser(os
.environ
.get('XDG_CONFIG_HOME', '~/.config'))
98 def load_first_config_gnome(uri
, appname
, leafname
):
99 for d
in [_xdg_config_home()] + \
100 os
.environ
.get('XDG_CONFIG_DIRS', '/etc/xdg').split(':'):
101 f
= os
.path
.join(d
, uri
, appname
, leafname
)
102 if os
.path
.exists(f
):
107 def save_config_path_gnome(uri
, appname
):
108 d
= os
.path
.join(_xdg_config_home(), uri
, appname
)
109 if not os
.path
.isdir(d
):