Commit f5eb2047 authored by Rui Matos's avatar Rui Matos
Browse files

mouse: Switch to new peripherals settings schema

Most peripherals settings have been moved to
gsettings-desktop-schemas.

There are some semantic differences:

* pointer and touchpad speed is now a single value in the [-1..1]
  range (from "unaccelerated" to "fast"). A value of 0 is the default;

* touchpad enabled is now an enum which can be enabled, disabled or
  disabled-on-external-mouse. This patch keeps the same UI so the last
  value is the same as disabled in the UI and can't be set for now;

* disable while typing is now always enabled so the checkbox has been
  removed;

* horizontal scrolling is always enabled when two finger scroll is
  disabled. It wasn't in the UI but we no longer need to set it since
  it doesn't exist anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=743194
parent 15227904
......@@ -30,6 +30,8 @@
#include <gnome-settings-daemon/gsd-enums.h>
#include <math.h>
#include <gdesktop-enums.h>
#include "gnome-mouse-properties.h"
#include "gsd-input-helper.h"
......@@ -49,6 +51,7 @@ struct _CcMousePropertiesPrivate
GtkBuilder *builder;
GSettings *mouse_settings;
GSettings *gsd_mouse_settings;
GSettings *touchpad_settings;
GdkDeviceManager *device_manager;
......@@ -92,7 +95,6 @@ scrollmethod_changed_event (GtkToggleButton *button, CcMousePropertiesPrivate *d
method = GSD_TOUCHPAD_SCROLL_METHOD_EDGE_SCROLLING;
g_settings_set_enum (d->touchpad_settings, "scroll-method", method);
g_settings_set_boolean (d->touchpad_settings, "horiz-scroll-enabled", TRUE);
}
static void
......@@ -144,43 +146,58 @@ synaptics_check_capabilities (CcMousePropertiesPrivate *d)
XFreeDeviceList (devicelist);
}
static void
pointer_speed_scale_event (GtkRange *scale, CcMousePropertiesPrivate *d)
static gboolean
get_touchpad_enabled (GSettings *settings)
{
gdouble value;
GSettings *settings;
GtkAdjustment *adjustment;
GDesktopDeviceSendEvents send_events;
if (GTK_WIDGET (scale) == WID ("pointer_speed_scale"))
settings = d->mouse_settings;
else
settings = d->touchpad_settings;
send_events = g_settings_get_enum (settings, "send-events");
adjustment = gtk_range_get_adjustment (scale);
value = gtk_adjustment_get_upper (adjustment) - gtk_range_get_value (scale) + 1;
g_settings_set_int (settings, "motion-threshold", value);
return send_events == G_DESKTOP_DEVICE_SEND_EVENTS_ENABLED;
}
static gboolean
show_touchpad_enabling_switch (GSettings *touchpad_settings)
{
gboolean enabled;
if (!touchpad_is_present())
return FALSE;
/* Lets show the button when the mouse/touchscreen is present */
if (mouse_is_present() || touchscreen_is_present())
return TRUE;
/* Lets also show when touch pad is disabled. */
enabled = g_settings_get_boolean (touchpad_settings, "touchpad-enabled");
if (!enabled)
if (!get_touchpad_enabled (touchpad_settings))
return TRUE;
return FALSE;
}
static gboolean
touchpad_enabled_get_mapping (GValue *value,
GVariant *variant,
gpointer user_data)
{
gboolean enabled;
enabled = g_strcmp0 (g_variant_get_string (variant, NULL), "enabled") == 0;
g_value_set_boolean (value, enabled);
return TRUE;
}
static GVariant *
touchpad_enabled_set_mapping (const GValue *value,
const GVariantType *type,
gpointer user_data)
{
gboolean enabled;
enabled = g_value_get_boolean (value);
return g_variant_new_string (enabled ? "enabled" : "disabled");
}
/* Set up the property editors in the dialog. */
static void
setup_dialog (CcMousePropertiesPrivate *d)
......@@ -199,7 +216,7 @@ setup_dialog (CcMousePropertiesPrivate *d)
G_CALLBACK (orientation_radio_button_release_event), NULL);
/* Double-click time */
g_settings_bind (d->mouse_settings, "double-click",
g_settings_bind (d->gsd_mouse_settings, "double-click",
gtk_range_get_adjustment (GTK_RANGE (WID ("double_click_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
......@@ -207,42 +224,43 @@ setup_dialog (CcMousePropertiesPrivate *d)
mouse_present = mouse_is_present ();
gtk_widget_set_visible (WID ("mouse_vbox"), mouse_present);
g_settings_bind (d->mouse_settings, "motion-acceleration",
gtk_scale_add_mark (GTK_SCALE (WID ("pointer_speed_scale")), 0,
GTK_POS_TOP, NULL);
g_settings_bind (d->mouse_settings, "speed",
gtk_range_get_adjustment (GTK_RANGE (WID ("pointer_speed_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
g_signal_connect (WID ("pointer_speed_scale"), "value-changed",
G_CALLBACK (pointer_speed_scale_event), d);
/* Trackpad page */
touchpad_present = touchpad_is_present ();
gtk_widget_set_visible (WID ("touchpad_vbox"), touchpad_present);
gtk_widget_set_visible (WID ("touchpad_enabled_switch"),
show_touchpad_enabling_switch (d->touchpad_settings));
g_settings_bind (d->touchpad_settings, "touchpad-enabled",
WID ("touchpad_enabled_switch"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (d->touchpad_settings, "touchpad-enabled",
WID ("touchpad_options_box"), "sensitive",
G_SETTINGS_BIND_GET);
g_settings_bind_with_mapping (d->touchpad_settings, "send-events",
WID ("touchpad_enabled_switch"), "active",
G_SETTINGS_BIND_DEFAULT,
touchpad_enabled_get_mapping,
touchpad_enabled_set_mapping,
NULL, NULL);
g_settings_bind_with_mapping (d->touchpad_settings, "send-events",
WID ("touchpad_options_box"), "sensitive",
G_SETTINGS_BIND_GET,
touchpad_enabled_get_mapping,
touchpad_enabled_set_mapping,
NULL, NULL);
g_settings_bind (d->touchpad_settings, "disable-while-typing",
WID ("disable_w_typing_toggle"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (d->touchpad_settings, "tap-to-click",
WID ("tap_to_click_toggle"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (d->touchpad_settings, "natural-scroll",
WID ("natural_scroll_toggle"), "active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (d->touchpad_settings, "motion-acceleration",
gtk_scale_add_mark (GTK_SCALE (WID ("touchpad_pointer_speed_scale")), 0,
GTK_POS_TOP, NULL);
g_settings_bind (d->touchpad_settings, "speed",
gtk_range_get_adjustment (GTK_RANGE (WID ("touchpad_pointer_speed_scale"))), "value",
G_SETTINGS_BIND_DEFAULT);
g_signal_connect (WID ("touchpad_pointer_speed_scale"), "value-changed",
G_CALLBACK (pointer_speed_scale_event), d);
if (touchpad_present) {
synaptics_check_capabilities (d);
setup_scrollmethod_radios (d);
......@@ -310,6 +328,7 @@ cc_mouse_properties_finalize (GObject *object)
CcMousePropertiesPrivate *d = CC_MOUSE_PROPERTIES (object)->priv;
g_clear_object (&d->mouse_settings);
g_clear_object (&d->gsd_mouse_settings);
g_clear_object (&d->touchpad_settings);
g_clear_object (&d->builder);
......@@ -346,8 +365,9 @@ cc_mouse_properties_init (CcMouseProperties *object)
"/org/gnome/control-center/mouse/gnome-mouse-properties.ui",
&error);
d->mouse_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.mouse");
d->touchpad_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.touchpad");
d->mouse_settings = g_settings_new ("org.gnome.desktop.peripherals.mouse");
d->gsd_mouse_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.mouse");
d->touchpad_settings = g_settings_new ("org.gnome.desktop.peripherals.touchpad");
d->device_manager = gdk_display_get_device_manager (gdk_display_get_default ());
d->device_added_id = g_signal_connect (d->device_manager, "device-added",
......
......@@ -2,18 +2,12 @@
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">10</property>
<property name="value">6</property>
<property name="step_increment">1</property>
<property name="page_increment">1</property>
<property name="lower">-1</property>
<property name="upper">1</property>
</object>
<object class="GtkAdjustment" id="adjustment11">
<property name="lower">1</property>
<property name="upper">10</property>
<property name="value">6</property>
<property name="step_increment">1</property>
<property name="page_increment">1</property>
<property name="lower">-1</property>
<property name="upper">1</property>
</object>
<object class="GtkAdjustment" id="adjustment4">
<property name="lower">100</property>
......@@ -317,12 +311,13 @@
</packing>
</child>
<child>
<object class="GtkHScale" id="pointer_speed_scale">
<object class="GtkScale" id="pointer_speed_scale">
<property name="orientation">horizontal</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="draw_value">False</property>
<property name="value_pos">right</property>
<property name="has_origin">False</property>
</object>
<packing>
<property name="expand">True</property>
......@@ -488,12 +483,13 @@
</packing>
</child>
<child>
<object class="GtkHScale" id="touchpad_pointer_speed_scale">
<object class="GtkScale" id="touchpad_pointer_speed_scale">
<property name="orientation">horizontal</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment11</property>
<property name="draw_value">False</property>
<property name="value_pos">right</property>
<property name="has_origin">False</property>
</object>
<packing>
<property name="expand">True</property>
......@@ -539,27 +535,6 @@
<property name="can_focus">False</property>
<property name="row_spacing">5</property>
<property name="column_spacing">10</property>
<child>
<object class="GtkCheckButton" id="disable_w_typing_toggle">
<property name="label" translatable="yes">Disable while _typing</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">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="use_action_appearance">False</property>
<property name="relief">none</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</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="GtkCheckButton" id="tap_to_click_toggle">
<property name="label" translatable="yes">Tap to _click</property>
......@@ -575,7 +550,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment