Commit 8ca612c9 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

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.
parent a4284569
Pipeline #218662 passed with stages
in 60 minutes and 2 seconds
......@@ -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>
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -23,6 +23,7 @@
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="adjustment">adjustment1</property>
<property name="draw-value">1</property>
</object>
</child>
<child>
......@@ -31,6 +32,7 @@
<property name="orientation">horizontal</property>
<property name="adjustment">adjustment1</property>
<property name="value-pos">bottom</property>
<property name="draw-value">1</property>
</object>
</child>
<child>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
<?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>
<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>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment