[gedit/gnome-3-8] document: directly bind some of the properties with the settings



commit c50dab0231c441972031c6485b36710bb6b0cf75
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sun Apr 21 11:27:57 2013 +0200

    document: directly bind some of the properties with the settings

 gedit/gedit-document.c | 28 ++++++++----------
 gedit/gedit-settings.c | 77 --------------------------------------------------
 2 files changed, 12 insertions(+), 93 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index bd1aa6f..dfe5ec5 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -946,9 +946,6 @@ static void
 gedit_document_init (GeditDocument *doc)
 {
        GtkSourceStyleScheme *style_scheme;
-       gint undo_actions;
-       gboolean bracket_matching;
-       gboolean search_hl;
 
        gedit_debug (DEBUG_DOCUMENT);
 
@@ -979,21 +976,20 @@ gedit_document_init (GeditDocument *doc)
 
        doc->priv->encoding = gedit_encoding_get_utf8 ();
 
-       undo_actions = g_settings_get_int (doc->priv->editor_settings,
-                                          GEDIT_SETTINGS_MAX_UNDO_ACTIONS);
-       bracket_matching = g_settings_get_boolean (doc->priv->editor_settings,
-                                                  GEDIT_SETTINGS_BRACKET_MATCHING);
-       search_hl = g_settings_get_boolean (doc->priv->editor_settings,
-                                           GEDIT_SETTINGS_SEARCH_HIGHLIGHTING);
+       g_settings_bind (doc->priv->editor_settings,
+                        GEDIT_SETTINGS_MAX_UNDO_ACTIONS,
+                        doc,
+                        "max-undo-levels");
 
-       gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (doc),
-                                              undo_actions);
+       g_settings_bind (doc->priv->editor_settings,
+                        GEDIT_SETTINGS_BRACKET_MATCHING,
+                        doc,
+                        "bracket-matching");
 
-       gtk_source_buffer_set_highlight_matching_brackets (GTK_SOURCE_BUFFER (doc),
-                                                          bracket_matching);
-
-       gedit_document_set_enable_search_highlighting (doc,
-                                                      search_hl);
+       g_settings_bind (doc->priv->editor_settings,
+                        GEDIT_SETTINGS_SEARCH_HIGHLIGHTING,
+                        doc,
+                        "enable-search-highlighting");
 
        style_scheme = get_default_style_scheme (doc->priv->editor_settings);
        if (style_scheme != NULL)
diff --git a/gedit/gedit-settings.c b/gedit/gedit-settings.c
index 25e04c1..953b78d 100644
--- a/gedit/gedit-settings.c
+++ b/gedit/gedit-settings.c
@@ -300,50 +300,6 @@ on_auto_save_interval_changed (GSettings     *settings,
 }
 
 static void
-on_undo_actions_limit_changed (GSettings     *settings,
-                              const gchar   *key,
-                              GeditSettings *gs)
-{
-       GList *docs, *l;
-       gint ul;
-
-       ul = g_settings_get_int (settings, key);
-
-       ul = CLAMP (ul, -1, 250);
-
-       docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
-
-       for (l = docs; l != NULL; l = g_list_next (l))
-       {
-               gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (l->data),
-                                                      ul);
-       }
-
-       g_list_free (docs);
-}
-
-static void
-on_bracket_matching_changed (GSettings     *settings,
-                            const gchar   *key,
-                            GeditSettings *gs)
-{
-       GList *docs, *l;
-       gboolean enable;
-
-       enable = g_settings_get_boolean (settings, key);
-
-       docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
-
-       for (l = docs; l != NULL; l = g_list_next (l))
-       {
-               gtk_source_buffer_set_highlight_matching_brackets (GTK_SOURCE_BUFFER (l->data),
-                                                                  enable);
-       }
-
-       g_list_free (docs);
-}
-
-static void
 on_syntax_highlighting_changed (GSettings     *settings,
                                const gchar   *key,
                                GeditSettings *gs)
@@ -383,27 +339,6 @@ on_syntax_highlighting_changed (GSettings     *settings,
 }
 
 static void
-on_search_highlighting_changed (GSettings     *settings,
-                               const gchar   *key,
-                               GeditSettings *gs)
-{
-       GList *docs, *l;
-       gboolean enable;
-
-       enable = g_settings_get_boolean (settings, key);
-
-       docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
-
-       for (l = docs; l != NULL; l = g_list_next (l))
-       {
-               gedit_document_set_enable_search_highlighting  (GEDIT_DOCUMENT (l->data),
-                                                               enable);
-       }
-
-       g_list_free (docs);
-}
-
-static void
 gedit_settings_init (GeditSettings *gs)
 {
        gs->priv = GEDIT_SETTINGS_GET_PRIVATE (gs);
@@ -449,21 +384,9 @@ gedit_settings_init (GeditSettings *gs)
                          G_CALLBACK (on_auto_save_interval_changed),
                          gs);
        g_signal_connect (gs->priv->editor,
-                         "changed::undo-actions-limit",
-                         G_CALLBACK (on_undo_actions_limit_changed),
-                         gs);
-       g_signal_connect (gs->priv->editor,
-                         "changed::bracket-matching",
-                         G_CALLBACK (on_bracket_matching_changed),
-                         gs);
-       g_signal_connect (gs->priv->editor,
                          "changed::syntax-highlighting",
                          G_CALLBACK (on_syntax_highlighting_changed),
                          gs);
-       g_signal_connect (gs->priv->editor,
-                         "changed::search-highlighting",
-                         G_CALLBACK (on_search_highlighting_changed),
-                         gs);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]