[gnome-notes] note-view: Update font on font changes



commit 359ede65a0724c2c0f767cab71d7f037d3b00256
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Thu Jun 10 08:48:52 2021 +0530

    note-view: Update font on font changes

 src/bjb-note-view.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
---
diff --git a/src/bjb-note-view.c b/src/bjb-note-view.c
index e592129f..2651ae72 100644
--- a/src/bjb-note-view.c
+++ b/src/bjb-note-view.c
@@ -162,6 +162,25 @@ on_note_color_changed_cb (BijiNoteObj *note, BjbNoteView *self)
   webkit_web_view_set_background_color (WEBKIT_WEB_VIEW (self->view), &color);
 }
 
+static void
+view_font_changed_cb (BjbNoteView *self,
+                      GParamSpec  *pspec,
+                      BjbSettings *settings)
+{
+  g_autofree char *default_font = NULL;
+
+  g_assert (BJB_IS_NOTE_VIEW (self));
+  g_assert (BJB_IS_SETTINGS (settings));
+
+  default_font = bjb_settings_get_font (settings);
+
+  if (default_font != NULL)
+    biji_webkit_editor_set_font (BIJI_WEBKIT_EDITOR (self->view), default_font);
+
+  biji_webkit_editor_set_text_size (BIJI_WEBKIT_EDITOR (self->view),
+                                    bjb_settings_get_text_size (settings));
+}
+
 static void
 bjb_note_view_constructed (GObject *obj)
 {
@@ -173,6 +192,10 @@ bjb_note_view_constructed (GObject *obj)
 
   settings = bjb_app_get_settings(g_application_get_default());
 
+  g_signal_connect_object (settings, "notify::font",
+                           G_CALLBACK (view_font_changed_cb),
+                           self, G_CONNECT_SWAPPED);
+
 
   /* view new from note deserializes the note-content. */
   self->view = biji_note_obj_open (self->note);


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