[Xfce4-commits] [apps/xfce4-terminal] 01/01: Add cell spacing options

noreply at xfce.org noreply at xfce.org
Sat Jan 20 17:38:29 CET 2018


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

f   2   4   0   4       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-terminal.

commit 1200fd705f5494037bbdbeb7609ccfb9a86653fb
Author: Igor <f2404 at yandex.ru>
Date:   Sat Jan 20 11:36:51 2018 -0500

    Add cell spacing options
    
    Increased line spacing and character spacing mostly for accessibility for
    people with imperfect sight.
    Available since vte 0.51.3.
    
    See bug #14127
---
 terminal/terminal-preferences-dialog.c |  45 +++++++++++
 terminal/terminal-preferences.c        |  24 +++++-
 terminal/terminal-preferences.glade    | 134 ++++++++++++++++++++++++++++++++-
 terminal/terminal-screen.c             |  17 +++++
 4 files changed, 218 insertions(+), 2 deletions(-)

diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index 4b52ad8..4c14867 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -55,6 +55,10 @@ static void     terminal_preferences_dialog_palette_changed   (GtkWidget
                                                                TerminalPreferencesDialog *dialog);
 static void     terminal_preferences_dialog_palette_notify    (TerminalPreferencesDialog *dialog);
 static void     terminal_preferences_dialog_presets_load      (TerminalPreferencesDialog *dialog);
+#if VTE_CHECK_VERSION (0, 51, 3)
+static void     terminal_preferences_dialog_reset_cell_scale  (GtkWidget                 *button,
+                                                               TerminalPreferencesDialog *dialog);
+#endif
 static void     terminal_preferences_dialog_reset_compat      (GtkWidget                 *button,
                                                                TerminalPreferencesDialog *dialog);
 static void     terminal_preferences_dialog_reset_word_chars  (GtkWidget                 *button,
@@ -288,6 +292,30 @@ error:
 #endif
 
 #if VTE_CHECK_VERSION (0, 51, 3)
+  /* bind cell width scale */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "spin-cell-width-scale");
+  object2 = G_OBJECT (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (object)));
+  terminal_return_if_fail (G_IS_OBJECT (object) && G_IS_OBJECT (object2));
+  binding = g_object_bind_property (G_OBJECT (dialog->preferences), "cell-width-scale",
+                                    G_OBJECT (object2), "value",
+                                    G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+  dialog->bindings = g_slist_prepend (dialog->bindings, binding);
+
+  /* bind cell height scale */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "spin-cell-height-scale");
+  object2 = G_OBJECT (gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (object)));
+  terminal_return_if_fail (G_IS_OBJECT (object) && G_IS_OBJECT (object2));
+  binding = g_object_bind_property (G_OBJECT (dialog->preferences), "cell-height-scale",
+                                    G_OBJECT (object2), "value",
+                                    G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+  dialog->bindings = g_slist_prepend (dialog->bindings, binding);
+
+  /* cell scale "Reset" button */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "reset-cell-scale");
+  terminal_return_if_fail (G_IS_OBJECT (object));
+  g_signal_connect (object, "clicked",
+                    G_CALLBACK (terminal_preferences_dialog_reset_cell_scale), dialog);
+
   /* hide "Allow bold" if vte supports "bold is bright" */
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "font-allow-bold");
   terminal_return_if_fail (G_IS_OBJECT (object));
@@ -298,6 +326,11 @@ error:
   terminal_return_if_fail (G_IS_OBJECT (object));
   gtk_widget_hide (GTK_WIDGET (object));
 
+  /* hide "Cell spacing" if vte doesn't support it */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "cell-sp-box");
+  terminal_return_if_fail (G_IS_OBJECT (object));
+  gtk_widget_hide (GTK_WIDGET (object));
+
   /* hide "Bold is bright" if vte doesn't support it */
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "color-bold-is-bright");
   terminal_return_if_fail (G_IS_OBJECT (object));
@@ -933,6 +966,18 @@ terminal_preferences_dialog_presets_load (TerminalPreferencesDialog *dialog)
 
 
 
+#if VTE_CHECK_VERSION (0, 51, 3)
+static void
+terminal_preferences_dialog_reset_cell_scale (GtkWidget                 *button,
+                                              TerminalPreferencesDialog *dialog)
+{
+  const gchar *properties[] = { "cell-width-scale", "cell-height-scale" };
+  RESET_PROPERTIES (properties);
+}
+#endif
+
+
+
 static void
 terminal_preferences_dialog_reset_compat (GtkWidget                 *button,
                                           TerminalPreferencesDialog *dialog)
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index 72ab3f1..6a01223 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -125,6 +125,8 @@ enum
   PROP_TAB_ACTIVITY_COLOR,
   PROP_TAB_ACTIVITY_TIMEOUT,
   PROP_TEXT_BLINK_MODE,
+  PROP_CELL_WIDTH_SCALE,
+  PROP_CELL_HEIGHT_SCALE,
   N_PROPERTIES,
 };
 
@@ -300,7 +302,7 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
   if (!g_value_type_transformable (G_TYPE_STRING, G_TYPE_UINT))
     g_value_register_transform_func (G_TYPE_STRING, G_TYPE_UINT, transform_string_to_uint);
   /* enum types */
-  for (i = 0; i < sizeof(enum_types) / sizeof (GType); ++i)
+  for (i = 0; i < G_N_ELEMENTS (enum_types); ++i)
     if (!g_value_type_transformable (G_TYPE_STRING, enum_types[i]))
       g_value_register_transform_func (G_TYPE_STRING, enum_types[i], transform_string_to_enum);
 
