2001-12-19 14:53:45 +00:00
|
|
|
/* -*- mode: c; style: linux -*- */
|
|
|
|
|
|
|
|
/* mouse-properties-capplet.c
|
|
|
|
* Copyright (C) 2001 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2001 Ximian, Inc.
|
|
|
|
*
|
|
|
|
* Written by: Jonathon Blandford <jrb@redhat.com>,
|
|
|
|
* Bradford Hovinen <hovinen@ximian.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
|
|
|
|
* 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
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-08-01 17:36:57 +00:00
|
|
|
#include <config.h>
|
2001-12-19 14:53:45 +00:00
|
|
|
|
2002-03-10 15:04:22 +00:00
|
|
|
#include <string.h>
|
2001-12-16 08:23:09 +00:00
|
|
|
#include <gnome.h>
|
|
|
|
#include <gconf/gconf-client.h>
|
2001-07-25 17:26:17 +00:00
|
|
|
#include <glade/glade.h>
|
2002-05-10 19:28:56 +00:00
|
|
|
#include <gdk/gdkx.h>
|
2001-12-16 08:23:09 +00:00
|
|
|
#include <math.h>
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
#include "capplet-util.h"
|
|
|
|
#include "gconf-property-editor.h"
|
2002-03-11 01:46:13 +00:00
|
|
|
#include "activate-settings-daemon.h"
|
2003-01-08 07:04:42 +00:00
|
|
|
#include "capplet-stock-icons.h"
|
2008-01-14 16:35:21 +00:00
|
|
|
#include "gnome-mouse-accessibility.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>
|
2001-12-19 14:53:45 +00:00
|
|
|
|
new cursor theme manager for the mouse capplet, patch by Sven Herzberg
2005-07-10 Sebastien Bacher <seb128@debian.org>
* gnome-mouse-properties.c: (cursor_size_from_widget),
(event_box_button_press_event), (cursor_theme_changed),
(cursor_font_changed), (cursor_changed),
(gdk_pixbuf_from_xcursor_image), (populate_tree_model),
(setup_dialog), (create_dialog):
* gnome-mouse-properties.glade:
new cursor theme manager for the mouse capplet,
patch by Sven Herzberg <herzi@gnome-de.org> with changes
by Matthias Clasen <mclasen@redhat.com> (Closes: #110670).
2005-07-10 11:02:10 +00:00
|
|
|
#ifdef HAVE_XCURSOR
|
|
|
|
#include <X11/Xcursor/Xcursor.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DOUBLE_CLICK_TEST_OFF,
|
|
|
|
DOUBLE_CLICK_TEST_MAYBE,
|
2004-03-31 21:30:23 +00:00
|
|
|
DOUBLE_CLICK_TEST_ON
|
2001-12-16 08:23:09 +00:00
|
|
|
};
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* We use this in at least half a dozen places, so it makes sense just to
|
|
|
|
* define the macro */
|
|
|
|
|
|
|
|
#define DOUBLE_CLICK_KEY "/desktop/gnome/peripherals/mouse/double_click"
|
2003-08-01 17:36:57 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* State in testing the double-click speed. Global for a great deal of
|
|
|
|
* convenience
|
|
|
|
*/
|
2005-11-14 15:18:09 +00:00
|
|
|
static gint double_click_state = DOUBLE_CLICK_TEST_OFF;
|
2001-12-16 08:23:09 +00:00
|
|
|
|
2007-01-17 10:50:17 +00:00
|
|
|
/* normalization routines */
|
2001-12-16 08:23:09 +00:00
|
|
|
/* All of our scales but double_click are on the range 1->10 as a result, we
|
|
|
|
* have a few routines to convert from whatever the gconf key is to our range.
|
2001-07-25 17:26:17 +00:00
|
|
|
*/
|
2001-12-19 20:18:23 +00:00
|
|
|
static GConfValue *
|
2002-03-21 15:24:20 +00:00
|
|
|
double_click_from_gconf (GConfPropertyEditor *peditor, const GConfValue *value)
|
2001-07-25 17:26:17 +00:00
|
|
|
{
|
2001-12-19 20:18:23 +00:00
|
|
|
GConfValue *new_value;
|
|
|
|
|
2003-08-11 17:55:34 +00:00
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
|
|
gconf_value_set_int (new_value, CLAMP ((int) floor ((gconf_value_get_int (value) + 50) / 100.0) * 100, 100, 1000));
|
2001-12-19 20:18:23 +00:00
|
|
|
return new_value;
|
2001-12-19 14:53:45 +00:00
|
|
|
}
|
|
|
|
|
2002-05-10 19:28:56 +00:00
|
|
|
static void
|
|
|
|
get_default_mouse_info (int *default_numerator, int *default_denominator, int *default_threshold)
|
|
|
|
{
|
|
|
|
int numerator, denominator;
|
|
|
|
int threshold;
|
|
|
|
int tmp_num, tmp_den, tmp_threshold;
|
2006-07-24 12:38:02 +00:00
|
|
|
|
2002-05-10 19:28:56 +00:00
|
|
|
/* Query X for the default value */
|
|
|
|
XGetPointerControl (GDK_DISPLAY (), &numerator, &denominator,
|
|
|
|
&threshold);
|
|
|
|
XChangePointerControl (GDK_DISPLAY (), True, True, -1, -1, -1);
|
|
|
|
XGetPointerControl (GDK_DISPLAY (), &tmp_num, &tmp_den, &tmp_threshold);
|
|
|
|
XChangePointerControl (GDK_DISPLAY (), True, True, numerator, denominator, threshold);
|
|
|
|
|
|
|
|
if (default_numerator)
|
|
|
|
*default_numerator = tmp_num;
|
|
|
|
|
|
|
|
if (default_denominator)
|
|
|
|
*default_denominator = tmp_den;
|
|
|
|
|
|
|
|
if (default_threshold)
|
|
|
|
*default_threshold = tmp_threshold;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-12-19 20:18:23 +00:00
|
|
|
static GConfValue *
|
2008-01-25 18:29:28 +00:00
|
|
|
motion_acceleration_from_gconf (GConfPropertyEditor *peditor,
|
2002-03-21 15:24:20 +00:00
|
|
|
const GConfValue *value)
|
2001-12-16 08:23:09 +00:00
|
|
|
{
|
2001-12-19 20:18:23 +00:00
|
|
|
GConfValue *new_value;
|
|
|
|
gfloat motion_acceleration;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
|
2008-01-25 18:29:28 +00:00
|
|
|
|
2002-05-10 19:28:56 +00:00
|
|
|
if (gconf_value_get_float (value) == -1.0) {
|
|
|
|
int numerator, denominator;
|
2008-01-25 18:29:28 +00:00
|
|
|
|
2002-05-10 19:28:56 +00:00
|
|
|
get_default_mouse_info (&numerator, &denominator, NULL);
|
|
|
|
|
|
|
|
motion_acceleration = CLAMP ((gfloat)(numerator / denominator), 0.2, 6.0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
motion_acceleration = CLAMP (gconf_value_get_float (value), 0.2, 6.0);
|
|
|
|
}
|
2001-12-19 14:53:45 +00:00
|
|
|
|
|
|
|
if (motion_acceleration >= 1)
|
2001-12-19 20:18:23 +00:00
|
|
|
gconf_value_set_float (new_value, motion_acceleration + 4);
|
2001-12-19 14:53:45 +00:00
|
|
|
else
|
2001-12-19 20:18:23 +00:00
|
|
|
gconf_value_set_float (new_value, motion_acceleration * 5);
|
|
|
|
|
|
|
|
return new_value;
|
2001-12-16 08:23:09 +00:00
|
|
|
}
|
2001-08-22 13:56:23 +00:00
|
|
|
|
2001-12-19 20:18:23 +00:00
|
|
|
static GConfValue *
|
2008-01-25 18:29:28 +00:00
|
|
|
motion_acceleration_to_gconf (GConfPropertyEditor *peditor,
|
2002-03-21 15:24:20 +00:00
|
|
|
const GConfValue *value)
|
2001-12-16 08:23:09 +00:00
|
|
|
{
|
2001-12-19 20:18:23 +00:00
|
|
|
GConfValue *new_value;
|
|
|
|
gfloat motion_acceleration;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
|
|
|
|
motion_acceleration = CLAMP (gconf_value_get_float (value), 1.0, 10.0);
|
2001-12-19 14:53:45 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
if (motion_acceleration < 5)
|
2001-12-19 20:18:23 +00:00
|
|
|
gconf_value_set_float (new_value, motion_acceleration / 5.0);
|
2001-12-19 14:53:45 +00:00
|
|
|
else
|
2001-12-19 20:18:23 +00:00
|
|
|
gconf_value_set_float (new_value, motion_acceleration - 4);
|
|
|
|
|
|
|
|
return new_value;
|
2001-12-16 08:23:09 +00:00
|
|
|
}
|
2001-12-19 14:53:45 +00:00
|
|
|
|
2001-12-19 20:18:23 +00:00
|
|
|
static GConfValue *
|
2008-01-25 18:29:28 +00:00
|
|
|
threshold_from_gconf (GConfPropertyEditor *peditor,
|
2002-03-21 15:24:20 +00:00
|
|
|
const GConfValue *value)
|
2001-12-16 08:23:09 +00:00
|
|
|
{
|
2001-12-19 20:18:23 +00:00
|
|
|
GConfValue *new_value;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
|
2002-05-10 19:28:56 +00:00
|
|
|
|
|
|
|
if (gconf_value_get_int (value) == -1) {
|
|
|
|
int threshold;
|
|
|
|
|
|
|
|
get_default_mouse_info (NULL, NULL, &threshold);
|
|
|
|
gconf_value_set_float (new_value, CLAMP (threshold, 1, 10));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gconf_value_set_float (new_value, CLAMP (gconf_value_get_int (value), 1, 10));
|
|
|
|
}
|
|
|
|
|
2001-12-19 20:18:23 +00:00
|
|
|
return new_value;
|
2001-12-16 08:23:09 +00:00
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
Lots of things. Fix drag threshold preference, use a GtkImage instead of a
2002-05-12 Anders Carlsson <andersca@gnu.org>
* gnome-mouse-properties.c: (drag_threshold_from_gconf),
(drag_threshold_to_gconf), (event_box_button_press_event),
(load_pixbufs), (setup_dialog), (create_dialog),
(dialog_response_cb), (main):
* gnome-mouse-properties.glade:
Lots of things. Fix drag threshold preference, use a GtkImage
instead of a GtkDrawingArea for the double click test. Remove
weird weak refs throughout the code. Clean up the glade file,
requires a new libglade that has an a11y ref count fix.
2002-05-12 09:04:14 +00:00
|
|
|
static GConfValue *
|
2008-01-25 18:29:28 +00:00
|
|
|
drag_threshold_from_gconf (GConfPropertyEditor *peditor,
|
Lots of things. Fix drag threshold preference, use a GtkImage instead of a
2002-05-12 Anders Carlsson <andersca@gnu.org>
* gnome-mouse-properties.c: (drag_threshold_from_gconf),
(drag_threshold_to_gconf), (event_box_button_press_event),
(load_pixbufs), (setup_dialog), (create_dialog),
(dialog_response_cb), (main):
* gnome-mouse-properties.glade:
Lots of things. Fix drag threshold preference, use a GtkImage
instead of a GtkDrawingArea for the double click test. Remove
weird weak refs throughout the code. Clean up the glade file,
requires a new libglade that has an a11y ref count fix.
2002-05-12 09:04:14 +00:00
|
|
|
const GConfValue *value)
|
|
|
|
{
|
|
|
|
GConfValue *new_value;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
|
|
|
|
|
|
|
|
gconf_value_set_float (new_value, CLAMP (gconf_value_get_int (value), 1, 10));
|
|
|
|
|
|
|
|
return new_value;
|
|
|
|
}
|
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
/* Double Click handling */
|
2001-08-22 13:56:23 +00:00
|
|
|
|
2008-01-25 18:29:28 +00:00
|
|
|
struct test_data_t
|
2001-12-16 08:23:09 +00:00
|
|
|
{
|
2001-12-19 14:53:45 +00:00
|
|
|
gint *timeout_id;
|
2002-05-22 00:08:37 +00:00
|
|
|
GtkWidget *image;
|
2001-12-19 14:53:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Timeout for the double click test */
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
test_maybe_timeout (struct test_data_t *data)
|
|
|
|
{
|
2001-12-16 08:23:09 +00:00
|
|
|
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
2002-11-02 19:03:15 +00:00
|
|
|
|
2008-01-25 18:29:28 +00:00
|
|
|
gtk_image_set_from_stock (GTK_IMAGE (data->image),
|
2003-01-08 07:04:42 +00:00
|
|
|
MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size());
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
*data->timeout_id = 0;
|
2001-08-22 13:56:23 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
return FALSE;
|
2001-07-25 17:26:17 +00:00
|
|
|
}
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* Callback issued when the user clicks the double click testing area. */
|
|
|
|
|
Lots of things. Fix drag threshold preference, use a GtkImage instead of a
2002-05-12 Anders Carlsson <andersca@gnu.org>
* gnome-mouse-properties.c: (drag_threshold_from_gconf),
(drag_threshold_to_gconf), (event_box_button_press_event),
(load_pixbufs), (setup_dialog), (create_dialog),
(dialog_response_cb), (main):
* gnome-mouse-properties.glade:
Lots of things. Fix drag threshold preference, use a GtkImage
instead of a GtkDrawingArea for the double click test. Remove
weird weak refs throughout the code. Clean up the glade file,
requires a new libglade that has an a11y ref count fix.
2002-05-12 09:04:14 +00:00
|
|
|
static gboolean
|
|
|
|
event_box_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GConfChangeSet *changeset)
|
2001-07-25 17:26:17 +00:00
|
|
|
{
|
2001-12-19 14:53:45 +00:00
|
|
|
gint double_click_time;
|
|
|
|
GConfValue *value;
|
|
|
|
static struct test_data_t data;
|
new cursor theme manager for the mouse capplet, patch by Sven Herzberg
2005-07-10 Sebastien Bacher <seb128@debian.org>
* gnome-mouse-properties.c: (cursor_size_from_widget),
(event_box_button_press_event), (cursor_theme_changed),
(cursor_font_changed), (cursor_changed),
(gdk_pixbuf_from_xcursor_image), (populate_tree_model),
(setup_dialog), (create_dialog):
* gnome-mouse-properties.glade:
new cursor theme manager for the mouse capplet,
patch by Sven Herzberg <herzi@gnome-de.org> with changes
by Matthias Clasen <mclasen@redhat.com> (Closes: #110670).
2005-07-10 11:02:10 +00:00
|
|
|
static gint test_on_timeout_id = 0;
|
|
|
|
static gint test_maybe_timeout_id = 0;
|
2001-12-19 14:53:45 +00:00
|
|
|
static guint32 double_click_timestamp = 0;
|
2008-04-11 07:12:14 +00:00
|
|
|
GtkWidget *image;
|
2005-05-22 15:46:45 +00:00
|
|
|
GConfClient *client;
|
2002-11-02 19:03:15 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
if (event->type != GDK_BUTTON_PRESS)
|
|
|
|
return FALSE;
|
|
|
|
|
Lots of things. Fix drag threshold preference, use a GtkImage instead of a
2002-05-12 Anders Carlsson <andersca@gnu.org>
* gnome-mouse-properties.c: (drag_threshold_from_gconf),
(drag_threshold_to_gconf), (event_box_button_press_event),
(load_pixbufs), (setup_dialog), (create_dialog),
(dialog_response_cb), (main):
* gnome-mouse-properties.glade:
Lots of things. Fix drag threshold preference, use a GtkImage
instead of a GtkDrawingArea for the double click test. Remove
weird weak refs throughout the code. Clean up the glade file,
requires a new libglade that has an a11y ref count fix.
2002-05-12 09:04:14 +00:00
|
|
|
image = g_object_get_data (G_OBJECT (widget), "image");
|
2008-01-25 18:29:28 +00:00
|
|
|
|
2005-05-22 15:46:45 +00:00
|
|
|
if (!(changeset && gconf_change_set_check_value (changeset, DOUBLE_CLICK_KEY, &value))) {
|
|
|
|
client = gconf_client_get_default();
|
|
|
|
double_click_time = gconf_client_get_int (client, DOUBLE_CLICK_KEY, NULL);
|
|
|
|
g_object_unref (client);
|
|
|
|
|
|
|
|
} else
|
2001-12-19 14:53:45 +00:00
|
|
|
double_click_time = gconf_value_get_int (value);
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
if (test_maybe_timeout_id != 0)
|
|
|
|
gtk_timeout_remove (test_maybe_timeout_id);
|
|
|
|
if (test_on_timeout_id != 0)
|
|
|
|
gtk_timeout_remove (test_on_timeout_id);
|
|
|
|
|
|
|
|
switch (double_click_state) {
|
|
|
|
case DOUBLE_CLICK_TEST_OFF:
|
|
|
|
double_click_state = DOUBLE_CLICK_TEST_MAYBE;
|
2002-05-22 00:08:37 +00:00
|
|
|
data.image = image;
|
2001-12-19 14:53:45 +00:00
|
|
|
data.timeout_id = &test_maybe_timeout_id;
|
|
|
|
test_maybe_timeout_id = gtk_timeout_add (double_click_time, (GtkFunction) test_maybe_timeout, &data);
|
2001-12-16 08:23:09 +00:00
|
|
|
break;
|
|
|
|
case DOUBLE_CLICK_TEST_MAYBE:
|
|
|
|
if (event->time - double_click_timestamp < double_click_time) {
|
|
|
|
double_click_state = DOUBLE_CLICK_TEST_ON;
|
2002-05-22 00:08:37 +00:00
|
|
|
data.image = image;
|
2001-12-19 14:53:45 +00:00
|
|
|
data.timeout_id = &test_on_timeout_id;
|
|
|
|
test_on_timeout_id = gtk_timeout_add (2500, (GtkFunction) test_maybe_timeout, &data);
|
2001-12-16 08:23:09 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DOUBLE_CLICK_TEST_ON:
|
|
|
|
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
|
|
|
break;
|
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
double_click_timestamp = event->time;
|
|
|
|
|
|
|
|
switch (double_click_state) {
|
|
|
|
case DOUBLE_CLICK_TEST_ON:
|
2008-01-25 18:29:28 +00:00
|
|
|
gtk_image_set_from_stock (GTK_IMAGE (image),
|
2003-01-08 07:04:42 +00:00
|
|
|
MOUSE_DBLCLCK_ON, mouse_capplet_dblclck_icon_get_size());
|
2001-12-16 08:23:09 +00:00
|
|
|
break;
|
|
|
|
case DOUBLE_CLICK_TEST_MAYBE:
|
2008-01-25 18:29:28 +00:00
|
|
|
gtk_image_set_from_stock (GTK_IMAGE (image),
|
2003-01-08 07:04:42 +00:00
|
|
|
MOUSE_DBLCLCK_MAYBE, mouse_capplet_dblclck_icon_get_size());
|
2001-12-16 08:23:09 +00:00
|
|
|
break;
|
|
|
|
case DOUBLE_CLICK_TEST_OFF:
|
2008-01-25 18:29:28 +00:00
|
|
|
gtk_image_set_from_stock (GTK_IMAGE (image),
|
2003-01-08 07:04:42 +00:00
|
|
|
MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size());
|
2001-12-16 08:23:09 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-09-07 21:45:59 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
return TRUE;
|
2001-09-07 21:45:59 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 13:39:00 +00:00
|
|
|
static void
|
|
|
|
orientation_radio_button_release_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
|
|
|
}
|
|
|
|
|
2008-01-14 16:35:21 +00:00
|
|
|
static GConfValue *
|
|
|
|
left_handed_from_gconf (GConfPropertyEditor *peditor,
|
|
|
|
const GConfValue *value)
|
|
|
|
{
|
|
|
|
GConfValue *new_value;
|
2001-09-07 21:45:59 +00:00
|
|
|
|
2008-01-14 16:35:21 +00:00
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
|
|
|
|
|
|
gconf_value_set_int (new_value, gconf_value_get_bool (value));
|
|
|
|
|
|
|
|
return new_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GConfValue *
|
|
|
|
left_handed_to_gconf (GConfPropertyEditor *peditor,
|
|
|
|
const GConfValue *value)
|
2001-09-07 21:45:59 +00:00
|
|
|
{
|
2008-01-14 16:35:21 +00:00
|
|
|
GConfValue *new_value;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_BOOL);
|
|
|
|
|
|
|
|
gconf_value_set_bool (new_value, gconf_value_get_int (value) == 1);
|
|
|
|
|
|
|
|
return new_value;
|
2001-12-16 08:23:09 +00:00
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
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
|
2001-12-19 14:53:45 +00:00
|
|
|
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
|
2001-12-16 08:23:09 +00:00
|
|
|
{
|
2008-01-14 16:35:21 +00:00
|
|
|
GtkRadioButton *radio;
|
2002-01-08 21:03:07 +00:00
|
|
|
GObject *peditor;
|
2002-02-08 07:05:04 +00:00
|
|
|
|
2008-01-14 16:35:21 +00:00
|
|
|
/* Orientation radio buttons */
|
|
|
|
radio = GTK_RADIO_BUTTON (WID ("left_handed_radio"));
|
|
|
|
peditor = gconf_peditor_new_select_radio
|
|
|
|
(changeset, "/desktop/gnome/peripherals/mouse/left_handed", gtk_radio_button_get_group (radio),
|
|
|
|
"conv-to-widget-cb", left_handed_from_gconf,
|
|
|
|
"conv-from-widget-cb", left_handed_to_gconf,
|
|
|
|
NULL);
|
2008-02-29 13:39:00 +00:00
|
|
|
g_signal_connect (WID ("right_handed_radio"), "button_release_event",
|
|
|
|
G_CALLBACK (orientation_radio_button_release_event), NULL);
|
|
|
|
g_signal_connect (WID ("left_handed_radio"), "button_release_event",
|
|
|
|
G_CALLBACK (orientation_radio_button_release_event), NULL);
|
2005-05-22 15:46:45 +00:00
|
|
|
|
2008-01-14 16:35:21 +00:00
|
|
|
/* Locate pointer toggle */
|
2001-12-19 14:53:45 +00:00
|
|
|
peditor = gconf_peditor_new_boolean
|
2008-01-14 16:35:21 +00:00
|
|
|
(changeset, "/desktop/gnome/peripherals/mouse/locate_pointer", WID ("locate_pointer_toggle"), NULL);
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
/* Double-click time */
|
2003-11-19 06:00:45 +00:00
|
|
|
peditor = gconf_peditor_new_numeric_range
|
|
|
|
(changeset, DOUBLE_CLICK_KEY, WID ("delay_scale"),
|
|
|
|
"conv-to-widget-cb", double_click_from_gconf,
|
|
|
|
NULL);
|
2003-01-08 07:04:42 +00:00
|
|
|
gtk_image_set_from_stock (GTK_IMAGE (WID ("double_click_image")), MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size ());
|
Lots of things. Fix drag threshold preference, use a GtkImage instead of a
2002-05-12 Anders Carlsson <andersca@gnu.org>
* gnome-mouse-properties.c: (drag_threshold_from_gconf),
(drag_threshold_to_gconf), (event_box_button_press_event),
(load_pixbufs), (setup_dialog), (create_dialog),
(dialog_response_cb), (main):
* gnome-mouse-properties.glade:
Lots of things. Fix drag threshold preference, use a GtkImage
instead of a GtkDrawingArea for the double click test. Remove
weird weak refs throughout the code. Clean up the glade file,
requires a new libglade that has an a11y ref count fix.
2002-05-12 09:04:14 +00:00
|
|
|
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), changeset);
|
2006-07-24 12:38:02 +00:00
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
/* speed */
|
2003-11-19 06:00:45 +00:00
|
|
|
gconf_peditor_new_numeric_range
|
2001-12-20 20:14:59 +00:00
|
|
|
(changeset, "/desktop/gnome/peripherals/mouse/motion_acceleration", WID ("accel_scale"),
|
|
|
|
"conv-to-widget-cb", motion_acceleration_from_gconf,
|
|
|
|
"conv-from-widget-cb", motion_acceleration_to_gconf,
|
|
|
|
NULL);
|
2001-12-19 20:18:23 +00:00
|
|
|
|
|
|
|
gconf_peditor_new_numeric_range
|
2002-02-12 06:16:11 +00:00
|
|
|
(changeset, "/desktop/gnome/peripherals/mouse/motion_threshold", WID ("sensitivity_scale"),
|
|
|
|
"conv-to-widget-cb", threshold_from_gconf,
|
|
|
|
NULL);
|
2001-12-20 20:14:59 +00:00
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
/* DnD threshold */
|
2001-12-20 20:14:59 +00:00
|
|
|
gconf_peditor_new_numeric_range
|
|
|
|
(changeset, "/desktop/gnome/peripherals/mouse/drag_threshold", WID ("drag_threshold_scale"),
|
Lots of things. Fix drag threshold preference, use a GtkImage instead of a
2002-05-12 Anders Carlsson <andersca@gnu.org>
* gnome-mouse-properties.c: (drag_threshold_from_gconf),
(drag_threshold_to_gconf), (event_box_button_press_event),
(load_pixbufs), (setup_dialog), (create_dialog),
(dialog_response_cb), (main):
* gnome-mouse-properties.glade:
Lots of things. Fix drag threshold preference, use a GtkImage
instead of a GtkDrawingArea for the double click test. Remove
weird weak refs throughout the code. Clean up the glade file,
requires a new libglade that has an a11y ref count fix.
2002-05-12 09:04:14 +00:00
|
|
|
"conv-to-widget-cb", drag_threshold_from_gconf,
|
2001-12-20 20:14:59 +00:00
|
|
|
NULL);
|
2001-12-19 14:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Construct the dialog */
|
|
|
|
|
|
|
|
static GladeXML *
|
2008-01-25 18:29:28 +00:00
|
|
|
create_dialog (void)
|
2001-12-19 14:53:45 +00:00
|
|
|
{
|
|
|
|
GladeXML *dialog;
|
|
|
|
GtkSizeGroup *size_group;
|
|
|
|
|
2007-02-02 18:12:40 +00:00
|
|
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/gnome-mouse-properties.glade", "mouse_properties_dialog", NULL);
|
2007-02-09 17:34:29 +00:00
|
|
|
if (!dialog)
|
|
|
|
return NULL;
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2001-12-19 14:53:45 +00:00
|
|
|
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"));
|
2008-02-08 16:55:40 +00:00
|
|
|
gtk_size_group_add_widget (size_group, WID ("timeout_label"));
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2008-02-08 16:55:40 +00:00
|
|
|
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"));
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2008-02-08 16:55:40 +00:00
|
|
|
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"));
|
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("simulated_delay_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("dwell_delay_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("dwell_threshold_label"));
|
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("simulated_delay_short_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("dwell_delay_short_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("dwell_threshold_small_label"));
|
|
|
|
|
|
|
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("simulated_delay_long_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("dwell_delay_long_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("dwell_threshold_large_label"));
|
2001-12-19 14:53:45 +00:00
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback issued when a button is clicked on the dialog */
|
|
|
|
|
|
|
|
static void
|
2008-01-25 18:29:28 +00:00
|
|
|
dialog_response_cb (GtkDialog *dialog, gint response_id, GConfChangeSet *changeset)
|
2001-12-19 14:53:45 +00:00
|
|
|
{
|
2002-05-27 02:54:19 +00:00
|
|
|
if (response_id == GTK_RESPONSE_HELP)
|
|
|
|
capplet_help (GTK_WINDOW (dialog),
|
2004-02-12 14:23:03 +00:00
|
|
|
"user-guide.xml",
|
2003-08-11 17:55:34 +00:00
|
|
|
"goscustperiph-5");
|
2002-05-27 02:54:19 +00:00
|
|
|
else
|
2001-12-20 18:21:12 +00:00
|
|
|
gtk_main_quit ();
|
2001-07-25 17:26:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-12-19 14:53:45 +00:00
|
|
|
main (int argc, char **argv)
|
2001-07-25 17:26:17 +00:00
|
|
|
{
|
2007-01-17 10:50:17 +00:00
|
|
|
GnomeProgram *program;
|
2001-12-19 14:53:45 +00:00
|
|
|
GConfClient *client;
|
|
|
|
GladeXML *dialog;
|
2008-03-27 19:23:18 +00:00
|
|
|
GtkWidget *dialog_win, *w;
|
|
|
|
GOptionContext *context;
|
|
|
|
gchar *start_page = NULL;
|
|
|
|
|
|
|
|
GOptionEntry cap_options[] = {
|
|
|
|
{"show-page", 'p', G_OPTION_FLAG_IN_MAIN,
|
|
|
|
G_OPTION_ARG_STRING,
|
|
|
|
&start_page,
|
|
|
|
/* TRANSLATORS: don't translate the terms in brackets */
|
|
|
|
N_("Specify the name of the page to show (general|accessibility)"),
|
|
|
|
N_("page") },
|
|
|
|
{NULL}
|
|
|
|
};
|
2001-12-19 14:53:45 +00:00
|
|
|
|
2002-02-27 22:17:05 +00:00
|
|
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
|
|
|
textdomain (GETTEXT_PACKAGE);
|
2001-12-19 14:53:45 +00:00
|
|
|
|
2008-03-27 19:23:18 +00:00
|
|
|
context = g_option_context_new (_("- GNOME Mouse Preferences"));
|
|
|
|
g_option_context_add_main_entries (context, cap_options,
|
|
|
|
GETTEXT_PACKAGE);
|
|
|
|
|
2007-01-17 10:50:17 +00:00
|
|
|
program = gnome_program_init ("gnome-mouse-properties", VERSION,
|
|
|
|
LIBGNOMEUI_MODULE, argc, argv,
|
2008-03-27 19:23:18 +00:00
|
|
|
GNOME_PARAM_GOPTION_CONTEXT, context,
|
2007-01-17 10:50:17 +00:00
|
|
|
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
|
|
|
NULL);
|
2001-12-16 08:23:09 +00:00
|
|
|
|
2003-01-08 07:04:42 +00:00
|
|
|
capplet_init_stock_icons ();
|
2002-11-02 19:03:15 +00:00
|
|
|
|
2002-03-11 01:46:13 +00:00
|
|
|
activate_settings_daemon ();
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
client = gconf_client_get_default ();
|
|
|
|
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2007-02-09 17:34:29 +00:00
|
|
|
dialog = create_dialog ();
|
|
|
|
|
|
|
|
if (dialog) {
|
|
|
|
setup_dialog (dialog, NULL);
|
2008-01-14 16:35:21 +00:00
|
|
|
setup_accessibility (dialog, client);
|
2001-12-19 14:53:45 +00:00
|
|
|
|
Lots of things. Fix drag threshold preference, use a GtkImage instead of a
2002-05-12 Anders Carlsson <andersca@gnu.org>
* gnome-mouse-properties.c: (drag_threshold_from_gconf),
(drag_threshold_to_gconf), (event_box_button_press_event),
(load_pixbufs), (setup_dialog), (create_dialog),
(dialog_response_cb), (main):
* gnome-mouse-properties.glade:
Lots of things. Fix drag threshold preference, use a GtkImage
instead of a GtkDrawingArea for the double click test. Remove
weird weak refs throughout the code. Clean up the glade file,
requires a new libglade that has an a11y ref count fix.
2002-05-12 09:04:14 +00:00
|
|
|
dialog_win = WID ("mouse_properties_dialog");
|
|
|
|
g_signal_connect (dialog_win, "response",
|
2007-02-09 17:34:29 +00:00
|
|
|
G_CALLBACK (dialog_response_cb), NULL);
|
2001-12-20 18:21:12 +00:00
|
|
|
|
2008-03-27 19:23:18 +00:00
|
|
|
if (start_page != NULL) {
|
|
|
|
gchar *page_name;
|
|
|
|
|
|
|
|
page_name = g_strconcat (start_page, "_vbox", NULL);
|
|
|
|
g_free (start_page);
|
|
|
|
|
|
|
|
w = WID (page_name);
|
|
|
|
if (w != NULL) {
|
|
|
|
GtkNotebook *nb;
|
|
|
|
gint pindex;
|
|
|
|
|
|
|
|
nb = GTK_NOTEBOOK (WID ("prefs_widget"));
|
|
|
|
pindex = gtk_notebook_page_num (nb, w);
|
|
|
|
if (pindex != -1)
|
|
|
|
gtk_notebook_set_current_page (nb, pindex);
|
|
|
|
}
|
|
|
|
g_free (page_name);
|
|
|
|
}
|
|
|
|
|
2004-08-20 16:50:57 +00:00
|
|
|
capplet_set_icon (dialog_win, "gnome-dev-mouse-optical");
|
2003-08-01 17:36:57 +00:00
|
|
|
gtk_widget_show (dialog_win);
|
2001-12-19 14:53:45 +00:00
|
|
|
|
|
|
|
gtk_main ();
|
2007-01-17 10:50:17 +00:00
|
|
|
|
|
|
|
g_object_unref (dialog);
|
2001-12-19 14:53:45 +00:00
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2008-01-14 16:35:21 +00:00
|
|
|
g_object_unref (client);
|
2007-01-17 10:50:17 +00:00
|
|
|
g_object_unref (program);
|
|
|
|
|
2001-07-25 17:26:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|