GtkButton/GtkActivatable insensitive properties bug
Juan Pablo Ugarte <[email protected]> Wed, 17 Oct 2012 15:34:36 -0700
| Newsgroups | gmane.comp.gnome.glade.devel |
|---|---|
| Message-ID | <CABQ3ToRi-7k=1DVeN0GGiGv2P_wA8K5je0zn+KUQj-euSjUaeA@mail.gmail.com> |
As you probably notice I broke some properties sensitivity in widgets that implement GtkActivatable. The most important being GtkButton. https://bugzilla.gnome.org/show_bug.cgi?id=685816 As tristan suggested in the bug thread, we could simply revert the change that exposed this bug and move on but since I am already in the middle of this mess I would like to fix it properly. This is why I am asking for you to try this patch on top of 3.14.1 and let me know if you find anything weird related to properties sensitivity. Btw I also included a test file with lots of GtkActivatable widgets in the bug report so let me know if I missed someone. thanks Juan Pablo _______________________________________________ Glade-devel maillist - [email protected] http://lists.ximian.com/mailman/listinfo/glade-devel
activatable-sensitivity.patch
(application/octet-stream, 13.1 KB)
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 2bffc1c..8b583e9 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -201,14 +201,20 @@ glade_editor_property_sensitivity_cb (GladeProperty *property,
GParamSpec *pspec,
GladeEditorProperty *eprop)
{
- gboolean sensitive = glade_property_get_sensitive (eprop->priv->property);
+ GladeEditorPropertyPrivate *priv = eprop->priv;
+ gboolean property_enabled = glade_property_get_enabled (property);
+ gboolean sensitive = glade_property_get_sensitive (priv->property);
gboolean support_sensitive =
- (glade_property_get_state (eprop->priv->property) & GLADE_STATE_SUPPORT_DISABLED) == 0;
+ (glade_property_get_state (priv->property) & GLADE_STATE_SUPPORT_DISABLED) == 0;
- gtk_widget_set_sensitive (eprop->priv->input, sensitive && support_sensitive &&
- glade_property_get_enabled (property));
- if (eprop->priv->check)
- gtk_widget_set_sensitive (eprop->priv->check, sensitive && support_sensitive);
+ gtk_widget_set_sensitive (priv->input,
+ sensitive && support_sensitive && property_enabled);
+
+ if (priv->item_label)
+ gtk_widget_set_sensitive (priv->item_label,
+ sensitive && support_sensitive && property_enabled);
+ if (priv->check)
+ gtk_widget_set_sensitive (priv->check, sensitive && support_sensitive);
}
static void
diff --git a/plugins/gtk+/glade-activatable-editor.c b/plugins/gtk+/glade-activatable-editor.c
index a8d5cfc..e33d266 100644
--- a/plugins/gtk+/glade-activatable-editor.c
+++ b/plugins/gtk+/glade-activatable-editor.c
@@ -276,6 +276,8 @@ related_action_pre_commit (GladeEditorProperty * property,
glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance);
+ use_appearance = action ? use_appearance : FALSE;
+
glade_command_push_group (_("Setting %s action"), glade_widget_get_name (gwidget));
reset_properties (gwidget, action, use_appearance, FALSE);
@@ -303,6 +305,8 @@ use_appearance_pre_commit (GladeEditorProperty * property,
glade_widget_property_get (gwidget, "related-action", &action);
+ use_appearance = action ? use_appearance : FALSE;
+
glade_editable_block (GLADE_EDITABLE (activatable_editor));
glade_command_push_group (use_appearance ?
diff --git a/plugins/gtk+/glade-button-editor.c b/plugins/gtk+/glade-button-editor.c
index f1cce8e..d365c47 100644
--- a/plugins/gtk+/glade-button-editor.c
+++ b/plugins/gtk+/glade-button-editor.c
@@ -25,7 +25,7 @@
#include <gdk/gdkkeysyms.h>
#include "glade-button-editor.h"
-
+#include "glade-gtk-activatable.h"
static void glade_button_editor_finalize (GObject * object);
@@ -62,7 +62,7 @@ glade_button_editor_load (GladeEditable * editable, GladeWidget * widget)
GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable);
GladeWidget *gchild = NULL;
GtkWidget *child, *button;
- gboolean use_stock = FALSE, use_appearance = FALSE;
+ gboolean use_stock = FALSE;
GList *l;
/* Chain up to default implementation */
@@ -79,9 +79,6 @@ glade_button_editor_load (GladeEditable * editable, GladeWidget * widget)
if (widget)
{
- glade_widget_property_get (widget, "use-action-appearance",
- &use_appearance);
-
button = GTK_WIDGET (glade_widget_get_object (widget));
child = gtk_bin_get_child (GTK_BIN (button));
if (child)
@@ -121,7 +118,7 @@ glade_button_editor_load (GladeEditable * editable, GladeWidget * widget)
}
}
- if (use_appearance)
+ if (glade_gtk_activatable_get_use_action_appearance (widget))
gtk_widget_set_sensitive (button_editor->custom_radio, FALSE);
else
gtk_widget_set_sensitive (button_editor->custom_radio, TRUE);
@@ -178,7 +175,6 @@ standard_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
GladeWidget *gchild = NULL, *gwidget;
GtkWidget *child, *button;
GValue value = { 0, };
- gboolean use_appearance = FALSE;
gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (button_editor));
@@ -219,9 +215,7 @@ standard_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
glade_widget_get_property (gwidget, "use-stock");
glade_command_set_property (property, FALSE);
- glade_widget_property_get (gwidget,
- "use-action-appearance", &use_appearance);
- if (!use_appearance)
+ if (!glade_gtk_activatable_get_use_action_appearance (gwidget))
{
property =
glade_widget_get_property (gwidget, "label");
@@ -287,7 +281,6 @@ static void
stock_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
{
GladeProperty *property;
- gboolean use_appearance = FALSE;
GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (button_editor));
if (glade_editable_loading (GLADE_EDITABLE (button_editor)) || !gwidget)
@@ -306,8 +299,7 @@ stock_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
property = glade_widget_get_property (gwidget, "image");
glade_command_set_property (property, NULL);
- glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance);
- if (!use_appearance)
+ if (!glade_gtk_activatable_get_use_action_appearance (gwidget))
{
property =
glade_widget_get_property (gwidget, "label");
@@ -334,7 +326,6 @@ label_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
{
GladeProperty *property;
GValue value = { 0, };
- gboolean use_appearance = FALSE;
GladeWidget *gwidget = glade_editable_loaded_widget (GLADE_EDITABLE (button_editor));
if (glade_editable_loading (GLADE_EDITABLE (button_editor)) || !gwidget)
@@ -355,8 +346,7 @@ label_toggled (GtkWidget * widget, GladeButtonEditor * button_editor)
property = glade_widget_get_property (gwidget, "use-stock");
glade_command_set_property (property, FALSE);
- glade_widget_property_get (gwidget, "use-action-appearance", &use_appearance);
- if (!use_appearance)
+ if (!glade_gtk_activatable_get_use_action_appearance (gwidget))
{
property =
glade_widget_get_property (gwidget, "label");
diff --git a/plugins/gtk+/glade-gtk-activatable.c b/plugins/gtk+/glade-gtk-activatable.c
index 7cf9bf5..8492e2d 100644
--- a/plugins/gtk+/glade-gtk-activatable.c
+++ b/plugins/gtk+/glade-gtk-activatable.c
@@ -26,65 +26,47 @@
#include "glade-gtk-activatable.h"
/* ----------------------------- GtkActivatable ------------------------------ */
-static void
-update_use_action_appearance (GladeWidget *gwidget,
- gboolean related_action,
- gboolean use_appearance)
+void
+glade_gtk_activatable_evaluate_property_sensitivity (GObject *object,
+ const gchar *id,
+ const GValue *value)
{
- gboolean sensitivity;
- gchar *msg;
-
- if (use_appearance)
- {
- sensitivity = FALSE;
- msg = ACTION_APPEARANCE_MSG;
- }
- else
+ GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+
+ if (!strcmp (id, "related-action") || !strcmp (id, "use-action-appearance"))
{
- sensitivity = TRUE;
- msg = NULL;
- }
+ gboolean sensitivity = !glade_gtk_activatable_get_use_action_appearance (gwidget);
+ gchar *msg = sensitivity ? NULL : ACTION_APPEARANCE_MSG;
- glade_widget_property_set_sensitive (gwidget, "label", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "use-underline", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "stock", sensitivity, msg);
- //glade_widget_property_set_sensitive (gwidget, "use-stock", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "image", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "image-position", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "custom-child", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "stock-id", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "label-widget", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "icon-name", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "icon-widget", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "icon", sensitivity, msg);
+ /* Update use-action-appearance related properties */
+ glade_widget_property_set_sensitive (gwidget, "label", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "use-underline", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "stock", sensitivity, msg);
+ //glade_widget_property_set_sensitive (gwidget, "use-stock", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "image", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "image-position", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "custom-child", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "stock-id", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "label-widget", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "icon-name", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "icon-widget", sensitivity, msg);
+ glade_widget_property_set_sensitive (gwidget, "icon", sensitivity, msg);
- if (related_action)
- {
+ /* And update action related properties */
glade_widget_property_set_sensitive (gwidget, "visible", sensitivity, msg);
glade_widget_property_set_sensitive (gwidget, "sensitive", sensitivity, msg);
glade_widget_property_set_sensitive (gwidget, "accel-group", sensitivity, msg);
- glade_widget_property_set_sensitive (gwidget, "use-action-appearance",
- !sensitivity, sensitivity ? msg : NULL);
}
}
-void
-glade_gtk_activatable_evaluate_property_sensitivity (GObject *object,
- const gchar *id,
- const GValue *value)
+gboolean
+glade_gtk_activatable_get_use_action_appearance (GladeWidget *widget)
{
- GladeWidget *gwidget = glade_widget_get_from_gobject (object);
+ gboolean use_appearance;
+ GtkAction *action;
- if (!strcmp (id, "related-action"))
- {
- update_use_action_appearance (gwidget, TRUE,
- g_value_get_object (value) != NULL);
- }
- else if (!strcmp (id, "use-action-appearance"))
- {
- GtkAction *action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (object));
- gboolean use_appearance = g_value_get_boolean (value);
-
- update_use_action_appearance (gwidget, FALSE, action && use_appearance);
- }
+ glade_widget_property_get (widget, "related-action", &action);
+ glade_widget_property_get (widget, "use-action-appearance", &use_appearance);
+
+ return (action != NULL) ? use_appearance : FALSE;
}
diff --git a/plugins/gtk+/glade-gtk-activatable.h b/plugins/gtk+/glade-gtk-activatable.h
index 1af54a2..bd0c9cd 100644
--- a/plugins/gtk+/glade-gtk-activatable.h
+++ b/plugins/gtk+/glade-gtk-activatable.h
@@ -34,6 +34,8 @@ void
glade_gtk_activatable_evaluate_property_sensitivity (GObject *object,
const gchar *id,
const GValue *value);
+gboolean
+glade_gtk_activatable_get_use_action_appearance (GladeWidget *widget);
G_END_DECLS
diff --git a/plugins/gtk+/glade-tool-button-editor.c b/plugins/gtk+/glade-tool-button-editor.c
index 9e612a2..63d1c61 100644
--- a/plugins/gtk+/glade-tool-button-editor.c
+++ b/plugins/gtk+/glade-tool-button-editor.c
@@ -25,7 +25,7 @@
#include <gdk/gdkkeysyms.h>
#include "glade-tool-button-editor.h"
-
+#include "glade-gtk-activatable.h"
static void glade_tool_button_editor_finalize (GObject * object);
@@ -60,7 +60,7 @@ static void
glade_tool_button_editor_load (GladeEditable * editable, GladeWidget * widget)
{
GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (editable);
- gboolean custom_label = FALSE, use_appearance = FALSE;
+ gboolean custom_label = FALSE;
GladeToolButtonImageMode image_mode = 0;
GList *l;
@@ -79,8 +79,6 @@ glade_tool_button_editor_load (GladeEditable * editable, GladeWidget * widget)
{
glade_widget_property_get (widget, "image-mode", &image_mode);
glade_widget_property_get (widget, "custom-label", &custom_label);
- glade_widget_property_get (widget, "use-action-appearance",
- &use_appearance);
if (custom_label)
gtk_toggle_button_set_active
@@ -107,7 +105,7 @@ glade_tool_button_editor_load (GladeEditable * editable, GladeWidget * widget)
break;
}
- if (use_appearance)
+ if (glade_gtk_activatable_get_use_action_appearance (widget))
{
gtk_widget_set_sensitive (button_editor->label_table, FALSE);
gtk_widget_set_sensitive (button_editor->image_table, FALSE);