[pitivi] preferences: Add methods to reload settings pages and remove a section
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] preferences: Add methods to reload settings pages and remove a section
- Date: Mon, 28 Aug 2017 22:07:51 +0000 (UTC)
commit ddc692133f9af2391bc4cdd0ad64750dc09dc09e
Author: Fabian Orccon <cfoch fabian gmail com>
Date: Wed Aug 16 16:33:15 2017 -0500
preferences: Add methods to reload settings pages and remove a section
Differential Revision: https://phabricator.freedesktop.org/D1853
pitivi/dialogs/prefs.py | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index 6bcccd1..04abe86 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -54,6 +54,7 @@ GlobalSettings.addConfigOption('prefsDialogHeight',
class PreferencesDialog(Loggable):
"""Preferences for how the app works."""
+ _instance = None
prefs = {}
section_names = {
"timeline": _("Timeline"),
@@ -63,6 +64,7 @@ class PreferencesDialog(Loggable):
def __init__(self, app):
Loggable.__init__(self)
+
self.app = app
self.app.shortcuts.connect("accel-changed", self.__accel_changed_cb)
@@ -94,7 +96,9 @@ class PreferencesDialog(Loggable):
def run(self):
"""Runs the dialog."""
+ PreferencesDialog._instance = self
self.dialog.run()
+ PreferencesDialog._instance = None
# Public API
@property
@@ -112,6 +116,16 @@ class PreferencesDialog(Loggable):
cls.section_names[section] = title
@classmethod
+ def remove_section(cls, section):
+ if cls._instance is not None:
+ cls._instance._remove_page(section)
+ try:
+ del cls.section_names[section]
+ del cls.prefs[section]
+ except KeyError:
+ pass
+
+ @classmethod
def _add_preference(cls, attrname, label, description, section,
widget_class, **args):
"""Adds a user preference.
@@ -133,6 +147,9 @@ class PreferencesDialog(Loggable):
if section not in cls.prefs:
cls.prefs[section] = {}
cls.prefs[section][attrname] = (label, description, widget_class, args)
+ if cls._instance is not None:
+ cls._instance._remove_page(section)
+ cls._instance.add_settings_page(section)
@classmethod
def addPathPreference(cls, attrname, label, description, section=None):
@@ -187,6 +204,15 @@ class PreferencesDialog(Loggable):
raise Exception("%s is not a valid section id" % section)
self.stack.add_titled(widget, section, self.section_names[section])
+ def _remove_page(self, section):
+ if section in self.section_names:
+ widget = self.stack.get_child_by_name(section)
+ if widget is not None:
+ self.stack.remove(widget)
+ widget.destroy()
+ else:
+ self.log("No widget associated to section '%s' found", section)
+
def add_settings_page(self, section_id):
"""Adds a page for the preferences in the specified section."""
options = self.prefs[section_id]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]