From 07aef8bceacc973fd2439fc9b04376477136a60a Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Sat, 28 Dec 2019 22:20:19 +0100 Subject: avoid to make new Gsettings variables use Gsettings 'pluma_prefs_manager' instead --- pluma/pluma-notebook.c | 10 +++------- pluma/pluma-tab.c | 6 ++---- pluma/pluma-view.c | 12 +++--------- pluma/pluma-window.c | 27 ++++++++++----------------- 4 files changed, 18 insertions(+), 37 deletions(-) diff --git a/pluma/pluma-notebook.c b/pluma/pluma-notebook.c index 6278fbcb..b9e78761 100644 --- a/pluma/pluma-notebook.c +++ b/pluma/pluma-notebook.c @@ -49,6 +49,7 @@ #include "pluma-marshal.h" #include "pluma-window.h" #include "pluma-prefs-manager.h" +#include "pluma-prefs-manager-private.h" #define AFTER_ALL_TABS -1 #define NOT_IN_APP_WINDOWS -2 @@ -786,15 +787,12 @@ update_tabs_visibility (PlumaNotebook *nb) { gboolean show_tabs; guint num; - GSettings *settings; num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb)); - settings = g_settings_new ("org.mate.pluma"); + show_tabs = (g_settings_get_boolean (pluma_prefs_manager->settings, "show-single-tab") || num > 1); - show_tabs = (g_settings_get_boolean (settings, "show-single-tab") || num > 1); - - if (g_settings_get_boolean (settings, "show-tabs-with-side-pane")) + if (g_settings_get_boolean (pluma_prefs_manager->settings, "show-tabs-with-side-pane")) gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs); else { @@ -803,8 +801,6 @@ update_tabs_visibility (PlumaNotebook *nb) else gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs); } - - g_object_unref (settings); } static void diff --git a/pluma/pluma-tab.c b/pluma/pluma-tab.c index d9b8a165..96ae895e 100644 --- a/pluma/pluma-tab.c +++ b/pluma/pluma-tab.c @@ -43,6 +43,7 @@ #include "pluma-progress-message-area.h" #include "pluma-debug.h" #include "pluma-prefs-manager-app.h" +#include "pluma-prefs-manager-private.h" #include "pluma-enum-types.h" #define PLUMA_TAB_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), PLUMA_TYPE_TAB, PlumaTabPrivate)) @@ -2607,7 +2608,6 @@ _pluma_tab_can_close (PlumaTab *tab) { PlumaDocument *doc; PlumaTabState ts; - GSettings *settings; g_return_val_if_fail (PLUMA_IS_TAB (tab), FALSE); @@ -2615,15 +2615,13 @@ _pluma_tab_can_close (PlumaTab *tab) doc = pluma_tab_get_document (tab); - settings = g_settings_new ("org.mate.pluma"); - /* if we are loading or reverting, the tab can be closed */ if ((ts == PLUMA_TAB_STATE_LOADING) || (ts == PLUMA_TAB_STATE_LOADING_ERROR) || (ts == PLUMA_TAB_STATE_REVERTING) || (ts == PLUMA_TAB_STATE_REVERTING_ERROR) || /* CHECK: I'm not sure this is the right behavior for REVERTING ERROR */ (!gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc))) || - (!g_settings_get_boolean (settings, "show-save-confirmation"))) + (!g_settings_get_boolean (pluma_prefs_manager->settings, "show-save-confirmation"))) return TRUE; /* Do not close tab with saving errors */ diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c index c72d3c51..0cf654bd 100644 --- a/pluma/pluma-view.c +++ b/pluma/pluma-view.c @@ -46,6 +46,7 @@ #include "pluma-debug.h" #include "pluma-prefs-manager.h" #include "pluma-prefs-manager-app.h" +#include "pluma-prefs-manager-private.h" #include "pluma-marshal.h" #include "pluma-utils.h" @@ -682,11 +683,9 @@ pluma_view_scroll_to_cursor (PlumaView *view) static PangoFontDescription* get_system_font (void) { PangoFontDescription *desc = NULL; - GSettings *settings; char *name; - settings = g_settings_new ("org.mate.interface"); - name = g_settings_get_string (settings, "font-name"); + name = g_settings_get_string (pluma_prefs_manager->interface_settings, "font-name"); if (name) { @@ -694,8 +693,6 @@ static PangoFontDescription* get_system_font (void) g_free (name); } - g_object_unref (settings); - return desc; } @@ -743,12 +740,9 @@ pluma_override_font (const gchar *item, if (provider == NULL) { - static GSettings *settings; /*We need this for the life of the provider and program*/ - provider = gtk_css_provider_new (); - settings = g_settings_new ("org.mate.interface"); - g_signal_connect (settings, + g_signal_connect (pluma_prefs_manager->interface_settings, "changed::" "font-name", G_CALLBACK (system_font_changed_cb), NULL); diff --git a/pluma/pluma-window.c b/pluma/pluma-window.c index 40d5f470..af6f4c53 100644 --- a/pluma/pluma-window.c +++ b/pluma/pluma-window.c @@ -55,6 +55,7 @@ #include "pluma-debug.h" #include "pluma-language-manager.h" #include "pluma-prefs-manager-app.h" +#include "pluma-prefs-manager-private.h" #include "pluma-panel.h" #include "pluma-documents-panel.h" #include "pluma-plugins-engine.h" @@ -303,13 +304,11 @@ pluma_window_key_press_event (GtkWidget *widget, if (event->state & GDK_CONTROL_MASK) { - GSettings *settings; gchar *font; gchar *tempsize; gint nsize; - settings = g_settings_new ("org.mate.pluma"); - font = g_settings_get_string (settings, "editor-font"); + font = g_settings_get_string (pluma_prefs_manager->settings, "editor-font"); tempsize = g_strdup (font); g_strreverse (tempsize); @@ -327,10 +326,10 @@ pluma_window_key_press_event (GtkWidget *widget, nsize = nsize + 1; sprintf (tempsize, "%d", nsize); - if (!g_settings_get_boolean (settings, "use-default-font") && (nsize < 73)) + if (!g_settings_get_boolean (pluma_prefs_manager->settings, "use-default-font") && (nsize < 73)) { gchar *tmp = g_strconcat (tempfont, tempsize, NULL); - g_settings_set_string (settings, "editor-font", tmp); + g_settings_set_string (pluma_prefs_manager->settings, "editor-font", tmp); g_free (tmp); } } @@ -339,15 +338,15 @@ pluma_window_key_press_event (GtkWidget *widget, nsize = nsize - 1; sprintf (tempsize, "%d", nsize); - if (!g_settings_get_boolean (settings, "use-default-font") && (nsize > 5)) + if (!g_settings_get_boolean (pluma_prefs_manager->settings, "use-default-font") && (nsize > 5)) { gchar *tmp = g_strconcat (tempfont, tempsize, NULL); - g_settings_set_string (settings, "editor-font", tmp); + g_settings_set_string (pluma_prefs_manager->settings, "editor-font", tmp); g_free (tmp); } } - if (g_settings_get_boolean (settings, "ctrl-tab-switch-tabs")) + if (g_settings_get_boolean (pluma_prefs_manager->settings, "ctrl-tab-switch-tabs")) { GtkNotebook *notebook = GTK_NOTEBOOK (_pluma_window_get_notebook (PLUMA_WINDOW (window))); @@ -372,7 +371,6 @@ pluma_window_key_press_event (GtkWidget *widget, handled = TRUE; } } - g_object_unref (settings); g_free (font); g_free (tempsize); } @@ -3624,24 +3622,21 @@ side_panel_visibility_changed (GtkWidget *side_panel, { gboolean visible; GtkAction *action; - GSettings *settings; visible = gtk_widget_get_visible (side_panel); - settings = g_settings_new ("org.mate.pluma"); - - if (!g_settings_get_boolean (settings, "show-tabs-with-side-pane")) + if (!g_settings_get_boolean (pluma_prefs_manager->settings, "show-tabs-with-side-pane")) { if (visible) gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE); else gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), - g_settings_get_boolean (settings, "show-single-tab") || + g_settings_get_boolean (pluma_prefs_manager->settings, "show-single-tab") || (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1)); } else gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), - g_settings_get_boolean (settings, "show-single-tab") || + g_settings_get_boolean (pluma_prefs_manager->settings, "show-single-tab") || (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1)); if (pluma_prefs_manager_side_pane_visible_can_set ()) @@ -3657,8 +3652,6 @@ side_panel_visibility_changed (GtkWidget *side_panel, if (!visible && window->priv->active_tab != NULL) gtk_widget_grab_focus (GTK_WIDGET ( pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab)))); - - g_object_unref (settings); } static void -- cgit v1.2.1