mouse: Reorganize widgets according to mockup
https://bugzilla.gnome.org/show_bug.cgi?id=677206
This commit is contained in:
parent
a416243050
commit
a6262b0ad4
2 changed files with 532 additions and 1068 deletions
|
@ -1,10 +1,11 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
||||
*
|
||||
* Copyright (C) 2001 Red Hat, Inc.
|
||||
* Copyright (C) 2001, 2012 Red Hat, Inc.
|
||||
* Copyright (C) 2001 Ximian, Inc.
|
||||
*
|
||||
* Written by: Jonathon Blandford <jrb@redhat.com>,
|
||||
* Bradford Hovinen <hovinen@ximian.com>,
|
||||
* Ondrej Holy <oholy@redhat.com>,
|
||||
*
|
||||
* 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
|
||||
|
@ -43,17 +44,6 @@
|
|||
|
||||
#define WID(x) (GtkWidget*) gtk_builder_get_object (dialog, x)
|
||||
|
||||
enum
|
||||
{
|
||||
DOUBLE_CLICK_TEST_OFF,
|
||||
DOUBLE_CLICK_TEST_MAYBE,
|
||||
DOUBLE_CLICK_TEST_ON
|
||||
};
|
||||
|
||||
/* State in testing the double-click speed. Global for a great deal of
|
||||
* convenience
|
||||
*/
|
||||
static gint double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||
static GSettings *mouse_settings = NULL;
|
||||
static GSettings *touchpad_settings = NULL;
|
||||
static GdkDeviceManager *device_manager = NULL;
|
||||
|
@ -61,91 +51,6 @@ static guint device_added_id = 0;
|
|||
static guint device_removed_id = 0;
|
||||
static gboolean changing_scroll = FALSE;
|
||||
|
||||
/* Double Click handling */
|
||||
|
||||
struct test_data_t
|
||||
{
|
||||
gint *timeout_id;
|
||||
GtkWidget *image;
|
||||
};
|
||||
|
||||
/* Timeout for the double click test */
|
||||
|
||||
static gboolean
|
||||
test_maybe_timeout (struct test_data_t *data)
|
||||
{
|
||||
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (data->image), "face-plain", GTK_ICON_SIZE_DIALOG);
|
||||
|
||||
*data->timeout_id = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Callback issued when the user clicks the double click testing area. */
|
||||
|
||||
static gboolean
|
||||
event_box_button_press_event (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GtkBuilder *dialog)
|
||||
{
|
||||
gint double_click_time;
|
||||
static struct test_data_t data;
|
||||
static gint test_on_timeout_id = 0;
|
||||
static gint test_maybe_timeout_id = 0;
|
||||
static guint32 double_click_timestamp = 0;
|
||||
GtkWidget *image;
|
||||
|
||||
if (event->type != GDK_BUTTON_PRESS)
|
||||
return FALSE;
|
||||
|
||||
image = g_object_get_data (G_OBJECT (widget), "image");
|
||||
|
||||
double_click_time = g_settings_get_int (mouse_settings, "double-click");
|
||||
|
||||
if (test_maybe_timeout_id != 0)
|
||||
g_source_remove (test_maybe_timeout_id);
|
||||
if (test_on_timeout_id != 0)
|
||||
g_source_remove (test_on_timeout_id);
|
||||
|
||||
switch (double_click_state) {
|
||||
case DOUBLE_CLICK_TEST_OFF:
|
||||
double_click_state = DOUBLE_CLICK_TEST_MAYBE;
|
||||
data.image = image;
|
||||
data.timeout_id = &test_maybe_timeout_id;
|
||||
test_maybe_timeout_id = g_timeout_add (double_click_time, (GSourceFunc) test_maybe_timeout, &data);
|
||||
break;
|
||||
case DOUBLE_CLICK_TEST_MAYBE:
|
||||
if (event->time - double_click_timestamp < double_click_time) {
|
||||
double_click_state = DOUBLE_CLICK_TEST_ON;
|
||||
data.image = image;
|
||||
data.timeout_id = &test_on_timeout_id;
|
||||
test_on_timeout_id = g_timeout_add (2500, (GSourceFunc) test_maybe_timeout, &data);
|
||||
}
|
||||
break;
|
||||
case DOUBLE_CLICK_TEST_ON:
|
||||
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||
break;
|
||||
}
|
||||
|
||||
double_click_timestamp = event->time;
|
||||
|
||||
switch (double_click_state) {
|
||||
case DOUBLE_CLICK_TEST_ON:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), "face-laugh", GTK_ICON_SIZE_DIALOG);
|
||||
break;
|
||||
case DOUBLE_CLICK_TEST_MAYBE:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), "face-smile", GTK_ICON_SIZE_DIALOG);
|
||||
break;
|
||||
case DOUBLE_CLICK_TEST_OFF:
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), "face-plain", GTK_ICON_SIZE_DIALOG);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
orientation_radio_button_release_event (GtkWidget *widget,
|
||||
GdkEventButton *event)
|
||||
|
@ -157,43 +62,25 @@ static void
|
|||
setup_scrollmethod_radios (GtkBuilder *dialog)
|
||||
{
|
||||
GsdTouchpadScrollMethod method;
|
||||
gboolean active;
|
||||
|
||||
method = g_settings_get_enum (touchpad_settings, "scroll-method");
|
||||
|
||||
switch (method) {
|
||||
case GSD_TOUCHPAD_SCROLL_METHOD_EDGE_SCROLLING:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("scroll_edge_radio")), TRUE);
|
||||
break;
|
||||
case GSD_TOUCHPAD_SCROLL_METHOD_TWO_FINGER_SCROLLING:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("scroll_twofinger_radio")), TRUE);
|
||||
break;
|
||||
case GSD_TOUCHPAD_SCROLL_METHOD_DISABLED:
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("scroll_disabled_radio")), TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (WID ("horiz_scroll_toggle"),
|
||||
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("scroll_disabled_radio"))));
|
||||
active = (method == GSD_TOUCHPAD_SCROLL_METHOD_TWO_FINGER_SCROLLING);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("two_finger_scroll_toggle")), active);
|
||||
}
|
||||
|
||||
static void
|
||||
scrollmethod_changed_event (GtkToggleButton *button, GtkBuilder *dialog)
|
||||
{
|
||||
GsdTouchpadScrollMethod method;
|
||||
GtkToggleButton *disabled = GTK_TOGGLE_BUTTON (WID ("scroll_disabled_radio"));
|
||||
|
||||
if (changing_scroll)
|
||||
return;
|
||||
|
||||
gtk_widget_set_sensitive (WID ("horiz_scroll_toggle"),
|
||||
!gtk_toggle_button_get_active (disabled));
|
||||
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("scroll_edge_radio"))))
|
||||
method = GSD_TOUCHPAD_SCROLL_METHOD_EDGE_SCROLLING;
|
||||
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("scroll_twofinger_radio"))))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (WID ("two_finger_scroll_toggle"))))
|
||||
method = GSD_TOUCHPAD_SCROLL_METHOD_TWO_FINGER_SCROLLING;
|
||||
else
|
||||
method = GSD_TOUCHPAD_SCROLL_METHOD_DISABLED;
|
||||
method = GSD_TOUCHPAD_SCROLL_METHOD_EDGE_SCROLLING;
|
||||
|
||||
g_settings_set_enum (touchpad_settings, "scroll-method", method);
|
||||
}
|
||||
|
@ -236,7 +123,7 @@ synaptics_check_capabilities (GtkBuilder *dialog)
|
|||
/* Disable two finger scrolling unless the hardware supports
|
||||
* double touch */
|
||||
if (!(data[3]))
|
||||
gtk_widget_set_sensitive (WID ("scroll_twofinger_radio"), FALSE);
|
||||
gtk_widget_set_sensitive (WID ("two_finger_scroll_toggle"), FALSE);
|
||||
|
||||
XFree (data);
|
||||
}
|
||||
|
@ -264,48 +151,38 @@ setup_dialog (GtkBuilder *dialog)
|
|||
g_signal_connect (WID ("left_handed_radio"), "button_release_event",
|
||||
G_CALLBACK (orientation_radio_button_release_event), NULL);
|
||||
|
||||
/* Locate pointer toggle */
|
||||
g_settings_bind (mouse_settings, "locate-pointer",
|
||||
WID ("locate_pointer_toggle"), "active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
/* Double-click time */
|
||||
g_settings_bind (mouse_settings, "double-click",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("delay_scale"))), "value",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("double_click_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (WID ("double_click_image")), "face-plain", GTK_ICON_SIZE_DIALOG);
|
||||
g_object_set_data (G_OBJECT (WID ("double_click_eventbox")), "image", WID ("double_click_image"));
|
||||
g_signal_connect (WID ("double_click_eventbox"), "button_press_event",
|
||||
G_CALLBACK (event_box_button_press_event), dialog);
|
||||
|
||||
/* speed */
|
||||
g_settings_bind (mouse_settings, "motion-acceleration",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("accel_scale"))), "value",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("acceleration_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (mouse_settings, "motion-threshold",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("sensitivity_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
/* DnD threshold */
|
||||
g_settings_bind (mouse_settings, "drag-threshold",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("drag_threshold_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
||||
/* Trackpad page */
|
||||
touchpad_present = touchpad_is_present ();
|
||||
gtk_widget_set_visible (WID ("touchpad_vbox"), touchpad_present);
|
||||
|
||||
g_settings_bind (touchpad_settings, "touchpad-enabled",
|
||||
WID ("touchpad_enabled_switch"), "active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (touchpad_settings, "touchpad-enabled",
|
||||
WID ("touchpad_options_box"), "sensitive",
|
||||
G_SETTINGS_BIND_GET);
|
||||
|
||||
g_settings_bind (touchpad_settings, "disable-while-typing",
|
||||
WID ("disable_w_typing_toggle"), "active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (touchpad_settings, "tap-to-click",
|
||||
WID ("tap_to_click_toggle"), "active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (touchpad_settings, "horiz-scroll-enabled",
|
||||
WID ("horiz_scroll_toggle"), "active",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (touchpad_settings, "motion-acceleration",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("touchpad_accel_scale"))), "value",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("touchpad_acceleration_scale"))), "value",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
g_settings_bind (touchpad_settings, "motion-threshold",
|
||||
gtk_range_get_adjustment (GTK_RANGE (WID ("touchpad_sensitivity_scale"))), "value",
|
||||
|
@ -316,11 +193,7 @@ setup_dialog (GtkBuilder *dialog)
|
|||
setup_scrollmethod_radios (dialog);
|
||||
}
|
||||
|
||||
g_signal_connect (WID ("scroll_disabled_radio"), "toggled",
|
||||
G_CALLBACK (scrollmethod_changed_event), dialog);
|
||||
g_signal_connect (WID ("scroll_edge_radio"), "toggled",
|
||||
G_CALLBACK (scrollmethod_changed_event), dialog);
|
||||
g_signal_connect (WID ("scroll_twofinger_radio"), "toggled",
|
||||
g_signal_connect (WID ("two_finger_scroll_toggle"), "toggled",
|
||||
G_CALLBACK (scrollmethod_changed_event), dialog);
|
||||
}
|
||||
|
||||
|
@ -332,22 +205,26 @@ create_dialog (GtkBuilder *dialog)
|
|||
GtkSizeGroup *size_group;
|
||||
|
||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
gtk_size_group_add_widget (size_group, WID ("primary_button_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("acceleration_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("sensitivity_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("threshold_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("timeout_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("double_click_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("touchpad_acceleration_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("touchpad_sensitivity_label"));
|
||||
|
||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
gtk_size_group_add_widget (size_group, WID ("acceleration_fast_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("sensitivity_high_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("threshold_large_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("timeout_long_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("double_click_fast_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("touchpad_acceleration_fast_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("touchpad_sensitivity_high_label"));
|
||||
|
||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||
gtk_size_group_add_widget (size_group, WID ("acceleration_slow_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("sensitivity_low_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("threshold_small_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("timeout_short_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("double_click_slow_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("touchpad_acceleration_slow_label"));
|
||||
gtk_size_group_add_widget (size_group, WID ("touchpad_sensitivity_low_label"));
|
||||
}
|
||||
|
||||
/* Callback issued when a button is clicked on the dialog */
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue