~onboard/onboard/0.99

« back to all changes in this revision

Viewing changes to Onboard/settings.py

  • Committer: marmuta
  • Date: 2013-08-18 18:00:28 UTC
  • Revision ID: marmvta@gmail.com-20130818180028-xdhfvw3i220volz2
Support XDG Base Directory Specification (LP: #1074448).

Onboard's data directory moves from ~/.onboard to the XDG data directory,
which will usually be ~/.local/share/onboard.
Existing data in either ~/.onboard or ~/.sok is migrated to the new location.

System defaults are looked up in XDG_CONFIG_HOME, XDG_CONFIG_DIRS and the
previous locations, in this order.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from Onboard.utils           import show_ask_string_dialog, \
29
29
                                    show_confirmation_dialog, \
30
30
                                    exists_in_path, \
31
 
                                    unicode_str, open_utf8
 
31
                                    unicode_str, open_utf8, \
 
32
                                    XDGDirs
32
33
 
33
34
app = "onboard"
34
35
 
319
320
                Gtk.TreeViewColumn(None, Gtk.CellRendererText(), markup=0))
320
321
 
321
322
        self.user_layout_root = os.path.join(config.user_dir, "layouts/")
322
 
        if not os.path.exists(self.user_layout_root):
323
 
            os.makedirs(self.user_layout_root)
 
323
        try:
 
324
            XDGDirs.assure_user_dir_exists(self.user_layout_root)
 
325
        except OSError as ex:
 
326
            pass
324
327
 
325
328
        self.layout_remove_button = \
326
329
                             builder.get_object("layout_remove_button")
338
341
        self.customize_theme_button = \
339
342
                                   builder.get_object("customize_theme_button")
340
343
 
341
 
        user_theme_root = Theme.user_path()
342
 
        if not os.path.exists(user_theme_root):
343
 
            os.makedirs(user_theme_root)
 
344
        try:
 
345
            XDGDirs.assure_user_dir_exists(Theme.user_path())
 
346
        except OSError as ex:
 
347
            pass
344
348
 
345
349
        self.update_themeList()
346
350
        config.theme_notify_add(self.on_theme_changed)