Blob Blame History Raw
From 0280d70745f2fcf3b839b9e2262ea93002efff36 Mon Sep 17 00:00:00 2001
From: Christian Persch <chpe@gnome.org>
Date: Thu, 14 Nov 2013 21:08:00 +0100
Subject: [PATCH] prefs: Replace scrollbar policy combo with checkbox

The combo was a leftover from when it contained more options, and from the
remaining three choices, the "Visible only when necessary" option was
unimplemented. Replace the combo box with a simple checkbox.

https://bugzilla.gnome.org/show_bug.cgi?id=712331
---
 src/profile-editor.c       | 29 ++++++++++++++++++---
 src/profile-preferences.ui | 64 ++++++++++++----------------------------------
 2 files changed, 41 insertions(+), 52 deletions(-)

diff --git a/src/profile-editor.c b/src/profile-editor.c
index ca820b0..0489212 100644
--- a/src/profile-editor.c
+++ b/src/profile-editor.c
@@ -648,6 +648,27 @@ enum_to_string (const GValue *value,
   return variant;
 }
 
+static gboolean
+scrollbar_policy_to_bool (GValue *value,
+                          GVariant *variant,
+                          gpointer user_data)
+{
+  const char *str;
+
+  g_variant_get (variant, "&s", &str);
+  g_value_set_boolean (value, g_str_equal (str, "always"));
+
+  return TRUE;
+}
+
+static GVariant *
+bool_to_scrollbar_policy (const GValue *value,
+                          const GVariantType *expected_type,
+                          gpointer user_data)
+{
+  return g_variant_new_string (g_value_get_boolean (value) ? "always" : "never");
+}
+
 /**
  * terminal_profile_edit:
  * @profile: a #GSettings
@@ -907,12 +928,12 @@ terminal_profile_edit (GSettings  *profile,
   g_settings_bind_with_mapping (profile,
                                 TERMINAL_PROFILE_SCROLLBAR_POLICY_KEY,
                                 gtk_builder_get_object (builder,
-                                                        "scrollbar-policy-combobox"),
+                                                        "scrollbar-checkbutton"),
                                 "active",
                                 G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET,
-                                (GSettingsBindGetMapping) string_to_enum,
-                                (GSettingsBindSetMapping) enum_to_string,
-                                gtk_policy_type_get_type, NULL);
+                                (GSettingsBindGetMapping) scrollbar_policy_to_bool,
+                                (GSettingsBindSetMapping) bool_to_scrollbar_policy,
+                                NULL, NULL);
   g_settings_bind (profile, TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE_KEY,
                    gtk_builder_get_object (builder,
                                            "scroll-on-keystroke-checkbutton"),
diff --git a/src/profile-preferences.ui b/src/profile-preferences.ui
index db1b6fb..21e4e9a 100644
--- a/src/profile-preferences.ui
+++ b/src/profile-preferences.ui
@@ -99,23 +99,6 @@
       </row>
     </data>
   </object>
-  <object class="GtkListStore" id="model5">
-    <columns>
-      <!-- column-name gchararray -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes" comments="Scrollbar is">Always visible</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" comments="Scrollbar is">Visible only when necessary</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes" comments="Scrollbar is">Hidden</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkListStore" id="model6">
     <columns>
       <!-- column-name gchararray -->
@@ -1637,21 +1620,6 @@
                   <placeholder/>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="scrollbar-policy-combobox-label">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">_Scrollbar is:</property>
-                    <property name="use_underline">True</property>
-                    <property name="justify">center</property>
-                    <property name="mnemonic_widget">scrollbar-policy-combobox</property>
-                  </object>
-                  <packing>
-                    <property name="x_options">GTK_FILL</property>
-                    <property name="y_options">GTK_FILL</property>
-                  </packing>
-                </child>
-                <child>
                   <object class="GtkLabel" id="scrollback-label">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
@@ -1725,22 +1693,7 @@
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <object class="GtkComboBox" id="scrollbar-policy-combobox">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="model">model5</property>
-                        <child>
-                          <object class="GtkCellRendererText" id="renderer5"/>
-                          <attributes>
-                            <attribute name="text">0</attribute>
-                          </attributes>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">True</property>
-                        <property name="position">0</property>
-                      </packing>
+                      <placeholder/>
                     </child>
                   </object>
                   <packing>
@@ -1792,6 +1745,21 @@
                     <property name="y_options">GTK_FILL</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkCheckButton" id="scrollbar-checkbutton">
+                    <property name="label" translatable="yes">_Show scrollbar</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">2</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="position">4</property>
-- 
1.8.4.2