2010-11-14 12:34:37 -05:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
|
|
*
|
2012-08-09 14:11:52 +02:00
|
|
|
* Copyright (C) 2001, 2012 Red Hat, Inc.
|
2001-12-19 14:53:45 +00:00
|
|
|
* Copyright (C) 2001 Ximian, Inc.
|
|
|
|
*
|
|
|
|
* Written by: Jonathon Blandford <jrb@redhat.com>,
|
|
|
|
* Bradford Hovinen <hovinen@ximian.com>,
|
2012-08-09 14:11:52 +02:00
|
|
|
* Ondrej Holy <oholy@redhat.com>,
|
2001-12-19 14:53:45 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 12:57:27 +01:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2001-12-19 14:53:45 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-01 17:36:57 +00:00
|
|
|
#include <config.h>
|
2001-12-19 14:53:45 +00:00
|
|
|
|
2008-10-24 21:50:29 +00:00
|
|
|
#include <glib/gi18n.h>
|
2002-03-10 15:04:22 +00:00
|
|
|
#include <string.h>
|
2011-03-16 13:48:08 +00:00
|
|
|
#include <gdk/gdk.h>
|
2002-05-10 19:28:56 +00:00
|
|
|
#include <gdk/gdkx.h>
|
2010-10-20 13:06:20 +02:00
|
|
|
#include <gnome-settings-daemon/gsd-enums.h>
|
2001-12-16 08:23:09 +00:00
|
|
|
#include <math.h>
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2015-01-19 18:45:13 +01:00
|
|
|
#include <gdesktop-enums.h>
|
|
|
|
|
2010-09-20 18:06:41 +01:00
|
|
|
#include "gnome-mouse-properties.h"
|
2010-12-09 12:07:48 +00:00
|
|
|
#include "gsd-input-helper.h"
|
2015-01-20 21:18:53 +01:00
|
|
|
#include "gsd-device-manager.h"
|
2018-04-06 13:38:40 +02:00
|
|
|
#include "list-box-helper.h"
|
2015-10-22 11:48:25 +02:00
|
|
|
#include "cc-mouse-caps-helper.h"
|
2002-03-11 01:46:13 +00:00
|
|
|
|
2002-02-20 05:11:10 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <dirent.h>
|
2010-10-12 19:43:32 +01:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
struct _CcMouseProperties
|
2013-03-28 10:50:58 +01:00
|
|
|
{
|
2018-05-28 12:02:48 +12:00
|
|
|
GtkBin parent_instance;
|
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
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;
|
2013-03-28 10:50:58 +01:00
|
|
|
|
|
|
|
GSettings *mouse_settings;
|
2015-01-19 18:45:13 +01:00
|
|
|
GSettings *gsd_mouse_settings;
|
2013-03-28 10:50:58 +01:00
|
|
|
GSettings *touchpad_settings;
|
|
|
|
|
2015-01-20 21:18:53 +01:00
|
|
|
GsdDeviceManager *device_manager;
|
2013-03-28 10:50:58 +01:00
|
|
|
guint device_added_id;
|
|
|
|
guint device_removed_id;
|
|
|
|
|
2015-01-20 21:18:53 +01:00
|
|
|
gboolean have_mouse;
|
|
|
|
gboolean have_touchpad;
|
|
|
|
gboolean have_touchscreen;
|
2016-04-04 20:01:31 +02:00
|
|
|
gboolean have_synaptics;
|
2015-01-20 21:18:53 +01:00
|
|
|
|
2015-10-22 15:33:08 +02:00
|
|
|
gboolean left_handed;
|
2015-10-28 13:26:24 +01:00
|
|
|
GtkGesture *left_gesture;
|
|
|
|
GtkGesture *right_gesture;
|
2015-10-22 15:33:08 +02:00
|
|
|
|
2013-03-28 10:50:58 +01:00
|
|
|
gboolean changing_scroll;
|
|
|
|
};
|
|
|
|
|
2014-10-20 11:29:55 +02:00
|
|
|
G_DEFINE_TYPE (CcMouseProperties, cc_mouse_properties, GTK_TYPE_BIN);
|
2001-12-16 08:23:09 +00:00
|
|
|
|
2009-04-02 13:50:10 +10:00
|
|
|
static void
|
2018-05-28 12:02:48 +12:00
|
|
|
setup_touchpad_options (CcMouseProperties *self)
|
2009-04-02 13:50:10 +10:00
|
|
|
{
|
2015-12-11 12:05:00 +01:00
|
|
|
gboolean edge_scroll_enabled;
|
2016-06-30 13:33:09 +02:00
|
|
|
gboolean two_finger_scroll_enabled;
|
2015-10-22 15:33:08 +02:00
|
|
|
gboolean have_two_finger_scrolling;
|
|
|
|
gboolean have_edge_scrolling;
|
|
|
|
gboolean have_tap_to_click;
|
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_set_visible (self->touchpad_frame, !self->have_synaptics);
|
2018-05-28 12:02:48 +12:00
|
|
|
if (self->have_synaptics)
|
2016-04-04 20:01:31 +02:00
|
|
|
return;
|
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_set_visible (self->touchpad_frame, self->have_touchpad);
|
2018-05-28 12:02:48 +12:00
|
|
|
if (!self->have_touchpad)
|
2016-04-04 19:59:16 +02:00
|
|
|
return;
|
|
|
|
|
2016-04-05 17:00:20 +02:00
|
|
|
cc_touchpad_check_capabilities (&have_two_finger_scrolling, &have_edge_scrolling, &have_tap_to_click);
|
2015-10-22 15:33:08 +02:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_show_all (self->touchpad_frame);
|
2015-10-22 15:33:08 +02:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_set_visible (self->two_finger_scrolling_row, have_two_finger_scrolling);
|
|
|
|
gtk_widget_set_visible (self->edge_scrolling_row, have_edge_scrolling);
|
|
|
|
gtk_widget_set_visible (self->tap_to_click_row, have_tap_to_click);
|
2015-10-22 15:33:08 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
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");
|
2016-06-30 13:42:28 +02:00
|
|
|
if (edge_scroll_enabled && two_finger_scroll_enabled) {
|
|
|
|
/* You cunning user set both, but you can only have one set in that UI */
|
2018-05-28 12:02:48 +12:00
|
|
|
self->changing_scroll = TRUE;
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->two_finger_scrolling_switch), two_finger_scroll_enabled);
|
2018-05-28 12:02:48 +12:00
|
|
|
self->changing_scroll = FALSE;
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->edge_scrolling_switch), FALSE);
|
2016-06-30 13:42:28 +02:00
|
|
|
} else {
|
2018-05-28 12:02:48 +12:00
|
|
|
self->changing_scroll = TRUE;
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->edge_scrolling_switch), edge_scroll_enabled);
|
|
|
|
gtk_switch_set_active (GTK_SWITCH (self->two_finger_scrolling_switch), two_finger_scroll_enabled);
|
2018-05-28 12:02:48 +12:00
|
|
|
self->changing_scroll = FALSE;
|
2016-06-30 13:42:28 +02:00
|
|
|
}
|
2015-10-22 15:33:08 +02:00
|
|
|
}
|
|
|
|
|
2016-06-30 13:33:09 +02:00
|
|
|
static void
|
|
|
|
two_finger_scrolling_changed_event (GtkSwitch *button,
|
|
|
|
gboolean state,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2018-05-28 12:02:48 +12:00
|
|
|
CcMouseProperties *self = user_data;
|
2016-06-30 13:33:09 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
if (self->changing_scroll)
|
2016-06-30 13:33:09 +02:00
|
|
|
return;
|
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_set_boolean (self->touchpad_settings, "two-finger-scrolling-enabled", state);
|
2016-06-30 13:33:09 +02:00
|
|
|
gtk_switch_set_state (button, state);
|
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
if (state && gtk_widget_get_visible (self->edge_scrolling_row)) {
|
2016-06-30 13:33:09 +02:00
|
|
|
/* Disable edge scrolling if two-finger scrolling is enabled */
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_switch_set_state (GTK_SWITCH (self->edge_scrolling_switch), FALSE);
|
2016-06-30 13:33:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-22 15:33:08 +02:00
|
|
|
static void
|
|
|
|
edge_scrolling_changed_event (GtkSwitch *button,
|
|
|
|
gboolean state,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2018-05-28 12:02:48 +12:00
|
|
|
CcMouseProperties *self = user_data;
|
2010-10-20 13:06:20 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
if (self->changing_scroll)
|
2015-10-22 15:33:08 +02:00
|
|
|
return;
|
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_set_boolean (self->touchpad_settings, "edge-scrolling-enabled", state);
|
2015-10-22 15:33:08 +02:00
|
|
|
gtk_switch_set_state (button, state);
|
2016-06-30 13:33:09 +02:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
if (state && gtk_widget_get_visible (self->two_finger_scrolling_row)) {
|
2016-06-30 13:33:09 +02:00
|
|
|
/* Disable two-finger scrolling if edge scrolling is enabled */
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_switch_set_state (GTK_SWITCH (self->two_finger_scrolling_switch), FALSE);
|
2016-06-30 13:33:09 +02:00
|
|
|
}
|
2009-04-02 13:50:10 +10:00
|
|
|
}
|
|
|
|
|
2015-01-19 18:45:13 +01:00
|
|
|
static gboolean
|
|
|
|
get_touchpad_enabled (GSettings *settings)
|
2012-08-09 15:16:05 +02:00
|
|
|
{
|
2015-01-19 18:45:13 +01:00
|
|
|
GDesktopDeviceSendEvents send_events;
|
2012-08-09 15:16:05 +02:00
|
|
|
|
2015-01-19 18:45:13 +01:00
|
|
|
send_events = g_settings_get_enum (settings, "send-events");
|
2012-08-09 15:16:05 +02:00
|
|
|
|
2015-01-19 18:45:13 +01:00
|
|
|
return send_events == G_DESKTOP_DEVICE_SEND_EVENTS_ENABLED;
|
2012-08-09 15:16:05 +02:00
|
|
|
}
|
|
|
|
|
2013-07-10 18:42:07 +05:30
|
|
|
static gboolean
|
2018-05-28 12:02:48 +12:00
|
|
|
show_touchpad_enabling_switch (CcMouseProperties *self)
|
2013-07-10 18:42:07 +05:30
|
|
|
{
|
2018-05-28 12:02:48 +12:00
|
|
|
if (!self->have_touchpad)
|
2013-07-10 18:42:07 +05:30
|
|
|
return FALSE;
|
|
|
|
|
2017-03-01 13:00:01 +01:00
|
|
|
g_debug ("Should we show the touchpad disable switch: have_mouse: %s have_touchscreen: %s\n",
|
2018-05-28 12:02:48 +12:00
|
|
|
self->have_mouse ? "true" : "false",
|
|
|
|
self->have_touchscreen ? "true" : "false");
|
2017-03-01 13:00:01 +01:00
|
|
|
|
2015-11-02 16:01:43 +01:00
|
|
|
/* Let's show the button when a mouse or touchscreen is present */
|
2018-05-28 12:02:48 +12:00
|
|
|
if (self->have_mouse || self->have_touchscreen)
|
2013-07-10 18:42:07 +05:30
|
|
|
return TRUE;
|
2015-01-19 18:45:13 +01:00
|
|
|
|
2015-11-02 16:01:43 +01:00
|
|
|
/* Let's also show when the touchpad is disabled. */
|
2018-05-28 12:02:48 +12:00
|
|
|
if (!get_touchpad_enabled (self->touchpad_settings))
|
2013-07-10 18:42:07 +05:30
|
|
|
return TRUE;
|
2015-01-19 18:45:13 +01:00
|
|
|
|
2013-07-10 18:42:07 +05:30
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-01-19 18:45:13 +01:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2015-10-28 13:26:24 +01:00
|
|
|
static void
|
2018-05-28 12:02:48 +12:00
|
|
|
handle_secondary_button (CcMouseProperties *self,
|
|
|
|
GtkWidget *button,
|
|
|
|
GtkGesture *gesture)
|
2015-10-28 13:26:24 +01:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture), GTK_PHASE_BUBBLE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-02-20 05:11:10 +00:00
|
|
|
/* Set up the property editors in the dialog. */
|
2001-12-16 08:23:09 +00:00
|
|
|
static void
|
2018-05-28 12:02:48 +12:00
|
|
|
setup_dialog (CcMouseProperties *self)
|
2001-12-16 08:23:09 +00:00
|
|
|
{
|
2015-10-28 13:26:24 +01:00
|
|
|
GtkWidget *button;
|
2002-02-08 07:05:04 +00:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
self->left_handed = g_settings_get_boolean (self->mouse_settings, "left-handed");
|
2018-05-28 12:40:11 +12:00
|
|
|
button = self->left_handed ? self->primary_button_right : self->primary_button_left;
|
2015-10-28 13:26:24 +01:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2015-10-28 12:20:02 +01:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind (self->mouse_settings, "left-handed",
|
2018-05-28 12:40:11 +12:00
|
|
|
self->primary_button_left, "active",
|
2015-10-28 12:20:02 +01:00
|
|
|
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind (self->mouse_settings, "left-handed",
|
2018-05-28 12:40:11 +12:00
|
|
|
self->primary_button_right, "active",
|
2015-10-28 12:20:02 +01:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
2010-10-20 13:06:20 +02:00
|
|
|
|
2015-10-28 13:26:24 +01:00
|
|
|
/* Allow changing orientation with either button */
|
2018-05-28 12:40:11 +12:00
|
|
|
button = self->primary_button_right;
|
2018-05-28 12:02:48 +12:00
|
|
|
self->right_gesture = gtk_gesture_multi_press_new (button);
|
|
|
|
handle_secondary_button (self, button, self->right_gesture);
|
2018-05-28 12:40:11 +12:00
|
|
|
button = self->primary_button_left;
|
2018-05-28 12:02:48 +12:00
|
|
|
self->left_gesture = gtk_gesture_multi_press_new (button);
|
|
|
|
handle_secondary_button (self, button, self->left_gesture);
|
2015-10-22 15:33:08 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind (self->mouse_settings, "natural-scroll",
|
2018-05-28 12:40:11 +12:00
|
|
|
self->mouse_natural_scrolling_switch, "active",
|
2010-10-20 13:06:20 +02:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
2015-10-22 15:33:08 +02:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
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 (self->touchpad_listbox), cc_list_box_update_header_func, NULL, NULL);
|
2006-07-24 12:38:02 +00:00
|
|
|
|
2012-08-20 14:50:44 +02:00
|
|
|
/* Mouse section */
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_set_visible (self->mouse_frame, self->have_mouse);
|
2012-08-20 14:50:44 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind (self->mouse_settings, "speed",
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_range_get_adjustment (GTK_RANGE (self->mouse_speed_scale)), "value",
|
2013-05-02 14:29:38 +02:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
2001-12-20 20:14:59 +00:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_list_box_set_header_func (GTK_LIST_BOX (self->mouse_listbox), cc_list_box_update_header_func, NULL, NULL);
|
2015-10-27 15:37:55 +01:00
|
|
|
|
2015-10-22 15:33:08 +02:00
|
|
|
/* Touchpad section */
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_set_visible (self->touchpad_toggle_switch,
|
2018-05-28 12:02:48 +12:00
|
|
|
show_touchpad_enabling_switch (self));
|
2011-03-16 13:12:11 +00:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind_with_mapping (self->touchpad_settings, "send-events",
|
2018-05-28 12:40:11 +12:00
|
|
|
self->touchpad_toggle_switch, "active",
|
2015-01-19 18:45:13 +01:00
|
|
|
G_SETTINGS_BIND_DEFAULT,
|
|
|
|
touchpad_enabled_get_mapping,
|
|
|
|
touchpad_enabled_set_mapping,
|
|
|
|
NULL, NULL);
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind_with_mapping (self->touchpad_settings, "send-events",
|
2018-05-28 12:40:11 +12:00
|
|
|
self->touchpad_options_listbox, "sensitive",
|
2015-01-19 18:45:13 +01:00
|
|
|
G_SETTINGS_BIND_GET,
|
|
|
|
touchpad_enabled_get_mapping,
|
|
|
|
touchpad_enabled_set_mapping,
|
|
|
|
NULL, NULL);
|
2012-08-09 14:11:52 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind (self->touchpad_settings, "natural-scroll",
|
2018-05-28 12:40:11 +12:00
|
|
|
self->touchpad_natural_scrolling_switch, "active",
|
2015-10-27 15:37:55 +01:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind (self->touchpad_settings, "speed",
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_range_get_adjustment (GTK_RANGE (self->touchpad_speed_scale)), "value",
|
2015-10-22 15:33:08 +02:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
g_settings_bind (self->touchpad_settings, "tap-to-click",
|
2018-05-28 12:40:11 +12:00
|
|
|
self->tap_to_click_switch, "active",
|
2013-05-02 14:29:38 +02:00
|
|
|
G_SETTINGS_BIND_DEFAULT);
|
2012-08-09 15:16:05 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
setup_touchpad_options (self);
|
2011-03-18 16:19:50 +00:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
g_signal_connect (self->edge_scrolling_switch, "state-set",
|
2018-05-28 12:02:48 +12:00
|
|
|
G_CALLBACK (edge_scrolling_changed_event), self);
|
2018-05-28 12:40:11 +12:00
|
|
|
g_signal_connect (self->two_finger_scrolling_switch, "state-set",
|
2018-05-28 12:02:48 +12:00
|
|
|
G_CALLBACK (two_finger_scrolling_changed_event), self);
|
2012-08-23 14:34:59 +02:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_list_box_set_header_func (GTK_LIST_BOX (self->touchpad_options_listbox), cc_list_box_update_header_func, NULL, NULL);
|
2001-12-19 14:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback issued when a button is clicked on the dialog */
|
2011-03-16 13:48:08 +00:00
|
|
|
static void
|
2015-01-20 21:18:53 +01:00
|
|
|
device_changed (GsdDeviceManager *device_manager,
|
|
|
|
GsdDevice *device,
|
2018-05-28 12:02:48 +12:00
|
|
|
CcMouseProperties *self)
|
2011-03-16 13:48:08 +00:00
|
|
|
{
|
2018-05-28 12:02:48 +12:00
|
|
|
self->have_touchpad = touchpad_is_present ();
|
2011-03-18 15:46:19 +00:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
setup_touchpad_options (self);
|
2012-08-20 14:50:44 +02:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
self->have_mouse = mouse_is_present ();
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_set_visible (self->mouse_frame, self->have_mouse);
|
|
|
|
gtk_widget_set_visible (self->touchpad_toggle_switch,
|
2018-05-28 12:02:48 +12:00
|
|
|
show_touchpad_enabling_switch (self));
|
2011-03-16 13:48:08 +00:00
|
|
|
}
|
|
|
|
|
2016-10-17 15:01:21 +02:00
|
|
|
static void
|
|
|
|
on_content_size_changed (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (allocation->height < 490) {
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
|
|
|
|
GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
|
|
|
} else {
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget),
|
|
|
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (widget), 490);
|
|
|
|
}
|
|
|
|
}
|
2013-03-28 10:50:58 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
cc_mouse_properties_finalize (GObject *object)
|
|
|
|
{
|
2018-05-28 12:02:48 +12:00
|
|
|
CcMouseProperties *self = CC_MOUSE_PROPERTIES (object);
|
|
|
|
|
|
|
|
g_clear_object (&self->mouse_settings);
|
|
|
|
g_clear_object (&self->gsd_mouse_settings);
|
|
|
|
g_clear_object (&self->touchpad_settings);
|
|
|
|
g_clear_object (&self->right_gesture);
|
|
|
|
g_clear_object (&self->left_gesture);
|
|
|
|
|
|
|
|
if (self->device_manager != NULL) {
|
|
|
|
g_signal_handler_disconnect (self->device_manager, self->device_added_id);
|
|
|
|
self->device_added_id = 0;
|
|
|
|
g_signal_handler_disconnect (self->device_manager, self->device_removed_id);
|
|
|
|
self->device_removed_id = 0;
|
|
|
|
self->device_manager = NULL;
|
2013-03-28 10:50:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_mouse_properties_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-05-28 12:40:11 +12:00
|
|
|
cc_mouse_properties_class_init (CcMousePropertiesClass *klass)
|
2013-03-28 10:50:58 +01:00
|
|
|
{
|
2018-05-28 12:40:11 +12:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2013-03-28 10:50:58 +01:00
|
|
|
|
|
|
|
object_class->finalize = cc_mouse_properties_finalize;
|
2018-05-28 12:40:11 +12:00
|
|
|
|
|
|
|
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);
|
2013-03-28 10:50:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-05-28 12:02:48 +12:00
|
|
|
cc_mouse_properties_init (CcMouseProperties *self)
|
2001-07-25 17:26:17 +00:00
|
|
|
{
|
2018-01-23 15:47:53 +13:00
|
|
|
g_autoptr(GError) error = NULL;
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
2011-03-16 13:48:08 +00:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
self->mouse_settings = g_settings_new ("org.gnome.desktop.peripherals.mouse");
|
|
|
|
self->gsd_mouse_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.mouse");
|
|
|
|
self->touchpad_settings = g_settings_new ("org.gnome.desktop.peripherals.touchpad");
|
|
|
|
|
|
|
|
self->device_manager = gsd_device_manager_get ();
|
|
|
|
self->device_added_id = g_signal_connect (self->device_manager, "device-added",
|
|
|
|
G_CALLBACK (device_changed), self);
|
|
|
|
self->device_removed_id = g_signal_connect (self->device_manager, "device-removed",
|
|
|
|
G_CALLBACK (device_changed), self);
|
|
|
|
|
|
|
|
self->have_mouse = mouse_is_present ();
|
|
|
|
self->have_touchpad = touchpad_is_present ();
|
|
|
|
self->have_touchscreen = touchscreen_is_present ();
|
|
|
|
self->have_synaptics = cc_synaptics_check ();
|
|
|
|
if (self->have_synaptics)
|
2016-04-04 20:01:31 +02:00
|
|
|
g_warning ("Detected synaptics X driver, please migrate to libinput");
|
2015-01-20 21:18:53 +01:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
self->changing_scroll = FALSE;
|
2013-03-28 10:50:58 +01:00
|
|
|
|
2018-05-28 12:02:48 +12:00
|
|
|
setup_dialog (self);
|
2016-10-17 15:01:21 +02:00
|
|
|
|
2018-05-28 12:40:11 +12:00
|
|
|
g_signal_connect (self->scrolled_window, "size-allocate", G_CALLBACK (on_content_size_changed), NULL);
|
2001-07-25 17:26:17 +00:00
|
|
|
}
|
2011-03-16 13:17:22 +00:00
|
|
|
|
2013-03-28 10:50:58 +01:00
|
|
|
GtkWidget *
|
|
|
|
cc_mouse_properties_new (void)
|
2011-03-16 13:17:22 +00:00
|
|
|
{
|
2013-03-28 10:50:58 +01:00
|
|
|
return (GtkWidget *) g_object_new (CC_TYPE_MOUSE_PROPERTIES, NULL);
|
2011-03-16 13:17:22 +00:00
|
|
|
}
|