diff --git a/pluma/dialogs/pluma-preferences-dialog.c b/pluma/dialogs/pluma-preferences-dialog.c index 1444ce6..b7b6e54 100755 --- a/pluma/dialogs/pluma-preferences-dialog.c +++ b/pluma/dialogs/pluma-preferences-dialog.c @@ -37,7 +37,6 @@ #include #include -#include #include diff --git a/pluma/dialogs/pluma-search-dialog.c b/pluma/dialogs/pluma-search-dialog.c index 1867bcc..7db2a2b 100755 --- a/pluma/dialogs/pluma-search-dialog.c +++ b/pluma/dialogs/pluma-search-dialog.c @@ -375,7 +375,7 @@ pluma_search_dialog_init (PlumaSearchDialog *dlg) return; } - dlg->priv->search_entry = pluma_history_entry_new ("pluma2_search_for_entry", + dlg->priv->search_entry = pluma_history_entry_new ("history-search-for", TRUE); gtk_widget_set_size_request (dlg->priv->search_entry, 300, -1); pluma_history_entry_set_escape_func @@ -391,7 +391,7 @@ pluma_search_dialog_init (PlumaSearchDialog *dlg) dlg->priv->search_entry, 1, 2, 0, 1); - dlg->priv->replace_entry = pluma_history_entry_new ("pluma2_replace_with_entry", + dlg->priv->replace_entry = pluma_history_entry_new ("history-replace-with", TRUE); pluma_history_entry_set_escape_func (PLUMA_HISTORY_ENTRY (dlg->priv->replace_entry), diff --git a/pluma/pluma-app.c b/pluma/pluma-app.c index 91631cc..2ba277c 100644 --- a/pluma/pluma-app.c +++ b/pluma/pluma-app.c @@ -811,7 +811,7 @@ pluma_app_get_views (PlumaApp *app) * * Gets the lockdown mask (see #PlumaLockdownMask) for the application. * The lockdown mask determines which functions are locked down using - * the MATE-wise lockdown MateConf keys. + * the MATE-wise lockdown GSettings keys. **/ PlumaLockdownMask pluma_app_get_lockdown (PlumaApp *app) diff --git a/pluma/pluma-history-entry.c b/pluma/pluma-history-entry.c index aca325e..0511553 100644 --- a/pluma/pluma-history-entry.c +++ b/pluma/pluma-history-entry.c @@ -35,9 +35,10 @@ #include #include #include -#include +#include #include "pluma-history-entry.h" +#include "pluma-prefs-manager.h" enum { PROP_0, @@ -60,7 +61,7 @@ struct _PlumaHistoryEntryPrivate GtkEntryCompletion *completion; - MateConfClient *mateconf_client; + GSettings *settings; }; G_DEFINE_TYPE(PlumaHistoryEntry, pluma_history_entry, GTK_TYPE_COMBO_BOX_ENTRY) @@ -132,10 +133,10 @@ pluma_history_entry_finalize (GObject *object) g_free (priv->history_id); - if (priv->mateconf_client != NULL) + if (priv->settings != NULL) { - g_object_unref (G_OBJECT (priv->mateconf_client)); - priv->mateconf_client = NULL; + g_object_unref (G_OBJECT (priv->settings)); + priv->settings = NULL; } G_OBJECT_CLASS (pluma_history_entry_parent_class)->finalize (object); @@ -188,30 +189,6 @@ get_history_store (PlumaHistoryEntry *entry) return (GtkListStore *) store; } -static char * -get_history_key (PlumaHistoryEntry *entry) -{ - gchar *tmp; - gchar *key; - - /* - * We store the data under /apps/mate-settings/ - * like the old MateEntry did. Maybe we should - * consider moving it to the /pluma MateConf prefix... - * Or maybe we should just switch away from MateConf. - */ - - tmp = mateconf_escape_key (entry->priv->history_id, -1); - key = g_strconcat ("/apps/mate-settings/", - "pluma", - "/history-", - tmp, - NULL); - g_free (tmp); - - return key; -} - static GSList * get_history_list (PlumaHistoryEntry *entry) { @@ -246,23 +223,18 @@ get_history_list (PlumaHistoryEntry *entry) static void pluma_history_entry_save_history (PlumaHistoryEntry *entry) { - GSList *mateconf_items; - gchar *key; + GSList *settings_items; g_return_if_fail (PLUMA_IS_HISTORY_ENTRY (entry)); - mateconf_items = get_history_list (entry); - key = get_history_key (entry); + settings_items = get_history_list (entry); - mateconf_client_set_list (entry->priv->mateconf_client, - key, - MATECONF_VALUE_STRING, - mateconf_items, - NULL); + pluma_prefs_manager_set_gslist (entry->priv->settings, + entry->priv->history_id, + settings_items); - g_slist_foreach (mateconf_items, (GFunc) g_free, NULL); - g_slist_free (mateconf_items); - g_free (key); + g_slist_foreach (settings_items, (GFunc) g_free, NULL); + g_slist_free (settings_items); } static gboolean @@ -382,25 +354,21 @@ pluma_history_entry_append_text (PlumaHistoryEntry *entry, static void pluma_history_entry_load_history (PlumaHistoryEntry *entry) { - GSList *mateconf_items, *l; + GSList *settings_items, *l; GtkListStore *store; GtkTreeIter iter; - gchar *key; guint i; g_return_if_fail (PLUMA_IS_HISTORY_ENTRY (entry)); store = get_history_store (entry); - key = get_history_key (entry); - mateconf_items = mateconf_client_get_list (entry->priv->mateconf_client, - key, - MATECONF_VALUE_STRING, - NULL); + settings_items = pluma_prefs_manager_get_gslist (entry->priv->settings, + entry->priv->history_id); gtk_list_store_clear (store); - for (l = mateconf_items, i = 0; + for (l = settings_items, i = 0; l != NULL && i < entry->priv->history_length; l = l->next, i++) { @@ -412,9 +380,8 @@ pluma_history_entry_load_history (PlumaHistoryEntry *entry) -1); } - g_slist_foreach (mateconf_items, (GFunc) g_free, NULL); - g_slist_free (mateconf_items); - g_free (key); + g_slist_foreach (settings_items, (GFunc) g_free, NULL); + g_slist_free (settings_items); } void @@ -442,8 +409,8 @@ pluma_history_entry_init (PlumaHistoryEntry *entry) priv->history_length = PLUMA_HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT; priv->completion = NULL; - - priv->mateconf_client = mateconf_client_get_default (); + + priv->settings = g_settings_new (PLUMA_SCHEMA); } void diff --git a/pluma/pluma-plugins-engine.c b/pluma/pluma-plugins-engine.c index 1cc89e5..306caf2 100644 --- a/pluma/pluma-plugins-engine.c +++ b/pluma/pluma-plugins-engine.c @@ -699,7 +699,7 @@ pluma_plugins_engine_activate_plugins (PlumaPluginsEngine *engine, g_return_if_fail (PLUMA_IS_PLUGINS_ENGINE (engine)); g_return_if_fail (PLUMA_IS_WINDOW (window)); - /* the first time, we get the 'active' plugins from mateconf */ + /* the first time, we get the 'active' plugins from GSettings */ if (engine->priv->activate_from_prefs) { active_plugins = pluma_prefs_manager_get_active_plugins (); diff --git a/pluma/pluma-plugins-engine.h b/pluma/pluma-plugins-engine.h index 9c51522..6a58f21 100644 --- a/pluma/pluma-plugins-engine.h +++ b/pluma/pluma-plugins-engine.h @@ -96,7 +96,7 @@ void pluma_plugins_engine_deactivate_plugins (PlumaPluginsEngine *engine, void pluma_plugins_engine_update_plugins_ui (PlumaPluginsEngine *engine, PlumaWindow *window); -/* private for mateconf notification */ +/* private for GSettings notification */ void pluma_plugins_engine_active_plugins_changed (PlumaPluginsEngine *engine); diff --git a/pluma/pluma-prefs-manager-app.c b/pluma/pluma-prefs-manager-app.c index 81051b2..18db8fa 100644 --- a/pluma/pluma-prefs-manager-app.c +++ b/pluma/pluma-prefs-manager-app.c @@ -35,6 +35,7 @@ #include +#include #include "pluma-prefs-manager.h" #include "pluma-prefs-manager-private.h" #include "pluma-prefs-manager-app.h" @@ -47,98 +48,79 @@ #include "pluma-style-scheme-manager.h" #include "pluma-dirs.h" -static void pluma_prefs_manager_editor_font_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_editor_font_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_system_font_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_system_font_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_tabs_size_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_tabs_size_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_wrap_mode_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_wrap_mode_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_line_numbers_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_line_numbers_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_auto_indent_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_auto_indent_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_undo_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_undo_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_right_margin_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_right_margin_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_smart_home_end_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_smart_home_end_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_hl_current_line_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_hl_current_line_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_bracket_matching_changed(MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_bracket_matching_changed(GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_syntax_hl_enable_changed(MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_syntax_hl_enable_changed(GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_search_hl_enable_changed(MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_search_hl_enable_changed(GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_source_style_scheme_changed - (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_source_style_scheme_changed(GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_max_recents_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_max_recents_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_auto_save_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_auto_save_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_active_plugins_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_active_plugins_changed (GSettings *settings, + gchar *key, gpointer user_data); -static void pluma_prefs_manager_lockdown_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +static void pluma_prefs_manager_lockdown_changed (GSettings *settings, + gchar *key, gpointer user_data); -/* GUI state is serialized to a .desktop file, not in mateconf */ +/* GUI state is serialized to a .desktop file, not in GSettings */ #define PLUMA_STATE_DEFAULT_WINDOW_STATE 0 #define PLUMA_STATE_DEFAULT_WINDOW_WIDTH 650 @@ -613,7 +595,7 @@ pluma_prefs_manager_active_file_filter_can_set (void) return TRUE; } -/* Normal prefs are stored in MateConf */ +/* Normal prefs are stored in GSettings */ gboolean pluma_prefs_manager_app_init (void) @@ -626,111 +608,120 @@ pluma_prefs_manager_app_init (void) if (pluma_prefs_manager != NULL) { - /* TODO: notify, add dirs */ - mateconf_client_add_dir (pluma_prefs_manager->mateconf_client, - GPM_PREFS_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_USE_DEFAULT_FONT, + G_CALLBACK (pluma_prefs_manager_editor_font_changed), NULL); - mateconf_client_add_dir (pluma_prefs_manager->mateconf_client, - GPM_PLUGINS_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_EDITOR_FONT, + G_CALLBACK (pluma_prefs_manager_editor_font_changed), NULL); - mateconf_client_add_dir (pluma_prefs_manager->mateconf_client, - GPM_LOCKDOWN_DIR, - MATECONF_CLIENT_PRELOAD_RECURSIVE, + g_signal_connect (pluma_prefs_manager->interface_settings, + "changed::" GPM_SYSTEM_FONT, + G_CALLBACK (pluma_prefs_manager_system_font_changed), NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_FONT_DIR, - pluma_prefs_manager_editor_font_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_TABS_SIZE, + G_CALLBACK (pluma_prefs_manager_tabs_size_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_SYSTEM_FONT, - pluma_prefs_manager_system_font_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_INSERT_SPACES, + G_CALLBACK (pluma_prefs_manager_tabs_size_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_TABS_DIR, - pluma_prefs_manager_tabs_size_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_WRAP_MODE, + G_CALLBACK (pluma_prefs_manager_wrap_mode_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_WRAP_MODE_DIR, - pluma_prefs_manager_wrap_mode_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_DISPLAY_LINE_NUMBERS, + G_CALLBACK (pluma_prefs_manager_line_numbers_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_LINE_NUMBERS_DIR, - pluma_prefs_manager_line_numbers_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_AUTO_INDENT, + G_CALLBACK (pluma_prefs_manager_auto_indent_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_AUTO_INDENT_DIR, - pluma_prefs_manager_auto_indent_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_UNDO_ACTIONS_LIMIT, + G_CALLBACK (pluma_prefs_manager_undo_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_UNDO_DIR, - pluma_prefs_manager_undo_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_DISPLAY_RIGHT_MARGIN, + G_CALLBACK (pluma_prefs_manager_right_margin_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_RIGHT_MARGIN_DIR, - pluma_prefs_manager_right_margin_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_RIGHT_MARGIN_POSITION, + G_CALLBACK (pluma_prefs_manager_right_margin_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_SMART_HOME_END_DIR, - pluma_prefs_manager_smart_home_end_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_SMART_HOME_END, + G_CALLBACK (pluma_prefs_manager_smart_home_end_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_CURRENT_LINE_DIR, - pluma_prefs_manager_hl_current_line_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_HIGHLIGHT_CURRENT_LINE, + G_CALLBACK (pluma_prefs_manager_hl_current_line_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_BRACKET_MATCHING_DIR, - pluma_prefs_manager_bracket_matching_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_BRACKET_MATCHING, + G_CALLBACK (pluma_prefs_manager_bracket_matching_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_SYNTAX_HL_ENABLE, - pluma_prefs_manager_syntax_hl_enable_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_SYNTAX_HL_ENABLE, + G_CALLBACK (pluma_prefs_manager_syntax_hl_enable_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_SEARCH_HIGHLIGHTING_ENABLE, - pluma_prefs_manager_search_hl_enable_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_SEARCH_HIGHLIGHTING_ENABLE, + G_CALLBACK (pluma_prefs_manager_search_hl_enable_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_SOURCE_STYLE_DIR, - pluma_prefs_manager_source_style_scheme_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_SOURCE_STYLE_SCHEME, + G_CALLBACK (pluma_prefs_manager_source_style_scheme_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_MAX_RECENTS, - pluma_prefs_manager_max_recents_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_MAX_RECENTS, + G_CALLBACK (pluma_prefs_manager_max_recents_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_SAVE_DIR, - pluma_prefs_manager_auto_save_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_CREATE_BACKUP_COPY, + G_CALLBACK (pluma_prefs_manager_auto_save_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_ACTIVE_PLUGINS, - pluma_prefs_manager_active_plugins_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_AUTO_SAVE_INTERVAL, + G_CALLBACK (pluma_prefs_manager_auto_save_changed), + NULL); - mateconf_client_notify_add (pluma_prefs_manager->mateconf_client, - GPM_LOCKDOWN_DIR, - pluma_prefs_manager_lockdown_changed, - NULL, NULL, NULL); + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_WRITABLE_VFS_SCHEMES, + G_CALLBACK (pluma_prefs_manager_auto_save_changed), + NULL); + + g_signal_connect (pluma_prefs_manager->settings, + "changed::" GPM_ACTIVE_PLUGINS, + G_CALLBACK (pluma_prefs_manager_active_plugins_changed), + NULL); + + g_signal_connect (pluma_prefs_manager->lockdown_settings, + "changed", + G_CALLBACK (pluma_prefs_manager_lockdown_changed), + NULL); } return pluma_prefs_manager != NULL; @@ -749,9 +740,8 @@ pluma_prefs_manager_app_shutdown (void) static void -pluma_prefs_manager_editor_font_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_editor_font_changed (GSettings *settings, + gchar *key, gpointer user_data) { GList *views; @@ -762,27 +752,18 @@ pluma_prefs_manager_editor_font_changed (MateConfClient *client, pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_USE_DEFAULT_FONT) == 0) + if (strcmp (key, GPM_USE_DEFAULT_FONT) == 0) { - if (entry->value->type == MATECONF_VALUE_BOOL) - def = mateconf_value_get_bool (entry->value); - else - def = GPM_DEFAULT_USE_DEFAULT_FONT; + def = g_settings_get_boolean (settings, key); if (def) font = pluma_prefs_manager_get_system_font (); else font = pluma_prefs_manager_get_editor_font (); } - else if (strcmp (entry->key, GPM_EDITOR_FONT) == 0) + else if (strcmp (key, GPM_EDITOR_FONT) == 0) { - if (entry->value->type == MATECONF_VALUE_STRING) - font = g_strdup (mateconf_value_get_string (entry->value)); - else - font = g_strdup (GPM_DEFAULT_EDITOR_FONT); + font = g_settings_get_string (settings, key); def = pluma_prefs_manager_get_use_default_font (); } @@ -798,7 +779,7 @@ pluma_prefs_manager_editor_font_changed (MateConfClient *client, while (l != NULL) { - /* Note: we use def=FALSE to avoid PlumaView to query mateconf */ + /* Note: we use def=FALSE to avoid PlumaView to query GSettings */ pluma_view_set_font (PLUMA_VIEW (l->data), FALSE, font); gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (l->data), ts); @@ -810,9 +791,8 @@ pluma_prefs_manager_editor_font_changed (MateConfClient *client, } static void -pluma_prefs_manager_system_font_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_system_font_changed (GSettings *settings, + gchar *key, gpointer user_data) { GList *views; @@ -822,19 +802,13 @@ pluma_prefs_manager_system_font_changed (MateConfClient *client, pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_SYSTEM_FONT) != 0) + if (strcmp (key, GPM_SYSTEM_FONT) != 0) return; if (!pluma_prefs_manager_get_use_default_font ()) return; - if (entry->value->type == MATECONF_VALUE_STRING) - font = g_strdup (mateconf_value_get_string (entry->value)); - else - font = g_strdup (GPM_DEFAULT_SYSTEM_FONT); + font = g_settings_get_string (settings, key); ts = pluma_prefs_manager_get_tabs_size (); @@ -843,7 +817,7 @@ pluma_prefs_manager_system_font_changed (MateConfClient *client, while (l != NULL) { - /* Note: we use def=FALSE to avoid PlumaView to query mateconf */ + /* Note: we use def=FALSE to avoid PlumaView to query GSettings */ pluma_view_set_font (PLUMA_VIEW (l->data), FALSE, font); gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (l->data), ts); @@ -855,26 +829,19 @@ pluma_prefs_manager_system_font_changed (MateConfClient *client, } static void -pluma_prefs_manager_tabs_size_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_tabs_size_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_TABS_SIZE) == 0) + if (strcmp (key, GPM_TABS_SIZE) == 0) { gint tab_width; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_INT) - tab_width = mateconf_value_get_int (entry->value); - else - tab_width = GPM_DEFAULT_TABS_SIZE; + tab_width = g_settings_get_int (settings, key); tab_width = CLAMP (tab_width, 1, 24); @@ -891,16 +858,13 @@ pluma_prefs_manager_tabs_size_changed (MateConfClient *client, g_list_free (views); } - else if (strcmp (entry->key, GPM_INSERT_SPACES) == 0) + else if (strcmp (key, GPM_INSERT_SPACES) == 0) { gboolean enable; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_BOOL) - enable = mateconf_value_get_bool (entry->value); - else - enable = GPM_DEFAULT_INSERT_SPACES; + enable = g_settings_get_boolean (settings, key); views = pluma_app_get_views (pluma_app_get_default ()); l = views; @@ -939,27 +903,19 @@ get_wrap_mode_from_string (const gchar* str) } static void -pluma_prefs_manager_wrap_mode_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +pluma_prefs_manager_wrap_mode_changed (GSettings *settings, + gchar *key, + gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_WRAP_MODE) == 0) + if (strcmp (key, GPM_WRAP_MODE) == 0) { GtkWrapMode wrap_mode; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_STRING) - wrap_mode = - get_wrap_mode_from_string (mateconf_value_get_string (entry->value)); - else - wrap_mode = get_wrap_mode_from_string (GPM_DEFAULT_WRAP_MODE); + wrap_mode = get_wrap_mode_from_string (g_settings_get_string(settings, key)); views = pluma_app_get_views (pluma_app_get_default ()); l = views; @@ -977,26 +933,19 @@ pluma_prefs_manager_wrap_mode_changed (MateConfClient *client, } static void -pluma_prefs_manager_line_numbers_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_line_numbers_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_DISPLAY_LINE_NUMBERS) == 0) + if (strcmp (key, GPM_DISPLAY_LINE_NUMBERS) == 0) { gboolean dln; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_BOOL) - dln = mateconf_value_get_bool (entry->value); - else - dln = GPM_DEFAULT_DISPLAY_LINE_NUMBERS; + dln = g_settings_get_boolean (settings, key); views = pluma_app_get_views (pluma_app_get_default ()); l = views; @@ -1014,26 +963,19 @@ pluma_prefs_manager_line_numbers_changed (MateConfClient *client, } static void -pluma_prefs_manager_hl_current_line_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_hl_current_line_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_HIGHLIGHT_CURRENT_LINE) == 0) + if (strcmp (key, GPM_HIGHLIGHT_CURRENT_LINE) == 0) { gboolean hl; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_BOOL) - hl = mateconf_value_get_bool (entry->value); - else - hl = GPM_DEFAULT_HIGHLIGHT_CURRENT_LINE; + hl = g_settings_get_boolean (settings, key); views = pluma_app_get_views (pluma_app_get_default ()); l = views; @@ -1051,26 +993,19 @@ pluma_prefs_manager_hl_current_line_changed (MateConfClient *client, } static void -pluma_prefs_manager_bracket_matching_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_bracket_matching_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_BRACKET_MATCHING) == 0) + if (strcmp (key, GPM_BRACKET_MATCHING) == 0) { gboolean enable; GList *docs; GList *l; - if (entry->value->type == MATECONF_VALUE_BOOL) - enable = mateconf_value_get_bool (entry->value); - else - enable = GPM_DEFAULT_BRACKET_MATCHING; + enable = g_settings_get_boolean (settings, key); docs = pluma_app_get_documents (pluma_app_get_default ()); l = docs; @@ -1088,26 +1023,19 @@ pluma_prefs_manager_bracket_matching_changed (MateConfClient *client, } static void -pluma_prefs_manager_auto_indent_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_auto_indent_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_AUTO_INDENT) == 0) + if (strcmp (key, GPM_AUTO_INDENT) == 0) { gboolean enable; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_BOOL) - enable = mateconf_value_get_bool (entry->value); - else - enable = GPM_DEFAULT_AUTO_INDENT; + enable = g_settings_get_boolean (settings, key); views = pluma_app_get_views (pluma_app_get_default ()); l = views; @@ -1125,26 +1053,19 @@ pluma_prefs_manager_auto_indent_changed (MateConfClient *client, } static void -pluma_prefs_manager_undo_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_undo_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_UNDO_ACTIONS_LIMIT) == 0) + if (strcmp (key, GPM_UNDO_ACTIONS_LIMIT) == 0) { gint ul; GList *docs; GList *l; - if (entry->value->type == MATECONF_VALUE_INT) - ul = mateconf_value_get_int (entry->value); - else - ul = GPM_DEFAULT_UNDO_ACTIONS_LIMIT; + ul = g_settings_get_int (settings, key); ul = CLAMP (ul, -1, 250); @@ -1164,26 +1085,19 @@ pluma_prefs_manager_undo_changed (MateConfClient *client, } static void -pluma_prefs_manager_right_margin_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_right_margin_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_RIGHT_MARGIN_POSITION) == 0) + if (strcmp (key, GPM_RIGHT_MARGIN_POSITION) == 0) { gint pos; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_INT) - pos = mateconf_value_get_int (entry->value); - else - pos = GPM_DEFAULT_RIGHT_MARGIN_POSITION; + pos = g_settings_get_int (settings, key); pos = CLAMP (pos, 1, 160); @@ -1200,16 +1114,13 @@ pluma_prefs_manager_right_margin_changed (MateConfClient *client, g_list_free (views); } - else if (strcmp (entry->key, GPM_DISPLAY_RIGHT_MARGIN) == 0) + else if (strcmp (key, GPM_DISPLAY_RIGHT_MARGIN) == 0) { gboolean display; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_BOOL) - display = mateconf_value_get_bool (entry->value); - else - display = GPM_DEFAULT_DISPLAY_RIGHT_MARGIN; + display = g_settings_get_boolean (settings, key); views = pluma_app_get_views (pluma_app_get_default ()); l = views; @@ -1246,27 +1157,19 @@ get_smart_home_end_from_string (const gchar *str) } static void -pluma_prefs_manager_smart_home_end_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_smart_home_end_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_SMART_HOME_END) == 0) + if (strcmp (key, GPM_SMART_HOME_END) == 0) { GtkSourceSmartHomeEndType smart_he; GList *views; GList *l; - if (entry->value->type == MATECONF_VALUE_STRING) - smart_he = - get_smart_home_end_from_string (mateconf_value_get_string (entry->value)); - else - smart_he = get_smart_home_end_from_string (GPM_DEFAULT_SMART_HOME_END); + smart_he = get_smart_home_end_from_string (g_settings_get_string (settings, key)); views = pluma_app_get_views (pluma_app_get_default ()); l = views; @@ -1284,27 +1187,20 @@ pluma_prefs_manager_smart_home_end_changed (MateConfClient *client, } static void -pluma_prefs_manager_syntax_hl_enable_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_syntax_hl_enable_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_SYNTAX_HL_ENABLE) == 0) + if (strcmp (key, GPM_SYNTAX_HL_ENABLE) == 0) { gboolean enable; GList *docs; GList *l; const GList *windows; - if (entry->value->type == MATECONF_VALUE_BOOL) - enable = mateconf_value_get_bool (entry->value); - else - enable = GPM_DEFAULT_SYNTAX_HL_ENABLE; + enable = g_settings_get_boolean (settings, key); docs = pluma_app_get_documents (pluma_app_get_default ()); l = docs; @@ -1341,26 +1237,19 @@ pluma_prefs_manager_syntax_hl_enable_changed (MateConfClient *client, } static void -pluma_prefs_manager_search_hl_enable_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_search_hl_enable_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_SEARCH_HIGHLIGHTING_ENABLE) == 0) + if (strcmp (key, GPM_SEARCH_HIGHLIGHTING_ENABLE) == 0) { gboolean enable; GList *docs; GList *l; - if (entry->value->type == MATECONF_VALUE_BOOL) - enable = mateconf_value_get_bool (entry->value); - else - enable = GPM_DEFAULT_SEARCH_HIGHLIGHTING_ENABLE; + enable = g_settings_get_boolean (settings, key); docs = pluma_app_get_documents (pluma_app_get_default ()); l = docs; @@ -1380,34 +1269,27 @@ pluma_prefs_manager_search_hl_enable_changed (MateConfClient *client, } static void -pluma_prefs_manager_source_style_scheme_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_source_style_scheme_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_SOURCE_STYLE_SCHEME) == 0) + if (strcmp (key, GPM_SOURCE_STYLE_SCHEME) == 0) { static gchar *old_scheme = NULL; - const gchar *scheme; + gchar *scheme; GtkSourceStyleScheme *style; GList *docs; GList *l; - if (entry->value->type == MATECONF_VALUE_STRING) - scheme = mateconf_value_get_string (entry->value); - else - scheme = GPM_DEFAULT_SOURCE_STYLE_SCHEME; + scheme = g_settings_get_string (settings, key); if (old_scheme != NULL && (strcmp (scheme, old_scheme) == 0)) return; g_free (old_scheme); - old_scheme = g_strdup (scheme); + old_scheme = scheme; style = gtk_source_style_scheme_manager_get_scheme ( pluma_get_style_scheme_manager (), @@ -1442,30 +1324,22 @@ pluma_prefs_manager_source_style_scheme_changed (MateConfClient *client, } static void -pluma_prefs_manager_max_recents_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_max_recents_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_MAX_RECENTS) == 0) + if (strcmp (key, GPM_MAX_RECENTS) == 0) { const GList *windows; gint max; - if (entry->value->type == MATECONF_VALUE_INT) - { - max = mateconf_value_get_int (entry->value); + max = g_settings_get_int (settings, key); - if (max < 0) - max = GPM_DEFAULT_MAX_RECENTS; - } - else + if (max < 0) { max = GPM_DEFAULT_MAX_RECENTS; + } windows = pluma_app_get_windows (pluma_app_get_default ()); while (windows != NULL) @@ -1484,9 +1358,8 @@ pluma_prefs_manager_max_recents_changed (MateConfClient *client, } static void -pluma_prefs_manager_auto_save_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_auto_save_changed (GSettings *settings, + gchar *key, gpointer user_data) { GList *docs; @@ -1494,17 +1367,11 @@ pluma_prefs_manager_auto_save_changed (MateConfClient *client, pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_AUTO_SAVE) == 0) + if (strcmp (key, GPM_AUTO_SAVE) == 0) { gboolean auto_save; - if (entry->value->type == MATECONF_VALUE_BOOL) - auto_save = mateconf_value_get_bool (entry->value); - else - auto_save = GPM_DEFAULT_AUTO_SAVE; + auto_save = g_settings_get_boolean (settings, key); docs = pluma_app_get_documents (pluma_app_get_default ()); l = docs; @@ -1521,18 +1388,13 @@ pluma_prefs_manager_auto_save_changed (MateConfClient *client, g_list_free (docs); } - else if (strcmp (entry->key, GPM_AUTO_SAVE_INTERVAL) == 0) + else if (strcmp (key, GPM_AUTO_SAVE_INTERVAL) == 0) { gint auto_save_interval; - if (entry->value->type == MATECONF_VALUE_INT) - { - auto_save_interval = mateconf_value_get_int (entry->value); + auto_save_interval = g_settings_get_int (settings, key); - if (auto_save_interval <= 0) - auto_save_interval = GPM_DEFAULT_AUTO_SAVE_INTERVAL; - } - else + if (auto_save_interval <= 0) auto_save_interval = GPM_DEFAULT_AUTO_SAVE_INTERVAL; docs = pluma_app_get_documents (pluma_app_get_default ()); @@ -1553,34 +1415,25 @@ pluma_prefs_manager_auto_save_changed (MateConfClient *client, } static void -pluma_prefs_manager_active_plugins_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_active_plugins_changed (GSettings *settings, + gchar *key, gpointer user_data) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (strcmp (entry->key, GPM_ACTIVE_PLUGINS) == 0) + if (strcmp (key, GPM_ACTIVE_PLUGINS) == 0) { - if ((entry->value->type == MATECONF_VALUE_LIST) && - (mateconf_value_get_list_type (entry->value) == MATECONF_VALUE_STRING)) - { - PlumaPluginsEngine *engine; + PlumaPluginsEngine *engine; - engine = pluma_plugins_engine_get_default (); + engine = pluma_plugins_engine_get_default (); - pluma_plugins_engine_active_plugins_changed (engine); - } + pluma_plugins_engine_active_plugins_changed (engine); } } static void -pluma_prefs_manager_lockdown_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +pluma_prefs_manager_lockdown_changed (GSettings *settings, + gchar *key, gpointer user_data) { PlumaApp *app; @@ -1588,32 +1441,26 @@ pluma_prefs_manager_lockdown_changed (MateConfClient *client, pluma_debug (DEBUG_PREFS); - g_return_if_fail (entry->key != NULL); - g_return_if_fail (entry->value != NULL); - - if (entry->value->type == MATECONF_VALUE_BOOL) - locked = mateconf_value_get_bool (entry->value); - else - locked = FALSE; + locked = g_settings_get_boolean (settings, key); app = pluma_app_get_default (); - if (strcmp (entry->key, GPM_LOCKDOWN_COMMAND_LINE) == 0) + if (strcmp (key, GPM_LOCKDOWN_COMMAND_LINE) == 0) _pluma_app_set_lockdown_bit (app, PLUMA_LOCKDOWN_COMMAND_LINE, locked); - else if (strcmp (entry->key, GPM_LOCKDOWN_PRINTING) == 0) + else if (strcmp (key, GPM_LOCKDOWN_PRINTING) == 0) _pluma_app_set_lockdown_bit (app, PLUMA_LOCKDOWN_PRINTING, locked); - else if (strcmp (entry->key, GPM_LOCKDOWN_PRINT_SETUP) == 0) + else if (strcmp (key, GPM_LOCKDOWN_PRINT_SETUP) == 0) _pluma_app_set_lockdown_bit (app, PLUMA_LOCKDOWN_PRINT_SETUP, locked); - else if (strcmp (entry->key, GPM_LOCKDOWN_SAVE_TO_DISK) == 0) + else if (strcmp (key, GPM_LOCKDOWN_SAVE_TO_DISK) == 0) _pluma_app_set_lockdown_bit (app, PLUMA_LOCKDOWN_SAVE_TO_DISK, locked); diff --git a/pluma/pluma-prefs-manager-private.h b/pluma/pluma-prefs-manager-private.h index 1d4bc89..f69e9d4 100644 --- a/pluma/pluma-prefs-manager-private.h +++ b/pluma/pluma-prefs-manager-private.h @@ -30,12 +30,14 @@ #ifndef __PLUMA_PREFS_MANAGER_PRIVATE_H__ #define __PLUMA_PREFS_MANAGER_PRIVATE_H__ -#include +#include typedef struct _PlumaPrefsManager PlumaPrefsManager; struct _PlumaPrefsManager { - MateConfClient *mateconf_client; + GSettings *settings; + GSettings *lockdown_settings; + GSettings *interface_settings; }; extern PlumaPrefsManager *pluma_prefs_manager; diff --git a/pluma/pluma-prefs-manager.c b/pluma/pluma-prefs-manager.c index a63e8f6..0226200 100644 --- a/pluma/pluma-prefs-manager.c +++ b/pluma/pluma-prefs-manager.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include "pluma-prefs-manager.h" #include "pluma-prefs-manager-private.h" @@ -42,13 +42,12 @@ #include "pluma-encodings.h" #include "pluma-utils.h" -#define DEFINE_BOOL_PREF(name, key, def) gboolean \ +#define DEFINE_BOOL_PREF(name, key) gboolean \ pluma_prefs_manager_get_ ## name (void) \ { \ pluma_debug (DEBUG_PREFS); \ \ - return pluma_prefs_manager_get_bool (key, \ - (def)); \ + return pluma_prefs_manager_get_bool (key); \ } \ \ void \ @@ -70,13 +69,12 @@ pluma_prefs_manager_ ## name ## _can_set (void) \ -#define DEFINE_INT_PREF(name, key, def) gint \ +#define DEFINE_INT_PREF(name, key) gint \ pluma_prefs_manager_get_ ## name (void) \ { \ pluma_debug (DEBUG_PREFS); \ \ - return pluma_prefs_manager_get_int (key, \ - (def)); \ + return pluma_prefs_manager_get_int (key); \ } \ \ void \ @@ -98,13 +96,12 @@ pluma_prefs_manager_ ## name ## _can_set (void) \ -#define DEFINE_STRING_PREF(name, key, def) gchar* \ +#define DEFINE_STRING_PREF(name, key) gchar* \ pluma_prefs_manager_get_ ## name (void) \ { \ pluma_debug (DEBUG_PREFS); \ \ - return pluma_prefs_manager_get_string (key, \ - def); \ + return pluma_prefs_manager_get_string (key); \ } \ \ void \ @@ -130,29 +127,11 @@ PlumaPrefsManager *pluma_prefs_manager = NULL; static GtkWrapMode get_wrap_mode_from_string (const gchar* str); -static gboolean mateconf_client_get_bool_with_default (MateConfClient* client, - const gchar* key, - gboolean def, - GError** err); +static gboolean pluma_prefs_manager_get_bool (const gchar* key); -static gchar *mateconf_client_get_string_with_default (MateConfClient* client, - const gchar* key, - const gchar* def, - GError** err); +static gint pluma_prefs_manager_get_int (const gchar* key); -static gint mateconf_client_get_int_with_default (MateConfClient* client, - const gchar* key, - gint def, - GError** err); - -static gboolean pluma_prefs_manager_get_bool (const gchar* key, - gboolean def); - -static gint pluma_prefs_manager_get_int (const gchar* key, - gint def); - -static gchar *pluma_prefs_manager_get_string (const gchar* key, - const gchar* def); +static gchar *pluma_prefs_manager_get_string (const gchar* key); gboolean @@ -162,28 +141,13 @@ pluma_prefs_manager_init (void) if (pluma_prefs_manager == NULL) { - MateConfClient *mateconf_client; - - mateconf_client = mateconf_client_get_default (); - if (mateconf_client == NULL) - { - g_warning (_("Cannot initialize preferences manager.")); - return FALSE; - } - pluma_prefs_manager = g_new0 (PlumaPrefsManager, 1); - - pluma_prefs_manager->mateconf_client = mateconf_client; - } - - if (pluma_prefs_manager->mateconf_client == NULL) - { - g_free (pluma_prefs_manager); - pluma_prefs_manager = NULL; + pluma_prefs_manager->settings = g_settings_new (PLUMA_SCHEMA); + pluma_prefs_manager->lockdown_settings = g_settings_new (GPM_LOCKDOWN_SCHEMA); + pluma_prefs_manager->interface_settings = g_settings_new (GPM_INTERFACE_SCHEMA); } return pluma_prefs_manager != NULL; - } void @@ -193,65 +157,47 @@ pluma_prefs_manager_shutdown (void) g_return_if_fail (pluma_prefs_manager != NULL); - g_object_unref (pluma_prefs_manager->mateconf_client); - pluma_prefs_manager->mateconf_client = NULL; + g_object_unref (pluma_prefs_manager->settings); + pluma_prefs_manager->settings = NULL; + g_object_unref (pluma_prefs_manager->lockdown_settings); + pluma_prefs_manager->lockdown_settings = NULL; + g_object_unref (pluma_prefs_manager->interface_settings); + pluma_prefs_manager->interface_settings = NULL; } static gboolean -pluma_prefs_manager_get_bool (const gchar* key, gboolean def) +pluma_prefs_manager_get_bool (const gchar* key) { pluma_debug (DEBUG_PREFS); - g_return_val_if_fail (pluma_prefs_manager != NULL, def); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, def); - - return mateconf_client_get_bool_with_default (pluma_prefs_manager->mateconf_client, - key, - def, - NULL); + return g_settings_get_boolean (pluma_prefs_manager->settings, key); } static gint -pluma_prefs_manager_get_int (const gchar* key, gint def) +pluma_prefs_manager_get_int (const gchar* key) { pluma_debug (DEBUG_PREFS); - g_return_val_if_fail (pluma_prefs_manager != NULL, def); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, def); - - return mateconf_client_get_int_with_default (pluma_prefs_manager->mateconf_client, - key, - def, - NULL); -} + return g_settings_get_int (pluma_prefs_manager->settings, key); +} static gchar * -pluma_prefs_manager_get_string (const gchar* key, const gchar* def) +pluma_prefs_manager_get_string (const gchar* key) { pluma_debug (DEBUG_PREFS); - g_return_val_if_fail (pluma_prefs_manager != NULL, - def ? g_strdup (def) : NULL); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, - def ? g_strdup (def) : NULL); - - return mateconf_client_get_string_with_default (pluma_prefs_manager->mateconf_client, - key, - def, - NULL); -} + return g_settings_get_string (pluma_prefs_manager->settings, key); +} static void pluma_prefs_manager_set_bool (const gchar* key, gboolean value) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (pluma_prefs_manager != NULL); - g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL); - g_return_if_fail (mateconf_client_key_is_writable ( - pluma_prefs_manager->mateconf_client, key, NULL)); - - mateconf_client_set_bool (pluma_prefs_manager->mateconf_client, key, value, NULL); + g_return_if_fail (g_settings_is_writable ( + pluma_prefs_manager->settings, key)); + + g_settings_set_boolean (pluma_prefs_manager->settings, key, value); } static void @@ -259,12 +205,10 @@ pluma_prefs_manager_set_int (const gchar* key, gint value) { pluma_debug (DEBUG_PREFS); - g_return_if_fail (pluma_prefs_manager != NULL); - g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL); - g_return_if_fail (mateconf_client_key_is_writable ( - pluma_prefs_manager->mateconf_client, key, NULL)); - - mateconf_client_set_int (pluma_prefs_manager->mateconf_client, key, value, NULL); + g_return_if_fail (g_settings_is_writable ( + pluma_prefs_manager->settings, key)); + + g_settings_set_int (pluma_prefs_manager->settings, key, value); } static void @@ -274,12 +218,10 @@ pluma_prefs_manager_set_string (const gchar* key, const gchar* value) g_return_if_fail (value != NULL); - g_return_if_fail (pluma_prefs_manager != NULL); - g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL); - g_return_if_fail (mateconf_client_key_is_writable ( - pluma_prefs_manager->mateconf_client, key, NULL)); - - mateconf_client_set_string (pluma_prefs_manager->mateconf_client, key, value, NULL); + g_return_if_fail (g_settings_is_writable ( + pluma_prefs_manager->settings, key)); + + g_settings_set_string (pluma_prefs_manager->settings, key, value); } static gboolean @@ -288,20 +230,18 @@ pluma_prefs_manager_key_is_writable (const gchar* key) pluma_debug (DEBUG_PREFS); g_return_val_if_fail (pluma_prefs_manager != NULL, FALSE); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, FALSE); + g_return_val_if_fail (pluma_prefs_manager->settings != NULL, FALSE); - return mateconf_client_key_is_writable (pluma_prefs_manager->mateconf_client, key, NULL); + return g_settings_is_writable (pluma_prefs_manager->settings, key); } /* Use default font */ DEFINE_BOOL_PREF (use_default_font, - GPM_USE_DEFAULT_FONT, - GPM_DEFAULT_USE_DEFAULT_FONT) + GPM_USE_DEFAULT_FONT) /* Editor font */ DEFINE_STRING_PREF (editor_font, - GPM_EDITOR_FONT, - GPM_DEFAULT_EDITOR_FONT) + GPM_EDITOR_FONT) /* System font */ gchar * @@ -309,30 +249,26 @@ pluma_prefs_manager_get_system_font (void) { pluma_debug (DEBUG_PREFS); - return pluma_prefs_manager_get_string (GPM_SYSTEM_FONT, - GPM_DEFAULT_SYSTEM_FONT); + return g_settings_get_string (pluma_prefs_manager->interface_settings, + GPM_SYSTEM_FONT); } /* Create backup copy */ DEFINE_BOOL_PREF (create_backup_copy, - GPM_CREATE_BACKUP_COPY, - GPM_DEFAULT_CREATE_BACKUP_COPY) + GPM_CREATE_BACKUP_COPY) /* Auto save */ DEFINE_BOOL_PREF (auto_save, - GPM_AUTO_SAVE, - GPM_DEFAULT_AUTO_SAVE) + GPM_AUTO_SAVE) /* Auto save interval */ DEFINE_INT_PREF (auto_save_interval, - GPM_AUTO_SAVE_INTERVAL, - GPM_DEFAULT_AUTO_SAVE_INTERVAL) + GPM_AUTO_SAVE_INTERVAL) /* Undo actions limit: if < 1 then no limits */ DEFINE_INT_PREF (undo_actions_limit, - GPM_UNDO_ACTIONS_LIMIT, - GPM_DEFAULT_UNDO_ACTIONS_LIMIT) + GPM_UNDO_ACTIONS_LIMIT) static GtkWrapMode get_wrap_mode_from_string (const gchar* str) @@ -363,8 +299,7 @@ pluma_prefs_manager_get_wrap_mode (void) pluma_debug (DEBUG_PREFS); - str = pluma_prefs_manager_get_string (GPM_WRAP_MODE, - GPM_DEFAULT_WRAP_MODE); + str = pluma_prefs_manager_get_string (GPM_WRAP_MODE); res = get_wrap_mode_from_string (str); @@ -409,28 +344,23 @@ pluma_prefs_manager_wrap_mode_can_set (void) /* Tabs size */ DEFINE_INT_PREF (tabs_size, - GPM_TABS_SIZE, - GPM_DEFAULT_TABS_SIZE) + GPM_TABS_SIZE) /* Insert spaces */ DEFINE_BOOL_PREF (insert_spaces, - GPM_INSERT_SPACES, - GPM_DEFAULT_INSERT_SPACES) + GPM_INSERT_SPACES) /* Auto indent */ DEFINE_BOOL_PREF (auto_indent, - GPM_AUTO_INDENT, - GPM_DEFAULT_AUTO_INDENT) + GPM_AUTO_INDENT) /* Display line numbers */ DEFINE_BOOL_PREF (display_line_numbers, - GPM_DISPLAY_LINE_NUMBERS, - GPM_DEFAULT_DISPLAY_LINE_NUMBERS) + GPM_DISPLAY_LINE_NUMBERS) /* Toolbar visibility */ DEFINE_BOOL_PREF (toolbar_visible, - GPM_TOOLBAR_VISIBLE, - GPM_DEFAULT_TOOLBAR_VISIBLE) + GPM_TOOLBAR_VISIBLE) /* Toolbar suttons style */ @@ -442,8 +372,7 @@ pluma_prefs_manager_get_toolbar_buttons_style (void) pluma_debug (DEBUG_PREFS); - str = pluma_prefs_manager_get_string (GPM_TOOLBAR_BUTTONS_STYLE, - GPM_DEFAULT_TOOLBAR_BUTTONS_STYLE); + str = pluma_prefs_manager_get_string (GPM_TOOLBAR_BUTTONS_STYLE); if (strcmp (str, "PLUMA_TOOLBAR_ICONS") == 0) res = PLUMA_TOOLBAR_ICONS; @@ -505,28 +434,23 @@ pluma_prefs_manager_toolbar_buttons_style_can_set (void) /* Statusbar visiblity */ DEFINE_BOOL_PREF (statusbar_visible, - GPM_STATUSBAR_VISIBLE, - GPM_DEFAULT_STATUSBAR_VISIBLE) + GPM_STATUSBAR_VISIBLE) /* Side Pane visiblity */ DEFINE_BOOL_PREF (side_pane_visible, - GPM_SIDE_PANE_VISIBLE, - GPM_DEFAULT_SIDE_PANE_VISIBLE) + GPM_SIDE_PANE_VISIBLE) /* Bottom Panel visiblity */ DEFINE_BOOL_PREF (bottom_panel_visible, - GPM_BOTTOM_PANEL_VISIBLE, - GPM_DEFAULT_BOTTOM_PANEL_VISIBLE) + GPM_BOTTOM_PANEL_VISIBLE) /* Print syntax highlighting */ DEFINE_BOOL_PREF (print_syntax_hl, - GPM_PRINT_SYNTAX, - GPM_DEFAULT_PRINT_SYNTAX) + GPM_PRINT_SYNTAX) /* Print header */ DEFINE_BOOL_PREF (print_header, - GPM_PRINT_HEADER, - GPM_DEFAULT_PRINT_HEADER) + GPM_PRINT_HEADER) /* Print Wrap mode */ @@ -538,8 +462,7 @@ pluma_prefs_manager_get_print_wrap_mode (void) pluma_debug (DEBUG_PREFS); - str = pluma_prefs_manager_get_string (GPM_PRINT_WRAP_MODE, - GPM_DEFAULT_PRINT_WRAP_MODE); + str = pluma_prefs_manager_get_string (GPM_PRINT_WRAP_MODE); if (strcmp (str, "GTK_WRAP_NONE") == 0) res = GTK_WRAP_NONE; @@ -590,53 +513,91 @@ pluma_prefs_manager_print_wrap_mode_can_set (void) /* Print line numbers */ DEFINE_INT_PREF (print_line_numbers, - GPM_PRINT_LINE_NUMBERS, - GPM_DEFAULT_PRINT_LINE_NUMBERS) + GPM_PRINT_LINE_NUMBERS) /* Printing fonts */ DEFINE_STRING_PREF (print_font_body, - GPM_PRINT_FONT_BODY, - GPM_DEFAULT_PRINT_FONT_BODY) + GPM_PRINT_FONT_BODY) -const gchar * +gchar * +pluma_prefs_manager_get_default_string_value (const gchar *key) +{ + gchar *font = NULL; + g_settings_delay (pluma_prefs_manager->settings); + g_settings_reset (pluma_prefs_manager->settings, key); + font = g_settings_get_string (pluma_prefs_manager->settings, key); + g_settings_revert (pluma_prefs_manager->settings); + return font; +} + +gchar * pluma_prefs_manager_get_default_print_font_body (void) { - return GPM_DEFAULT_PRINT_FONT_BODY; + return pluma_prefs_manager_get_default_string_value (GPM_PRINT_FONT_BODY); } DEFINE_STRING_PREF (print_font_header, - GPM_PRINT_FONT_HEADER, - GPM_DEFAULT_PRINT_FONT_HEADER) + GPM_PRINT_FONT_HEADER) -const gchar * +gchar * pluma_prefs_manager_get_default_print_font_header (void) { - return GPM_DEFAULT_PRINT_FONT_HEADER; + return pluma_prefs_manager_get_default_string_value (GPM_PRINT_FONT_HEADER); } DEFINE_STRING_PREF (print_font_numbers, - GPM_PRINT_FONT_NUMBERS, - GPM_DEFAULT_PRINT_FONT_NUMBERS) + GPM_PRINT_FONT_NUMBERS) -const gchar * +gchar * pluma_prefs_manager_get_default_print_font_numbers (void) { - return GPM_DEFAULT_PRINT_FONT_NUMBERS; + return pluma_prefs_manager_get_default_string_value (GPM_PRINT_FONT_NUMBERS); } /* Max number of files in "Recent Files" menu. - * This is configurable only using mateconftool or mateconf-editor + * This is configurable only using gsettings, dconf or dconf-editor */ gint pluma_prefs_manager_get_max_recents (void) { pluma_debug (DEBUG_PREFS); - return pluma_prefs_manager_get_int (GPM_MAX_RECENTS, - GPM_DEFAULT_MAX_RECENTS); + return pluma_prefs_manager_get_int (GPM_MAX_RECENTS); } +/* GSettings/GSList utility functions from mate-panel */ + +GSList* +pluma_prefs_manager_get_gslist (GSettings *settings, const gchar *key) +{ + gchar **array; + GSList *list = NULL; + gint i; + array = g_settings_get_strv (settings, key); + if (array != NULL) { + for (i = 0; array[i]; i++) { + list = g_slist_append (list, g_strdup (array[i])); + } + } + g_strfreev (array); + return list; +} + +void +pluma_prefs_manager_set_gslist (GSettings *settings, const gchar *key, GSList *list) +{ + GArray *array; + GSList *l; + array = g_array_new (TRUE, TRUE, sizeof (gchar *)); + for (l = list; l; l = l->next) { + array = g_array_append_val (array, l->data); + } + g_settings_set_strv (settings, key, (const gchar **) array->data); + g_array_free (array, TRUE); +} + + /* Encodings */ static gboolean @@ -663,28 +624,9 @@ pluma_prefs_manager_get_auto_detected_encodings (void) pluma_debug (DEBUG_PREFS); g_return_val_if_fail (pluma_prefs_manager != NULL, NULL); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL); + g_return_val_if_fail (pluma_prefs_manager->settings != NULL, NULL); - strings = mateconf_client_get_list (pluma_prefs_manager->mateconf_client, - GPM_AUTO_DETECTED_ENCODINGS, - MATECONF_VALUE_STRING, - NULL); - - if (strings == NULL) - { - gint i = 0; - const gchar* s[] = GPM_DEFAULT_AUTO_DETECTED_ENCODINGS; - - while (s[i] != NULL) - { - strings = g_slist_prepend (strings, g_strdup (s[i])); - - ++i; - } - - - strings = g_slist_reverse (strings); - } + strings = pluma_prefs_manager_get_gslist (pluma_prefs_manager->settings, GPM_AUTO_DETECTED_ENCODINGS); if (strings != NULL) { @@ -733,12 +675,9 @@ pluma_prefs_manager_get_shown_in_menu_encodings (void) pluma_debug (DEBUG_PREFS); g_return_val_if_fail (pluma_prefs_manager != NULL, NULL); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL); + g_return_val_if_fail (pluma_prefs_manager->settings != NULL, NULL); - strings = mateconf_client_get_list (pluma_prefs_manager->mateconf_client, - GPM_SHOWN_IN_MENU_ENCODINGS, - MATECONF_VALUE_STRING, - NULL); + strings = pluma_prefs_manager_get_gslist (pluma_prefs_manager->settings, GPM_SHOWN_IN_MENU_ENCODINGS); if (strings != NULL) { @@ -781,7 +720,7 @@ pluma_prefs_manager_set_shown_in_menu_encodings (const GSList *encs) GSList *list = NULL; g_return_if_fail (pluma_prefs_manager != NULL); - g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL); + g_return_if_fail (pluma_prefs_manager->settings != NULL); g_return_if_fail (pluma_prefs_manager_shown_in_menu_encodings_can_set ()); while (encs != NULL) @@ -800,12 +739,8 @@ pluma_prefs_manager_set_shown_in_menu_encodings (const GSList *encs) } list = g_slist_reverse (list); - - mateconf_client_set_list (pluma_prefs_manager->mateconf_client, - GPM_SHOWN_IN_MENU_ENCODINGS, - MATECONF_VALUE_STRING, - list, - NULL); + + pluma_prefs_manager_set_gslist (pluma_prefs_manager->settings, GPM_SHOWN_IN_MENU_ENCODINGS, list); g_slist_free (list); } @@ -821,23 +756,19 @@ pluma_prefs_manager_shown_in_menu_encodings_can_set (void) /* Highlight current line */ DEFINE_BOOL_PREF (highlight_current_line, - GPM_HIGHLIGHT_CURRENT_LINE, - GPM_DEFAULT_HIGHLIGHT_CURRENT_LINE) + GPM_HIGHLIGHT_CURRENT_LINE) /* Highlight matching bracket */ DEFINE_BOOL_PREF (bracket_matching, - GPM_BRACKET_MATCHING, - GPM_DEFAULT_BRACKET_MATCHING) + GPM_BRACKET_MATCHING) /* Display Right Margin */ DEFINE_BOOL_PREF (display_right_margin, - GPM_DISPLAY_RIGHT_MARGIN, - GPM_DEFAULT_DISPLAY_RIGHT_MARGIN) + GPM_DISPLAY_RIGHT_MARGIN) /* Right Margin Position */ DEFINE_INT_PREF (right_margin_position, - GPM_RIGHT_MARGIN_POSITION, - GPM_DEFAULT_RIGHT_MARGIN_POSITION) + GPM_RIGHT_MARGIN_POSITION) static GtkSourceSmartHomeEndType get_smart_home_end_from_string (const gchar *str) @@ -866,8 +797,7 @@ pluma_prefs_manager_get_smart_home_end (void) pluma_debug (DEBUG_PREFS); - str = pluma_prefs_manager_get_string (GPM_SMART_HOME_END, - GPM_DEFAULT_SMART_HOME_END); + str = pluma_prefs_manager_get_string (GPM_SMART_HOME_END); res = get_smart_home_end_from_string (str); @@ -914,18 +844,15 @@ pluma_prefs_manager_smart_home_end_can_set (void) /* Enable syntax highlighting */ DEFINE_BOOL_PREF (enable_syntax_highlighting, - GPM_SYNTAX_HL_ENABLE, - GPM_DEFAULT_SYNTAX_HL_ENABLE) + GPM_SYNTAX_HL_ENABLE) /* Enable search highlighting */ DEFINE_BOOL_PREF (enable_search_highlighting, - GPM_SEARCH_HIGHLIGHTING_ENABLE, - GPM_DEFAULT_SEARCH_HIGHLIGHTING_ENABLE) + GPM_SEARCH_HIGHLIGHTING_ENABLE) /* Source style scheme */ DEFINE_STRING_PREF (source_style_scheme, - GPM_SOURCE_STYLE_SCHEME, - GPM_DEFAULT_SOURCE_STYLE_SCHEME) + GPM_SOURCE_STYLE_SCHEME) GSList * pluma_prefs_manager_get_writable_vfs_schemes (void) @@ -935,27 +862,9 @@ pluma_prefs_manager_get_writable_vfs_schemes (void) pluma_debug (DEBUG_PREFS); g_return_val_if_fail (pluma_prefs_manager != NULL, NULL); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL); + g_return_val_if_fail (pluma_prefs_manager->settings != NULL, NULL); - strings = mateconf_client_get_list (pluma_prefs_manager->mateconf_client, - GPM_WRITABLE_VFS_SCHEMES, - MATECONF_VALUE_STRING, - NULL); - - if (strings == NULL) - { - gint i = 0; - const gchar* s[] = GPM_DEFAULT_WRITABLE_VFS_SCHEMES; - - while (s[i] != NULL) - { - strings = g_slist_prepend (strings, g_strdup (s[i])); - - ++i; - } - - strings = g_slist_reverse (strings); - } + strings = pluma_prefs_manager_get_gslist (pluma_prefs_manager->settings, GPM_WRITABLE_VFS_SCHEMES); /* The 'file' scheme is writable by default. */ strings = g_slist_prepend (strings, g_strdup ("file")); @@ -970,8 +879,7 @@ pluma_prefs_manager_get_restore_cursor_position (void) { pluma_debug (DEBUG_PREFS); - return pluma_prefs_manager_get_bool (GPM_RESTORE_CURSOR_POSITION, - GPM_DEFAULT_RESTORE_CURSOR_POSITION); + return pluma_prefs_manager_get_bool (GPM_RESTORE_CURSOR_POSITION); } /* Plugins: we just store/return a list of strings, all the magic has to @@ -985,12 +893,9 @@ pluma_prefs_manager_get_active_plugins (void) pluma_debug (DEBUG_PREFS); g_return_val_if_fail (pluma_prefs_manager != NULL, NULL); - g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL); + g_return_val_if_fail (pluma_prefs_manager->settings != NULL, NULL); - plugins = mateconf_client_get_list (pluma_prefs_manager->mateconf_client, - GPM_ACTIVE_PLUGINS, - MATECONF_VALUE_STRING, - NULL); + plugins = pluma_prefs_manager_get_gslist (pluma_prefs_manager->settings, GPM_ACTIVE_PLUGINS); return plugins; } @@ -999,14 +904,10 @@ void pluma_prefs_manager_set_active_plugins (const GSList *plugins) { g_return_if_fail (pluma_prefs_manager != NULL); - g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL); + g_return_if_fail (pluma_prefs_manager->settings != NULL); g_return_if_fail (pluma_prefs_manager_active_plugins_can_set ()); - mateconf_client_set_list (pluma_prefs_manager->mateconf_client, - GPM_ACTIVE_PLUGINS, - MATECONF_VALUE_STRING, - (GSList *) plugins, - NULL); + pluma_prefs_manager_set_gslist (pluma_prefs_manager->settings, GPM_ACTIVE_PLUGINS, (GSList *) plugins); } gboolean @@ -1024,218 +925,17 @@ pluma_prefs_manager_get_lockdown (void) { guint lockdown = 0; - if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_COMMAND_LINE, FALSE)) + if (g_settings_get_boolean (pluma_prefs_manager->lockdown_settings, GPM_LOCKDOWN_COMMAND_LINE)) lockdown |= PLUMA_LOCKDOWN_COMMAND_LINE; - if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_PRINTING, FALSE)) + if (g_settings_get_boolean (pluma_prefs_manager->lockdown_settings, GPM_LOCKDOWN_PRINTING)) lockdown |= PLUMA_LOCKDOWN_PRINTING; - if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_PRINT_SETUP, FALSE)) + if (g_settings_get_boolean (pluma_prefs_manager->lockdown_settings, GPM_LOCKDOWN_PRINT_SETUP)) lockdown |= PLUMA_LOCKDOWN_PRINT_SETUP; - if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_SAVE_TO_DISK, FALSE)) + if (g_settings_get_boolean (pluma_prefs_manager->lockdown_settings, GPM_LOCKDOWN_SAVE_TO_DISK)) lockdown |= PLUMA_LOCKDOWN_SAVE_TO_DISK; return lockdown; } - -/* The following functions are taken from mateconf-client.c - * and partially modified. - * The licensing terms on these is: - * - * - * MateConf - * Copyright (C) 1999, 2000, 2000 Red Hat Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - - -static const gchar* -mateconf_value_type_to_string(MateConfValueType type) -{ - switch (type) - { - case MATECONF_VALUE_INT: - return "int"; - break; - case MATECONF_VALUE_STRING: - return "string"; - break; - case MATECONF_VALUE_FLOAT: - return "float"; - break; - case MATECONF_VALUE_BOOL: - return "bool"; - break; - case MATECONF_VALUE_SCHEMA: - return "schema"; - break; - case MATECONF_VALUE_LIST: - return "list"; - break; - case MATECONF_VALUE_PAIR: - return "pair"; - break; - case MATECONF_VALUE_INVALID: - return "*invalid*"; - break; - default: - g_return_val_if_reached (NULL); - break; - } -} - -/* Emit the proper signals for the error, and fill in err */ -static gboolean -handle_error (MateConfClient* client, GError* error, GError** err) -{ - if (error != NULL) - { - mateconf_client_error(client, error); - - if (err == NULL) - { - mateconf_client_unreturned_error(client, error); - - g_error_free(error); - } - else - *err = error; - - return TRUE; - } - else - return FALSE; -} - -static gboolean -check_type (const gchar* key, MateConfValue* val, MateConfValueType t, GError** err) -{ - if (val->type != t) - { - /* - mateconf_set_error(err, MATECONF_ERROR_TYPE_MISMATCH, - _("Expected `%s' got, `%s' for key %s"), - mateconf_value_type_to_string(t), - mateconf_value_type_to_string(val->type), - key); - */ - g_set_error (err, MATECONF_ERROR, MATECONF_ERROR_TYPE_MISMATCH, - _("Expected `%s', got `%s' for key %s"), - mateconf_value_type_to_string(t), - mateconf_value_type_to_string(val->type), - key); - - return FALSE; - } - else - return TRUE; -} - -static gboolean -mateconf_client_get_bool_with_default (MateConfClient* client, const gchar* key, - gboolean def, GError** err) -{ - GError* error = NULL; - MateConfValue* val; - - g_return_val_if_fail (err == NULL || *err == NULL, def); - - val = mateconf_client_get (client, key, &error); - - if (val != NULL) - { - gboolean retval = def; - - g_return_val_if_fail (error == NULL, retval); - - if (check_type (key, val, MATECONF_VALUE_BOOL, &error)) - retval = mateconf_value_get_bool (val); - else - handle_error (client, error, err); - - mateconf_value_free (val); - - return retval; - } - else - { - if (error != NULL) - handle_error (client, error, err); - return def; - } -} - -static gchar* -mateconf_client_get_string_with_default (MateConfClient* client, const gchar* key, - const gchar* def, GError** err) -{ - GError* error = NULL; - gchar* val; - - g_return_val_if_fail (err == NULL || *err == NULL, def ? g_strdup (def) : NULL); - - val = mateconf_client_get_string (client, key, &error); - - if (val != NULL) - { - g_return_val_if_fail (error == NULL, def ? g_strdup (def) : NULL); - - return val; - } - else - { - if (error != NULL) - handle_error (client, error, err); - return def ? g_strdup (def) : NULL; - } -} - -static gint -mateconf_client_get_int_with_default (MateConfClient* client, const gchar* key, - gint def, GError** err) -{ - GError* error = NULL; - MateConfValue* val; - - g_return_val_if_fail (err == NULL || *err == NULL, def); - - val = mateconf_client_get (client, key, &error); - - if (val != NULL) - { - gint retval = def; - - g_return_val_if_fail (error == NULL, def); - - if (check_type (key, val, MATECONF_VALUE_INT, &error)) - retval = mateconf_value_get_int(val); - else - handle_error (client, error, err); - - mateconf_value_free (val); - - return retval; - } - else - { - if (error != NULL) - handle_error (client, error, err); - return def; - } -} - diff --git a/pluma/pluma-prefs-manager.h b/pluma/pluma-prefs-manager.h index e9e786c..f5822c9 100644 --- a/pluma/pluma-prefs-manager.h +++ b/pluma/pluma-prefs-manager.h @@ -35,184 +35,92 @@ #include #include "pluma-app.h" -#define PLUMA_BASE_KEY "/apps/pluma" - -#define GPM_PREFS_DIR PLUMA_BASE_KEY "/preferences" +#define PLUMA_SCHEMA "org.mate.pluma" /* Editor */ -#define GPM_FONT_DIR GPM_PREFS_DIR "/editor/font" -#define GPM_USE_DEFAULT_FONT GPM_FONT_DIR "/use_default_font" -#define GPM_EDITOR_FONT GPM_FONT_DIR "/editor_font" -#define GPM_SYSTEM_FONT "/desktop/mate/interface/monospace_font_name" +#define GPM_USE_DEFAULT_FONT "use-default-font" +#define GPM_EDITOR_FONT "editor-font" -#define GPM_SAVE_DIR GPM_PREFS_DIR "/editor/save" -#define GPM_CREATE_BACKUP_COPY GPM_SAVE_DIR "/create_backup_copy" +#define GPM_CREATE_BACKUP_COPY "create-backup-copy" -#define GPM_AUTO_SAVE GPM_SAVE_DIR "/auto_save" -#define GPM_AUTO_SAVE_INTERVAL GPM_SAVE_DIR "/auto_save_interval" +#define GPM_AUTO_SAVE "auto-save" +#define GPM_AUTO_SAVE_INTERVAL "auto-save-interval" -#define GPM_UNDO_DIR GPM_PREFS_DIR "/editor/undo" -#define GPM_UNDO_ACTIONS_LIMIT GPM_UNDO_DIR "/max_undo_actions" +#define GPM_UNDO_ACTIONS_LIMIT "max-undo-actions" -#define GPM_WRAP_MODE_DIR GPM_PREFS_DIR "/editor/wrap_mode" -#define GPM_WRAP_MODE GPM_WRAP_MODE_DIR "/wrap_mode" +#define GPM_WRAP_MODE "wrap-mode" -#define GPM_TABS_DIR GPM_PREFS_DIR "/editor/tabs" -#define GPM_TABS_SIZE GPM_TABS_DIR "/tabs_size" -#define GPM_INSERT_SPACES GPM_TABS_DIR "/insert_spaces" +#define GPM_TABS_SIZE "tabs-size" +#define GPM_INSERT_SPACES "insert-spaces" -#define GPM_AUTO_INDENT_DIR GPM_PREFS_DIR "/editor/auto_indent" -#define GPM_AUTO_INDENT GPM_AUTO_INDENT_DIR "/auto_indent" +#define GPM_AUTO_INDENT "auto-indent" -#define GPM_LINE_NUMBERS_DIR GPM_PREFS_DIR "/editor/line_numbers" -#define GPM_DISPLAY_LINE_NUMBERS GPM_LINE_NUMBERS_DIR "/display_line_numbers" +#define GPM_DISPLAY_LINE_NUMBERS "display-line-numbers" -#define GPM_CURRENT_LINE_DIR GPM_PREFS_DIR "/editor/current_line" -#define GPM_HIGHLIGHT_CURRENT_LINE GPM_CURRENT_LINE_DIR "/highlight_current_line" +#define GPM_HIGHLIGHT_CURRENT_LINE "highlight-current-line" -#define GPM_BRACKET_MATCHING_DIR GPM_PREFS_DIR "/editor/bracket_matching" -#define GPM_BRACKET_MATCHING GPM_BRACKET_MATCHING_DIR "/bracket_matching" +#define GPM_BRACKET_MATCHING "bracket-matching" -#define GPM_RIGHT_MARGIN_DIR GPM_PREFS_DIR "/editor/right_margin" -#define GPM_DISPLAY_RIGHT_MARGIN GPM_RIGHT_MARGIN_DIR "/display_right_margin" -#define GPM_RIGHT_MARGIN_POSITION GPM_RIGHT_MARGIN_DIR "/right_margin_position" +#define GPM_DISPLAY_RIGHT_MARGIN "display-right-margin" +#define GPM_RIGHT_MARGIN_POSITION "right-margin-position" -#define GPM_SMART_HOME_END_DIR GPM_PREFS_DIR "/editor/smart_home_end" -#define GPM_SMART_HOME_END GPM_SMART_HOME_END_DIR "/smart_home_end" +#define GPM_SMART_HOME_END "smart-home-end" -#define GPM_CURSOR_POSITION_DIR GPM_PREFS_DIR "/editor/cursor_position" -#define GPM_RESTORE_CURSOR_POSITION GPM_CURSOR_POSITION_DIR "/restore_cursor_position" +#define GPM_RESTORE_CURSOR_POSITION "restore-cursor-position" -#define GPM_SEARCH_HIGHLIGHTING_DIR GPM_PREFS_DIR "/editor/search_highlighting" -#define GPM_SEARCH_HIGHLIGHTING_ENABLE GPM_SEARCH_HIGHLIGHTING_DIR "/enable" +#define GPM_SEARCH_HIGHLIGHTING_ENABLE "enable-search-highlighting" -#define GPM_SOURCE_STYLE_DIR GPM_PREFS_DIR "/editor/colors" -#define GPM_SOURCE_STYLE_SCHEME GPM_SOURCE_STYLE_DIR "/scheme" +#define GPM_SOURCE_STYLE_SCHEME "color-scheme" /* UI */ -#define GPM_TOOLBAR_DIR GPM_PREFS_DIR "/ui/toolbar" -#define GPM_TOOLBAR_VISIBLE GPM_TOOLBAR_DIR "/toolbar_visible" -#define GPM_TOOLBAR_BUTTONS_STYLE GPM_TOOLBAR_DIR "/toolbar_buttons_style" +#define GPM_TOOLBAR_VISIBLE "toolbar-visible" +#define GPM_TOOLBAR_BUTTONS_STYLE "toolbar-buttons-style" -#define GPM_STATUSBAR_DIR GPM_PREFS_DIR "/ui/statusbar" -#define GPM_STATUSBAR_VISIBLE GPM_STATUSBAR_DIR "/statusbar_visible" +#define GPM_STATUSBAR_VISIBLE "statusbar-visible" -#define GPM_SIDE_PANE_DIR GPM_PREFS_DIR "/ui/side_pane" -#define GPM_SIDE_PANE_VISIBLE GPM_SIDE_PANE_DIR "/side_pane_visible" +#define GPM_SIDE_PANE_VISIBLE "side-pane-visible" -#define GPM_BOTTOM_PANEL_DIR GPM_PREFS_DIR "/ui/bottom_panel" -#define GPM_BOTTOM_PANEL_VISIBLE GPM_BOTTOM_PANEL_DIR "/bottom_panel_visible" +#define GPM_BOTTOM_PANEL_VISIBLE "bottom-panel-visible" -#define GPM_RECENTS_DIR GPM_PREFS_DIR "/ui/recents" -#define GPM_MAX_RECENTS GPM_RECENTS_DIR "/max_recents" +#define GPM_MAX_RECENTS "max-recents" /* Print */ -#define GPM_PRINT_PAGE_DIR GPM_PREFS_DIR "/print/page" -#define GPM_PRINT_SYNTAX GPM_PRINT_PAGE_DIR "/print_syntax_highlighting" -#define GPM_PRINT_HEADER GPM_PRINT_PAGE_DIR "/print_header" -#define GPM_PRINT_WRAP_MODE GPM_PRINT_PAGE_DIR "/print_wrap_mode" -#define GPM_PRINT_LINE_NUMBERS GPM_PRINT_PAGE_DIR "/print_line_numbers" +#define GPM_PRINT_SYNTAX "print-syntax-highlighting" +#define GPM_PRINT_HEADER "print-header" +#define GPM_PRINT_WRAP_MODE "print-wrap-mode" +#define GPM_PRINT_LINE_NUMBERS "print-line-numbers" -#define GPM_PRINT_FONT_DIR GPM_PREFS_DIR "/print/fonts" -#define GPM_PRINT_FONT_BODY GPM_PRINT_FONT_DIR "/print_font_body_pango" -#define GPM_PRINT_FONT_HEADER GPM_PRINT_FONT_DIR "/print_font_header_pango" -#define GPM_PRINT_FONT_NUMBERS GPM_PRINT_FONT_DIR "/print_font_numbers_pango" +#define GPM_PRINT_FONT_BODY "print-font-body-pango" +#define GPM_PRINT_FONT_HEADER "print-font-header-pango" +#define GPM_PRINT_FONT_NUMBERS "print-font-numbers-pango" /* Encodings */ -#define GPM_ENCODINGS_DIR GPM_PREFS_DIR "/encodings" -#define GPM_AUTO_DETECTED_ENCODINGS GPM_ENCODINGS_DIR "/auto_detected" -#define GPM_SHOWN_IN_MENU_ENCODINGS GPM_ENCODINGS_DIR "/shown_in_menu" +#define GPM_AUTO_DETECTED_ENCODINGS "auto-detected-encodings" +#define GPM_SHOWN_IN_MENU_ENCODINGS "shown-in-menu-encodings" /* Syntax highlighting */ -#define GPM_SYNTAX_HL_DIR GPM_PREFS_DIR "/syntax_highlighting" -#define GPM_SYNTAX_HL_ENABLE GPM_SYNTAX_HL_DIR "/enable" +#define GPM_SYNTAX_HL_ENABLE "enable-syntax-highlighting" /* White list of writable mate-vfs methods */ -#define GPM_WRITABLE_VFS_SCHEMES GPM_SAVE_DIR "/writable_vfs_schemes" +#define GPM_WRITABLE_VFS_SCHEMES "writable-vfs-schemes" /* Plugins */ -#define GPM_PLUGINS_DIR PLUMA_BASE_KEY "/plugins" -#define GPM_ACTIVE_PLUGINS GPM_PLUGINS_DIR "/active-plugins" +#define GPM_ACTIVE_PLUGINS "active-plugins" + +/* Global Interface keys */ +#define GPM_INTERFACE_SCHEMA "org.mate.interface" +#define GPM_SYSTEM_FONT "monospace-font-name" /* Global Lockdown keys */ -#define GPM_LOCKDOWN_DIR "/desktop/mate/lockdown" -#define GPM_LOCKDOWN_COMMAND_LINE GPM_LOCKDOWN_DIR "/disable_command_line" -#define GPM_LOCKDOWN_PRINTING GPM_LOCKDOWN_DIR "/disable_printing" -#define GPM_LOCKDOWN_PRINT_SETUP GPM_LOCKDOWN_DIR "/disable_print_setup" -#define GPM_LOCKDOWN_SAVE_TO_DISK GPM_LOCKDOWN_DIR "/disable_save_to_disk" +#define GPM_LOCKDOWN_SCHEMA "org.mate.lockdown" +#define GPM_LOCKDOWN_COMMAND_LINE "disable-command-line" +#define GPM_LOCKDOWN_PRINTING "disable-printing" +#define GPM_LOCKDOWN_PRINT_SETUP "disable-print-setup" +#define GPM_LOCKDOWN_SAVE_TO_DISK "disable-save-to-disk" -/* Fallback default values. Keep in sync with pluma.schemas */ - -#define GPM_DEFAULT_USE_DEFAULT_FONT 1 /* TRUE */ - -#ifndef PLATFORM_OSX -#define GPM_DEFAULT_EDITOR_FONT (const gchar*) "Monospace 12" -#define GPM_DEFAULT_SYSTEM_FONT (const gchar*) "Monospace 10" -#else -#define GPM_DEFAULT_EDITOR_FONT (const gchar*) "Monaco 12" -#define GPM_DEFAULT_SYSTEM_FONT (const gchar*) "Monaco 12" -#endif - -#define GPM_DEFAULT_CREATE_BACKUP_COPY 0 /* FALSE */ - -#define GPM_DEFAULT_AUTO_SAVE 0 /* FALSE */ +/* Fallback default values. Keep in sync with org.mate.pluma.gschema.xml */ #define GPM_DEFAULT_AUTO_SAVE_INTERVAL 10 /* minutes */ - -#define GPM_DEFAULT_UNDO_ACTIONS_LIMIT 2000 /* actions */ - -#define GPM_DEFAULT_WRAP_MODE "GTK_WRAP_WORD" - -#define GPM_DEFAULT_TABS_SIZE 8 -#define GPM_DEFAULT_INSERT_SPACES 0 /* FALSE */ - -#define GPM_DEFAULT_AUTO_INDENT 0 /* FALSE */ - -#define GPM_DEFAULT_DISPLAY_LINE_NUMBERS 0 /* FALSE */ - -#define GPM_DEFAULT_AUTO_DETECTED_ENCODINGS {"UTF-8", "CURRENT", "ISO-8859-15", NULL} - -#define GPM_DEFAULT_TOOLBAR_VISIBLE 1 /* TRUE */ -#define GPM_DEFAULT_TOOLBAR_BUTTONS_STYLE "PLUMA_TOOLBAR_SYSTEM" -#define GPM_DEFAULT_TOOLBAR_SHOW_TOOLTIPS 1 /* TRUE */ - -#define GPM_DEFAULT_STATUSBAR_VISIBLE 1 /* TRUE */ -#define GPM_DEFAULT_SIDE_PANE_VISIBLE 0 /* FALSE */ -#define GPM_DEFAULT_BOTTOM_PANEL_VISIBLE 0 /* FALSE */ - -#define GPM_DEFAULT_PRINT_SYNTAX 1 /* TRUE */ -#define GPM_DEFAULT_PRINT_HEADER 1 /* TRUE */ -#define GPM_DEFAULT_PRINT_WRAP_MODE "GTK_WRAP_WORD" -#define GPM_DEFAULT_PRINT_LINE_NUMBERS 0 /* No numbers */ - -#ifndef PLATFORM_OSX -#define GPM_DEFAULT_PRINT_FONT_BODY (const gchar*) "Monospace 9" -#else -#define GPM_DEFAULT_PRINT_FONT_BODY (const gchar*) "Monaco 10" -#endif - -#define GPM_DEFAULT_PRINT_FONT_HEADER (const gchar*) "Sans 11" -#define GPM_DEFAULT_PRINT_FONT_NUMBERS (const gchar*) "Sans 8" - -#define GPM_DEFAULT_MAX_RECENTS 5 - -#define GPM_DEFAULT_HIGHLIGHT_CURRENT_LINE 1 /* TRUE */ - -#define GPM_DEFAULT_BRACKET_MATCHING 0 /* FALSE */ - -#define GPM_DEFAULT_DISPLAY_RIGHT_MARGIN 0 /* FALSE */ -#define GPM_DEFAULT_RIGHT_MARGIN_POSITION 80 - -#define GPM_DEFAULT_SMART_HOME_END "AFTER" - -#define GPM_DEFAULT_SYNTAX_HL_ENABLE 1 /* TRUE */ - -#define GPM_DEFAULT_WRITABLE_VFS_SCHEMES {"ssh", "sftp", "smb", "dav", "davs", NULL} - -#define GPM_DEFAULT_RESTORE_CURSOR_POSITION 1 /* TRUE */ - -#define GPM_DEFAULT_SEARCH_HIGHLIGHTING_ENABLE 1 /* TRUE */ - -#define GPM_DEFAULT_SOURCE_STYLE_SCHEME "classic" +#define GPM_DEFAULT_MAX_RECENTS 5 typedef enum { PLUMA_TOOLBAR_SYSTEM = 0, @@ -337,22 +245,22 @@ gboolean pluma_prefs_manager_print_line_numbers_can_set (void); gchar *pluma_prefs_manager_get_print_font_body (void); void pluma_prefs_manager_set_print_font_body (const gchar *font); gboolean pluma_prefs_manager_print_font_body_can_set (void); -const gchar *pluma_prefs_manager_get_default_print_font_body (void); +gchar *pluma_prefs_manager_get_default_print_font_body (void); /* Font used to print headers */ gchar *pluma_prefs_manager_get_print_font_header (void); void pluma_prefs_manager_set_print_font_header (const gchar *font); gboolean pluma_prefs_manager_print_font_header_can_set (void); -const gchar *pluma_prefs_manager_get_default_print_font_header (void); +gchar *pluma_prefs_manager_get_default_print_font_header (void); /* Font used to print line numbers */ gchar *pluma_prefs_manager_get_print_font_numbers (void); void pluma_prefs_manager_set_print_font_numbers (const gchar *font); gboolean pluma_prefs_manager_print_font_numbers_can_set (void); -const gchar *pluma_prefs_manager_get_default_print_font_numbers (void); +gchar *pluma_prefs_manager_get_default_print_font_numbers (void); /* Max number of files in "Recent Files" menu. - * This is configurable only using mateconftool or mateconf-editor + * This is configurable only using gsettings, dconf or dconf-editor */ gint pluma_prefs_manager_get_max_recents (void); @@ -418,6 +326,11 @@ gboolean pluma_prefs_manager_active_plugins_can_set (void); /* Global lockdown */ PlumaLockdownMask pluma_prefs_manager_get_lockdown (void); +/* GSettings utilities */ +GSList* pluma_prefs_manager_get_gslist (GSettings *settings, const gchar *key); +void pluma_prefs_manager_set_gslist (GSettings *settings, const gchar *key, GSList *list); + + #endif /* __PLUMA_PREFS_MANAGER_H__ */ diff --git a/pluma/pluma-print-job.c b/pluma/pluma-print-job.c index cfc9205..69de06c 100644 --- a/pluma/pluma-print-job.c +++ b/pluma/pluma-print-job.c @@ -269,35 +269,41 @@ restore_button_clicked (GtkButton *button, { if (pluma_prefs_manager_print_font_body_can_set ()) { - const gchar *font; + gchar *font; font = pluma_prefs_manager_get_default_print_font_body (); gtk_font_button_set_font_name ( GTK_FONT_BUTTON (job->priv->body_fontbutton), font); + + g_free (font); } if (pluma_prefs_manager_print_font_header_can_set ()) { - const gchar *font; + gchar *font; font = pluma_prefs_manager_get_default_print_font_header (); gtk_font_button_set_font_name ( GTK_FONT_BUTTON (job->priv->headers_fontbutton), font); + + g_free (font); } if (pluma_prefs_manager_print_font_numbers_can_set ()) { - const gchar *font; + gchar *font; font = pluma_prefs_manager_get_default_print_font_numbers (); gtk_font_button_set_font_name ( GTK_FONT_BUTTON (job->priv->numbers_fontbutton), font); + + g_free (font); } }