GSettings
Ways to implement our new settings system:
First of all a copy of the new scheme file to make things more clear in the explanation:
-------------------------------------------------------------------------------
schema org.gnome.gedit:
path apps/gedit/
child preferences:
child editor:
key use_default_font = true
key editor_font = 'Monospace 12'
key scheme = 'classic'
key create_backup_copy = true
key backup_copy_extension = '~'
key auto_save = false
key auto_save_interval = 10
key undo_actions_limit = 25
key max_undo_actions = 2000
key wrap_mode = 'GTK_WRAP_WORD'
key tabs_size = 8
key insert_spaces = false
key auto_indent = false
key display_line_numbers = false
key highlight_current_line = false
key bracket_matching = false
key display_right_margin = false
key right_margin_position = 80
key smart_home_end = 'after'
key writable_vfs_schemes = ('dav', 'davs', 'ftp', 'sftp', 'smb', 'ssh')
key restore_cursor_position = true
key search_highlighting = true
child ui:
key toolbar_visible = true
key toolbar_buttons_style = 'GEDIT_TOOLBAR_SYSTEM'
key statusbar_visible = true
key side_pane_visible = false
key bottom_pane_visible = false
key max_recents = 5
key syntax_highlighting = true
child print:
key print_syntax_highlighting = true
key print_header = true
key print_wrap_mode = 'GTK_WRAP_WORD'
key print_line_numbers = 0
key print_font_body_pango = 'Monospace 9'
key print_font_header_pango = 'Sans 11'
key print_font_numbers_pango = 'Sans 8'
child encodings:
key auto_detected = ('UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16')
key shown_in_menu = (ISO-8859-15)
child plugins:
key active_plugins = (@ACTIVE_PLUGINS@)
schema org.gnome.Desktop.Lockdown:
path desktop/gnome/lockdown
key disable_command_line = false
key disable_printing = false
key disable_print_setup = false
key disable_save_to_disk = false
schema org.gnome.Desktop.Interface:
path desktop/gnome/interface
key monospace_font_name = 'Monospace 10'
-----------------------------------------------------------------------------------------
What does have gsettings that gconf doesn't:
Signal: changed -> This signal works in a similar way as the notify signal
we can connect to changed::key so we don't need a child per key to listen
into changes as we had in gconf.
New useful functions:
void g_settings_bind (GSettings *settings,
const gchar *key,
gpointer object,
const gchar *property,
GSettingsBindFlags flags);
void g_settings_unbind (gpointer object,
const gchar *key);
this functions allow us to bind or unbind an object to a property so we can do
something like:
g_settings_bind (editor_settings, "use_default_font", check_button, "value", G_SETTINGS_BIND_SET);
so in this way we don't need to add callbacks in the preferences dialog, once the check button changes
the key value is gonna change too.
---------------------------------------------------------------------------------------
On going implementation:
GSettings *
gedit_app_get_settings (GeditApp *app,
const gchar *path_list,
...)
if path_list is null the toplevel is returned.
- GeditSettingsManager inherits from GSettings, in this object the default schema is parsed. It is also managed internally the Desktop.Interface and the Desktop.Lockdown schemas.
- This object is the one that takes care of the changes. By using the signal changed::key it listens for the changes in the key and manages the changes. Same as gedit-prefs-manager-app
Another way to implement this:
- GeditApp parses the 3 schemas.
- GeditSettingsManager (is not an object) has init and shutdown methods. Or it is an object and the GeditApp takes care of it.
- In the init method gets the 3 schemas from the app and connects to all the needed changed signals.
----------------------------------------------------------------------------------------
About possible implementations: (Deprecated)
We need a singleton for parsing the scheme and get the settings (editor_settings, ui_settings etc)
two ways to go in this way:
1) Go in the way we go now by having the gedit-prefs-manager{-app}.[ch]
- and get the settings from the gedit-app singleton
- or get the settings from a new gedit-settings-manager singleton (convert gedit-prefs-manager to gedit-settings-manager
2) Create a GeditSettings singleton that inherits from GeditSettings and works in this way:
- one property per key value
- implement the g_object_set_property with g_settings_set
- g_object_get_property with g_settings_get
- have the GSettings "changed" signal emit g_object_notify() (like, write a handler function for that)
- also have the getters for the settings so we can bind them too in the preferences dialog
3) Same as the previous one but instead of having a new singleton use gedit-app for this purpose