Commit 38bbaeb8 authored by Robert Ancell's avatar Robert Ancell Committed by Georges Basile Stavracas Neto

mouse: Replace GObject boilerplace with G_DECLARE_TYPE

parent 5c418b89
......@@ -30,16 +30,15 @@
#include <glib/gi18n.h>
CC_PANEL_REGISTER (CcMousePanel, cc_mouse_panel)
#define MOUSE_PANEL_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_MOUSE_PANEL, CcMousePanelPrivate))
struct _CcMousePanelPrivate
struct _CcMousePanel
{
GtkWidget *stack;
CcPanel parent_instance;
GtkWidget *stack;
};
CC_PANEL_REGISTER (CcMousePanel, cc_mouse_panel)
enum {
CC_MOUSE_PAGE_PREFS,
CC_MOUSE_PAGE_TEST
......@@ -60,11 +59,10 @@ cc_mouse_panel_get_help_uri (CcPanel *panel)
static void
shell_test_button_toggled (GtkToggleButton *button, CcMousePanel *panel)
{
CcMousePanelPrivate *priv = panel->priv;
gboolean active;
active = gtk_toggle_button_get_active (button);
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), active ? "test_widget" : "prefs_widget");
gtk_stack_set_visible_child_name (GTK_STACK (panel->stack), active ? "test_widget" : "prefs_widget");
}
static void
......@@ -95,10 +93,8 @@ cc_mouse_panel_constructed (GObject *object)
static void
cc_mouse_panel_init (CcMousePanel *self)
{
CcMousePanelPrivate *priv;
GtkWidget *prefs_widget, *test_widget;
priv = self->priv = MOUSE_PANEL_PRIVATE (self);
g_resources_register (cc_mouse_get_resource ());
prefs_widget = cc_mouse_properties_new ();
......@@ -106,12 +102,12 @@ cc_mouse_panel_init (CcMousePanel *self)
test_widget = cc_mouse_test_new ();
gtk_widget_show (test_widget);
priv->stack = gtk_stack_new ();
gtk_widget_show (priv->stack);
gtk_stack_add_named (GTK_STACK (priv->stack), prefs_widget, "prefs_widget");
gtk_stack_add_named (GTK_STACK (priv->stack), test_widget, "test_widget");
self->stack = gtk_stack_new ();
gtk_widget_show (self->stack);
gtk_stack_add_named (GTK_STACK (self->stack), prefs_widget, "prefs_widget");
gtk_stack_add_named (GTK_STACK (self->stack), test_widget, "test_widget");
gtk_container_add (GTK_CONTAINER (self), priv->stack);
gtk_container_add (GTK_CONTAINER (self), self->stack);
}
static void
......@@ -120,8 +116,6 @@ cc_mouse_panel_class_init (CcMousePanelClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcMousePanelPrivate));
panel_class->get_help_uri = cc_mouse_panel_get_help_uri;
object_class->dispose = cc_mouse_panel_dispose;
......
......@@ -18,7 +18,6 @@
*
*/
#ifndef _CC_MOUSE_PANEL_H
#define _CC_MOUSE_PANEL_H
......@@ -26,45 +25,8 @@
G_BEGIN_DECLS
#define CC_TYPE_MOUSE_PANEL cc_mouse_panel_get_type()
#define CC_MOUSE_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
CC_TYPE_MOUSE_PANEL, CcMousePanel))
#define CC_MOUSE_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
CC_TYPE_MOUSE_PANEL, CcMousePanelClass))
#define CC_IS_MOUSE_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
CC_TYPE_MOUSE_PANEL))
#define CC_IS_MOUSE_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
CC_TYPE_MOUSE_PANEL))
#define CC_MOUSE_PANEL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CC_TYPE_MOUSE_PANEL, CcMousePanelClass))
typedef struct _CcMousePanel CcMousePanel;
typedef struct _CcMousePanelClass CcMousePanelClass;
typedef struct _CcMousePanelPrivate CcMousePanelPrivate;
struct _CcMousePanel
{
CcPanel parent;
CcMousePanelPrivate *priv;
};
struct _CcMousePanelClass
{
CcPanelClass parent_class;
};
GType cc_mouse_panel_get_type (void) G_GNUC_CONST;
#define CC_TYPE_MOUSE_PANEL (cc_mouse_panel_get_type ())
G_DECLARE_FINAL_TYPE (CcMousePanel, cc_mouse_panel, CC, MOUSE_PANEL, CcPanel)
G_END_DECLS
......
......@@ -42,12 +42,12 @@
#include <sys/stat.h>
#include <dirent.h>
#define WID(x) (GtkWidget *) gtk_builder_get_object (d->builder, x)
#define WID(x) (GtkWidget *) gtk_builder_get_object (self->builder, x)
#define CC_MOUSE_PROPERTIES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TYPE_MOUSE_PROPERTIES, CcMousePropertiesPrivate))
struct _CcMousePropertiesPrivate
struct _CcMouseProperties
{
GtkBin parent_instance;
GtkBuilder *builder;
GSettings *mouse_settings;
......@@ -73,7 +73,7 @@ struct _CcMousePropertiesPrivate
G_DEFINE_TYPE (CcMouseProperties, cc_mouse_properties, GTK_TYPE_BIN);
static void
setup_touchpad_options (CcMousePropertiesPrivate *d)
setup_touchpad_options (CcMouseProperties *self)
{
gboolean edge_scroll_enabled;
gboolean two_finger_scroll_enabled;
......@@ -81,12 +81,12 @@ setup_touchpad_options (CcMousePropertiesPrivate *d)
gboolean have_edge_scrolling;
gboolean have_tap_to_click;
gtk_widget_set_visible (WID ("touchpad-frame"), !d->have_synaptics);
if (d->have_synaptics)
gtk_widget_set_visible (WID ("touchpad-frame"), !self->have_synaptics);
if (self->have_synaptics)
return;
gtk_widget_set_visible (WID ("touchpad-frame"), d->have_touchpad);
if (!d->have_touchpad)
gtk_widget_set_visible (WID ("touchpad-frame"), self->have_touchpad);
if (!self->have_touchpad)
return;
cc_touchpad_check_capabilities (&have_two_finger_scrolling, &have_edge_scrolling, &have_tap_to_click);
......@@ -97,19 +97,19 @@ setup_touchpad_options (CcMousePropertiesPrivate *d)
gtk_widget_set_visible (WID ("edge-scrolling-row"), have_edge_scrolling);
gtk_widget_set_visible (WID ("tap-to-click-row"), have_tap_to_click);
edge_scroll_enabled = g_settings_get_boolean (d->touchpad_settings, "edge-scrolling-enabled");
two_finger_scroll_enabled = g_settings_get_boolean (d->touchpad_settings, "two-finger-scrolling-enabled");
edge_scroll_enabled = g_settings_get_boolean (self->touchpad_settings, "edge-scrolling-enabled");
two_finger_scroll_enabled = g_settings_get_boolean (self->touchpad_settings, "two-finger-scrolling-enabled");
if (edge_scroll_enabled && two_finger_scroll_enabled) {
/* You cunning user set both, but you can only have one set in that UI */
d->changing_scroll = TRUE;
self->changing_scroll = TRUE;
gtk_switch_set_active (GTK_SWITCH (WID ("two-finger-scrolling-switch")), two_finger_scroll_enabled);
d->changing_scroll = FALSE;
self->changing_scroll = FALSE;
gtk_switch_set_active (GTK_SWITCH (WID ("edge-scrolling-switch")), FALSE);
} else {
d->changing_scroll = TRUE;
self->changing_scroll = TRUE;
gtk_switch_set_active (GTK_SWITCH (WID ("edge-scrolling-switch")), edge_scroll_enabled);
gtk_switch_set_active (GTK_SWITCH (WID ("two-finger-scrolling-switch")), two_finger_scroll_enabled);
d->changing_scroll = FALSE;
self->changing_scroll = FALSE;
}
}
......@@ -118,12 +118,12 @@ two_finger_scrolling_changed_event (GtkSwitch *button,
gboolean state,
gpointer user_data)
{
CcMousePropertiesPrivate *d = user_data;
CcMouseProperties *self = user_data;
if (d->changing_scroll)
if (self->changing_scroll)
return;
g_settings_set_boolean (d->touchpad_settings, "two-finger-scrolling-enabled", state);
g_settings_set_boolean (self->touchpad_settings, "two-finger-scrolling-enabled", state);
gtk_switch_set_state (button, state);
if (state && gtk_widget_get_visible (WID ("edge-scrolling-row"))) {
......@@ -137,12 +137,12 @@ edge_scrolling_changed_event (GtkSwitch *button,
gboolean state,
gpointer user_data)
{
CcMousePropertiesPrivate *d = user_data;
CcMouseProperties *self = user_data;
if (d->changing_scroll)
if (self->changing_scroll)
return;
g_settings_set_boolean (d->touchpad_settings, "edge-scrolling-enabled", state);
g_settings_set_boolean (self->touchpad_settings, "edge-scrolling-enabled", state);
gtk_switch_set_state (button, state);
if (state && gtk_widget_get_visible (WID ("two-finger-scrolling-row"))) {
......@@ -162,21 +162,21 @@ get_touchpad_enabled (GSettings *settings)
}
static gboolean
show_touchpad_enabling_switch (CcMousePropertiesPrivate *d)
show_touchpad_enabling_switch (CcMouseProperties *self)
{
if (!d->have_touchpad)
if (!self->have_touchpad)
return FALSE;
g_debug ("Should we show the touchpad disable switch: have_mouse: %s have_touchscreen: %s\n",
d->have_mouse ? "true" : "false",
d->have_touchscreen ? "true" : "false");
self->have_mouse ? "true" : "false",
self->have_touchscreen ? "true" : "false");
/* Let's show the button when a mouse or touchscreen is present */
if (d->have_mouse || d->have_touchscreen)
if (self->have_mouse || self->have_touchscreen)
return TRUE;
/* Let's also show when the touchpad is disabled. */
if (!get_touchpad_enabled (d->touchpad_settings))
if (!get_touchpad_enabled (self->touchpad_settings))
return TRUE;
return FALSE;
......@@ -208,9 +208,9 @@ touchpad_enabled_set_mapping (const GValue *value,
}
static void
handle_secondary_button (CcMousePropertiesPrivate *d,
GtkWidget *button,
GtkGesture *gesture)
handle_secondary_button (CcMouseProperties *self,
GtkWidget *button,
GtkGesture *gesture)
{
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
......@@ -222,30 +222,30 @@ handle_secondary_button (CcMousePropertiesPrivate *d,
/* Set up the property editors in the dialog. */
static void
setup_dialog (CcMousePropertiesPrivate *d)
setup_dialog (CcMouseProperties *self)
{
GtkWidget *button;
d->left_handed = g_settings_get_boolean (d->mouse_settings, "left-handed");
button = WID (d->left_handed ? "primary-button-right" : "primary-button-left");
self->left_handed = g_settings_get_boolean (self->mouse_settings, "left-handed");
button = WID (self->left_handed ? "primary-button-right" : "primary-button-left");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_settings_bind (d->mouse_settings, "left-handed",
g_settings_bind (self->mouse_settings, "left-handed",
WID ("primary-button-left"), "active",
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
g_settings_bind (d->mouse_settings, "left-handed",
g_settings_bind (self->mouse_settings, "left-handed",
WID ("primary-button-right"), "active",
G_SETTINGS_BIND_DEFAULT);
/* Allow changing orientation with either button */
button = WID ("primary-button-right");
d->right_gesture = gtk_gesture_multi_press_new (button);
handle_secondary_button (d, button, d->right_gesture);
self->right_gesture = gtk_gesture_multi_press_new (button);
handle_secondary_button (self, button, self->right_gesture);
button = WID ("primary-button-left");
d->left_gesture = gtk_gesture_multi_press_new (button);
handle_secondary_button (d, button, d->left_gesture);
self->left_gesture = gtk_gesture_multi_press_new (button);
handle_secondary_button (self, button, self->left_gesture);
g_settings_bind (d->mouse_settings, "natural-scroll",
g_settings_bind (self->mouse_settings, "natural-scroll",
WID ("mouse-natural-scrolling-switch"), "active",
G_SETTINGS_BIND_DEFAULT);
......@@ -253,9 +253,9 @@ setup_dialog (CcMousePropertiesPrivate *d)
gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("touchpad-listbox")), cc_list_box_update_header_func, NULL, NULL);
/* Mouse section */
gtk_widget_set_visible (WID ("mouse-frame"), d->have_mouse);
gtk_widget_set_visible (WID ("mouse-frame"), self->have_mouse);
g_settings_bind (d->mouse_settings, "speed",
g_settings_bind (self->mouse_settings, "speed",
gtk_range_get_adjustment (GTK_RANGE (WID ("mouse-speed-scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
......@@ -263,39 +263,39 @@ setup_dialog (CcMousePropertiesPrivate *d)
/* Touchpad section */
gtk_widget_set_visible (WID ("touchpad-toggle-switch"),
show_touchpad_enabling_switch (d));
show_touchpad_enabling_switch (self));
g_settings_bind_with_mapping (d->touchpad_settings, "send-events",
g_settings_bind_with_mapping (self->touchpad_settings, "send-events",
WID ("touchpad-toggle-switch"), "active",
G_SETTINGS_BIND_DEFAULT,
touchpad_enabled_get_mapping,
touchpad_enabled_set_mapping,
NULL, NULL);
g_settings_bind_with_mapping (d->touchpad_settings, "send-events",
g_settings_bind_with_mapping (self->touchpad_settings, "send-events",
WID ("touchpad-options-listbox"), "sensitive",
G_SETTINGS_BIND_GET,
touchpad_enabled_get_mapping,
touchpad_enabled_set_mapping,
NULL, NULL);
g_settings_bind (d->touchpad_settings, "natural-scroll",
g_settings_bind (self->touchpad_settings, "natural-scroll",
WID ("touchpad-natural-scrolling-switch"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (d->touchpad_settings, "speed",
g_settings_bind (self->touchpad_settings, "speed",
gtk_range_get_adjustment (GTK_RANGE (WID ("touchpad-speed-scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (d->touchpad_settings, "tap-to-click",
g_settings_bind (self->touchpad_settings, "tap-to-click",
WID ("tap-to-click-switch"), "active",
G_SETTINGS_BIND_DEFAULT);
setup_touchpad_options (d);
setup_touchpad_options (self);
g_signal_connect (WID ("edge-scrolling-switch"), "state-set",
G_CALLBACK (edge_scrolling_changed_event), d);
G_CALLBACK (edge_scrolling_changed_event), self);
g_signal_connect (WID ("two-finger-scrolling-switch"), "state-set",
G_CALLBACK (two_finger_scrolling_changed_event), d);
G_CALLBACK (two_finger_scrolling_changed_event), self);
gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("touchpad-options-listbox")), cc_list_box_update_header_func, NULL, NULL);
}
......@@ -304,16 +304,16 @@ setup_dialog (CcMousePropertiesPrivate *d)
static void
device_changed (GsdDeviceManager *device_manager,
GsdDevice *device,
CcMousePropertiesPrivate *d)
CcMouseProperties *self)
{
d->have_touchpad = touchpad_is_present ();
self->have_touchpad = touchpad_is_present ();
setup_touchpad_options (d);
setup_touchpad_options (self);
d->have_mouse = mouse_is_present ();
gtk_widget_set_visible (WID ("mouse-frame"), d->have_mouse);
self->have_mouse = mouse_is_present ();
gtk_widget_set_visible (WID ("mouse-frame"), self->have_mouse);
gtk_widget_set_visible (WID ("touchpad-toggle-switch"),
show_touchpad_enabling_switch (d));
show_touchpad_enabling_switch (self));
}
static void
......@@ -334,21 +334,21 @@ on_content_size_changed (GtkWidget *widget,
static void
cc_mouse_properties_finalize (GObject *object)
{
CcMousePropertiesPrivate *d = CC_MOUSE_PROPERTIES (object)->priv;
g_clear_object (&d->mouse_settings);
g_clear_object (&d->gsd_mouse_settings);
g_clear_object (&d->touchpad_settings);
g_clear_object (&d->builder);
g_clear_object (&d->right_gesture);
g_clear_object (&d->left_gesture);
if (d->device_manager != NULL) {
g_signal_handler_disconnect (d->device_manager, d->device_added_id);
d->device_added_id = 0;
g_signal_handler_disconnect (d->device_manager, d->device_removed_id);
d->device_removed_id = 0;
d->device_manager = NULL;
CcMouseProperties *self = CC_MOUSE_PROPERTIES (object);
g_clear_object (&self->mouse_settings);
g_clear_object (&self->gsd_mouse_settings);
g_clear_object (&self->touchpad_settings);
g_clear_object (&self->builder);
g_clear_object (&self->right_gesture);
g_clear_object (&self->left_gesture);
if (self->device_manager != NULL) {
g_signal_handler_disconnect (self->device_manager, self->device_added_id);
self->device_added_id = 0;
g_signal_handler_disconnect (self->device_manager, self->device_removed_id);
self->device_removed_id = 0;
self->device_manager = NULL;
}
G_OBJECT_CLASS (cc_mouse_properties_parent_class)->finalize (object);
......@@ -361,43 +361,40 @@ cc_mouse_properties_class_init (CcMousePropertiesClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->finalize = cc_mouse_properties_finalize;
g_type_class_add_private (class, sizeof (CcMousePropertiesPrivate));
}
static void
cc_mouse_properties_init (CcMouseProperties *object)
cc_mouse_properties_init (CcMouseProperties *self)
{
CcMousePropertiesPrivate *d = object->priv = CC_MOUSE_PROPERTIES_GET_PRIVATE (object);
g_autoptr(GError) error = NULL;
d->builder = gtk_builder_new ();
gtk_builder_add_from_resource (d->builder,
self->builder = gtk_builder_new ();
gtk_builder_add_from_resource (self->builder,
"/org/gnome/control-center/mouse/gnome-mouse-properties.ui",
&error);
d->mouse_settings = g_settings_new ("org.gnome.desktop.peripherals.mouse");
d->gsd_mouse_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.mouse");
d->touchpad_settings = g_settings_new ("org.gnome.desktop.peripherals.touchpad");
d->device_manager = gsd_device_manager_get ();
d->device_added_id = g_signal_connect (d->device_manager, "device-added",
G_CALLBACK (device_changed), d);
d->device_removed_id = g_signal_connect (d->device_manager, "device-removed",
G_CALLBACK (device_changed), d);
d->have_mouse = mouse_is_present ();
d->have_touchpad = touchpad_is_present ();
d->have_touchscreen = touchscreen_is_present ();
d->have_synaptics = cc_synaptics_check ();
if (d->have_synaptics)
self->mouse_settings = g_settings_new ("org.gnome.desktop.peripherals.mouse");
self->gsd_mouse_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.mouse");
self->touchpad_settings = g_settings_new ("org.gnome.desktop.peripherals.touchpad");
self->device_manager = gsd_device_manager_get ();
self->device_added_id = g_signal_connect (self->device_manager, "device-added",
G_CALLBACK (device_changed), self);
self->device_removed_id = g_signal_connect (self->device_manager, "device-removed",
G_CALLBACK (device_changed), self);
self->have_mouse = mouse_is_present ();
self->have_touchpad = touchpad_is_present ();
self->have_touchscreen = touchscreen_is_present ();
self->have_synaptics = cc_synaptics_check ();
if (self->have_synaptics)
g_warning ("Detected synaptics X driver, please migrate to libinput");
d->changing_scroll = FALSE;
self->changing_scroll = FALSE;
gtk_container_add (GTK_CONTAINER (object), WID ("scrolled-window"));
gtk_container_add (GTK_CONTAINER (self), WID ("scrolled-window"));
setup_dialog (d);
setup_dialog (self);
g_signal_connect (WID ("scrolled-window"), "size-allocate", G_CALLBACK (on_content_size_changed), NULL);
}
......
......@@ -28,31 +28,9 @@
G_BEGIN_DECLS
#define CC_TYPE_MOUSE_PROPERTIES cc_mouse_properties_get_type ()
#define CC_TYPE_MOUSE_PROPERTIES (cc_mouse_properties_get_type ())
G_DECLARE_FINAL_TYPE (CcMouseProperties, cc_mouse_properties, CC, MOUSE_PROPERTIES, GtkBin)
#define CC_MOUSE_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CC_TYPE_MOUSE_PROPERTIES, CcMouseProperties))
#define CC_MOUSE_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CC_TYPE_MOUSE_PROPERTIES, CcMousePropertiesClass))
#define CC_IS_MOUSE_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CC_TYPE_MOUSE_PROPERTIES))
#define CC_IS_MOUSE_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CC_TYPE_MOUSE_PROPERTIES))
#define CC_MOUSE_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CC_TYPE_MOUSE_PROPERTIES, CcMousePropertiesClass))
typedef struct _CcMouseProperties CcMouseProperties;
typedef struct _CcMousePropertiesClass CcMousePropertiesClass;
typedef struct _CcMousePropertiesPrivate CcMousePropertiesPrivate;
struct _CcMouseProperties
{
GtkAlignment parent;
CcMousePropertiesPrivate *priv;
};
struct _CcMousePropertiesClass
{
GtkAlignmentClass parent_class;
};
GType cc_mouse_properties_get_type (void) G_GNUC_CONST;
GtkWidget *cc_mouse_properties_new (void);
G_END_DECLS
......
......@@ -32,7 +32,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#define WID(x) (GtkWidget *) gtk_builder_get_object (d->builder, x)
#define WID(x) (GtkWidget *) gtk_builder_get_object (self->builder, x)
/* Click test button sizes. */
#define SHADOW_SIZE (10.0 / 180 * size)
......@@ -42,10 +42,8 @@
#define ANNULUS_SIZE (6.0 / 180 * size)
#define INNER_CIRCLE_SIZE (52.0 / 180 * size)
#define CC_MOUSE_TEST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CC_TYPE_MOUSE_TEST, CcMouseTestPrivate))
static void setup_information_label (CcMouseTestPrivate *d);
static void setup_scroll_image (CcMouseTestPrivate *d);
static void setup_information_label (CcMouseTest *self);
static void setup_scroll_image (CcMouseTest *self);
enum
{
......@@ -57,8 +55,10 @@ enum
DOUBLE_CLICK_TEST_GEGL
};
struct _CcMouseTestPrivate
struct _CcMouseTest
{
GtkBin parent_instance;
GtkBuilder *builder;
guint32 double_click_timestamp;
......@@ -77,13 +77,13 @@ G_DEFINE_TYPE (CcMouseTest, cc_mouse_test, GTK_TYPE_BIN);
/* Timeout for the double click test */
static gboolean
test_maybe_timeout (CcMouseTestPrivate *d)
test_maybe_timeout (CcMouseTest *self)
{
d->double_click_state = DOUBLE_CLICK_TEST_OFF;
self->double_click_state = DOUBLE_CLICK_TEST_OFF;
gtk_widget_queue_draw (WID ("button_drawing_area"));
d->button_drawing_area_timeout_id = 0;
self->button_drawing_area_timeout_id = 0;
return FALSE;
}
......@@ -91,11 +91,11 @@ test_maybe_timeout (CcMouseTestPrivate *d)
/* Timeout for the information label */
static gboolean
information_label_timeout (CcMouseTestPrivate *d)
information_label_timeout (CcMouseTest *self)
{
setup_information_label (d);
setup_information_label (self);
d->information_label_timeout_id = 0;
self->information_label_timeout_id = 0;
return FALSE;
}
......@@ -103,11 +103,11 @@ information_label_timeout (CcMouseTestPrivate *d)
/* Timeout for the scroll image */
static gboolean
scroll_image_timeout (CcMouseTestPrivate *d)
scroll_image_timeout (CcMouseTest *self)
{
setup_scroll_image (d);
setup_scroll_image (self);
d->scroll_image_timeout_id = 0;
self->scroll_image_timeout_id = 0;
return FALSE;
}
......@@ -115,27 +115,27 @@ scroll_image_timeout (CcMouseTestPrivate *d)
/* Set information label */
static void
setup_information_label (CcMouseTestPrivate *d)
setup_information_label (CcMouseTest *self)
{
const gchar *message = NULL;
g_autofree gchar *label_text = NULL;
gboolean double_click;
if (d->information_label_timeout_id != 0) {
g_source_remove (d->information_label_timeout_id);
d->information_label_timeout_id = 0;
if (self->information_label_timeout_id != 0) {
g_source_remove (self->information_label_timeout_id);
self->information_label_timeout_id = 0;
}
if (d->double_click_state == DOUBLE_CLICK_TEST_OFF) {
if (self->double_click_state == DOUBLE_CLICK_TEST_OFF) {
gtk_label_set_label (GTK_LABEL (WID ("information_label")), _("Try clicking, double clicking, scrolling"));
return;
}
if (d->double_click_state == DOUBLE_CLICK_TEST_GEGL) {
if (self->double_click_state == DOUBLE_CLICK_TEST_GEGL) {
message = _("Five clicks, GEGL time!"), "</b>";
} else {
double_click = (d->double_click_state >= DOUBLE_CLICK_TEST_ON);
switch (d->button_state) {
double_click = (self->double_click_state >= DOUBLE_CLICK_TEST_ON);
switch (self->button_state) {
case 1:
message = (double_click) ? _("Double click, primary button") : _("Single click, primary button");
break;
......@@ -151,31 +151,31 @@ setup_information_label (CcMouseTestPrivate *d)
label_text = g_strconcat ("<b>", message, "</b>", NULL);
gtk_label_set_markup (GTK_LABEL (WID ("information_label")), label_text);
d->information_label_timeout_id = g_timeout_add (2500, (GSourceFunc) information_label_timeout, d);
self->information_label_timeout_id = g_timeout_add (2500, (GSourceFunc) information_label_timeout, self);
}
/* Update scroll image */
static void
setup_scroll_image (CcMouseTestPrivate *d)
setup_scroll_image (CcMouseTest *self)
{
const char *resource;
if (d->scroll_image_timeout_id != 0) {
g_source_remove (d->scroll_image_timeout_id);
d->scroll_image_timeout_id = 0;
if (self->scroll_image_timeout_id != 0) {
g_source_remove (self->scroll_image_timeout_id);
self->scroll_image_timeout_id = 0;
}
if (d->double_click_state == DOUBLE_CLICK_TEST_GEGL)
if (self->double_click_state == DOUBLE_CLICK_TEST_GEGL)
resource = "/org/gnome/control-center/mouse/scroll-test-gegl.svg";
else
resource = "/org/gnome/control-center/mouse/scroll-test.svg";
gtk_image_set_from_resource (GTK_IMAGE (WID ("image")), resource);
if (d->double_click_state != DOUBLE_CLICK_TEST_GEGL)
if (self->double_click_state != DOUBLE_CLICK_TEST_GEGL)
return;
d->scroll_image_timeout_id = g_timeout_add (5000, (GSourceFunc) scroll_image_timeout, d);
self->scroll_image_timeout_id = g_timeout_add (5000, (GSourceFunc) scroll_image_timeout, self);
}
/* Callback issued when the user clicks the double click testing area. */
......@@ -183,52 +183,52 @@ setup_scroll_image (CcMouseTestPrivate *d)
static gboolean
button_drawing_area_button_press_event (GtkWidget *widget,
GdkEventButton *event,
CcMouseTestPrivate *d)
CcMouseTest *self)
{
gint double_click_time;
if (event->type != GDK_BUTTON_PRESS || event->button > 3)
return FALSE;
double_click_time = g_settings_get_int (d->mouse_settings, "double-click");
double_click_time = g_settings_get_int (self->mouse_settings, "double-click");
if (d->button_drawing_area_timeout_id != 0) {
g_source_remove (d->button_drawing_area_timeout_id);
d->button_drawing_area_timeout_id = 0;
if (self->button_drawing_area_timeout_id != 0) {
g_source_remove (self->button_drawing_area_timeout_id);
self->button_drawing_area_timeout_id = 0;
}
/* Ignore fake double click using different buttons. */
if (d->double_click_state != DOUBLE_CLICK_TEST_OFF && d->button_state != event->button)
d->double_click_state = DOUBLE_CLICK_TEST_OFF;
if (self->double_click_state != DOUBLE_CLICK_TEST_OFF && self->button_state != event->button)
self->double_click_state = DOUBLE_CLICK_TEST_OFF;
switch (d->double_click_state) {
switch (self->double_click_state) {
case DOUBLE_CLICK_TEST_OFF:
d->double_click_state = DOUBLE_CLICK_TEST_MAYBE;
d->button_drawing_area_timeout_id = g_timeout_add (double_click_time, (GSourceFunc) test_maybe_timeout, d);
self->double_click_state = DOUBLE_CLICK_TEST_MAYBE;
self->button_drawing_area_timeout_id = g_timeout_add (double_click_time, (GSourceFunc) test_maybe_timeout, self);
break;
case DOUBLE_CLICK_TEST_MAYBE:
case DOUBLE_CLICK_TEST_ON:
case DOUBLE_CLICK_TEST_STILL_ON:
case DOUBLE_CLICK_TEST_ALMOST_THERE: