[Xfce4-commits] [apps/xfce4-terminal] 01/01: Allow to select system-wide monospace font in preferences

noreply at xfce.org noreply at xfce.org
Sun Nov 20 13:58:37 CET 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit 1ad6b32cf6f6a47656f9a50cc5c796fcaf48c613
Author: Igor <f2404 at yandex.ru>
Date:   Sun Nov 20 14:58:31 2016 +0200

    Allow to select system-wide monospace font in preferences
---
 terminal/terminal-preferences-dialog.c | 32 ++++++++++++++++++++++++++++++--
 terminal/terminal-preferences.c        | 11 +++++++++++
 terminal/terminal-preferences.glade    | 19 ++++++++++++++++++-
 terminal/terminal-screen.c             | 22 ++++++++++++++++------
 4 files changed, 75 insertions(+), 9 deletions(-)

diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index be6b689..d011097 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -66,6 +66,8 @@ static void terminal_preferences_dialog_encoding_changed  (GtkComboBox
                                                            TerminalPreferencesDialog *dialog);
 static void terminal_preferences_dialog_scroll_unlimited  (GtkWidget                 *button,
                                                            TerminalPreferencesDialog *dialog);
+static void terminal_preferences_dialog_font_use_system   (GtkWidget                 *button,
+                                                           TerminalPreferencesDialog *dialog);
 
 
 
@@ -141,7 +143,8 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog)
                                        "scrolling-on-output", "scrolling-on-keystroke",
                                        "scrolling-bar", "scrolling-unlimited",
                                        "misc-cursor-shape", "misc-cursor-blinks",
-                                       "font-allow-bold", "misc-menubar-default",
+                                       "font-allow-bold", "font-use-system",
+                                       "misc-menubar-default",
                                        "misc-toolbar-default", "misc-borders-default",
                                        "misc-tab-close-middle-click", "misc-mouse-autohide",
                                        "misc-rewrap-on-resize", "misc-copy-on-select",
@@ -245,6 +248,14 @@ error:
   g_signal_connect (G_OBJECT (object), "clicked",
       G_CALLBACK (terminal_preferences_dialog_scroll_unlimited), dialog);
 
+  /* use system font button */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "font-use-system");
+  terminal_return_if_fail (G_IS_OBJECT (object));
+  g_signal_connect (G_OBJECT (object), "realize",
+      G_CALLBACK (terminal_preferences_dialog_font_use_system), dialog);
+  g_signal_connect (G_OBJECT (object), "clicked",
+      G_CALLBACK (terminal_preferences_dialog_font_use_system), dialog);
+
   /* reset comparibility button */
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "reset-compatibility");
   terminal_return_if_fail (G_IS_OBJECT (object));
@@ -947,7 +958,6 @@ terminal_preferences_dialog_scroll_unlimited (GtkWidget                 *button,
   terminal_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
 
   unlimited = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
-
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "scrolling-lines");
   terminal_return_if_fail (G_IS_OBJECT (object));
   g_object_set (G_OBJECT (object), "sensitive", !unlimited, NULL);
@@ -955,6 +965,24 @@ terminal_preferences_dialog_scroll_unlimited (GtkWidget                 *button,
 
 
 
+static void
+terminal_preferences_dialog_font_use_system (GtkWidget                 *button,
+                                             TerminalPreferencesDialog *dialog)
+{
+  GObject *object;
+  gboolean use_system;
+
+  terminal_return_if_fail (TERMINAL_IS_PREFERENCES_DIALOG (dialog));
+  terminal_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
+
+  use_system = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "font-name");
+  terminal_return_if_fail (G_IS_OBJECT (object));
+  g_object_set (G_OBJECT (object), "sensitive", !use_system, NULL);
+}
+
+
+
 /**
  * terminal_preferences_dialog_new:
  *
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index 08d38e4..ed548d9 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -74,6 +74,7 @@ enum
   PROP_ENCODING,
   PROP_FONT_ALLOW_BOLD,
   PROP_FONT_NAME,
+  PROP_FONT_USE_SYSTEM,
   PROP_MISC_ALWAYS_SHOW_TABS,
   PROP_MISC_BELL,
   PROP_MISC_BELL_URGENT,
@@ -645,6 +646,16 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
+   * TerminalPreferences:font-allow-bold:
+   **/
+  preferences_props[PROP_FONT_USE_SYSTEM] =
+      g_param_spec_boolean ("font-use-system",
+                            NULL,
+                            "FontUseSystem",
+                            FALSE,
+                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  /**
    * TerminalPreferences:misc-always-show-tabs:
    **/
   preferences_props[PROP_MISC_ALWAYS_SHOW_TABS] =
diff --git a/terminal/terminal-preferences.glade b/terminal/terminal-preferences.glade
index d02e38a..3dfe2dc 100644
--- a/terminal/terminal-preferences.glade
+++ b/terminal/terminal-preferences.glade
@@ -1228,6 +1228,23 @@ Opacity setting is not available.</property>
                               </packing>
                             </child>
                             <child>
+                              <object class="GtkCheckButton" id="font-use-system">
+                                <property name="label" translatable="yes">Use system _font</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Enable this option to use system-wide monospace font.</property>
+                                <property name="halign">start</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
                               <object class="GtkCheckButton" id="font-allow-bold">
                                 <property name="label" translatable="yes">Allow bold te_xt</property>
                                 <property name="visible">True</property>
@@ -1241,7 +1258,7 @@ Opacity setting is not available.</property>
                               <packing>
                                 <property name="expand">True</property>
                                 <property name="fill">True</property>
-                                <property name="position">1</property>
+                                <property name="position">2</property>
                               </packing>
                             </child>
                           </object>
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index b577e92..089d1ca 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -2318,21 +2318,31 @@ terminal_screen_update_scrolling_bar (TerminalScreen *screen)
 void
 terminal_screen_update_font (TerminalScreen *screen)
 {
-  gboolean               font_allow_bold;
-  gchar                 *font_name;
-  PangoFontDescription  *font_desc;
-  glong                  grid_w = 0, grid_h = 0;
-  GtkWidget             *toplevel;
+  gboolean              font_use_system, font_allow_bold;
+  gchar                *font_name;
+  PangoFontDescription *font_desc;
+  glong                 grid_w = 0, grid_h = 0;
+  GtkWidget            *toplevel;
+  GSettings            *settings;
 
   terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
   terminal_return_if_fail (TERMINAL_IS_PREFERENCES (screen->preferences));
   terminal_return_if_fail (VTE_IS_TERMINAL (screen->terminal));
 
   g_object_get (G_OBJECT (screen->preferences),
+                "font-use-system", &font_use_system,
                 "font-allow-bold", &font_allow_bold,
-                "font-name", &font_name,
                 NULL);
 
+  if (font_use_system)
+    {
+      settings = g_settings_new ("org.gnome.desktop.interface");
+      font_name = g_settings_get_string (settings, "monospace-font-name");
+      g_object_unref (settings);
+    }
+  else
+    g_object_get (G_OBJECT (screen->preferences), "font-name", &font_name, NULL);
+
   toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
   if (TERMINAL_IS_WINDOW (toplevel))
     {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list