mouse: Use GtkTemplate

This commit is contained in:
Robert Ancell 2018-05-28 12:40:11 +12:00 committed by Georges Basile Stavracas Neto
parent 02f0353fc4
commit a7e84dcf2e
4 changed files with 700 additions and 652 deletions

View file

@ -42,13 +42,30 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#define WID(x) (GtkWidget *) gtk_builder_get_object (self->builder, x)
struct _CcMouseProperties struct _CcMouseProperties
{ {
GtkBin parent_instance; GtkBin parent_instance;
GtkBuilder *builder; GtkWidget *edge_scrolling_row;
GtkWidget *edge_scrolling_switch;
GtkWidget *general_listbox;
GtkWidget *mouse_frame;
GtkWidget *mouse_listbox;
GtkWidget *mouse_natural_scrolling_switch;
GtkWidget *mouse_speed_scale;
GtkWidget *primary_button_left;
GtkWidget *primary_button_right;
GtkWidget *scrolled_window;
GtkWidget *tap_to_click_row;
GtkWidget *tap_to_click_switch;
GtkWidget *touchpad_frame;
GtkWidget *touchpad_listbox;
GtkWidget *touchpad_natural_scrolling_switch;
GtkWidget *touchpad_options_listbox;
GtkWidget *touchpad_speed_scale;
GtkWidget *touchpad_toggle_switch;
GtkWidget *two_finger_scrolling_row;
GtkWidget *two_finger_scrolling_switch;
GSettings *mouse_settings; GSettings *mouse_settings;
GSettings *gsd_mouse_settings; GSettings *gsd_mouse_settings;
@ -81,34 +98,34 @@ setup_touchpad_options (CcMouseProperties *self)
gboolean have_edge_scrolling; gboolean have_edge_scrolling;
gboolean have_tap_to_click; gboolean have_tap_to_click;
gtk_widget_set_visible (WID ("touchpad-frame"), !self->have_synaptics); gtk_widget_set_visible (self->touchpad_frame, !self->have_synaptics);
if (self->have_synaptics) if (self->have_synaptics)
return; return;
gtk_widget_set_visible (WID ("touchpad-frame"), self->have_touchpad); gtk_widget_set_visible (self->touchpad_frame, self->have_touchpad);
if (!self->have_touchpad) if (!self->have_touchpad)
return; return;
cc_touchpad_check_capabilities (&have_two_finger_scrolling, &have_edge_scrolling, &have_tap_to_click); cc_touchpad_check_capabilities (&have_two_finger_scrolling, &have_edge_scrolling, &have_tap_to_click);
gtk_widget_show_all (WID ("touchpad-frame")); gtk_widget_show_all (self->touchpad_frame);
gtk_widget_set_visible (WID ("two-finger-scrolling-row"), have_two_finger_scrolling); gtk_widget_set_visible (self->two_finger_scrolling_row, have_two_finger_scrolling);
gtk_widget_set_visible (WID ("edge-scrolling-row"), have_edge_scrolling); gtk_widget_set_visible (self->edge_scrolling_row, have_edge_scrolling);
gtk_widget_set_visible (WID ("tap-to-click-row"), have_tap_to_click); gtk_widget_set_visible (self->tap_to_click_row, have_tap_to_click);
edge_scroll_enabled = g_settings_get_boolean (self->touchpad_settings, "edge-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"); two_finger_scroll_enabled = g_settings_get_boolean (self->touchpad_settings, "two-finger-scrolling-enabled");
if (edge_scroll_enabled && two_finger_scroll_enabled) { if (edge_scroll_enabled && two_finger_scroll_enabled) {
/* You cunning user set both, but you can only have one set in that UI */ /* You cunning user set both, but you can only have one set in that UI */
self->changing_scroll = TRUE; self->changing_scroll = TRUE;
gtk_switch_set_active (GTK_SWITCH (WID ("two-finger-scrolling-switch")), two_finger_scroll_enabled); gtk_switch_set_active (GTK_SWITCH (self->two_finger_scrolling_switch), two_finger_scroll_enabled);
self->changing_scroll = FALSE; self->changing_scroll = FALSE;
gtk_switch_set_active (GTK_SWITCH (WID ("edge-scrolling-switch")), FALSE); gtk_switch_set_active (GTK_SWITCH (self->edge_scrolling_switch), FALSE);
} else { } else {
self->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 (self->edge_scrolling_switch), edge_scroll_enabled);
gtk_switch_set_active (GTK_SWITCH (WID ("two-finger-scrolling-switch")), two_finger_scroll_enabled); gtk_switch_set_active (GTK_SWITCH (self->two_finger_scrolling_switch), two_finger_scroll_enabled);
self->changing_scroll = FALSE; self->changing_scroll = FALSE;
} }
} }
@ -126,9 +143,9 @@ two_finger_scrolling_changed_event (GtkSwitch *button,
g_settings_set_boolean (self->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); gtk_switch_set_state (button, state);
if (state && gtk_widget_get_visible (WID ("edge-scrolling-row"))) { if (state && gtk_widget_get_visible (self->edge_scrolling_row)) {
/* Disable edge scrolling if two-finger scrolling is enabled */ /* Disable edge scrolling if two-finger scrolling is enabled */
gtk_switch_set_state (GTK_SWITCH (WID ("edge-scrolling-switch")), FALSE); gtk_switch_set_state (GTK_SWITCH (self->edge_scrolling_switch), FALSE);
} }
} }
@ -145,9 +162,9 @@ edge_scrolling_changed_event (GtkSwitch *button,
g_settings_set_boolean (self->touchpad_settings, "edge-scrolling-enabled", state); g_settings_set_boolean (self->touchpad_settings, "edge-scrolling-enabled", state);
gtk_switch_set_state (button, state); gtk_switch_set_state (button, state);
if (state && gtk_widget_get_visible (WID ("two-finger-scrolling-row"))) { if (state && gtk_widget_get_visible (self->two_finger_scrolling_row)) {
/* Disable two-finger scrolling if edge scrolling is enabled */ /* Disable two-finger scrolling if edge scrolling is enabled */
gtk_switch_set_state (GTK_SWITCH (WID ("two-finger-scrolling-switch")), FALSE); gtk_switch_set_state (GTK_SWITCH (self->two_finger_scrolling_switch), FALSE);
} }
} }
@ -227,77 +244,77 @@ setup_dialog (CcMouseProperties *self)
GtkWidget *button; GtkWidget *button;
self->left_handed = g_settings_get_boolean (self->mouse_settings, "left-handed"); self->left_handed = g_settings_get_boolean (self->mouse_settings, "left-handed");
button = WID (self->left_handed ? "primary-button-right" : "primary-button-left"); button = self->left_handed ? self->primary_button_right : self->primary_button_left;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_settings_bind (self->mouse_settings, "left-handed", g_settings_bind (self->mouse_settings, "left-handed",
WID ("primary-button-left"), "active", self->primary_button_left, "active",
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN); G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
g_settings_bind (self->mouse_settings, "left-handed", g_settings_bind (self->mouse_settings, "left-handed",
WID ("primary-button-right"), "active", self->primary_button_right, "active",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
/* Allow changing orientation with either button */ /* Allow changing orientation with either button */
button = WID ("primary-button-right"); button = self->primary_button_right;
self->right_gesture = gtk_gesture_multi_press_new (button); self->right_gesture = gtk_gesture_multi_press_new (button);
handle_secondary_button (self, button, self->right_gesture); handle_secondary_button (self, button, self->right_gesture);
button = WID ("primary-button-left"); button = self->primary_button_left;
self->left_gesture = gtk_gesture_multi_press_new (button); self->left_gesture = gtk_gesture_multi_press_new (button);
handle_secondary_button (self, button, self->left_gesture); handle_secondary_button (self, button, self->left_gesture);
g_settings_bind (self->mouse_settings, "natural-scroll", g_settings_bind (self->mouse_settings, "natural-scroll",
WID ("mouse-natural-scrolling-switch"), "active", self->mouse_natural_scrolling_switch, "active",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("general-listbox")), cc_list_box_update_header_func, NULL, NULL); gtk_list_box_set_header_func (GTK_LIST_BOX (self->general_listbox), cc_list_box_update_header_func, NULL, NULL);
gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("touchpad-listbox")), cc_list_box_update_header_func, NULL, NULL); gtk_list_box_set_header_func (GTK_LIST_BOX (self->touchpad_listbox), cc_list_box_update_header_func, NULL, NULL);
/* Mouse section */ /* Mouse section */
gtk_widget_set_visible (WID ("mouse-frame"), self->have_mouse); gtk_widget_set_visible (self->mouse_frame, self->have_mouse);
g_settings_bind (self->mouse_settings, "speed", g_settings_bind (self->mouse_settings, "speed",
gtk_range_get_adjustment (GTK_RANGE (WID ("mouse-speed-scale"))), "value", gtk_range_get_adjustment (GTK_RANGE (self->mouse_speed_scale)), "value",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("mouse-listbox")), cc_list_box_update_header_func, NULL, NULL); gtk_list_box_set_header_func (GTK_LIST_BOX (self->mouse_listbox), cc_list_box_update_header_func, NULL, NULL);
/* Touchpad section */ /* Touchpad section */
gtk_widget_set_visible (WID ("touchpad-toggle-switch"), gtk_widget_set_visible (self->touchpad_toggle_switch,
show_touchpad_enabling_switch (self)); show_touchpad_enabling_switch (self));
g_settings_bind_with_mapping (self->touchpad_settings, "send-events", g_settings_bind_with_mapping (self->touchpad_settings, "send-events",
WID ("touchpad-toggle-switch"), "active", self->touchpad_toggle_switch, "active",
G_SETTINGS_BIND_DEFAULT, G_SETTINGS_BIND_DEFAULT,
touchpad_enabled_get_mapping, touchpad_enabled_get_mapping,
touchpad_enabled_set_mapping, touchpad_enabled_set_mapping,
NULL, NULL); NULL, NULL);
g_settings_bind_with_mapping (self->touchpad_settings, "send-events", g_settings_bind_with_mapping (self->touchpad_settings, "send-events",
WID ("touchpad-options-listbox"), "sensitive", self->touchpad_options_listbox, "sensitive",
G_SETTINGS_BIND_GET, G_SETTINGS_BIND_GET,
touchpad_enabled_get_mapping, touchpad_enabled_get_mapping,
touchpad_enabled_set_mapping, touchpad_enabled_set_mapping,
NULL, NULL); NULL, NULL);
g_settings_bind (self->touchpad_settings, "natural-scroll", g_settings_bind (self->touchpad_settings, "natural-scroll",
WID ("touchpad-natural-scrolling-switch"), "active", self->touchpad_natural_scrolling_switch, "active",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
g_settings_bind (self->touchpad_settings, "speed", g_settings_bind (self->touchpad_settings, "speed",
gtk_range_get_adjustment (GTK_RANGE (WID ("touchpad-speed-scale"))), "value", gtk_range_get_adjustment (GTK_RANGE (self->touchpad_speed_scale)), "value",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
g_settings_bind (self->touchpad_settings, "tap-to-click", g_settings_bind (self->touchpad_settings, "tap-to-click",
WID ("tap-to-click-switch"), "active", self->tap_to_click_switch, "active",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
setup_touchpad_options (self); setup_touchpad_options (self);
g_signal_connect (WID ("edge-scrolling-switch"), "state-set", g_signal_connect (self->edge_scrolling_switch, "state-set",
G_CALLBACK (edge_scrolling_changed_event), self); G_CALLBACK (edge_scrolling_changed_event), self);
g_signal_connect (WID ("two-finger-scrolling-switch"), "state-set", g_signal_connect (self->two_finger_scrolling_switch, "state-set",
G_CALLBACK (two_finger_scrolling_changed_event), self); 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); gtk_list_box_set_header_func (GTK_LIST_BOX (self->touchpad_options_listbox), cc_list_box_update_header_func, NULL, NULL);
} }
/* Callback issued when a button is clicked on the dialog */ /* Callback issued when a button is clicked on the dialog */
@ -311,8 +328,8 @@ device_changed (GsdDeviceManager *device_manager,
setup_touchpad_options (self); setup_touchpad_options (self);
self->have_mouse = mouse_is_present (); self->have_mouse = mouse_is_present ();
gtk_widget_set_visible (WID ("mouse-frame"), self->have_mouse); gtk_widget_set_visible (self->mouse_frame, self->have_mouse);
gtk_widget_set_visible (WID ("touchpad-toggle-switch"), gtk_widget_set_visible (self->touchpad_toggle_switch,
show_touchpad_enabling_switch (self)); show_touchpad_enabling_switch (self));
} }
@ -339,7 +356,6 @@ cc_mouse_properties_finalize (GObject *object)
g_clear_object (&self->mouse_settings); g_clear_object (&self->mouse_settings);
g_clear_object (&self->gsd_mouse_settings); g_clear_object (&self->gsd_mouse_settings);
g_clear_object (&self->touchpad_settings); g_clear_object (&self->touchpad_settings);
g_clear_object (&self->builder);
g_clear_object (&self->right_gesture); g_clear_object (&self->right_gesture);
g_clear_object (&self->left_gesture); g_clear_object (&self->left_gesture);
@ -355,12 +371,35 @@ cc_mouse_properties_finalize (GObject *object)
} }
static void static void
cc_mouse_properties_class_init (CcMousePropertiesClass *class) cc_mouse_properties_class_init (CcMousePropertiesClass *klass)
{ {
GObjectClass *object_class; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class = G_OBJECT_CLASS (class);
object_class->finalize = cc_mouse_properties_finalize; object_class->finalize = cc_mouse_properties_finalize;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/mouse/gnome-mouse-properties.ui");
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, edge_scrolling_row);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, edge_scrolling_switch);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, general_listbox);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, mouse_frame);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, mouse_listbox);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, mouse_natural_scrolling_switch);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, mouse_speed_scale);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, primary_button_left);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, primary_button_right);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, scrolled_window);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, tap_to_click_row);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, tap_to_click_switch);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, touchpad_frame);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, touchpad_listbox);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, touchpad_natural_scrolling_switch);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, touchpad_options_listbox);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, touchpad_speed_scale);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, touchpad_toggle_switch);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, two_finger_scrolling_row);
gtk_widget_class_bind_template_child (widget_class, CcMouseProperties, two_finger_scrolling_switch);
} }
static void static void
@ -368,10 +407,7 @@ cc_mouse_properties_init (CcMouseProperties *self)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
self->builder = gtk_builder_new (); gtk_widget_init_template (GTK_WIDGET (self));
gtk_builder_add_from_resource (self->builder,
"/org/gnome/control-center/mouse/gnome-mouse-properties.ui",
&error);
self->mouse_settings = g_settings_new ("org.gnome.desktop.peripherals.mouse"); 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->gsd_mouse_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.mouse");
@ -392,11 +428,9 @@ cc_mouse_properties_init (CcMouseProperties *self)
self->changing_scroll = FALSE; self->changing_scroll = FALSE;
gtk_container_add (GTK_CONTAINER (self), WID ("scrolled-window"));
setup_dialog (self); setup_dialog (self);
g_signal_connect (WID ("scrolled-window"), "size-allocate", G_CALLBACK (on_content_size_changed), NULL); g_signal_connect (self->scrolled_window, "size-allocate", G_CALLBACK (on_content_size_changed), NULL);
} }
GtkWidget * GtkWidget *

