mouse: Add "Click method" option

Fixes #229
This commit is contained in:
Felipe Borges 2023-12-08 12:09:34 +01:00
parent 8da25aaef5
commit 3335985290
7 changed files with 53 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -48,6 +48,7 @@ struct _CcMousePanel
GtkToggleButton *primary_button_left;
GtkToggleButton *primary_button_right;
AdwPreferencesPage*preferences;
CcSplitRow *two_finger_push_row;
GtkStack *title_stack;
CcIllustratedRow *tap_to_click_row;
GtkSwitch *tap_to_click_switch;
@ -89,6 +90,7 @@ setup_illustrations (CcMousePanel *self)
const gchar *alternative_resource;
} row_resources[] = {
{ self->mouse_scroll_direction_row, "scroll-traditional", "scroll-natural" },
{ self->two_finger_push_row, "push-to-click-anywhere", "push-areas" },
{ self->touchpad_scroll_method_row, "scroll-2finger", "edge-scroll" },
{ self->touchpad_scroll_direction_row, "touch-scroll-traditional", "touch-scroll-natural" },
};
@ -215,6 +217,31 @@ touchpad_enabled_set_mapping (const GValue *value,
return g_variant_new_string (enabled ? "enabled" : "disabled");
}
static gboolean
click_method_get_mapping (GValue *value,
GVariant *variant,
gpointer user_data)
{
gboolean is_default;
is_default = g_strcmp0 (g_variant_get_string (variant, NULL), "fingers") == 0;
g_value_set_boolean (value, is_default);
return TRUE;
}
static GVariant *
click_method_set_mapping (const GValue *value,
const GVariantType *type,
gpointer user_data)
{
gboolean is_default;
is_default = g_value_get_boolean (value);
return g_variant_new_string (is_default ? "fingers" : "areas");
}
static void
pressed_cb (GtkButton *button)
{
@ -352,6 +379,13 @@ setup_dialog (CcMousePanel *self)
G_SETTINGS_BIND_DEFAULT |
G_SETTINGS_BIND_NO_SENSITIVITY);
g_settings_bind_with_mapping (self->touchpad_settings, "click-method",
self->two_finger_push_row, "use-default",
G_SETTINGS_BIND_DEFAULT,
click_method_get_mapping,
click_method_set_mapping,
NULL, NULL);
g_settings_bind (self->touchpad_settings, "two-finger-scrolling-enabled",
self->touchpad_scroll_method_row, "use-default",
G_SETTINGS_BIND_DEFAULT |
@ -495,6 +529,7 @@ cc_mouse_panel_class_init (CcMousePanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_toggle_row);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_toggle_switch);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, touchpad_typing_row);
gtk_widget_class_bind_template_child (widget_class, CcMousePanel, two_finger_push_row);
gtk_widget_class_bind_template_callback (widget_class, on_touchpad_scroll_method_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, test_button_clicked_cb);

View file

@ -239,10 +239,24 @@
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Clicking</property>
<child>
<object class="CcSplitRow" id="two_finger_push_row">
<property name="title" translatable="yes">Secondary Click</property>
<property name="default-option-title" translatable="yes">Two Finger Push</property>
<property name="default-option-subtitle" translatable="yes">Push anywhere with 2 fingers</property>
<property name="alternative-option-title" translatable="yes">Corner Push</property>
<property name="alternative-option-subtitle" translatable="yes">Push with a single finger in the corner</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="CcIllustratedRow" id="tap_to_click_row">
<property name="visible">False</property>

View file

@ -13,6 +13,10 @@
<file>assets/scroll-traditional-l.webm</file>
<file>assets/scroll-natural-d.webm</file>
<file>assets/scroll-natural-l.webm</file>
<file>assets/push-areas-d.webm</file>
<file>assets/push-areas-l.webm</file>
<file>assets/push-to-click-anywhere-d.webm</file>
<file>assets/push-to-click-anywhere-l.webm</file>
<file>assets/touch-scroll-natural-d.webm</file>
<file>assets/touch-scroll-natural-l.webm</file>
<file>assets/touch-scroll-traditional-d.webm</file>