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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
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>
|
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"
|
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DOUBLE_CLICK_TEST_OFF,
|
|
|
|
DOUBLE_CLICK_TEST_MAYBE,
|
|
|
|
DOUBLE_CLICK_TEST_ON,
|
|
|
|
};
|
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLUMN_PIXBUF,
|
|
|
|
COLUMN_TEXT,
|
|
|
|
N_COLUMNS
|
|
|
|
};
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
/* Write-once data; global for convenience. Set only by load_pixbufs */
|
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
GdkPixbuf *left_handed_pixbuf;
|
|
|
|
GdkPixbuf *right_handed_pixbuf;
|
|
|
|
GdkPixbuf *double_click_on_pixbuf;
|
|
|
|
GdkPixbuf *double_click_maybe_pixbuf;
|
|
|
|
GdkPixbuf *double_click_off_pixbuf;
|
2002-01-08 21:03:07 +00:00
|
|
|
GConfClient *client;
|
2001-12-19 14:53:45 +00:00
|
|
|
/* State in testing the double-click speed. Global for a great deal of
|
|
|
|
* convenience
|
|
|
|
*/
|
|
|
|
gint double_click_state = DOUBLE_CLICK_TEST_OFF;
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
/* normalilzation routines */
|
|
|
|
/* 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 *
|
|
|
|
double_click_from_gconf (const GConfValue *value)
|
2001-07-25 17:26:17 +00:00
|
|
|
{
|
2001-12-19 20:18:23 +00:00
|
|
|
GConfValue *new_value;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
|
|
|
|
gconf_value_set_float (new_value, CLAMP (floor ((gconf_value_get_int (value) + 50) / 100) * 100, 0, 1000) / 1000.0);
|
|
|
|
return new_value;
|
2001-12-19 14:53:45 +00:00
|
|
|
}
|
|
|
|
|
2001-12-19 20:18:23 +00:00
|
|
|
static GConfValue *
|
|
|
|
double_click_to_gconf (const GConfValue *value)
|
2001-12-19 14:53:45 +00:00
|
|
|
{
|
2001-12-19 20:18:23 +00:00
|
|
|
GConfValue *new_value;
|
|
|
|
|
|
|
|
new_value = gconf_value_new (GCONF_VALUE_INT);
|
|
|
|
gconf_value_set_int (new_value, gconf_value_get_float (value) * 1000.0);
|
|
|
|
return new_value;
|
2001-12-16 08:23:09 +00:00
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-19 20:18:23 +00:00
|
|
|
static GConfValue *
|
|
|
|
motion_acceleration_from_gconf (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), 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 *
|
|
|
|
motion_acceleration_to_gconf (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 *
|
|
|
|
threshold_from_gconf (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);
|
|
|
|
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
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* Retrieve legacy settings */
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_legacy_settings (void)
|
|
|
|
{
|
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
/* Double Click handling */
|
2001-08-22 13:56:23 +00:00
|
|
|
|
2001-12-19 14:53:45 +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;
|
2001-12-16 08:23:09 +00:00
|
|
|
GtkWidget *darea;
|
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;
|
2001-12-19 14:53:45 +00:00
|
|
|
gtk_widget_queue_draw (data->darea);
|
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. */
|
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
static gint
|
|
|
|
drawing_area_button_press_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
2001-12-19 14:53:45 +00:00
|
|
|
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;
|
|
|
|
static guint test_on_timeout_id = 0;
|
|
|
|
static guint test_maybe_timeout_id = 0;
|
|
|
|
static guint32 double_click_timestamp = 0;
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
if (event->type != GDK_BUTTON_PRESS)
|
|
|
|
return FALSE;
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
if (!gconf_change_set_check_value (changeset, DOUBLE_CLICK_KEY, &value))
|
|
|
|
double_click_time = gconf_client_get_int (gconf_client_get_default (), DOUBLE_CLICK_KEY, NULL);
|
|
|
|
else
|
|
|
|
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;
|
2001-12-19 14:53:45 +00:00
|
|
|
data.darea = widget;
|
|
|
|
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;
|
2001-12-19 14:53:45 +00:00
|
|
|
data.darea = widget;
|
|
|
|
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;
|
2001-12-19 14:53:45 +00:00
|
|
|
gtk_widget_queue_draw (widget);
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
return TRUE;
|
2001-07-25 17:26:17 +00:00
|
|
|
}
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* Callback to display the appropriate image on the double click testing area. */
|
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
static gint
|
|
|
|
drawing_area_expose_event (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event,
|
2001-12-19 14:53:45 +00:00
|
|
|
GConfChangeSet *changeset)
|
2001-09-07 21:45:59 +00:00
|
|
|
{
|
2001-12-19 14:53:45 +00:00
|
|
|
static gboolean first_time = TRUE;
|
2002-02-04 17:48:43 +00:00
|
|
|
GdkPixbuf *pixbuf = NULL;
|
2001-09-07 21:45:59 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
if (first_time) {
|
|
|
|
gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | GDK_BUTTON_PRESS_MASK);
|
2001-12-19 14:53:45 +00:00
|
|
|
g_signal_connect (G_OBJECT (widget), "button_press_event", (GCallback) drawing_area_button_press_event, changeset);
|
|
|
|
first_time = FALSE;
|
2001-09-07 21:45:59 +00:00
|
|
|
}
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
gdk_draw_rectangle (widget->window, widget->style->white_gc,
|
2001-12-16 08:23:09 +00:00
|
|
|
TRUE, 0, 0,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height);
|
|
|
|
|
|
|
|
switch (double_click_state) {
|
|
|
|
case DOUBLE_CLICK_TEST_ON:
|
|
|
|
pixbuf = double_click_on_pixbuf;
|
|
|
|
break;
|
|
|
|
case DOUBLE_CLICK_TEST_MAYBE:
|
|
|
|
pixbuf = double_click_maybe_pixbuf;
|
|
|
|
break;
|
|
|
|
case DOUBLE_CLICK_TEST_OFF:
|
|
|
|
pixbuf = double_click_off_pixbuf;
|
|
|
|
break;
|
|
|
|
}
|
2001-09-07 21:45:59 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
gdk_pixbuf_render_to_drawable_alpha
|
|
|
|
(pixbuf, widget->window,
|
|
|
|
0, 0,
|
|
|
|
(widget->allocation.width - gdk_pixbuf_get_width (pixbuf)) / 2,
|
|
|
|
(widget->allocation.height - gdk_pixbuf_get_height (pixbuf)) / 2,
|
|
|
|
-1, -1, GDK_PIXBUF_ALPHA_FULL, 0, GDK_RGB_DITHER_NORMAL, 0, 0);
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2001-09-07 21:45:59 +00:00
|
|
|
}
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* Callback issued when the user switches between left- and right-handed button
|
|
|
|
* mappings. Updates the appropriate image on the dialog.
|
|
|
|
*/
|
2001-09-07 21:45:59 +00:00
|
|
|
|
2001-12-16 08:23:09 +00:00
|
|
|
static void
|
2001-12-19 14:53:45 +00:00
|
|
|
left_handed_toggle_cb (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *image)
|
2001-09-07 21:45:59 +00:00
|
|
|
{
|
2002-02-05 11:13:58 +00:00
|
|
|
if (value && gconf_value_get_bool (value))
|
2001-12-16 08:23:09 +00:00
|
|
|
g_object_set (G_OBJECT (image),
|
|
|
|
"pixbuf", left_handed_pixbuf,
|
|
|
|
NULL);
|
|
|
|
else
|
|
|
|
g_object_set (G_OBJECT (image),
|
|
|
|
"pixbuf", right_handed_pixbuf,
|
|
|
|
NULL);
|
2001-09-07 21:45:59 +00:00
|
|
|
}
|
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* Load the pixbufs we are going to use */
|
2001-07-25 17:26:17 +00:00
|
|
|
|
|
|
|
static void
|
2001-12-19 14:53:45 +00:00
|
|
|
load_pixbufs (void)
|
2001-07-25 17:26:17 +00:00
|
|
|
{
|
2001-12-19 14:53:45 +00:00
|
|
|
static gboolean called = FALSE;
|
2001-12-20 18:52:39 +00:00
|
|
|
gchar *filename;
|
|
|
|
GnomeProgram *program;
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
if (called) return;
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-20 18:52:39 +00:00
|
|
|
program = gnome_program_get ();
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-20 18:52:39 +00:00
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-left.png", TRUE, NULL);
|
|
|
|
left_handed_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (left_handed_pixbuf), (gpointer *) &left_handed_pixbuf);
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-right.png", TRUE, NULL);
|
|
|
|
right_handed_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (right_handed_pixbuf), (gpointer *) &right_handed_pixbuf);
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "double-click-on.png", TRUE, NULL);
|
|
|
|
double_click_on_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (double_click_on_pixbuf), (gpointer *) &double_click_on_pixbuf);
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "double-click-maybe.png", TRUE, NULL);
|
|
|
|
double_click_maybe_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
2001-12-19 14:53:45 +00:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (double_click_maybe_pixbuf), (gpointer *) &double_click_maybe_pixbuf);
|
2001-12-20 18:52:39 +00:00
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "double-click-off.png", TRUE, NULL);
|
|
|
|
double_click_off_pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (double_click_off_pixbuf), (gpointer *) &double_click_off_pixbuf);
|
|
|
|
g_free (filename);
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
called = TRUE;
|
2001-12-16 08:23:09 +00:00
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
2001-12-19 14:53:45 +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
|
|
|
{
|
2002-01-08 21:03:07 +00:00
|
|
|
GObject *peditor;
|
|
|
|
GtkWidget *tree_view;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GConfValue *value;
|
2002-02-08 07:05:04 +00:00
|
|
|
gchar *filename;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
GnomeProgram *program;
|
|
|
|
|
|
|
|
program = gnome_program_get ();
|
2002-01-08 21:03:07 +00:00
|
|
|
|
|
|
|
/* Buttons page */
|
2001-12-16 08:23:09 +00:00
|
|
|
/* Left-handed toggle */
|
2001-12-19 14:53:45 +00:00
|
|
|
peditor = gconf_peditor_new_boolean
|
2001-12-20 20:14:59 +00:00
|
|
|
(changeset, "/desktop/gnome/peripherals/mouse/left_handed", WID ("left_handed_toggle"), NULL);
|
2001-12-19 14:53:45 +00:00
|
|
|
g_signal_connect (peditor, "value-changed", (GCallback) left_handed_toggle_cb, WID ("orientation_image"));
|
2001-12-16 08:23:09 +00:00
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
/* Make sure the image gets initialized correctly */
|
|
|
|
value = gconf_client_get (gconf_client_get_default (), "/desktop/gnome/peripherals/mouse/left_handed", NULL);
|
|
|
|
left_handed_toggle_cb (GCONF_PROPERTY_EDITOR (peditor), NULL, value, WID ("orientation_image"));
|
|
|
|
gconf_value_free (value);
|
2001-12-16 08:23:09 +00:00
|
|
|
|
|
|
|
/* Double-click time */
|
2001-12-19 14:53:45 +00:00
|
|
|
g_signal_connect (WID ("double_click_darea"), "expose_event", (GCallback) drawing_area_expose_event, changeset);
|
|
|
|
|
2002-01-08 21:03:07 +00:00
|
|
|
/* Cursors page */
|
|
|
|
tree_view = WID ("cursor_tree");
|
2002-02-04 17:48:43 +00:00
|
|
|
model = (GtkTreeModel *) gtk_list_store_new (N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING);
|
2002-01-08 21:03:07 +00:00
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), model);
|
|
|
|
column = gtk_tree_view_column_new ();
|
|
|
|
renderer = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer, FALSE);
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
|
|
|
"pixbuf", COLUMN_PIXBUF,
|
|
|
|
NULL);
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
|
|
|
gtk_tree_view_column_pack_start (column, renderer, TRUE);
|
|
|
|
gtk_tree_view_column_set_attributes (column, renderer,
|
|
|
|
"markup", COLUMN_TEXT,
|
|
|
|
NULL);
|
2002-02-08 07:05:04 +00:00
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-cursor-normal.png", TRUE, NULL);
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_free (filename);
|
2002-01-08 21:03:07 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
2002-02-08 07:05:04 +00:00
|
|
|
COLUMN_PIXBUF, pixbuf,
|
2002-01-08 21:03:07 +00:00
|
|
|
COLUMN_TEXT, "<b>Default Cursor</b>\nThe default cursor that ships with X",
|
|
|
|
-1);
|
2002-02-08 07:05:04 +00:00
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-cursor-white.png", TRUE, NULL);
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_free (filename);
|
2002-01-08 21:03:07 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
2002-02-08 07:05:04 +00:00
|
|
|
COLUMN_PIXBUF, pixbuf,
|
2002-01-08 21:03:07 +00:00
|
|
|
COLUMN_TEXT, "<b>White Cursor</b>\nThe default cursor inverted",
|
|
|
|
-1);
|
2002-02-08 07:05:04 +00:00
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-cursor-normal-large.png", TRUE, NULL);
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_free (filename);
|
2002-01-08 21:03:07 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
2002-02-08 07:05:04 +00:00
|
|
|
COLUMN_PIXBUF, pixbuf,
|
2002-01-08 21:03:07 +00:00
|
|
|
COLUMN_TEXT, "<b>Large Cursor</b>\nLarge version of normal cursor",
|
|
|
|
-1);
|
2002-02-08 07:05:04 +00:00
|
|
|
|
|
|
|
filename = gnome_program_locate_file (program, GNOME_FILE_DOMAIN_APP_PIXMAP, "mouse-cursor-white-large.png", TRUE, NULL);
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
|
|
|
g_free (filename);
|
2002-01-08 21:03:07 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
2002-02-08 07:05:04 +00:00
|
|
|
COLUMN_PIXBUF, pixbuf,
|
2002-01-08 21:03:07 +00:00
|
|
|
COLUMN_TEXT, "<b>Large White Cursor</b>\nLarge version of white cursor",
|
|
|
|
-1);
|
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
|
|
|
|
|
|
|
|
|
|
|
gconf_peditor_new_boolean
|
|
|
|
(changeset, "/desktop/gnome/peripherals/mouse/locate_pointer_id", WID ("locate_pointer_toggle"), NULL);
|
|
|
|
/* Motion page */
|
|
|
|
/* speed */
|
2001-12-20 20:14:59 +00:00
|
|
|
gconf_peditor_new_numeric_range
|
|
|
|
(changeset, DOUBLE_CLICK_KEY, WID ("delay_scale"),
|
|
|
|
"conv-to-widget-cb", double_click_from_gconf,
|
|
|
|
"conv-from-widget-cb", double_click_to_gconf,
|
|
|
|
NULL);
|
2001-12-19 20:18:23 +00:00
|
|
|
|
2001-12-20 20:14:59 +00:00
|
|
|
gconf_peditor_new_numeric_range
|
|
|
|
(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,
|
|
|
|
"conv-from-widget-cb", gconf_value_float_to_int,
|
|
|
|
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"),
|
|
|
|
"conv-to-widget-cb", threshold_from_gconf,
|
|
|
|
"conv-from-widget-cb", gconf_value_float_to_int,
|
|
|
|
NULL);
|
2001-12-19 14:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Construct the dialog */
|
|
|
|
|
|
|
|
static GladeXML *
|
|
|
|
create_dialog (void)
|
|
|
|
{
|
|
|
|
GtkWidget *widget;
|
|
|
|
GladeXML *dialog;
|
|
|
|
GtkSizeGroup *size_group;
|
|
|
|
|
2002-01-08 21:24:41 +00:00
|
|
|
dialog = glade_xml_new (GNOMECC_DATA_DIR "/interfaces/gnome-mouse-properties.glade", "prefs_widget", NULL);
|
2001-12-19 14:53:45 +00:00
|
|
|
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
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"));
|
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 ("high_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("fast_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("large_label"));
|
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 ("low_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("slow_label"));
|
|
|
|
gtk_size_group_add_widget (size_group, WID ("small_label"));
|
|
|
|
|
|
|
|
g_object_weak_ref (G_OBJECT (widget), (GWeakNotify) g_object_unref, dialog);
|
|
|
|
|
|
|
|
return dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback issued when a button is clicked on the dialog */
|
|
|
|
|
|
|
|
static void
|
2002-02-04 17:48:43 +00:00
|
|
|
dialog_button_clicked_cb (GtkDialog *dialog, gint response_id, GConfChangeSet *changeset)
|
2001-12-19 14:53:45 +00:00
|
|
|
{
|
2001-12-20 18:21:12 +00:00
|
|
|
switch (response_id) {
|
|
|
|
case GTK_RESPONSE_CLOSE:
|
2002-02-12 06:16:11 +00:00
|
|
|
default:
|
2001-12-20 18:21:12 +00:00
|
|
|
gtk_main_quit ();
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
{
|
2001-12-19 14:53:45 +00:00
|
|
|
GConfClient *client;
|
|
|
|
GConfChangeSet *changeset;
|
|
|
|
GladeXML *dialog;
|
|
|
|
GtkWidget *dialog_win;
|
|
|
|
|
|
|
|
static gboolean get_legacy;
|
|
|
|
static struct poptOption cap_options[] = {
|
|
|
|
{ "get-legacy", '\0', POPT_ARG_NONE, &get_legacy, 0,
|
|
|
|
N_("Retrieve and store legacy settings"), NULL },
|
|
|
|
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
|
|
|
bind_textdomain_codeset (PACKAGE, "UTF-8");
|
|
|
|
textdomain (PACKAGE);
|
|
|
|
|
|
|
|
gnome_program_init (argv[0], VERSION, LIBGNOMEUI_MODULE, argc, argv,
|
|
|
|
GNOME_PARAM_POPT_TABLE, cap_options,
|
2001-12-20 18:52:39 +00:00
|
|
|
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
|
2001-12-16 08:23:09 +00:00
|
|
|
NULL);
|
|
|
|
|
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
|
|
|
|
2001-12-19 14:53:45 +00:00
|
|
|
if (get_legacy) {
|
|
|
|
get_legacy_settings ();
|
|
|
|
} else {
|
2002-02-12 06:16:11 +00:00
|
|
|
changeset = NULL;
|
2001-12-19 14:53:45 +00:00
|
|
|
dialog = create_dialog ();
|
|
|
|
load_pixbufs ();
|
|
|
|
setup_dialog (dialog, changeset);
|
|
|
|
|
2001-12-20 18:21:12 +00:00
|
|
|
dialog_win = gtk_dialog_new_with_buttons
|
2002-01-08 21:03:07 +00:00
|
|
|
(_("Mouse Properties"), NULL, -1,
|
2001-12-20 18:21:12 +00:00
|
|
|
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (dialog_win), "response", (GCallback) dialog_button_clicked_cb, changeset);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_win)->vbox), WID ("prefs_widget"), TRUE, TRUE, GNOME_PAD_SMALL);
|
2001-12-19 14:53:45 +00:00
|
|
|
gtk_widget_show_all (dialog_win);
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
}
|
2001-07-25 17:26:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|