View file

@ -16,7 +16,11 @@
<property name="step_increment">100</property> <property name="step_increment">100</property>
<property name="page_increment">100</property> <property name="page_increment">100</property>
</object> </object>
<object class="GtkScrolledWindow" id="scrolled-window"> <template class="CcMouseProperties" parent="GtkBin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
@ -30,7 +34,7 @@
<property name="margin_bottom">32</property> <property name="margin_bottom">32</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkFrame" id="general-frame"> <object class="GtkFrame" id="general_frame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
@ -50,22 +54,22 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkFrame" id="general-frame-listbox"> <object class="GtkFrame" id="general_frame_listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkListBox" id="general-listbox"> <object class="GtkListBox" id="general_listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="selection_mode">none</property> <property name="selection_mode">none</property>
<child> <child>
<object class="GtkListBoxRow" id="primary-button-row"> <object class="GtkListBoxRow" id="primary_button_row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="primary-button-grid"> <object class="GtkGrid" id="primary_button_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">2</property> <property name="row_spacing">2</property>
@ -75,14 +79,14 @@
<property name="margin_top">12</property> <property name="margin_top">12</property>
<property name="margin_bottom">12</property> <property name="margin_bottom">12</property>
<child> <child>
<object class="GtkLabel" id="primary-button-label"> <object class="GtkLabel" id="primary_button_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">Primary Button</property> <property name="label" translatable="yes">Primary Button</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">primary-button-chooser-grid</property> <property name="mnemonic_widget">primary_button_chooser_grid</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -92,7 +96,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="primary-button-description"> <object class="GtkLabel" id="primary_button_description">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
@ -115,7 +119,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkGrid" id="primary-button-chooser-grid"> <object class="GtkGrid" id="primary_button_chooser_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="valign">center</property> <property name="valign">center</property>
@ -124,7 +128,7 @@
<class name="linked"/> <class name="linked"/>
</style> </style>
<child> <child>
<object class="GtkRadioButton" id="primary-button-left"> <object class="GtkRadioButton" id="primary_button_left">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -134,13 +138,13 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="primary-button-right"> <object class="GtkRadioButton" id="primary_button_right">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="label" translatable="yes">Right</property> <property name="label" translatable="yes">Right</property>
<property name="draw-indicator">False</property> <property name="draw-indicator">False</property>
<property name="group">primary-button-left</property> <property name="group">primary_button_left</property>
<property name="height_request">35</property> <property name="height_request">35</property>
</object> </object>
</child> </child>
@ -163,7 +167,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkFrame" id="mouse-frame"> <object class="GtkFrame" id="mouse_frame">
<property name="visible">False</property> <property name="visible">False</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
@ -182,22 +186,22 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkFrame" id="mouse-frame-listbox"> <object class="GtkFrame" id="mouse_frame_listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkListBox" id="mouse-listbox"> <object class="GtkListBox" id="mouse_listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="selection_mode">none</property> <property name="selection_mode">none</property>
<child> <child>
<object class="GtkListBoxRow" id="mouse-row"> <object class="GtkListBoxRow" id="mouse_row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="mouse-grid"> <object class="GtkGrid" id="mouse_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@ -208,14 +212,14 @@
<property name="margin_bottom">8</property> <property name="margin_bottom">8</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="mouse-label"> <object class="GtkLabel" id="mouse_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="valign">end</property> <property name="valign">end</property>
<property name="label" translatable="yes">Mouse Speed</property> <property name="label" translatable="yes">Mouse Speed</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">primary-button-chooser-grid</property> <property name="mnemonic_widget">primary_button_chooser_grid</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -225,7 +229,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScale" id="mouse-speed-scale"> <object class="GtkScale" id="mouse_speed_scale">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="adjustment">adjustment1</property> <property name="adjustment">adjustment1</property>
@ -234,7 +238,7 @@
<property name="halign">end</property> <property name="halign">end</property>
<property name="expand">True</property> <property name="expand">True</property>
<child internal-child="accessible"> <child internal-child="accessible">
<object class="AtkObject" id="mouse_speed_scale-atkobject"> <object class="AtkObject" id="mouse_speed_scale_atkobject">
<property name="AtkObject::accessible-description" translatable="yes">Double-click timeout</property> <property name="AtkObject::accessible-description" translatable="yes">Double-click timeout</property>
</object> </object>
</child> </child>
@ -251,12 +255,12 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkListBoxRow" id="mouse-natural-scrolling-row"> <object class="GtkListBoxRow" id="mouse_natural_scrolling_row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="mouse-natural-scrolling-grid"> <object class="GtkGrid" id="mouse_natural_scrolling_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">2</property> <property name="row_spacing">2</property>
@ -267,14 +271,14 @@
<property name="margin_bottom">6</property> <property name="margin_bottom">6</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="mouse-natural-scrolling-label"> <object class="GtkLabel" id="mouse_natural_scrolling_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes" comments="Translators: This switch reverses the scrolling direction for mices. The term used comes from OS X so use the same translation if possible.">Natural Scrolling</property> <property name="label" translatable="yes" comments="Translators: This switch reverses the scrolling direction for mices. The term used comes from OS X so use the same translation if possible.">Natural Scrolling</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">mouse-natural-scrolling-switch</property> <property name="mnemonic_widget">mouse_natural_scrolling_switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -284,7 +288,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="mouse-natural-scrolling-description"> <object class="GtkLabel" id="mouse_natural_scrolling_description">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
@ -304,7 +308,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="mouse-natural-scrolling-switch"> <object class="GtkSwitch" id="mouse_natural_scrolling_switch">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
@ -328,7 +332,7 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkFrame" id="touchpad-frame"> <object class="GtkFrame" id="touchpad_frame">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
@ -346,27 +350,27 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkFrame" id="touchpad-frame-listbox"> <object class="GtkFrame" id="touchpad_frame_listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkBox" id="touchpad-box"> <object class="GtkBox" id="touchpad_box">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
<object class="GtkListBox" id="touchpad-listbox"> <object class="GtkListBox" id="touchpad_listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="selection_mode">none</property> <property name="selection_mode">none</property>
<child> <child>
<object class="GtkListBoxRow" id="touchpad-toggle-row"> <object class="GtkListBoxRow" id="touchpad_toggle_row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="touchpad-toggle-grid"> <object class="GtkGrid" id="touchpad_toggle_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@ -377,7 +381,7 @@
<property name="margin_bottom">12</property> <property name="margin_bottom">12</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="touchpad-toggle-label"> <object class="GtkLabel" id="touchpad_toggle_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -385,7 +389,7 @@
<property name="valign">end</property> <property name="valign">end</property>
<property name="label" translatable="yes">Touchpad</property> <property name="label" translatable="yes">Touchpad</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">touchpad-toggle-switch</property> <property name="mnemonic_widget">touchpad_toggle_switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -395,7 +399,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="touchpad-toggle-switch"> <object class="GtkSwitch" id="touchpad_toggle_switch">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
@ -422,17 +426,17 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkListBox" id="touchpad-options-listbox"> <object class="GtkListBox" id="touchpad_options_listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="selection_mode">none</property> <property name="selection_mode">none</property>
<child> <child>
<object class="GtkListBoxRow" id="touchpad-natural-scrolling-row"> <object class="GtkListBoxRow" id="touchpad_natural_scrolling_row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="touchpad-natural-scrolling-grid"> <object class="GtkGrid" id="touchpad_natural_scrolling_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">2</property> <property name="row_spacing">2</property>
@ -443,14 +447,14 @@
<property name="margin_bottom">6</property> <property name="margin_bottom">6</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="touchpad-natural-scrolling-label"> <object class="GtkLabel" id="touchpad_natural_scrolling_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes" comments="Translators: This switch reverses the scrolling direction for touchpads. The term used comes from OS X so use the same translation if possible. ">Natural Scrolling</property> <property name="label" translatable="yes" comments="Translators: This switch reverses the scrolling direction for touchpads. The term used comes from OS X so use the same translation if possible. ">Natural Scrolling</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">touchpad-natural-scrolling-switch</property> <property name="mnemonic_widget">touchpad_natural_scrolling_switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -460,7 +464,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="touchpad-natural-scrolling-description"> <object class="GtkLabel" id="touchpad_natural_scrolling_description">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
@ -480,7 +484,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="touchpad-natural-scrolling-switch"> <object class="GtkSwitch" id="touchpad_natural_scrolling_switch">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
@ -498,12 +502,12 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkListBoxRow" id="touchpad-speed-row"> <object class="GtkListBoxRow" id="touchpad_speed_row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="touchpad-speed-grid"> <object class="GtkGrid" id="touchpad_speed_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@ -514,14 +518,14 @@
<property name="margin_bottom">8</property> <property name="margin_bottom">8</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="touchpad-speed-label"> <object class="GtkLabel" id="touchpad_speed_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="valign">end</property> <property name="valign">end</property>
<property name="label" translatable="yes">Touchpad Speed</property> <property name="label" translatable="yes">Touchpad Speed</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">touchpad-speed-scale</property> <property name="mnemonic_widget">touchpad_speed_scale</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -531,7 +535,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScale" id="touchpad-speed-scale"> <object class="GtkScale" id="touchpad_speed_scale">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="adjustment">adjustment11</property> <property name="adjustment">adjustment11</property>
@ -539,7 +543,7 @@
<property name="expand">True</property> <property name="expand">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<child internal-child="accessible"> <child internal-child="accessible">
<object class="AtkObject" id="touchpad_speed_scale-atkobject"> <object class="AtkObject" id="touchpad_speed_scale_atkobject">
<property name="AtkObject::accessible-description" translatable="yes">Double-click timeout</property> <property name="AtkObject::accessible-description" translatable="yes">Double-click timeout</property>
</object> </object>
</child> </child>
@ -556,12 +560,12 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkListBoxRow" id="tap-to-click-row"> <object class="GtkListBoxRow" id="tap_to_click_row">
<property name="visible">False</property> <property name="visible">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="tap-to-click-grid"> <object class="GtkGrid" id="tap_to_click_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@ -572,7 +576,7 @@
<property name="margin_bottom">12</property> <property name="margin_bottom">12</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="tap-to-click-label"> <object class="GtkLabel" id="tap_to_click_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -580,7 +584,7 @@
<property name="valign">end</property> <property name="valign">end</property>
<property name="label" translatable="yes">Tap to Click</property> <property name="label" translatable="yes">Tap to Click</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">tap-to-click-switch</property> <property name="mnemonic_widget">tap_to_click_switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -590,7 +594,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="tap-to-click-switch"> <object class="GtkSwitch" id="tap_to_click_switch">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
@ -608,13 +612,13 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkListBoxRow" id="two-finger-scrolling-row"> <object class="GtkListBoxRow" id="two_finger_scrolling_row">
<property name="visible">False</property> <property name="visible">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="two-finger-scrolling-grid"> <object class="GtkGrid" id="two_finger_scrolling_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@ -625,7 +629,7 @@
<property name="margin_bottom">12</property> <property name="margin_bottom">12</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="two-finger-scrolling-label"> <object class="GtkLabel" id="two_finger_scrolling_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -633,7 +637,7 @@
<property name="valign">end</property> <property name="valign">end</property>
<property name="label" translatable="yes">Two-finger Scrolling</property> <property name="label" translatable="yes">Two-finger Scrolling</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">two-finger-scrolling-switch</property> <property name="mnemonic_widget">two_finger_scrolling_switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -643,7 +647,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="two-finger-scrolling-switch"> <object class="GtkSwitch" id="two_finger_scrolling_switch">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
@ -661,13 +665,13 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkListBoxRow" id="edge-scrolling-row"> <object class="GtkListBoxRow" id="edge_scrolling_row">
<property name="visible">False</property> <property name="visible">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="edge-scrolling-grid"> <object class="GtkGrid" id="edge_scrolling_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">0</property> <property name="row_spacing">0</property>
@ -678,7 +682,7 @@
<property name="margin_bottom">12</property> <property name="margin_bottom">12</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel" id="edge-scrolling-label"> <object class="GtkLabel" id="edge_scrolling_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@ -686,7 +690,7 @@
<property name="valign">end</property> <property name="valign">end</property>
<property name="label" translatable="yes">Edge Scrolling</property> <property name="label" translatable="yes">Edge Scrolling</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">edge-scrolling-switch</property> <property name="mnemonic_widget">edge_scrolling_switch</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
@ -696,7 +700,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkSwitch" id="edge-scrolling-switch"> <object class="GtkSwitch" id="edge_scrolling_switch">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="halign">end</property> <property name="halign">end</property>
@ -724,25 +728,27 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</template>
<object class="GtkSizeGroup"> <object class="GtkSizeGroup">
<property name="mode">vertical</property> <property name="mode">vertical</property>
<widgets> <widgets>
<widget name="mouse-row"/> <widget name="mouse_row"/>
<widget name="mouse-natural-scrolling-row"/> <widget name="mouse_natural_scrolling_row"/>
<widget name="touchpad-toggle-row"/> <widget name="touchpad_toggle_row"/>
<widget name="touchpad-natural-scrolling-row"/> <widget name="touchpad_natural_scrolling_row"/>
<widget name="touchpad-speed-row"/> <widget name="touchpad_speed_row"/>
<widget name="tap-to-click-row"/> <widget name="tap_to_click_row"/>
<widget name="edge-scrolling-row"/> <widget name="edge_scrolling_row"/>
</widgets> </widgets>
</object> </object>
<object class="GtkSizeGroup"> <object class="GtkSizeGroup">
<property name="mode">horizontal</property> <property name="mode">horizontal</property>
<widgets> <widgets>
<widget name="mouse-speed-scale"/> <widget name="mouse_speed_scale"/>
<widget name="touchpad-speed-scale"/> <widget name="touchpad_speed_scale"/>
</widgets> </widgets>
</object> </object>
</interface> </interface>

