forked from AuroraMiddleware/gtk
checkbutton: Support GtkActionable properly
Support grouping buttons via a radio action, as well as via explicit gtk_check_button_set_group() calls.
This commit is contained in:
parent
3569360949
commit
5f8769e1a8
@ -37,6 +37,7 @@
|
|||||||
#include "gtkprivate.h"
|
#include "gtkprivate.h"
|
||||||
#include "gtkstylecontextprivate.h"
|
#include "gtkstylecontextprivate.h"
|
||||||
#include "gtkwidgetprivate.h"
|
#include "gtkwidgetprivate.h"
|
||||||
|
#include "gtkmodelbuttonprivate.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkcheckbutton
|
* SECTION:gtkcheckbutton
|
||||||
@ -121,6 +122,32 @@ gtk_check_button_dispose (GObject *object)
|
|||||||
G_OBJECT_CLASS (gtk_check_button_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gtk_check_button_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
button_role_changed (GtkCheckButton *self)
|
||||||
|
{
|
||||||
|
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
||||||
|
|
||||||
|
if (gtk_action_helper_get_role (priv->action_helper) == GTK_BUTTON_ROLE_RADIO)
|
||||||
|
gtk_css_node_set_name (gtk_widget_get_css_node (priv->indicator_widget),
|
||||||
|
g_quark_from_static_string("radio"));
|
||||||
|
else
|
||||||
|
gtk_css_node_set_name (gtk_widget_get_css_node (priv->indicator_widget),
|
||||||
|
g_quark_from_static_string("check"));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ensure_action_helper (GtkCheckButton *self)
|
||||||
|
{
|
||||||
|
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
||||||
|
|
||||||
|
if (priv->action_helper)
|
||||||
|
return;
|
||||||
|
|
||||||
|
priv->action_helper = gtk_action_helper_new (GTK_ACTIONABLE (self));
|
||||||
|
g_signal_connect_swapped (priv->action_helper, "notify::role",
|
||||||
|
G_CALLBACK (button_role_changed), self);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_button_set_action_name (GtkActionable *actionable,
|
gtk_check_button_set_action_name (GtkActionable *actionable,
|
||||||
const char *action_name)
|
const char *action_name)
|
||||||
@ -128,8 +155,7 @@ gtk_check_button_set_action_name (GtkActionable *actionable,
|
|||||||
GtkCheckButton *self = GTK_CHECK_BUTTON (actionable);
|
GtkCheckButton *self = GTK_CHECK_BUTTON (actionable);
|
||||||
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
||||||
|
|
||||||
if (!priv->action_helper)
|
ensure_action_helper (self);
|
||||||
priv->action_helper = gtk_action_helper_new (actionable);
|
|
||||||
|
|
||||||
gtk_action_helper_set_action_name (priv->action_helper, action_name);
|
gtk_action_helper_set_action_name (priv->action_helper, action_name);
|
||||||
}
|
}
|
||||||
@ -141,8 +167,7 @@ gtk_check_button_set_action_target_value (GtkActionable *actionable,
|
|||||||
GtkCheckButton *self = GTK_CHECK_BUTTON (actionable);
|
GtkCheckButton *self = GTK_CHECK_BUTTON (actionable);
|
||||||
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
GtkCheckButtonPrivate *priv = gtk_check_button_get_instance_private (self);
|
||||||
|
|
||||||
if (!priv->action_helper)
|
ensure_action_helper (self);
|
||||||
priv->action_helper = gtk_action_helper_new (actionable);
|
|
||||||
|
|
||||||
gtk_action_helper_set_action_target_value (priv->action_helper, action_target);
|
gtk_action_helper_set_action_target_value (priv->action_helper, action_target);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user