[gnome-builder] editor: add GbSourceView:font-name property.



commit c2ffa34b86c78d8fcce3db1d45776a1e57ae2b11
Author: Christian Hergert <christian hergert me>
Date:   Wed Oct 15 23:11:12 2014 -0700

    editor: add GbSourceView:font-name property.

 src/editor/gb-source-view.c |   28 ++++++++++++++++++++++++++++
 src/editor/gb-source-view.h |    2 ++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index 632c28f..1c537ac 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -59,6 +59,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GbSourceView, gb_source_view, GTK_SOURCE_TYPE_VIEW)
 enum {
   PROP_0,
   PROP_AUTO_INDENTER,
+  PROP_FONT_NAME,
   PROP_SEARCH_HIGHLIGHTER,
   PROP_SHOW_SHADOW,
   LAST_PROP
@@ -1285,6 +1286,20 @@ gb_source_view_grab_focus (GtkWidget *widget)
   GTK_WIDGET_CLASS (gb_source_view_parent_class)->grab_focus (widget);
 }
 
+void
+gb_source_view_set_font_name (GbSourceView *view,
+                              const gchar  *font_name)
+{
+  PangoFontDescription *font_desc;
+
+  g_return_if_fail (GB_IS_SOURCE_VIEW (view));
+
+  font_desc = pango_font_description_from_string (font_name);
+  gtk_widget_override_font (GTK_WIDGET (view), font_desc);
+  if (font_desc)
+    pango_font_description_free (font_desc);
+}
+
 static void
 gb_source_view_finalize (GObject *object)
 {
@@ -1378,6 +1393,10 @@ gb_source_view_set_property (GObject      *object,
       gb_source_view_set_auto_indenter (view, g_value_get_object (value));
       break;
 
+    case PROP_FONT_NAME:
+      gb_source_view_set_font_name (view, g_value_get_string (value));
+      break;
+
     case PROP_SEARCH_HIGHLIGHTER:
       gb_source_view_set_search_highlighter (view, g_value_get_object (value));
       break;
@@ -1423,6 +1442,15 @@ gb_source_view_class_init (GbSourceViewClass *klass)
   g_object_class_install_property (object_class, PROP_AUTO_INDENTER,
                                    gParamSpecs [PROP_AUTO_INDENTER]);
 
+  gParamSpecs [PROP_FONT_NAME] =
+    g_param_spec_string ("font-name",
+                         _("Font Name"),
+                         _("The font name to apply to the widget."),
+                         NULL,
+                         (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_FONT_NAME,
+                                   gParamSpecs [PROP_FONT_NAME]);
+
   gParamSpecs[PROP_SHOW_SHADOW] =
     g_param_spec_boolean ("show-shadow",
                           _("Show Shadow"),
diff --git a/src/editor/gb-source-view.h b/src/editor/gb-source-view.h
index 0cb6775..841fc9c 100644
--- a/src/editor/gb-source-view.h
+++ b/src/editor/gb-source-view.h
@@ -76,6 +76,8 @@ void                  gb_source_view_begin_search       (GbSourceView         *v
                                                          const gchar          *search_text);
 void                  gb_source_view_indent_selection   (GbSourceView         *view);
 void                  gb_source_view_unindent_selection (GbSourceView         *view);
+void                  gb_source_view_set_font_name      (GbSourceView         *view,
+                                                         const gchar          *font_name);
 
 G_END_DECLS
 


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