Commit 025e4721 authored by Matthias Clasen's avatar Matthias Clasen

spin button: Drop keybinding signals

parent ab24a463
Pipeline #90615 failed with stages
in 8 minutes and 24 seconds
...@@ -198,10 +198,6 @@ struct _GtkSpinButtonClass ...@@ -198,10 +198,6 @@ struct _GtkSpinButtonClass
gint (*output) (GtkSpinButton *spin_button); gint (*output) (GtkSpinButton *spin_button);
void (*value_changed) (GtkSpinButton *spin_button); void (*value_changed) (GtkSpinButton *spin_button);
/* Action signals for keybindings, do not connect to these */
void (*change_value) (GtkSpinButton *spin_button,
GtkScrollType scroll);
void (*wrapped) (GtkSpinButton *spin_button); void (*wrapped) (GtkSpinButton *spin_button);
}; };
...@@ -255,7 +251,6 @@ enum ...@@ -255,7 +251,6 @@ enum
INPUT, INPUT,
OUTPUT, OUTPUT,
VALUE_CHANGED, VALUE_CHANGED,
CHANGE_VALUE,
WRAPPED, WRAPPED,
LAST_SIGNAL LAST_SIGNAL
}; };
...@@ -312,7 +307,9 @@ static void gtk_spin_button_real_change_value (GtkSpinButton *spin, ...@@ -312,7 +307,9 @@ static void gtk_spin_button_real_change_value (GtkSpinButton *spin,
static gint gtk_spin_button_default_input (GtkSpinButton *spin_button, static gint gtk_spin_button_default_input (GtkSpinButton *spin_button,
gdouble *new_val); gdouble *new_val);
static void gtk_spin_button_default_output (GtkSpinButton *spin_button); static void gtk_spin_button_default_output (GtkSpinButton *spin_button);
static void gtk_spin_button_activate_value_change (GtkWidget *widget,
const char *action_name,
GVariant *parameter);
static guint spinbutton_signals[LAST_SIGNAL] = {0}; static guint spinbutton_signals[LAST_SIGNAL] = {0};
static GParamSpec *spinbutton_props[NUM_SPINBUTTON_PROPS] = {NULL, }; static GParamSpec *spinbutton_props[NUM_SPINBUTTON_PROPS] = {NULL, };
...@@ -323,10 +320,9 @@ G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_WIDGET, ...@@ -323,10 +320,9 @@ G_DEFINE_TYPE_WITH_CODE (GtkSpinButton, gtk_spin_button, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
gtk_spin_button_editable_init)) gtk_spin_button_editable_init))
#define add_spin_binding(widget_class, keyval, mask, scroll) \ #define add_spin_binding(widget_class, keyval, mask, scroll) \
gtk_widget_class_add_binding_signal (widget_class, keyval, mask, \ gtk_widget_class_bind_action (widget_class, keyval, mask, \
"change-value", \ "value.change", "i", scroll)
"(i)", scroll)
static void static void
...@@ -371,7 +367,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) ...@@ -371,7 +367,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
class->input = NULL; class->input = NULL;
class->output = NULL; class->output = NULL;
class->change_value = gtk_spin_button_real_change_value;
spinbutton_props[PROP_ADJUSTMENT] = spinbutton_props[PROP_ADJUSTMENT] =
g_param_spec_object ("adjustment", g_param_spec_object ("adjustment",
...@@ -528,34 +523,24 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) ...@@ -528,34 +523,24 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
NULL, NULL,
G_TYPE_NONE, 0); G_TYPE_NONE, 0);
/* Action signals */ /* Actions */
/** /**
* GtkSpinButton::change-value: * GtkSpinButton|value.change:
* @spin_button: the object on which the signal was emitted
* @scroll: a #GtkScrollType to specify the speed and amount of change * @scroll: a #GtkScrollType to specify the speed and amount of change
* *
* The ::change-value signal is a [keybinding signal][GtkBindingSignal] * The value.change action changes the value according to the
* which gets emitted when the user initiates a value change. * provided @scroll granularity.
* *
* Applications should not connect to it, but may emit it with * The default bindings for this action are Up/Down and PageUp and/PageDown.
* g_signal_emit_by_name() if they need to control the cursor
* programmatically.
*
* The default bindings for this signal are Up/Down and PageUp and/PageDown.
*/ */
spinbutton_signals[CHANGE_VALUE] = gtk_widget_class_install_action (widget_class, "value.change", "i",
g_signal_new (I_("change-value"), gtk_spin_button_activate_value_change);
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkSpinButtonClass, change_value),
NULL, NULL,
NULL,
G_TYPE_NONE, 1,
GTK_TYPE_SCROLL_TYPE);
gtk_widget_class_install_action (widget_class, "activate", NULL, gtk_widget_class_install_action (widget_class, "activate", NULL,
gtk_spin_button_activate); gtk_spin_button_activate);
/* Key bindings */
gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0, gtk_widget_class_bind_action (widget_class, GDK_KEY_Return, 0,
"activate", NULL); "activate", NULL);
gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0, gtk_widget_class_bind_action (widget_class, GDK_KEY_ISO_Enter, 0,
...@@ -1346,6 +1331,18 @@ gtk_spin_button_real_change_value (GtkSpinButton *spin, ...@@ -1346,6 +1331,18 @@ gtk_spin_button_real_change_value (GtkSpinButton *spin,
gtk_widget_error_bell (GTK_WIDGET (spin)); gtk_widget_error_bell (GTK_WIDGET (spin));
} }
static void
gtk_spin_button_activate_value_change (GtkWidget *widget,
const char *action_name,
GVariant *parameter)
{
GtkScrollType scroll = g_variant_get_int32 (parameter);
scroll = CLAMP (scroll, GTK_SCROLL_NONE, GTK_SCROLL_END);
gtk_spin_button_real_change_value (GTK_SPIN_BUTTON (widget), scroll);
}
static void static void
gtk_spin_button_snap (GtkSpinButton *spin_button, gtk_spin_button_snap (GtkSpinButton *spin_button,
gdouble val) gdouble val)
......
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