[gnome-builder/wip/chergert/layout] editor: add convenience API for current language



commit da374f8863214f16567002dc4d61dd21b46c63f6
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jul 7 21:32:04 2017 -0700

    editor: add convenience API for current language

 libide/editor/ide-editor-view.c |   37 +++++++++++++++++++++++++++++++++++++
 libide/editor/ide-editor-view.h |   25 ++++++++++++++-----------
 2 files changed, 51 insertions(+), 11 deletions(-)
---
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index 7703984..1f5e7ed 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -869,3 +869,40 @@ ide_editor_view_set_show_map (IdeEditorView *self,
       g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_AUTO_HIDE_MAP]);
     }
 }
+
+/**
+ * ide_editor_view_set_language:
+ * @self: a #IdeEditorView
+ *
+ * This is a convenience function to set the language on the underlying
+ * #IdeBuffer text buffer.
+ *
+ * Since: 3.26
+ */
+void
+ide_editor_view_set_language (IdeEditorView     *self,
+                              GtkSourceLanguage *language)
+{
+  g_return_if_fail (IDE_IS_EDITOR_VIEW (self));
+  g_return_if_fail (!language || GTK_SOURCE_IS_LANGUAGE (language));
+
+  gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (self->buffer), language);
+}
+
+/**
+ * ide_editor_view_get_language:
+ * @self: a #IdeEditorView
+ *
+ * Gets the #GtkSourceLanguage that is used by the underlying buffer.
+ *
+ * Returns: (transfer none) (nullable): A #GtkSourceLanguage or %NULL.
+ *
+ * Since: 3.26
+ */
+GtkSourceLanguage *
+ide_editor_view_get_language (IdeEditorView *self)
+{
+  g_return_val_if_fail (IDE_IS_EDITOR_VIEW (self), NULL);
+
+  return gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (self->buffer));
+}
diff --git a/libide/editor/ide-editor-view.h b/libide/editor/ide-editor-view.h
index b46b2eb..443c322 100644
--- a/libide/editor/ide-editor-view.h
+++ b/libide/editor/ide-editor-view.h
@@ -30,16 +30,19 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (IdeEditorView, ide_editor_view, IDE, EDITOR_VIEW, IdeLayoutView)
 
-IdeBuffer     *ide_editor_view_get_buffer        (IdeEditorView *self);
-IdeSourceView *ide_editor_view_get_view          (IdeEditorView *self);
-const gchar   *ide_editor_view_get_language_id   (IdeEditorView *self);
-void           ide_editor_view_scroll_to_line    (IdeEditorView *self,
-                                                  guint          line);
-gboolean       ide_editor_view_get_auto_hide_map (IdeEditorView *self);
-void           ide_editor_view_set_auto_hide_map (IdeEditorView *self,
-                                                  gboolean       auto_hide_map);
-gboolean       ide_editor_view_get_show_map      (IdeEditorView *self);
-void           ide_editor_view_set_show_map      (IdeEditorView *self,
-                                                  gboolean       show_map);
+IdeBuffer         *ide_editor_view_get_buffer        (IdeEditorView     *self);
+IdeSourceView     *ide_editor_view_get_view          (IdeEditorView     *self);
+const gchar       *ide_editor_view_get_language_id   (IdeEditorView     *self);
+void               ide_editor_view_scroll_to_line    (IdeEditorView     *self,
+                                                      guint              line);
+gboolean           ide_editor_view_get_auto_hide_map (IdeEditorView     *self);
+void               ide_editor_view_set_auto_hide_map (IdeEditorView     *self,
+                                                      gboolean           auto_hide_map);
+gboolean           ide_editor_view_get_show_map      (IdeEditorView     *self);
+void               ide_editor_view_set_show_map      (IdeEditorView     *self,
+                                                      gboolean           show_map);
+GtkSourceLanguage *ide_editor_view_get_language      (IdeEditorView     *self);
+void               ide_editor_view_set_language      (IdeEditorView     *self,
+                                                      GtkSourceLanguage *language);
 
 G_END_DECLS


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