View file

@ -32,8 +32,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#define WID(x) (GtkWidget *) gtk_builder_get_object (self->builder, x)
/* Click test button sizes. */ /* Click test button sizes. */
#define SHADOW_SIZE (10.0 / 180 * size) #define SHADOW_SIZE (10.0 / 180 * size)
#define SHADOW_SHIFT_Y (-1.0 / 180 * size) #define SHADOW_SHIFT_Y (-1.0 / 180 * size)
@ -59,7 +57,11 @@ struct _CcMouseTest
{ {
GtkBin parent_instance; GtkBin parent_instance;
GtkBuilder *builder; GtkWidget *button_drawing_area;
GtkWidget *information_label;
GtkWidget *image;
GtkWidget *scrolled_window_adjustment;
GtkWidget *viewport;
guint32 double_click_timestamp; guint32 double_click_timestamp;
gint double_click_state; gint double_click_state;
@ -81,7 +83,7 @@ test_maybe_timeout (CcMouseTest *self)
{ {
self->double_click_state = DOUBLE_CLICK_TEST_OFF; self->double_click_state = DOUBLE_CLICK_TEST_OFF;
gtk_widget_queue_draw (WID ("button_drawing_area")); gtk_widget_queue_draw (self->button_drawing_area);
self->button_drawing_area_timeout_id = 0; self->button_drawing_area_timeout_id = 0;
@ -127,7 +129,7 @@ setup_information_label (CcMouseTest *self)
} }
if (self->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")); gtk_label_set_label (GTK_LABEL (self->information_label), _("Try clicking, double clicking, scrolling"));
return; return;
} }
@ -149,7 +151,7 @@ setup_information_label (CcMouseTest *self)
} }
label_text = g_strconcat ("<b>", message, "</b>", NULL); label_text = g_strconcat ("<b>", message, "</b>", NULL);
gtk_label_set_markup (GTK_LABEL (WID ("information_label")), label_text); gtk_label_set_markup (GTK_LABEL (self->information_label), label_text);
self->information_label_timeout_id = g_timeout_add (2500, (GSourceFunc) information_label_timeout, self); self->information_label_timeout_id = g_timeout_add (2500, (GSourceFunc) information_label_timeout, self);
} }
@ -170,7 +172,7 @@ setup_scroll_image (CcMouseTest *self)
resource = "/org/gnome/control-center/mouse/scroll-test-gegl.svg"; resource = "/org/gnome/control-center/mouse/scroll-test-gegl.svg";
else else
resource = "/org/gnome/control-center/mouse/scroll-test.svg"; resource = "/org/gnome/control-center/mouse/scroll-test.svg";
gtk_image_set_from_resource (GTK_IMAGE (WID ("image")), resource); gtk_image_set_from_resource (GTK_IMAGE (self->image), resource);
if (self->double_click_state != DOUBLE_CLICK_TEST_GEGL) if (self->double_click_state != DOUBLE_CLICK_TEST_GEGL)
return; return;
@ -224,7 +226,7 @@ button_drawing_area_button_press_event (GtkWidget *widget,
self->double_click_timestamp = event->time; self->double_click_timestamp = event->time;
gtk_widget_queue_draw (WID ("button_drawing_area")); gtk_widget_queue_draw (self->button_drawing_area);
self->button_state = event->button; self->button_state = event->button;
setup_information_label (self); setup_information_label (self);
@ -297,23 +299,23 @@ setup_dialog (CcMouseTest *self)
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
GtkStyleProvider *provider; GtkStyleProvider *provider;
g_signal_connect (WID ("button_drawing_area"), "button_press_event", g_signal_connect (self->button_drawing_area, "button_press_event",
G_CALLBACK (button_drawing_area_button_press_event), G_CALLBACK (button_drawing_area_button_press_event),
self); self);
g_signal_connect (WID ("button_drawing_area"), "draw", g_signal_connect (self->button_drawing_area, "draw",
G_CALLBACK (button_drawing_area_draw_event), G_CALLBACK (button_drawing_area_draw_event),
self); self);
adjustment = GTK_ADJUSTMENT (WID ("scrolled_window_adjustment")); adjustment = GTK_ADJUSTMENT (self->scrolled_window_adjustment);
gtk_adjustment_set_value (adjustment, gtk_adjustment_set_value (adjustment,
gtk_adjustment_get_upper (adjustment)); gtk_adjustment_get_upper (adjustment));
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ()); provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider), "* {background: #565854}", -1, NULL); gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider), "* {background: #565854}", -1, NULL);
gtk_style_context_add_provider (gtk_widget_get_style_context (WID ("viewport")), gtk_style_context_add_provider (gtk_widget_get_style_context (self->viewport),
provider, provider,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_style_context_add_provider (gtk_widget_get_style_context (WID ("button_drawing_area")), gtk_style_context_add_provider (gtk_widget_get_style_context (self->button_drawing_area),
provider, provider,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider); g_object_unref (provider);
@ -325,7 +327,6 @@ cc_mouse_test_finalize (GObject *object)
CcMouseTest *self = CC_MOUSE_TEST (object); CcMouseTest *self = CC_MOUSE_TEST (object);
g_clear_object (&self->mouse_settings); g_clear_object (&self->mouse_settings);
g_clear_object (&self->builder);
if (self->information_label_timeout_id != 0) { if (self->information_label_timeout_id != 0) {
g_source_remove (self->information_label_timeout_id); g_source_remove (self->information_label_timeout_id);
@ -346,12 +347,20 @@ cc_mouse_test_finalize (GObject *object)
} }
static void static void
cc_mouse_test_class_init (CcMouseTestClass *class) cc_mouse_test_class_init (CcMouseTestClass *klass)
{ {
GObjectClass *object_class; GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class = G_OBJECT_CLASS (class);
object_class->finalize = cc_mouse_test_finalize; object_class->finalize = cc_mouse_test_finalize;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/mouse/gnome-mouse-test.ui");
gtk_widget_class_bind_template_child (widget_class, CcMouseTest, button_drawing_area);
gtk_widget_class_bind_template_child (widget_class, CcMouseTest, information_label);
gtk_widget_class_bind_template_child (widget_class, CcMouseTest, image);
gtk_widget_class_bind_template_child (widget_class, CcMouseTest, scrolled_window_adjustment);
gtk_widget_class_bind_template_child (widget_class, CcMouseTest, viewport);
} }
static void static void
@ -359,10 +368,7 @@ cc_mouse_test_init (CcMouseTest *self)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
self->builder = gtk_builder_new (); gtk_widget_init_template (GTK_WIDGET (self));
gtk_builder_add_from_resource (self->builder,
"/org/gnome/control-center/mouse/gnome-mouse-test.ui",
&error);
self->double_click_timestamp = 0; self->double_click_timestamp = 0;
self->double_click_state = DOUBLE_CLICK_TEST_OFF; self->double_click_state = DOUBLE_CLICK_TEST_OFF;
@ -374,8 +380,6 @@ cc_mouse_test_init (CcMouseTest *self)
self->button_drawing_area_timeout_id = 0; self->button_drawing_area_timeout_id = 0;
self->scroll_image_timeout_id = 0; self->scroll_image_timeout_id = 0;
gtk_container_add (GTK_CONTAINER (self), WID ("test_widget"));
setup_dialog (self); setup_dialog (self);
} }

View file

@ -7,6 +7,8 @@
<property name="step_increment">1</property> <property name="step_increment">1</property>
<property name="page_increment">10</property> <property name="page_increment">10</property>
</object> </object>
<template class="CcMouseTest" parent="GtkBin">
<child>
<object class="GtkGrid" id="test_widget"> <object class="GtkGrid" id="test_widget">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
@ -95,4 +97,6 @@
</packing> </packing>
</child> </child>
</object> </object>
</child>
</template>
</interface> </interface>