mouse: Add penta-click test in addition to double-click
Clicking anything five times should obviously bring up an image (by Jakub Steiner) of a five-legged goat :-) https://bugzilla.gnome.org/show_bug.cgi?id=682492
This commit is contained in:
parent
49797e8ae2
commit
eee381abdd
4 changed files with 1861 additions and 14 deletions
|
@ -43,6 +43,7 @@ uidir = $(pkgdatadir)/ui
|
||||||
ui_DATA = \
|
ui_DATA = \
|
||||||
gnome-mouse-properties.ui \
|
gnome-mouse-properties.ui \
|
||||||
gnome-mouse-test.ui \
|
gnome-mouse-test.ui \
|
||||||
|
scroll-test-gegl.svg \
|
||||||
scroll-test.svg
|
scroll-test.svg
|
||||||
|
|
||||||
desktopdir = $(datadir)/applications
|
desktopdir = $(datadir)/applications
|
||||||
|
|
BIN
panels/mouse/double-click-gegl.png
Normal file
BIN
panels/mouse/double-click-gegl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
|
@ -45,12 +45,16 @@
|
||||||
#define INNER_CIRCLE_SIZE (52.0 / 180 * size)
|
#define INNER_CIRCLE_SIZE (52.0 / 180 * size)
|
||||||
|
|
||||||
static void setup_information_label (GtkWidget *widget);
|
static void setup_information_label (GtkWidget *widget);
|
||||||
|
static void setup_scroll_image (GtkWidget *widget);
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DOUBLE_CLICK_TEST_OFF,
|
DOUBLE_CLICK_TEST_OFF,
|
||||||
DOUBLE_CLICK_TEST_MAYBE,
|
DOUBLE_CLICK_TEST_MAYBE,
|
||||||
DOUBLE_CLICK_TEST_ON
|
DOUBLE_CLICK_TEST_ON,
|
||||||
|
DOUBLE_CLICK_TEST_STILL_ON,
|
||||||
|
DOUBLE_CLICK_TEST_ALMOST_THERE,
|
||||||
|
DOUBLE_CLICK_TEST_GEGL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* State in testing the double-click speed. Global for a great deal of
|
/* State in testing the double-click speed. Global for a great deal of
|
||||||
|
@ -63,6 +67,7 @@ static GSettings *mouse_settings = NULL;
|
||||||
|
|
||||||
static gint information_label_timeout_id = 0;
|
static gint information_label_timeout_id = 0;
|
||||||
static gint button_drawing_area_timeout_id = 0;
|
static gint button_drawing_area_timeout_id = 0;
|
||||||
|
static gint scroll_image_timeout_id = 0;
|
||||||
|
|
||||||
/* Double Click handling */
|
/* Double Click handling */
|
||||||
|
|
||||||
|
@ -98,6 +103,18 @@ information_label_timeout (struct test_data_t *data)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Timeout for the scroll image */
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
scroll_image_timeout (struct test_data_t *data)
|
||||||
|
{
|
||||||
|
setup_scroll_image (data->widget);
|
||||||
|
|
||||||
|
*data->timeout_id = 0;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set information label according global state variables. */
|
/* Set information label according global state variables. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -118,17 +135,21 @@ setup_information_label (GtkWidget *widget)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double_click = (double_click_state == DOUBLE_CLICK_TEST_ON);
|
if (double_click_state == DOUBLE_CLICK_TEST_GEGL) {
|
||||||
switch (button_state) {
|
message = _("Five clicks, GEGL time!"), "</b>";
|
||||||
case 1:
|
} else {
|
||||||
message = (double_click) ? _("Double click, primary button") : _("Single click, primary button");
|
double_click = (double_click_state >= DOUBLE_CLICK_TEST_ON);
|
||||||
break;
|
switch (button_state) {
|
||||||
case 2:
|
case 1:
|
||||||
message = (double_click) ? _("Double click, middle button") : _("Single click, middle button");
|
message = (double_click) ? _("Double click, primary button") : _("Single click, primary button");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 2:
|
||||||
message = (double_click) ? _("Double click, secondary button") : _("Single click, secondary button");
|
message = (double_click) ? _("Double click, middle button") : _("Single click, middle button");
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
message = (double_click) ? _("Double click, secondary button") : _("Single click, secondary button");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
label_text = g_strconcat ("<b>", message, "</b>", NULL);
|
label_text = g_strconcat ("<b>", message, "</b>", NULL);
|
||||||
|
@ -142,6 +163,36 @@ setup_information_label (GtkWidget *widget)
|
||||||
&data);
|
&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update scroll image according to the global state variables */
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_scroll_image (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
static struct test_data_t data;
|
||||||
|
char *filename;
|
||||||
|
|
||||||
|
if (scroll_image_timeout_id != 0) {
|
||||||
|
g_source_remove (scroll_image_timeout_id);
|
||||||
|
scroll_image_timeout_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (double_click_state == DOUBLE_CLICK_TEST_GEGL)
|
||||||
|
filename = GNOMECC_UI_DIR "/scroll-test-gegl.svg";
|
||||||
|
else
|
||||||
|
filename = GNOMECC_UI_DIR "/scroll-test.svg";
|
||||||
|
gtk_image_set_from_file (GTK_IMAGE (widget), filename);
|
||||||
|
|
||||||
|
if (double_click_state != DOUBLE_CLICK_TEST_GEGL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
data.widget = widget;
|
||||||
|
data.timeout_id = &scroll_image_timeout_id;
|
||||||
|
scroll_image_timeout_id = g_timeout_add (5000,
|
||||||
|
(GSourceFunc) scroll_image_timeout,
|
||||||
|
&data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Callback issued when the user clicks the double click testing area. */
|
/* Callback issued when the user clicks the double click testing area. */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -175,14 +226,19 @@ button_drawing_area_button_press_event (GtkWidget *widget,
|
||||||
button_drawing_area_timeout_id = g_timeout_add (double_click_time, (GSourceFunc) test_maybe_timeout, &data);
|
button_drawing_area_timeout_id = g_timeout_add (double_click_time, (GSourceFunc) test_maybe_timeout, &data);
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_MAYBE:
|
case DOUBLE_CLICK_TEST_MAYBE:
|
||||||
|
case DOUBLE_CLICK_TEST_ON:
|
||||||
|
case DOUBLE_CLICK_TEST_STILL_ON:
|
||||||
|
case DOUBLE_CLICK_TEST_ALMOST_THERE:
|
||||||
if (event->time - double_click_timestamp < double_click_time) {
|
if (event->time - double_click_timestamp < double_click_time) {
|
||||||
double_click_state = DOUBLE_CLICK_TEST_ON;
|
double_click_state++;
|
||||||
data.widget = widget;
|
data.widget = widget;
|
||||||
data.timeout_id = &button_drawing_area_timeout_id;
|
data.timeout_id = &button_drawing_area_timeout_id;
|
||||||
button_drawing_area_timeout_id = g_timeout_add (2500, (GSourceFunc) test_maybe_timeout, &data);
|
button_drawing_area_timeout_id = g_timeout_add (2500, (GSourceFunc) test_maybe_timeout, &data);
|
||||||
|
} else {
|
||||||
|
test_maybe_timeout (&data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_ON:
|
case DOUBLE_CLICK_TEST_GEGL:
|
||||||
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -193,6 +249,7 @@ button_drawing_area_button_press_event (GtkWidget *widget,
|
||||||
|
|
||||||
button_state = event->button;
|
button_state = event->button;
|
||||||
setup_information_label (WID ("information_label"));
|
setup_information_label (WID ("information_label"));
|
||||||
|
setup_scroll_image (WID ("image"));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -212,6 +269,9 @@ button_drawing_area_draw_event (GtkWidget *widget,
|
||||||
|
|
||||||
switch (double_click_state) {
|
switch (double_click_state) {
|
||||||
case DOUBLE_CLICK_TEST_ON:
|
case DOUBLE_CLICK_TEST_ON:
|
||||||
|
case DOUBLE_CLICK_TEST_STILL_ON:
|
||||||
|
case DOUBLE_CLICK_TEST_ALMOST_THERE:
|
||||||
|
case DOUBLE_CLICK_TEST_GEGL:
|
||||||
gdk_rgba_parse (&outer_color, "#729fcf");
|
gdk_rgba_parse (&outer_color, "#729fcf");
|
||||||
gdk_rgba_parse (&inner_color, "#729fcf");
|
gdk_rgba_parse (&inner_color, "#729fcf");
|
||||||
break;
|
break;
|
||||||
|
@ -298,6 +358,11 @@ gnome_mouse_test_dispose (GtkWidget *widget)
|
||||||
information_label_timeout_id = 0;
|
information_label_timeout_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scroll_image_timeout_id != 0) {
|
||||||
|
g_source_remove (scroll_image_timeout_id);
|
||||||
|
scroll_image_timeout_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (button_drawing_area_timeout_id != 0) {
|
if (button_drawing_area_timeout_id != 0) {
|
||||||
g_source_remove (button_drawing_area_timeout_id);
|
g_source_remove (button_drawing_area_timeout_id);
|
||||||
button_drawing_area_timeout_id = 0;
|
button_drawing_area_timeout_id = 0;
|
||||||
|
|
1781
panels/mouse/scroll-test-gegl.svg
Normal file
1781
panels/mouse/scroll-test-gegl.svg
Normal file
File diff suppressed because it is too large
Load diff
After Width: | Height: | Size: 113 KiB |
Loading…
Add table
Add a link
Reference in a new issue