Skip to content

Commit

Permalink
refactor(settings): split into app and ui settings (friendlier to git…
Browse files Browse the repository at this point in the history
…-managed dotfiles)
  • Loading branch information
actionless committed Dec 28, 2018
1 parent fb894a7 commit e5028b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions oomox_gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
THEME_PLUGINS, ICONS_PLUGINS, IMPORT_PLUGINS, EXPORT_PLUGINS,
)
from .plugin_api import PLUGIN_PATH_PREFIX
from .settings import SETTINGS
from .settings import UI_SETTINGS


class NewDialog(EntryDialog):
Expand Down Expand Up @@ -448,14 +448,14 @@ def _on_export_plugin(self, action, _param=None):

def _on_quit(self, _arg1, _arg2):
self.check_unsaved_changes()
SETTINGS.save()
UI_SETTINGS.save()

def _on_show_help(self, _action, _param=None):
self.show_help()

def _on_pane_resize(self, _action, _param=None):
position = self.paned_box.get_position()
SETTINGS.preset_list_width = position
UI_SETTINGS.preset_list_width = position

###########################################################################
# Init widgets:
Expand Down Expand Up @@ -580,7 +580,7 @@ def _init_window(self):
self.set_wmclass("oomox", "Oomox")
self.set_role("Oomox-GUI")
self.connect("delete-event", self._on_quit)
self.set_default_size(width=600, height=400)
self.set_default_size(width=600, height=400) # @TODO: save in ui-settings
self.set_hide_titlebar_when_maximized(False)

self._init_headerbar()
Expand Down Expand Up @@ -642,7 +642,7 @@ def __init__(self, application):
self.theme_edit.hide_all_rows()
self.preview.hide()

self.paned_box.set_position(SETTINGS.preset_list_width)
self.paned_box.set_position(UI_SETTINGS.preset_list_width)
self.paned_box.connect("notify::position", self._on_pane_resize)


Expand Down
9 changes: 5 additions & 4 deletions oomox_gui/presets_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class Keys:


class Settings:
# @TODO: move to real settings
presets_list_system_expanded = True
presets_list_plugins_expanded = True
presets_list_user_expanded = True


SETTINGS = Settings()
UI_SETTINGS = Settings()
PRESET_LIST_MIN_SIZE = 250

_SECTION_RESERVED_NAME = '<section>'
Expand Down Expand Up @@ -149,7 +150,7 @@ def _load_system_presets(self, all_presets):
colors_dir=COLORS_DIR, preset_dir=preset_dir, preset_list=preset_list,
parent=presets_iter
)
if SETTINGS.presets_list_system_expanded:
if UI_SETTINGS.presets_list_system_expanded:
self.treeview.expand_row(self.treestore.get_path(presets_iter), False)

def _load_plugin_presets(self, all_presets):
Expand All @@ -176,7 +177,7 @@ def _load_plugin_presets(self, all_presets):
colors_dir=plugin_theme_dir, preset_dir=preset_dir, preset_list=preset_list,
plugin_name=plugin_display_name, parent=plugins_iter
)
if SETTINGS.presets_list_plugins_expanded:
if UI_SETTINGS.presets_list_plugins_expanded:
self.treeview.expand_row(self.treestore.get_path(plugins_iter), False)

def _load_user_presets(self, all_presets):
Expand All @@ -188,7 +189,7 @@ def _load_user_presets(self, all_presets):
colors_dir=USER_COLORS_DIR, preset_dir=preset_dir, preset_list=preset_list,
parent=user_presets_iter
)
if SETTINGS.presets_list_user_expanded:
if UI_SETTINGS.presets_list_user_expanded:
self.treeview.expand_row(self.treestore.get_path(user_presets_iter), False)

def load_presets(self):
Expand Down
6 changes: 5 additions & 1 deletion oomox_gui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ def __setattr__(self, item, value):
super().__setattr__(item, value)


UI_SETTINGS = OomoxSettings(
config_name='ui_config', default_config=dict(
preset_list_width=PRESET_LIST_MIN_SIZE
)
)
SETTINGS = OomoxSettings(
config_name='app_config', default_config=dict(
preset_list_width=PRESET_LIST_MIN_SIZE
)
)

0 comments on commit e5028b4

Please sign in to comment.