[gedit] GeditDocument: bind syntax-highlighting gsetting



commit ce1a2e802a6459c3253cdfbe346196727cf3d4bd
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Apr 29 17:13:06 2015 +0200

    GeditDocument: bind syntax-highlighting gsetting
    
    The goal is to concentrate the use of GSettings in one place in
    GeditDocument, so that it'll be easier to make the code reusable.
    
    Having the "highlight-syntax" property as TRUE with a NULL language is
    fine for GtkSourceBuffer, so the code is easier like that. A binding is
    also better, so if the gsetting changes, it is reflected directly in
    gedit.

 gedit/gedit-document.c |   22 ++++++----------------
 1 files changed, 6 insertions(+), 16 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index b92ffae..0e20f38 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -594,22 +594,6 @@ set_language (GeditDocument     *doc,
 
        gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (doc), lang);
 
-       if (lang != NULL)
-       {
-               gboolean syntax_hl;
-
-               syntax_hl = g_settings_get_boolean (priv->editor_settings,
-                                                   GEDIT_SETTINGS_SYNTAX_HIGHLIGHTING);
-
-               gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (doc),
-                                                       syntax_hl);
-       }
-       else
-       {
-               gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (doc),
-                                                       FALSE);
-       }
-
        if (set_by_user)
        {
                const gchar *language = get_language_string (doc);
@@ -847,6 +831,12 @@ gedit_document_init (GeditDocument *doc)
                         G_SETTINGS_BIND_GET);
 
        g_settings_bind (priv->editor_settings,
+                        GEDIT_SETTINGS_SYNTAX_HIGHLIGHTING,
+                        doc,
+                        "highlight-syntax",
+                        G_SETTINGS_BIND_GET);
+
+       g_settings_bind (priv->editor_settings,
                         GEDIT_SETTINGS_BRACKET_MATCHING,
                         doc,
                         "highlight-matching-brackets",


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