adjusted stylus-only code to fit gtk code conventions

This commit is contained in:
Florian "sp1rit"​ 2022-11-21 16:30:56 +01:00
parent 789778105d
commit c85fbcea55
No known key found for this signature in database
GPG Key ID: 7D8C1CD573166D09
2 changed files with 45 additions and 43 deletions

View File

@ -53,35 +53,37 @@ enum {
N_SIGNALS
};
static GParamSpec* obj_properties[N_PROPERTIES] = { NULL, };
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
static guint signals[N_SIGNALS] = { 0, };
static void gtk_gesture_stylus_get_property (GObject* object,
static void gtk_gesture_stylus_get_property (GObject *object,
guint prop_id,
GValue* value,
GParamSpec* pspec)
GValue *value,
GParamSpec *pspec)
{
GtkGestureStylus* gesture = GTK_GESTURE_STYLUS(object);
GtkGestureStylus *gesture = GTK_GESTURE_STYLUS (object);
switch (prop_id) {
switch (prop_id)
{
case PROP_STYLUS_ONLY:
g_value_set_boolean(value, gtk_gesture_stylus_get_stylus_only(gesture));
g_value_set_boolean (value, gtk_gesture_stylus_get_stylus_only (gesture));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void gtk_gesture_stylus_set_property (GObject* object,
static void gtk_gesture_stylus_set_property (GObject *object,
guint prop_id,
const GValue* value,
GParamSpec* pspec)
const GValue *value,
GParamSpec *pspec)
{
GtkGestureStylus* gesture = GTK_GESTURE_STYLUS(object);
GtkGestureStylus *gesture = GTK_GESTURE_STYLUS (object);
switch (prop_id) {
switch (prop_id)
{
case PROP_STYLUS_ONLY:
gtk_gesture_stylus_set_stylus_only(gesture, g_value_get_boolean(value));
gtk_gesture_stylus_set_stylus_only (gesture, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -98,7 +100,7 @@ gtk_gesture_stylus_handle_event (GtkEventController *controller,
GdkModifierType modifiers;
guint n_signal;
priv = gtk_gesture_stylus_get_instance_private(GTK_GESTURE_STYLUS(controller));
priv = gtk_gesture_stylus_get_instance_private (GTK_GESTURE_STYLUS (controller));
GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_stylus_parent_class)->handle_event (controller, event, x, y);
if (!(priv->stylus_only || gdk_event_get_device_tool (event)))
@ -144,12 +146,10 @@ gtk_gesture_stylus_class_init (GtkGestureStylusClass *klass)
*
* If this gesture should exclusively react to stylus input devices.
*/
obj_properties[PROP_STYLUS_ONLY] = g_param_spec_boolean("stylus-only",
P_("Stylus only"),
P_("Should this gesture exclusively react to stylus input devices."),
obj_properties[PROP_STYLUS_ONLY] = g_param_spec_boolean ("stylus-only", NULL, NULL,
TRUE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_CONSTRUCT);
g_object_class_install_properties(object_class, N_PROPERTIES, obj_properties);
g_object_class_install_properties (object_class, N_PROPERTIES, obj_properties);
event_controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
event_controller_class->handle_event = gtk_gesture_stylus_handle_event;
@ -268,12 +268,13 @@ gtk_gesture_stylus_new (void)
* Returns: The state of stylus-only set via [method@Gtk.GestureStylus.set_stylus_only]
*/
gboolean
gtk_gesture_stylus_get_stylus_only(GtkGestureStylus* gesture) {
GtkGestureStylusPrivate* priv;
gtk_gesture_stylus_get_stylus_only (GtkGestureStylus *gesture)
{
GtkGestureStylusPrivate *priv;
g_return_val_if_fail(GTK_IS_GESTURE_STYLUS(gesture), FALSE);
g_return_val_if_fail (GTK_IS_GESTURE_STYLUS (gesture), FALSE);
priv = gtk_gesture_stylus_get_instance_private(gesture);
priv = gtk_gesture_stylus_get_instance_private (gesture);
return priv->stylus_only;
}
@ -289,12 +290,13 @@ gtk_gesture_stylus_get_stylus_only(GtkGestureStylus* gesture) {
* otherwise it'll handle events from any pointing device.
*/
void
gtk_gesture_stylus_set_stylus_only(GtkGestureStylus* gesture, gboolean stylus_only) {
GtkGestureStylusPrivate* priv;
gtk_gesture_stylus_set_stylus_only (GtkGestureStylus *gesture, gboolean stylus_only)
{
GtkGestureStylusPrivate *priv;
g_return_if_fail(GTK_IS_GESTURE_STYLUS(gesture));
g_return_if_fail (GTK_IS_GESTURE_STYLUS (gesture));
priv = gtk_gesture_stylus_get_instance_private(gesture);
priv = gtk_gesture_stylus_get_instance_private (gesture);
if (priv->stylus_only == stylus_only)
return;

View File

@ -43,10 +43,10 @@ GType gtk_gesture_stylus_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkGesture * gtk_gesture_stylus_new (void);
GDK_AVAILABLE_IN_4_8
gboolean gtk_gesture_stylus_get_stylus_only (GtkGestureStylus* gesture);
GDK_AVAILABLE_IN_4_8
void gtk_gesture_stylus_set_stylus_only (GtkGestureStylus* gesture,
GDK_AVAILABLE_IN_4_10
gboolean gtk_gesture_stylus_get_stylus_only (GtkGestureStylus *gesture);
GDK_AVAILABLE_IN_4_10
void gtk_gesture_stylus_set_stylus_only (GtkGestureStylus *gesture,
gboolean stylus_only);
GDK_AVAILABLE_IN_ALL