[gnome-builder] libide: after buffer is loaded, handle modified GtkSourceLanguage



commit c7b5be70251f06bcecbf0a280d13c79821d1aca3
Author: Christian Hergert <christian hergert me>
Date:   Sat Mar 14 15:22:26 2015 -0700

    libide: after buffer is loaded, handle modified GtkSourceLanguage

 libide/ide-buffer.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index f5d2876..b539796 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -1147,6 +1147,23 @@ _ide_buffer_set_loading (IdeBuffer *self,
        */
 
       if (!self->loading)
-        g_signal_emit (self, gSignals [LOADED], 0);
+        {
+          IdeLanguage *language;
+          GtkSourceLanguage *srclang;
+          GtkSourceLanguage *current;
+
+          /*
+           * It is possible our source language has changed since the buffer loaded (as loading
+           * contents provides us the opportunity to inspect file contents and get a more
+           * accurate content-type).
+           */
+          language = ide_file_get_language (self->file);
+          srclang = ide_language_get_source_language (language);
+          current = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (self));
+          if (current != srclang)
+            gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (self), srclang);
+
+          g_signal_emit (self, gSignals [LOADED], 0);
+        }
     }
 }


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