[gnome-control-center/gbsneto/gtk4: 25/35] mouse: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/gtk4: 25/35] mouse: Port to GTK4
- Date: Mon, 1 Nov 2021 01:13:24 +0000 (UTC)
commit 7b5ab5f0764ab9a62ccbbe69dc5675f4f1ba1068
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Oct 21 15:59:55 2021 -0300
mouse: Port to GTK4
This one is an interesting case. It was easier to simply switch
to AdwPreferencesPage than actually port all the GtkFrames in
there.
In addition to that, the mouse test page now uses a GtkPicture
instead of a GtkImage, and the GtkDrawingArea API changes are
reflected in the code.
panels/meson.build | 2 +-
panels/mouse/cc-mouse-caps-helper.c | 10 +-
panels/mouse/cc-mouse-panel.c | 68 +++---
panels/mouse/cc-mouse-panel.ui | 408 +++++++++++++----------------------
panels/mouse/cc-mouse-test.c | 67 +++---
panels/mouse/cc-mouse-test.h | 4 +-
panels/mouse/cc-mouse-test.ui | 65 ++----
panels/mouse/test-gnome-mouse-test.c | 21 +-
shell/cc-panel-loader.c | 4 +-
9 files changed, 248 insertions(+), 401 deletions(-)
---
diff --git a/panels/meson.build b/panels/meson.build
index 63f3e9d60..af5d9a68c 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -14,7 +14,7 @@ panels = [
'location',
'lock',
'microphone',
-# 'mouse',
+ 'mouse',
'multitasking',
'notifications',
# 'online-accounts',
diff --git a/panels/mouse/cc-mouse-caps-helper.c b/panels/mouse/cc-mouse-caps-helper.c
index 69546b2b6..6658f413e 100644
--- a/panels/mouse/cc-mouse-caps-helper.c
+++ b/panels/mouse/cc-mouse-caps-helper.c
@@ -18,7 +18,7 @@
* Author: Felipe Borges <feborges redhat com>
*/
-#include <gdk/gdkx.h>
+#include <gdk/x11/gdkx.h>
#include <X11/Xatom.h>
#include <X11/extensions/XInput2.h>
@@ -51,8 +51,8 @@ touchpad_check_capabilities_x11 (gboolean *have_two_finger_scrolling,
gdk_x11_display_error_trap_push (gdisplay);
- devicelist = gdk_seat_get_slaves (gdk_display_get_default_seat (gdk_display_get_default ()),
- GDK_SEAT_CAPABILITY_ALL_POINTING);
+ devicelist = gdk_seat_get_devices (gdk_display_get_default_seat (gdk_display_get_default ()),
+ GDK_SEAT_CAPABILITY_ALL_POINTING);
for (l = devicelist; l != NULL; l = l->next) {
GdkDevice *device = l->data;
if (gdk_device_get_source (device) != GDK_SOURCE_TOUCHPAD)
@@ -126,8 +126,8 @@ cc_synaptics_check (void)
gdk_x11_display_error_trap_push (gdisplay);
- devicelist = gdk_seat_get_slaves (gdk_display_get_default_seat (gdk_display_get_default ()),
- GDK_SEAT_CAPABILITY_ALL_POINTING);
+ devicelist = gdk_seat_get_devices (gdk_display_get_default_seat (gdk_display_get_default ()),
+ GDK_SEAT_CAPABILITY_ALL_POINTING);
for (l = devicelist; l != NULL; l = l->next) {
GdkDevice *device = l->data;
diff --git a/panels/mouse/cc-mouse-panel.c b/panels/mouse/cc-mouse-panel.c
index ddf3fc1a8..505c20fac 100644
--- a/panels/mouse/cc-mouse-panel.c
+++ b/panels/mouse/cc-mouse-panel.c
@@ -30,7 +30,6 @@
#include "cc-mouse-test.h"
#include "gsd-device-manager.h"
#include "gsd-input-helper.h"
-#include "list-box-helper.h"
struct _CcMousePanel
{
@@ -39,20 +38,20 @@ struct _CcMousePanel
GtkListBoxRow *edge_scrolling_row;
GtkSwitch *edge_scrolling_switch;
GtkListBox *general_listbox;
- GtkFrame *mouse_frame;
+ AdwPreferencesGroup *mouse_group;
GtkListBox *mouse_listbox;
GtkSwitch *mouse_natural_scrolling_switch;
GtkScale *mouse_speed_scale;
CcMouseTest *mouse_test;
GtkBox *primary_button_box;
- GtkRadioButton *primary_button_left;
- GtkRadioButton *primary_button_right;
- GtkScrolledWindow *scrolled_window;
+ GtkToggleButton *primary_button_left;
+ GtkToggleButton *primary_button_right;
+ AdwPreferencesPage*preferences;
GtkStack *stack;
GtkListBoxRow *tap_to_click_row;
GtkSwitch *tap_to_click_switch;
GtkButton *test_button;
- GtkFrame *touchpad_frame;
+ AdwPreferencesGroup *touchpad_group;
GtkListBox *touchpad_listbox;
GtkListBoxRow *touchpad_natural_scrolling_row;
GtkSwitch *touchpad_natural_scrolling_switch;
@@ -87,13 +86,13 @@ setup_touchpad_options (CcMousePanel *self)
gboolean have_tap_to_click;
if (self->have_synaptics || !self->have_touchpad) {
- gtk_widget_hide (GTK_WIDGET (self->touchpad_frame));
+ gtk_widget_hide (GTK_WIDGET (self->touchpad_group));
return;
}
cc_touchpad_check_capabilities (&have_two_finger_scrolling, &have_edge_scrolling, &have_tap_to_click);
- gtk_widget_show (GTK_WIDGET (self->touchpad_frame));
+ gtk_widget_show (GTK_WIDGET (self->touchpad_group));
gtk_widget_set_visible (GTK_WIDGET (self->two_finger_scrolling_row), have_two_finger_scrolling);
gtk_widget_set_visible (GTK_WIDGET (self->edge_scrolling_row), have_edge_scrolling);
@@ -189,22 +188,29 @@ touchpad_enabled_set_mapping (const GValue *value,
}
static void
-handle_secondary_button (CcMousePanel *self,
- GtkRadioButton *button,
- GtkGesture *gesture)
+pressed_cb (GtkButton *button)
+{
+ g_signal_emit_by_name (button, "activate");
+}
+
+static void
+handle_secondary_button (CcMousePanel *self,
+ GtkToggleButton *button,
+ GtkGesture *gesture)
{
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
gtk_gesture_single_set_exclusive (GTK_GESTURE_SINGLE (gesture), TRUE);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY);
- g_signal_connect_swapped (gesture, "pressed", G_CALLBACK (gtk_button_clicked), button);
+ g_signal_connect_swapped (gesture, "pressed", G_CALLBACK (pressed_cb), button);
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_BUBBLE);
+ gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (gesture));
}
/* Set up the property editors in the dialog. */
static void
setup_dialog (CcMousePanel *self)
{
- GtkRadioButton *button;
+ GtkToggleButton *button;
gtk_widget_set_direction (GTK_WIDGET (self->primary_button_box), GTK_TEXT_DIR_LTR);
@@ -221,10 +227,10 @@ setup_dialog (CcMousePanel *self)
/* Allow changing orientation with either button */
button = self->primary_button_right;
- self->right_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (button));
+ self->right_gesture = gtk_gesture_click_new ();
handle_secondary_button (self, button, self->right_gesture);
button = self->primary_button_left;
- self->left_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (button));
+ self->left_gesture = gtk_gesture_click_new ();
handle_secondary_button (self, button, self->left_gesture);
g_settings_bind (self->mouse_settings, "natural-scroll",
@@ -232,7 +238,7 @@ setup_dialog (CcMousePanel *self)
G_SETTINGS_BIND_DEFAULT);
/* Mouse section */
- gtk_widget_set_visible (GTK_WIDGET (self->mouse_frame), self->have_mouse);
+ gtk_widget_set_visible (GTK_WIDGET (self->mouse_group), self->have_mouse);
g_settings_bind (self->mouse_settings, "speed",
gtk_range_get_adjustment (GTK_RANGE (self->mouse_speed_scale)), "value",
@@ -310,27 +316,10 @@ device_changed (CcMousePanel *self)
setup_touchpad_options (self);
self->have_mouse = mouse_is_present ();
- gtk_widget_set_visible (GTK_WIDGET (self->mouse_frame), self->have_mouse);
+ gtk_widget_set_visible (GTK_WIDGET (self->mouse_group), self->have_mouse);
gtk_widget_set_visible (GTK_WIDGET (self->touchpad_toggle_switch), show_touchpad_enabling_switch (self));
}
-static void
-on_content_size_changed (CcMousePanel *self,
- GtkAllocation *allocation)
-{
- if (allocation->height < 490)
- {
- gtk_scrolled_window_set_policy (self->scrolled_window,
- GTK_POLICY_NEVER, GTK_POLICY_NEVER);
- }
- else
- {
- gtk_scrolled_window_set_policy (self->scrolled_window,
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_min_content_height (self->scrolled_window, 490);
- }
-}
-
static void
cc_mouse_panel_dispose (GObject *object)
{
@@ -338,8 +327,6 @@ cc_mouse_panel_dispose (GObject *object)
g_clear_object (&self->mouse_settings);
g_clear_object (&self->touchpad_settings);
- g_clear_object (&self->right_gesture);
- g_clear_object (&self->left_gesture);
G_OBJECT_CLASS (cc_mouse_panel_parent_class)->dispose (object);
}
@@ -356,7 +343,7 @@ test_button_toggled_cb (CcMousePanel *self)
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->test_button)))
gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->mouse_test));
else
- gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->scrolled_window));
+ gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->preferences));
}
static void
@@ -418,7 +405,7 @@ cc_mouse_panel_class_init (CcMousePanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, edge_scrolling_row);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, edge_scrolling_switch);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, general_listbox);
- gtk_widget_class_bind_template_child (widget_class, CcMousePanel, mouse_frame);
+ gtk_widget_class_bind_template_child (widget_class, CcMousePanel, mouse_group);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, mouse_listbox);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, mouse_natural_scrolling_switch);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, mouse_speed_scale);
@@ -426,12 +413,12 @@ cc_mouse_panel_class_init (CcMousePanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, primary_button_box);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, primary_button_left);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, primary_button_right);
- gtk_widget_class_bind_template_child (widget_class, CcMousePanel, scrolled_window);
+ gtk_widget_class_bind_template_child (widget_class, CcMousePanel, preferences);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, stack);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, tap_to_click_row);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, tap_to_click_switch);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, test_button);
- gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_frame);
+ gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_group);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_listbox);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_natural_scrolling_row);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_natural_scrolling_switch);
@@ -442,7 +429,6 @@ cc_mouse_panel_class_init (CcMousePanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, two_finger_scrolling_switch);
gtk_widget_class_bind_template_callback (widget_class, edge_scrolling_changed_event);
- gtk_widget_class_bind_template_callback (widget_class, on_content_size_changed);
gtk_widget_class_bind_template_callback (widget_class, test_button_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, two_finger_scrolling_changed_event);
}
diff --git a/panels/mouse/cc-mouse-panel.ui b/panels/mouse/cc-mouse-panel.ui
index 883666361..997a1a219 100644
--- a/panels/mouse/cc-mouse-panel.ui
+++ b/panels/mouse/cc-mouse-panel.ui
@@ -2,101 +2,53 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<template class="CcMousePanel" parent="CcPanel">
- <property name="visible">True</property>
<child>
<object class="GtkStack" id="stack">
- <property name="visible">True</property>
<child>
- <object class="GtkScrolledWindow" id="scrolled_window">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="shadow_type">none</property>
- <property name="hscrollbar_policy">never</property>
- <signal name="size-allocate" handler="on_content_size_changed" object="CcMousePanel"
swapped="yes"/>
+ <object class="AdwPreferencesPage" id="preferences">
<child>
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="margin_top">32</property>
- <property name="margin_bottom">32</property>
- <property name="orientation">vertical</property>
+ <object class="AdwPreferencesGroup">
+ <property name="title" translatable="yes">General</property>
<child>
- <object class="GtkFrame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="shadow_type">in</property>
- <property name="margin_bottom">32</property>
- <property name="label_yalign">0.45</property>
- <property name="shadow_type">none</property>
- <child type="label">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">General</property>
- <property name="margin_bottom">12</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
+ <object class="GtkListBox" id="general_listbox">
+ <property name="selection_mode">none</property>
+ <style>
+ <class name="content"/>
+ </style>
<child>
- <object class="GtkListBox" id="general_listbox">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="selection_mode">none</property>
- <style>
- <class name="content"/>
- </style>
+ <object class="AdwActionRow" id="primary_button_row">
+ <property name="activatable">false</property>
+ <property name="title" translatable="yes">Primary Button</property>
+ <property name="subtitle" translatable="yes">Sets the order of physical buttons on
mice and touchpads.</property>
+ <property name="subtitle-lines">0</property>
<child>
- <object class="HdyActionRow" id="primary_button_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" translatable="yes">Primary Button</property>
- <property name="subtitle" translatable="yes">Sets the order of physical buttons
on mice and touchpads.</property>
- <property name="subtitle-lines">0</property>
+ <object class="GtkGrid">
+ <property name="row_spacing">2</property>
+ <property name="column_spacing">16</property>
+ <property name="margin_start">20</property>
+ <property name="margin_end">20</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
<child>
- <object class="GtkGrid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="row_spacing">2</property>
- <property name="column_spacing">16</property>
- <property name="margin_start">20</property>
- <property name="margin_end">20</property>
- <property name="margin_top">12</property>
- <property name="margin_bottom">12</property>
+ <object class="GtkBox" id="primary_button_box">
+ <property name="valign">center</property>
+ <property name="homogeneous">True</property>
+ <style>
+ <class name="linked"/>
+ </style>
<child>
- <object class="GtkBox" id="primary_button_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="homogeneous">True</property>
- <style>
- <class name="linked"/>
- </style>
- <child>
- <object class="GtkRadioButton" id="primary_button_left">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Left</property>
- <property name="draw-indicator">False</property>
- <property name="height_request">35</property>
- </object>
- </child>
- <child>
- <object class="GtkRadioButton" id="primary_button_right">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Right</property>
- <property name="draw-indicator">False</property>
- <property name="group">primary_button_left</property>
- <property name="height_request">35</property>
- </object>
- </child>
+ <object class="GtkToggleButton" id="primary_button_left">
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">Left</property>
+ <property name="height_request">35</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="primary_button_right">
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">Right</property>
+ <property name="group">primary_button_left</property>
+ <property name="height_request">35</property>
</object>
</child>
</object>
@@ -107,209 +59,144 @@
</child>
</object>
</child>
+ </object>
+ </child>
+
+ <child>
+ <object class="AdwPreferencesGroup" id="mouse_group">
+ <property name="title" translatable="yes">Mouse</property>
<child>
- <object class="GtkFrame" id="mouse_frame">
- <property name="visible">False</property>
- <property name="can_focus">False</property>
- <property name="shadow_type">none</property>
- <property name="label_yalign">0.45</property>
- <property name="margin_bottom">32</property>
- <child type="label">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Mouse</property>
- <property name="margin_bottom">12</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
+ <object class="GtkListBox" id="mouse_listbox">
+ <property name="selection_mode">none</property>
+ <style>
+ <class name="content"/>
+ </style>
<child>
- <object class="GtkListBox" id="mouse_listbox">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="selection_mode">none</property>
- <style>
- <class name="content"/>
- </style>
+ <object class="AdwActionRow" id="mouse_row">
+ <property name="activatable">false</property>
+ <property name="title" translatable="yes">Mouse Speed</property>
<child>
- <object class="HdyActionRow" id="mouse_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" translatable="yes">Mouse Speed</property>
- <child>
- <object class="GtkScale" id="mouse_speed_scale">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">mouse_speed_adjustment</property>
- <property name="draw_value">False</property>
- <property name="width-request">300</property>
- <property name="halign">end</property>
- <property name="expand">True</property>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-description"
translatable="yes">Double-click timeout</property>
- </object>
- </child>
- </object>
- </child>
+ <object class="GtkScale" id="mouse_speed_scale">
+ <property name="adjustment">mouse_speed_adjustment</property>
+ <property name="draw_value">False</property>
+ <property name="width-request">300</property>
+ <property name="halign">end</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <accessibility>
+ <property name="label">Mouse speed</property>
+ </accessibility>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow" id="mouse_natural_scrolling_row">
+ <property name="activatable">false</property>
+ <property name="title" 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="subtitle" translatable="yes">Scrolling moves the content, not the
view.</property>
<child>
- <object class="HdyActionRow" id="mouse_natural_scrolling_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" 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="subtitle" translatable="yes">Scrolling moves the content, not
the view.</property>
- <child>
- <object class="GtkSwitch" id="mouse_natural_scrolling_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- </object>
- </child>
+ <object class="GtkSwitch" id="mouse_natural_scrolling_switch">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
+ </object>
+ </child>
+
+ <child>
+ <object class="AdwPreferencesGroup" id="touchpad_group">
+ <property name="title" translatable="yes">Touchpad</property>
<child>
- <object class="GtkFrame" id="touchpad_frame">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="shadow_type">none</property>
- <property name="label_yalign">0.45</property>
- <child type="label">
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Touchpad</property>
- <property name="margin_bottom">12</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
+ <object class="GtkListBox" id="touchpad_listbox">
+ <property name="selection_mode">none</property>
+ <style>
+ <class name="content"/>
+ </style>
<child>
- <object class="GtkListBox" id="touchpad_listbox">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="selection_mode">none</property>
- <style>
- <class name="content"/>
- </style>
+ <object class="AdwActionRow" id="touchpad_toggle_row">
+ <property name="activatable">false</property>
+ <property name="title" translatable="yes">Touchpad</property>
<child>
- <object class="HdyActionRow" id="touchpad_toggle_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" translatable="yes">Touchpad</property>
- <child>
- <object class="GtkSwitch" id="touchpad_toggle_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- <property name="events">GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- </object>
- </child>
+ <object class="GtkSwitch" id="touchpad_toggle_switch">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow" id="touchpad_natural_scrolling_row">
+ <property name="activatable">false</property>
+ <property name="title" 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="subtitle" translatable="yes">Scrolling moves the content, not the
view.</property>
<child>
- <object class="HdyActionRow" id="touchpad_natural_scrolling_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" 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="subtitle" translatable="yes">Scrolling moves the content, not
the view.</property>
- <child>
- <object class="GtkSwitch" id="touchpad_natural_scrolling_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- </object>
- </child>
+ <object class="GtkSwitch" id="touchpad_natural_scrolling_switch">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow" id="touchpad_speed_row">
+ <property name="activatable">false</property>
+ <property name="title" translatable="yes">Touchpad Speed</property>
<child>
- <object class="HdyActionRow" id="touchpad_speed_row">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" translatable="yes">Touchpad Speed</property>
- <child>
- <object class="GtkScale" id="touchpad_speed_scale">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">touchpad_speed_adjustment</property>
- <property name="draw_value">False</property>
- <property name="expand">True</property>
- <property name="halign">end</property>
- <child internal-child="accessible">
- <object class="AtkObject">
- <property name="AtkObject::accessible-description"
translatable="yes">Double-click timeout</property>
- </object>
- </child>
- </object>
- </child>
+ <object class="GtkScale" id="touchpad_speed_scale">
+ <property name="adjustment">touchpad_speed_adjustment</property>
+ <property name="draw_value">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="halign">end</property>
+ <accessibility>
+ <property name="label">Double-click timeout</property>
+ </accessibility>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow" id="tap_to_click_row">
+ <property name="visible">False</property>
+ <property name="activatable">false</property>
+ <property name="title" translatable="yes">Tap to Click</property>
<child>
- <object class="HdyActionRow" id="tap_to_click_row">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" translatable="yes">Tap to Click</property>
- <child>
- <object class="GtkSwitch" id="tap_to_click_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- </object>
- </child>
+ <object class="GtkSwitch" id="tap_to_click_switch">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow" id="two_finger_scrolling_row">
+ <property name="visible">False</property>
+ <property name="activatable">false</property>
+ <property name="title" translatable="yes">Two-finger Scrolling</property>
<child>
- <object class="HdyActionRow" id="two_finger_scrolling_row">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" translatable="yes">Two-finger Scrolling</property>
- <child>
- <object class="GtkSwitch" id="two_finger_scrolling_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- <signal name="state-set" handler="two_finger_scrolling_changed_event"
object="CcMousePanel" swapped="yes"/>
- </object>
- </child>
+ <object class="GtkSwitch" id="two_finger_scrolling_switch">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <signal name="state-set" handler="two_finger_scrolling_changed_event"
object="CcMousePanel" swapped="yes"/>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow" id="edge_scrolling_row">
+ <property name="visible">False</property>
+ <property name="activatable">false</property>
+ <property name="title" translatable="yes">Edge Scrolling</property>
<child>
- <object class="HdyActionRow" id="edge_scrolling_row">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="activatable">false</property>
- <property name="title" translatable="yes">Edge Scrolling</property>
- <child>
- <object class="GtkSwitch" id="edge_scrolling_switch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- <signal name="state-set" handler="edge_scrolling_changed_event"
object="CcMousePanel" swapped="yes"/>
- </object>
- </child>
+ <object class="GtkSwitch" id="edge_scrolling_switch">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <signal name="state-set" handler="edge_scrolling_changed_event"
object="CcMousePanel" swapped="yes"/>
</object>
</child>
</object>
@@ -318,18 +205,17 @@
</child>
</object>
</child>
+
</object>
</child>
<child>
<object class="CcMouseTest" id="mouse_test">
- <property name="visible">True</property>
</object>
</child>
</object>
</child>
</template>
<object class="GtkToggleButton" id="test_button">
- <property name="visible">True</property>
<property name="use_underline">True</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Test Your _Settings</property>
diff --git a/panels/mouse/cc-mouse-test.c b/panels/mouse/cc-mouse-test.c
index e4115c9af..145cb74bb 100644
--- a/panels/mouse/cc-mouse-test.c
+++ b/panels/mouse/cc-mouse-test.c
@@ -23,7 +23,7 @@
#include <glib/gi18n.h>
#include <string.h>
#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
+#include <gdk/x11/gdkx.h>
#include <math.h>
#include "cc-mouse-test.h"
@@ -54,7 +54,7 @@ enum
struct _CcMouseTest
{
- GtkBin parent_instance;
+ AdwBin parent_instance;
GtkWidget *button_drawing_area;
GtkWidget *information_label;
@@ -73,7 +73,7 @@ struct _CcMouseTest
gint scroll_image_timeout_id;
};
-G_DEFINE_TYPE (CcMouseTest, cc_mouse_test, GTK_TYPE_BIN);
+G_DEFINE_TYPE (CcMouseTest, cc_mouse_test, ADW_TYPE_BIN);
/* Timeout for the double click test */
@@ -171,7 +171,7 @@ setup_scroll_image (CcMouseTest *self)
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 (self->image), resource);
+ gtk_picture_set_resource (GTK_PICTURE (self->image), resource);
if (self->double_click_state != DOUBLE_CLICK_TEST_GEGL)
return;
@@ -181,13 +181,21 @@ setup_scroll_image (CcMouseTest *self)
/* Callback issued when the user clicks the double click testing area. */
-static gboolean
-button_drawing_area_button_press_event (CcMouseTest *self, GdkEventButton *event)
+static void
+button_drawing_area_button_pressed_cb (GtkGestureClick *click_gesture,
+ gint n_press,
+ gdouble x,
+ gdouble y,
+ CcMouseTest *self)
{
+ guint32 event_time;
+ guint current_button;
gint double_click_time;
- if (event->type != GDK_BUTTON_PRESS || event->button > 3)
- return FALSE;
+ current_button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (click_gesture));
+
+ if (current_button > 3)
+ return;
double_click_time = g_settings_get_int (self->mouse_settings, "double-click");
@@ -197,9 +205,10 @@ button_drawing_area_button_press_event (CcMouseTest *self, GdkEventButton *event
}
/* Ignore fake double click using different buttons. */
- if (self->double_click_state != DOUBLE_CLICK_TEST_OFF && self->button_state != event->button)
+ if (self->double_click_state != DOUBLE_CLICK_TEST_OFF && self->button_state != current_button)
self->double_click_state = DOUBLE_CLICK_TEST_OFF;
+ event_time = gtk_event_controller_get_current_event_time (GTK_EVENT_CONTROLLER (click_gesture));
switch (self->double_click_state) {
case DOUBLE_CLICK_TEST_OFF:
self->double_click_state = DOUBLE_CLICK_TEST_MAYBE;
@@ -209,7 +218,7 @@ button_drawing_area_button_press_event (CcMouseTest *self, GdkEventButton *event
case DOUBLE_CLICK_TEST_ON:
case DOUBLE_CLICK_TEST_STILL_ON:
case DOUBLE_CLICK_TEST_ALMOST_THERE:
- if (event->time - self->double_click_timestamp < double_click_time) {
+ if (event_time - self->double_click_timestamp < double_click_time) {
self->double_click_state++;
self->button_drawing_area_timeout_id = g_timeout_add (2500, (GSourceFunc)
test_maybe_timeout, self);
} else {
@@ -221,28 +230,30 @@ button_drawing_area_button_press_event (CcMouseTest *self, GdkEventButton *event
break;
}
- self->double_click_timestamp = event->time;
+ self->double_click_timestamp = event_time;
gtk_widget_queue_draw (self->button_drawing_area);
- self->button_state = event->button;
+ self->button_state = current_button;
setup_information_label (self);
setup_scroll_image (self);
-
- return TRUE;
}
-static gboolean
-button_drawing_area_draw_event (CcMouseTest *self,
- cairo_t *cr)
+static void
+button_drawing_area_draw_func (GtkDrawingArea *drawing_area,
+ cairo_t *cr,
+ int width,
+ int height,
+ gpointer user_data)
{
+ CcMouseTest *self = CC_MOUSE_TEST (user_data);
gdouble center_x, center_y, size;
GdkRGBA inner_color, outer_color;
cairo_pattern_t *pattern;
- size = MAX (MIN (gtk_widget_get_allocated_width (self->button_drawing_area),
gtk_widget_get_allocated_height (self->button_drawing_area)), 1);
- center_x = gtk_widget_get_allocated_width (self->button_drawing_area) / 2.0;
- center_y = gtk_widget_get_allocated_height (self->button_drawing_area) / 2.0;
+ size = MAX (MIN (width, height), 1);
+ center_x = width / 2.0;
+ center_y = height / 2.0;
switch (self->double_click_state) {
case DOUBLE_CLICK_TEST_ON:
@@ -285,8 +296,6 @@ button_drawing_area_draw_event (CcMouseTest *self,
0, 2 * G_PI);
gdk_cairo_set_source_rgba (cr, &inner_color);
cairo_fill (cr);
-
- return FALSE;
}
static void
@@ -300,13 +309,10 @@ setup_dialog (CcMouseTest *self)
gtk_adjustment_get_upper (adjustment));
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
- gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider), "* {background: #26a269}", -1, NULL);
+ gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (provider), "* {background: #26a269;}", -1);
gtk_style_context_add_provider (gtk_widget_get_style_context (self->viewport),
provider,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- gtk_style_context_add_provider (gtk_widget_get_style_context (self->button_drawing_area),
- provider,
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
}
@@ -351,17 +357,18 @@ cc_mouse_test_class_init (CcMouseTestClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcMouseTest, scrolled_window_adjustment);
gtk_widget_class_bind_template_child (widget_class, CcMouseTest, viewport);
- gtk_widget_class_bind_template_callback (widget_class, button_drawing_area_button_press_event);
- gtk_widget_class_bind_template_callback (widget_class, button_drawing_area_draw_event);
+ gtk_widget_class_bind_template_callback (widget_class, button_drawing_area_button_pressed_cb);
}
static void
cc_mouse_test_init (CcMouseTest *self)
{
- g_autoptr(GError) error = NULL;
-
gtk_widget_init_template (GTK_WIDGET (self));
+ gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (self->button_drawing_area),
+ button_drawing_area_draw_func,
+ self, NULL);
+
self->double_click_timestamp = 0;
self->double_click_state = DOUBLE_CLICK_TEST_OFF;
self->button_state = 0;
diff --git a/panels/mouse/cc-mouse-test.h b/panels/mouse/cc-mouse-test.h
index eb2af1bcf..dc425f8a5 100644
--- a/panels/mouse/cc-mouse-test.h
+++ b/panels/mouse/cc-mouse-test.h
@@ -20,12 +20,12 @@
#pragma once
-#include <gtk/gtk.h>
+#include <adwaita.h>
G_BEGIN_DECLS
#define CC_TYPE_MOUSE_TEST (cc_mouse_test_get_type ())
-G_DECLARE_FINAL_TYPE (CcMouseTest, cc_mouse_test, CC, MOUSE_TEST, GtkBin)
+G_DECLARE_FINAL_TYPE (CcMouseTest, cc_mouse_test, CC, MOUSE_TEST, AdwBin)
GtkWidget *cc_mouse_test_new (void);
diff --git a/panels/mouse/cc-mouse-test.ui b/panels/mouse/cc-mouse-test.ui
index c15c36d1f..c007361c5 100644
--- a/panels/mouse/cc-mouse-test.ui
+++ b/panels/mouse/cc-mouse-test.ui
@@ -7,71 +7,45 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
- <template class="CcMouseTest" parent="GtkBin">
+ <template class="CcMouseTest" parent="AdwBin">
<child>
- <object class="GtkGrid" id="test_widget">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <object class="GtkBox" id="test_widget">
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <child>
- <object class="GtkLabel" id="information_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="margin_top">10</property>
- <property name="margin_bottom">5</property>
- <property name="hexpand">True</property>
- <property name="label" translatable="yes">Try clicking, double clicking, scrolling</property>
- <property name="wrap">True</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="vadjustment">scrolled_window_adjustment</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">always</property>
- <property name="shadow_type">in</property>
<property name="max_content_height">440</property>
<child>
<object class="GtkViewport" id="viewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<child>
<object class="GtkOverlay" id="grid1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<child>
- <object class="GtkImage" id="image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <object class="GtkPicture" id="image">
<property name="margin_start">25</property>
<property name="margin_end">25</property>
- <property name="resource">/org/gnome/control-center/mouse/scroll-test.svg</property>
+ <property name="can-shrink">False</property>
+ <property
name="file">resource:///org/gnome/control-center/mouse/scroll-test.svg</property>
</object>
</child>
<child type="overlay">
<object class="GtkDrawingArea" id="button_drawing_area">
<property name="width_request">180</property>
<property name="height_request">180</property>
- <property name="visible">True</property>
<property name="valign">end</property>
- <property name="can_focus">False</property>
- <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_STRUCTURE_MASK</property>
<property name="margin_top">20</property>
<property name="margin_bottom">20</property>
- <signal name="button_press_event" handler="button_drawing_area_button_press_event"
object="CcMouseTest" swapped="yes"/>
- <signal name="draw" handler="button_drawing_area_draw_event" object="CcMouseTest"
swapped="yes"/>
+ <child>
+ <object class="GtkGestureClick">
+ <property name="button">0</property>
+ <signal name="pressed" handler="button_drawing_area_button_pressed_cb"
object="CcMouseTest" swapped="no"/>
+ </object>
+ </child>
</object>
</child>
</object>
@@ -79,12 +53,15 @@
</object>
</child>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="information_label">
+ <property name="margin_top">10</property>
+ <property name="margin_bottom">5</property>
+ <property name="hexpand">True</property>
+ <property name="label" translatable="yes">Try clicking, double clicking, scrolling</property>
+ <property name="wrap">True</property>
+ </object>
</child>
</object>
</child>
diff --git a/panels/mouse/test-gnome-mouse-test.c b/panels/mouse/test-gnome-mouse-test.c
index 5b006f669..ca37f9092 100644
--- a/panels/mouse/test-gnome-mouse-test.c
+++ b/panels/mouse/test-gnome-mouse-test.c
@@ -4,30 +4,21 @@
#include "cc-mouse-resources.h"
#include "cc-mouse-test.h"
-static gboolean
-delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)
-{
- gtk_main_quit ();
-
- return FALSE;
-}
-
int main (int argc, char **argv)
{
GtkWidget *widget;
GtkWidget *window;
- gtk_init (&argc, &argv);
+ gtk_init ();
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_widget_show (window);
widget = cc_mouse_test_new ();
- gtk_widget_show (widget);
- gtk_container_add (GTK_CONTAINER (window), widget);
- g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (delete_event_cb), NULL);
+ window = gtk_window_new ();
+ gtk_window_set_child (GTK_WINDOW (window), widget);
+ gtk_window_present (GTK_WINDOW (window));
- gtk_main ();
+ while (g_list_model_get_n_items (gtk_window_get_toplevels ()) > 0)
+ g_main_context_iteration (NULL, TRUE);
return 0;
}
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 396d97e8f..290816965 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -42,7 +42,7 @@ extern GType cc_default_apps_panel_get_type (void);
//extern GType cc_display_panel_get_type (void);
extern GType cc_info_overview_panel_get_type (void);
//extern GType cc_keyboard_panel_get_type (void);
-//extern GType cc_mouse_panel_get_type (void);
+extern GType cc_mouse_panel_get_type (void);
extern GType cc_multitasking_panel_get_type (void);
#ifdef BUILD_NETWORK
//extern GType cc_network_panel_get_type (void);
@@ -113,7 +113,7 @@ static CcPanelLoaderVtable default_panels[] =
PANEL_TYPE("location", cc_location_panel_get_type, NULL),
PANEL_TYPE("lock", cc_lock_panel_get_type, NULL),
PANEL_TYPE("microphone", cc_microphone_panel_get_type, NULL),
- //PANEL_TYPE("mouse", cc_mouse_panel_get_type, NULL),
+ PANEL_TYPE("mouse", cc_mouse_panel_get_type, NULL),
PANEL_TYPE("multitasking", cc_multitasking_panel_get_type, NULL),
#ifdef BUILD_NETWORK
//PANEL_TYPE("network", cc_network_panel_get_type, NULL),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]