[evolution] EHeaderBarButton: Use gtk_action_is_sensitive() in "sensitivity" property binding
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHeaderBarButton: Use gtk_action_is_sensitive() in "sensitivity" property binding
- Date: Tue, 2 Aug 2022 13:43:31 +0000 (UTC)
commit 4f73c15c0f5f66165ad97f16d60ad75d492811ae
Author: Milan Crha <mcrha redhat com>
Date: Tue Aug 2 15:41:24 2022 +0200
EHeaderBarButton: Use gtk_action_is_sensitive() in "sensitivity" property binding
The GtkAction::sensitivity property does not take into consideration
the action's group sensitivity, which can leave the buttons sensitive,
even the group is not, causing unexpected state of the header bar buttons.
src/e-util/e-headerbar-button.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/e-util/e-headerbar-button.c b/src/e-util/e-headerbar-button.c
index c443af1c93..9bb1c2a04d 100644
--- a/src/e-util/e-headerbar-button.c
+++ b/src/e-util/e-headerbar-button.c
@@ -164,6 +164,20 @@ header_bar_button_set_prefer_item (EHeaderBarButton *self,
header_bar_button_update_button (self);
}
+static gboolean
+e_headerbar_button_transform_sensitive_cb (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ /* The GtkAction::sensitive property does not take into the consideration
+ also the group's sensitivity, thus use the gtk_action_is_sensitive() function. */
+
+ g_value_set_boolean (to_value, gtk_action_is_sensitive (GTK_ACTION (g_binding_get_source (binding))));
+
+ return TRUE;
+}
+
static void
header_bar_button_set_property (GObject *object,
guint property_id,
@@ -243,10 +257,12 @@ header_bar_button_constructed (GObject *object)
GTK_BUTTON (header_bar_button->priv->button),
header_bar_button->priv->action);
- e_binding_bind_property (
+ e_binding_bind_property_full (
header_bar_button->priv->action, "sensitive",
header_bar_button, "sensitive",
- G_BINDING_SYNC_CREATE);
+ G_BINDING_SYNC_CREATE,
+ e_headerbar_button_transform_sensitive_cb,
+ NULL, NULL, NULL);
if (GTK_IS_TOGGLE_ACTION (header_bar_button->priv->action))
e_binding_bind_property (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]