@@ -1161,6 +1163,26 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                          TERMINAL_TEXT_BLINK_MODE_ALWAYS,
                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
+  /**
+   * TerminalPreferences:cell-width-scale:
+   **/
+  preferences_props[PROP_CELL_WIDTH_SCALE] =
+      g_param_spec_double ("cell-width-scale",
+                           NULL,
+                           "CellWidthScale",
+                           1.0, 2.0, 1.0,
+                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  /**
+   * TerminalPreferences:cell-height-scale:
+   **/
+  preferences_props[PROP_CELL_HEIGHT_SCALE] =
+      g_param_spec_double ("cell-height-scale",
+                           NULL,
+                           "CellHeightScale",
+                           1.0, 2.0, 1.0,
+                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
   /* install all properties */
   g_object_class_install_properties (gobject_class, N_PROPERTIES, preferences_props);
 }
diff --git a/terminal/terminal-preferences.glade b/terminal/terminal-preferences.glade
index 7aed608..f5072b2 100644
--- a/terminal/terminal-preferences.glade
+++ b/terminal/terminal-preferences.glade
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.20.2 -->
 <interface>
   <requires lib="gtk+" version="3.14"/>
   <requires lib="libxfce4ui" version="4.12"/>
@@ -14,6 +14,20 @@
     <property name="step_increment">0.01</property>
     <property name="page_increment">0.10000000000000001</property>
   </object>
+  <object class="GtkAdjustment" id="cell-height-scale">
+    <property name="lower">1</property>
+    <property name="upper">2</property>
+    <property name="value">1</property>
+    <property name="step_increment">0.050000000000000003</property>
+    <property name="page_increment">0.25</property>
+  </object>
+  <object class="GtkAdjustment" id="cell-width-scale">
+    <property name="lower">1</property>
+    <property name="upper">2</property>
+    <property name="value">1</property>
+    <property name="step_increment">0.050000000000000003</property>
+    <property name="page_increment">0.25</property>
+  </object>
   <object class="GtkAdjustment" id="dropdown-animation-time">
     <property name="upper">500</property>
     <property name="step_increment">1</property>
@@ -1535,6 +1549,124 @@ Opacity setting is not available.</property>
                                 <property name="position">3</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkBox" id="cell-sp-box">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">12</property>
+                                <child>
+                                  <object class="GtkLabel" id="label27">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">Cell spacing:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkBox" id="hbox11">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <object class="GtkSpinButton" id="spin-cell-width-scale">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="adjustment">cell-width-scale</property>
+                                        <property name="digits">2</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label59">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label" translatable="yes">x width</property>
+                                        <property name="use_underline">True</property>
+                                        <property name="mnemonic_widget">spin-columns</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkBox" id="hbox12">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <object class="GtkSpinButton" id="spin-cell-height-scale">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="adjustment">cell-height-scale</property>
+                                        <property name="digits">2</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label60">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label" translatable="yes">x height</property>
+                                        <property name="use_underline">True</property>
+                                        <property name="mnemonic_widget">spin-rows</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="reset-cell-scale">
+                                    <property name="label" translatable="yes">Rese_t</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">True</property>
+                                    <property name="tooltip_text" translatable="yes">Reset cell spacing values to defaults</property>
+                                    <property name="valign">center</property>
+                                    <property name="use_underline">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">3</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">4</property>
+                              </packing>
+                            </child>
                           </object>
                         </child>
                       </object>
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index a65f4f0..2fcf42c 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -579,6 +579,10 @@ terminal_screen_preferences_changed (TerminalPreferences *preferences,
     terminal_screen_update_binding_delete (screen);
   else if (strcmp ("binding-ambiguous-width", name) == 0)
     terminal_screen_update_binding_ambiguous_width (screen);
+#if VTE_CHECK_VERSION (0, 51, 3)
+  else if (strcmp ("cell-width-scale", name) == 0 || strcmp ("cell-height-scale", name) == 0)
+    terminal_screen_update_font (screen);
+#endif
   else if (strncmp ("color-", name, strlen ("color-")) == 0)
     terminal_screen_update_colors (screen);
   else if (strncmp ("font-", name, strlen ("font-")) == 0)
@@ -2550,6 +2554,9 @@ terminal_screen_update_font (TerminalScreen *screen)
   PangoFontDescription *font_desc;
   glong                 grid_w = 0, grid_h = 0;
   GSettings            *settings;
+#if VTE_CHECK_VERSION (0, 51, 3)
+  gdouble cell_width_scale, cell_height_scale;
+#endif
 
   terminal_return_if_fail (TERMINAL_IS_SCREEN (screen));
   terminal_return_if_fail (TERMINAL_IS_PREFERENCES (screen->preferences));
@@ -2597,6 +2604,16 @@ terminal_screen_update_font (TerminalScreen *screen)
       g_free (font_name);
     }
 
+#if VTE_CHECK_VERSION (0, 51, 3)
+  g_object_get (G_OBJECT (screen->preferences),
+                "cell-width-scale", &cell_width_scale,
+                "cell-height-scale", &cell_height_scale,
+                NULL);
+
+  vte_terminal_set_cell_width_scale (VTE_TERMINAL (screen->terminal), cell_width_scale);
+  vte_terminal_set_cell_height_scale (VTE_TERMINAL (screen->terminal), cell_height_scale);
+#endif
+
   /* update window geometry it required (not needed for drop-down) */
   if (TERMINAL_IS_WINDOW (toplevel) && !TERMINAL_WINDOW (toplevel)->drop_down && grid_w > 0 && grid_h > 0)
     terminal_screen_force_resize_window (screen, GTK_WINDOW (toplevel), grid_w, grid_h);

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


More information about the Xfce4-commits mailing list