[gnome-builder/wip/libide] libide: reload gtksourcelanguage when file changes



commit 27584323404e99316f486b5000587fa7a0206b19
Author: Christian Hergert <christian hergert me>
Date:   Tue Feb 24 17:25:38 2015 -0800

    libide: reload gtksourcelanguage when file changes

 libide/ide-source-view.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index a5684f8..f0b374f 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -65,8 +65,19 @@ ide_source_view__buffer_notify_file_cb (IdeSourceView *self,
                                         GParamSpec    *pspec,
                                         IdeBuffer     *buffer)
 {
+  IdeFile *file;
+  IdeLanguage *language;
+  GtkSourceLanguage *source_language;
+
   g_assert (IDE_IS_SOURCE_VIEW (self));
   g_assert (IDE_IS_BUFFER (buffer));
+
+  if ((file = ide_buffer_get_file (buffer)) &&
+      (language = ide_file_get_language (file)) &&
+      (source_language = ide_language_get_source_language (language)))
+    gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (buffer), source_language);
+  else
+    gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (buffer), NULL);
 }
 
 static void


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