[gtk/matthiasc/for-master] scale: Make draw-value default to FALSE
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] scale: Make draw-value default to FALSE
- Date: Sun, 4 Oct 2020 05:14:12 +0000 (UTC)
commit 57235bb0fac17c26c6795c51ddc88b6bd16cd7ab
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 3 20:08:29 2020 -0400
scale: Make draw-value default to FALSE
This is rarely what you want, so lets turn it off
by default.
Update the one place in our demos where we want to
draw a value, add support for this to gtk-builder-tool,
add a test and mention this change in the migration
guide.
demos/widget-factory/widget-factory.ui | 2 ++
docs/reference/gtk/migrating-3to4.md | 9 +++++
gtk/gtkscale.c | 3 +-
gtk/tools/gtk-builder-tool-simplify.c | 43 +++++++++++++++++++++++
testsuite/gtk/focus-chain/widget-factory.ui | 2 ++
testsuite/gtk/focus-chain/widget-factory2.ui | 2 ++
testsuite/gtk/focus-chain/widget-factory3.ui | 2 ++
testsuite/tools/simplify-data-3to4/scale.expected | 14 ++++++++
testsuite/tools/simplify-data-3to4/scale.ui | 10 ++++++
9 files changed, 85 insertions(+), 2 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 139ef083e0..0b383655ee 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -1011,6 +1011,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">end</property>
</object>
</child>
@@ -1023,6 +1024,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">start</property>
</object>
</child>
diff --git a/docs/reference/gtk/migrating-3to4.md b/docs/reference/gtk/migrating-3to4.md
index 429e7c7421..8e19740e12 100644
--- a/docs/reference/gtk/migrating-3to4.md
+++ b/docs/reference/gtk/migrating-3to4.md
@@ -891,6 +891,15 @@ gtk_search_entry_handle_event() has been dropped and replaced by
gtk_search_entry_set_key_capture_widget() and
gtk_event_controller_key_forward().
+### Adapt to GtkScale changes
+
+The default value of #GtkScale:draw-value has been changed to %FALSE.
+If you want your scales to draw values, you will have to set this
+property explicitly now.
+
+gtk4-builder-tool can help with this conversion, with the --3to4 option
+of the simplify command.
+
### Stop using gtk_window_activate_default()
The handling of default widgets has been changed, and activating
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index c604642bff..d9928636cf 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -684,7 +684,7 @@ gtk_scale_class_init (GtkScaleClass *class)
g_param_spec_boolean ("draw-value",
P_("Draw Value"),
P_("Whether the current value is displayed as a string next to the slider"),
- TRUE,
+ FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_HAS_ORIGIN] =
@@ -839,7 +839,6 @@ gtk_scale_init (GtkScale *scale)
_gtk_range_set_has_origin (range, TRUE);
- gtk_scale_set_draw_value (scale, TRUE);
gtk_range_set_round_digits (range, priv->digits);
gtk_range_set_flippable (range, TRUE);
diff --git a/gtk/tools/gtk-builder-tool-simplify.c b/gtk/tools/gtk-builder-tool-simplify.c
index 0650f54941..f2f57d8eab 100644
--- a/gtk/tools/gtk-builder-tool-simplify.c
+++ b/gtk/tools/gtk-builder-tool-simplify.c
@@ -1770,6 +1770,45 @@ rewrite_radio_button (Element *element,
}
}
+static gboolean
+has_prop (Element *element,
+ MyParserData *data,
+ const char *prop_name)
+{
+ GList *l;
+
+ for (l = element->children; l; l = l->next)
+ {
+ Element *child = l->data;
+
+ if (g_str_equal (child->element_name, "property") &&
+ has_attribute (child, "name", prop_name))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+rewrite_scale (Element *element,
+ MyParserData *data)
+{
+ if (!has_prop (element, data, "draw-value") &&
+ !has_prop (element, data, "draw_value"))
+ {
+ Element *child;
+ child = g_new0 (Element, 1);
+ child->parent = element;
+ child->element_name = g_strdup ("property");
+ child->attribute_names = g_new0 (char *, 2);
+ child->attribute_names[0] = g_strdup ("name");
+ child->attribute_values = g_new0 (char *, 2);
+ child->attribute_values[0] = g_strdup ("draw-value");
+ child->data = g_strdup ("1");
+ element->children = g_list_prepend (element->children, child);
+ }
+}
+
/* returns TRUE to remove the element from the parent */
static gboolean
simplify_element (Element *element,
@@ -1919,6 +1958,10 @@ rewrite_element (Element *element,
g_str_equal (get_class_name (element), "GtkRadioButton"))
rewrite_radio_button (element, data);
+ if (element_is_object_or_template (element) &&
+ g_str_equal (get_class_name (element), "GtkScale"))
+ rewrite_scale (element, data);
+
if (g_str_equal (element->element_name, "property"))
maybe_rename_property (element, data);
diff --git a/testsuite/gtk/focus-chain/widget-factory.ui b/testsuite/gtk/focus-chain/widget-factory.ui
index c090dbf228..f3aa01b9fe 100644
--- a/testsuite/gtk/focus-chain/widget-factory.ui
+++ b/testsuite/gtk/focus-chain/widget-factory.ui
@@ -1014,6 +1014,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">end</property>
</object>
</child>
@@ -1026,6 +1027,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">start</property>
</object>
</child>
diff --git a/testsuite/gtk/focus-chain/widget-factory2.ui b/testsuite/gtk/focus-chain/widget-factory2.ui
index cfc151da11..3f5c3bb0d3 100644
--- a/testsuite/gtk/focus-chain/widget-factory2.ui
+++ b/testsuite/gtk/focus-chain/widget-factory2.ui
@@ -1015,6 +1015,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">end</property>
</object>
</child>
@@ -1027,6 +1028,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">start</property>
</object>
</child>
diff --git a/testsuite/gtk/focus-chain/widget-factory3.ui b/testsuite/gtk/focus-chain/widget-factory3.ui
index 9f454b90c2..de944471ef 100644
--- a/testsuite/gtk/focus-chain/widget-factory3.ui
+++ b/testsuite/gtk/focus-chain/widget-factory3.ui
@@ -1015,6 +1015,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">end</property>
</object>
</child>
@@ -1027,6 +1028,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<property name="restrict-to-fill-level">0</property>
<property name="fill-level">75</property>
<property name="digits">-1</property>
+ <property name="draw-value">1</property>
<property name="halign">start</property>
</object>
</child>
diff --git a/testsuite/tools/simplify-data-3to4/scale.expected
b/testsuite/tools/simplify-data-3to4/scale.expected
new file mode 100644
index 0000000000..20e71ab9da
--- /dev/null
+++ b/testsuite/tools/simplify-data-3to4/scale.expected
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkScale">
+ <property name="draw-value">1</property>
+ <property name="visible">0</property>
+ </object>
+ <object class="GtkScale">
+ <property name="visible">0</property>
+ <property name="draw-value">1</property>
+ </object>
+ <object class="GtkScale">
+ <property name="visible">0</property>
+ </object>
+</interface>
diff --git a/testsuite/tools/simplify-data-3to4/scale.ui b/testsuite/tools/simplify-data-3to4/scale.ui
new file mode 100644
index 0000000000..279b797df7
--- /dev/null
+++ b/testsuite/tools/simplify-data-3to4/scale.ui
@@ -0,0 +1,10 @@
+<interface>
+ <object class="GtkScale">
+ </object>
+ <object class="GtkScale">
+ <property name="draw-value">1</property>
+ </object>
+ <object class="GtkScale">
+ <property name="draw_value">0</property>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]