[gimp] libgimpwidgets: allow prop labels on read-only properties.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: allow prop labels on read-only properties.
- Date: Tue, 1 Dec 2020 23:31:53 +0000 (UTC)
commit 91728164cd99f1af3a24fa9142325a2fd094c121
Author: Jehan <jehan girinstud io>
Date: Wed Dec 2 00:29:09 2020 +0100
libgimpwidgets: allow prop labels on read-only properties.
When creating a label bound to a property, only make the binding
directional if the property is read-write.
This fixes WARNINGs and broken label in the GimpDeviceInfoEditor widget,
such as this one:
> The source object of type GimpDeviceInfo has no writable property called 'vendor-id'
libgimpwidgets/gimppropwidgets.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index adbefe22e8..6faaa7117d 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -1940,9 +1940,10 @@ GtkWidget *
gimp_prop_label_new (GObject *config,
const gchar *property_name)
{
- GParamSpec *param_spec;
- GtkWidget *label;
- const gchar *blurb;
+ GParamSpec *param_spec;
+ GtkWidget *label;
+ const gchar *blurb;
+ GBindingFlags flags = G_BINDING_SYNC_CREATE;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
@@ -1959,9 +1960,15 @@ gimp_prop_label_new (GObject *config,
if (blurb)
gimp_help_set_help_data (label, blurb, NULL);
+ /* As labels are read-only widgets, allow read-only properties (though
+ * we still keep possibility for bidirectional binding, which can be
+ * useful even with labels).
+ */
+ if (param_spec->flags & G_PARAM_WRITABLE)
+ flags |= G_BINDING_BIDIRECTIONAL;
+
g_object_bind_property (config, property_name,
- label, "label",
- G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+ label, "label", flags);
return label;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]