Divide by 1000.0, use floats (double_click_to_gconf): Implement
2001-12-19 Bradford Hovinen <hovinen@ximian.com> * mouse-properties-capplet.c (double_click_from_gconf): Divide by 1000.0, use floats (double_click_to_gconf): Implement (drawing_area_button_press_event): Don't call double_click_from_gconf (drawing_area_button_press_event): Use response of gconf_change_set_check_value to determine if value is in changeset 2001-12-18 Bradford Hovinen <hovinen@ximian.com> * mouse-properties-capplet.c (double_click_from_gconf): Single closed-form formula here Code reorganization; many changes
This commit is contained in:
parent
c1a1e50573
commit
b8fd80b0a1
4 changed files with 1301 additions and 1040 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
2001-12-19 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* mouse-properties-capplet.c (double_click_from_gconf): Divide by
|
||||||
|
1000.0, use floats
|
||||||
|
(double_click_to_gconf): Implement
|
||||||
|
(drawing_area_button_press_event): Don't call
|
||||||
|
double_click_from_gconf
|
||||||
|
(drawing_area_button_press_event): Use response of
|
||||||
|
gconf_change_set_check_value to determine if value is in changeset
|
||||||
|
|
||||||
|
2001-12-18 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* mouse-properties-capplet.c (double_click_from_gconf): Single
|
||||||
|
closed-form formula here
|
||||||
|
Code reorganization; many changes
|
||||||
|
|
||||||
2001-10-18 Bradford Hovinen <hovinen@ximian.com>
|
2001-10-18 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
* mouse-properties-capplet.c (apply_settings): Only swap buttons 1
|
* mouse-properties-capplet.c (apply_settings): Only swap buttons 1
|
||||||
|
|
|
@ -1,8 +1,40 @@
|
||||||
|
/* -*- 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
|
||||||
|
|
||||||
#include <gnome.h>
|
#include <gnome.h>
|
||||||
#include <gconf/gconf-client.h>
|
#include <gconf/gconf-client.h>
|
||||||
#include <glade/glade.h>
|
#include <glade/glade.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "capplet-util.h"
|
||||||
|
#include "gconf-property-editor.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DOUBLE_CLICK_TEST_OFF,
|
DOUBLE_CLICK_TEST_OFF,
|
||||||
|
@ -10,111 +42,119 @@ enum
|
||||||
DOUBLE_CLICK_TEST_ON,
|
DOUBLE_CLICK_TEST_ON,
|
||||||
};
|
};
|
||||||
|
|
||||||
GladeXML *xml;
|
/* 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 */
|
||||||
|
|
||||||
GdkPixbuf *left_handed_pixbuf;
|
GdkPixbuf *left_handed_pixbuf;
|
||||||
GdkPixbuf *right_handed_pixbuf;
|
GdkPixbuf *right_handed_pixbuf;
|
||||||
GdkPixbuf *double_click_on_pixbuf;
|
GdkPixbuf *double_click_on_pixbuf;
|
||||||
GdkPixbuf *double_click_maybe_pixbuf;
|
GdkPixbuf *double_click_maybe_pixbuf;
|
||||||
GdkPixbuf *double_click_off_pixbuf;
|
GdkPixbuf *double_click_off_pixbuf;
|
||||||
GConfClient *client;
|
|
||||||
|
/* State in testing the double-click speed. Global for a great deal of
|
||||||
|
* convenience
|
||||||
|
*/
|
||||||
|
|
||||||
gint double_click_state = DOUBLE_CLICK_TEST_OFF;
|
gint double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||||
guint32 double_click_timestamp = 0;
|
|
||||||
guint test_maybe_timeout_id = 0;
|
|
||||||
guint test_on_timeout_id = 0;
|
|
||||||
|
|
||||||
#define LEFT_HANDED_KEY "/desktop/gnome/peripherals/mouse/left_handed"
|
|
||||||
#define DOUBLE_CLICK_KEY "/desktop/gnome/peripherals/mouse/double_click"
|
|
||||||
#define MOTION_ACCELERATION_KEY "/desktop/gnome/peripherals/mouse/motion_acceleration"
|
|
||||||
#define MOTION_THRESHOLD_KEY "/desktop/gnome/peripherals/mouse/motion_threshold"
|
|
||||||
#define DRAG_THRESHOLD_KEY "/desktop/gnome/peripherals/mouse/drag_threshold"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* normalilzation routines */
|
/* normalilzation routines */
|
||||||
/* All of our scales but double_click are on the range 1->10 as a result, we
|
/* 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.
|
* have a few routines to convert from whatever the gconf key is to our range.
|
||||||
*/
|
*/
|
||||||
static gint
|
static gfloat
|
||||||
double_click_from_gconf (gint double_click)
|
double_click_from_gconf (gfloat double_click)
|
||||||
{
|
{
|
||||||
/* watch me be lazy */
|
return CLAMP (floor ((double_click + 50) / 100) * 100, 0, 1000) / 1000.0;
|
||||||
if (double_click < 150)
|
}
|
||||||
return 100;
|
|
||||||
else if (double_click < 250)
|
static gfloat
|
||||||
return 200;
|
double_click_to_gconf (gfloat double_click)
|
||||||
else if (double_click < 350)
|
{
|
||||||
return 300;
|
return double_click * 1000.0;
|
||||||
else if (double_click < 450)
|
|
||||||
return 400;
|
|
||||||
else if (double_click < 550)
|
|
||||||
return 500;
|
|
||||||
else if (double_click < 650)
|
|
||||||
return 600;
|
|
||||||
else if (double_click < 750)
|
|
||||||
return 700;
|
|
||||||
else if (double_click < 850)
|
|
||||||
return 800;
|
|
||||||
else if (double_click < 950)
|
|
||||||
return 900;
|
|
||||||
else
|
|
||||||
return 1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfloat
|
static gfloat
|
||||||
motion_acceleration_from_gconf (gfloat motion_acceleration)
|
motion_acceleration_from_gconf (gfloat motion_acceleration)
|
||||||
{
|
{
|
||||||
motion_acceleration = CLAMP (motion_acceleration, 0.2, 6.0);
|
motion_acceleration = CLAMP (motion_acceleration, 0.2, 6.0);
|
||||||
if (motion_acceleration >=1)
|
|
||||||
|
if (motion_acceleration >= 1)
|
||||||
return motion_acceleration + 4;
|
return motion_acceleration + 4;
|
||||||
return motion_acceleration * 5;
|
else
|
||||||
|
return motion_acceleration * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfloat
|
static gfloat
|
||||||
motion_acceleration_to_gconf (gfloat motion_acceleration)
|
motion_acceleration_to_gconf (gfloat motion_acceleration)
|
||||||
{
|
{
|
||||||
motion_acceleration = CLAMP (motion_acceleration, 1.0, 10.0);
|
motion_acceleration = CLAMP (motion_acceleration, 1.0, 10.0);
|
||||||
|
|
||||||
if (motion_acceleration < 5)
|
if (motion_acceleration < 5)
|
||||||
return motion_acceleration / 5.0;
|
return motion_acceleration / 5.0;
|
||||||
return motion_acceleration - 4;
|
else
|
||||||
|
return motion_acceleration - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfloat
|
static gfloat
|
||||||
threshold_from_gconf (gfloat drag_threshold)
|
threshold_from_gconf (gfloat drag_threshold)
|
||||||
{
|
{
|
||||||
return CLAMP (drag_threshold, 1, 10);
|
return CLAMP (drag_threshold, 1, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Retrieve legacy settings */
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_legacy_settings (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* Double Click handling */
|
/* Double Click handling */
|
||||||
|
|
||||||
static gboolean
|
struct test_data_t
|
||||||
test_maybe_timeout (gpointer data)
|
|
||||||
{
|
{
|
||||||
|
gint *timeout_id;
|
||||||
GtkWidget *darea;
|
GtkWidget *darea;
|
||||||
darea = glade_xml_get_widget (xml, "double_click_darea");
|
};
|
||||||
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
|
||||||
gtk_widget_queue_draw (darea);
|
|
||||||
|
|
||||||
*((gint *)data) = 0;
|
/* Timeout for the double click test */
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
test_maybe_timeout (struct test_data_t *data)
|
||||||
|
{
|
||||||
|
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||||
|
gtk_widget_queue_draw (data->darea);
|
||||||
|
|
||||||
|
*data->timeout_id = 0;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback issued when the user clicks the double click testing area. */
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
drawing_area_button_press_event (GtkWidget *widget,
|
drawing_area_button_press_event (GtkWidget *widget,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
gpointer data)
|
GConfChangeSet *changeset)
|
||||||
{
|
{
|
||||||
GtkWidget *scale;
|
gint double_click_time;
|
||||||
GtkWidget *darea;
|
GConfValue *value;
|
||||||
gint double_click_time;
|
|
||||||
|
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;
|
||||||
|
|
||||||
if (event->type != GDK_BUTTON_PRESS)
|
if (event->type != GDK_BUTTON_PRESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
scale = glade_xml_get_widget (xml, "delay_scale");
|
if (!gconf_change_set_check_value (changeset, DOUBLE_CLICK_KEY, &value))
|
||||||
double_click_time = 1000 * gtk_range_get_value (GTK_RANGE (scale));
|
double_click_time = gconf_client_get_int (gconf_client_get_default (), DOUBLE_CLICK_KEY, NULL);
|
||||||
darea = glade_xml_get_widget (xml, "double_click_darea");
|
else
|
||||||
|
double_click_time = gconf_value_get_int (value);
|
||||||
|
|
||||||
if (test_maybe_timeout_id != 0)
|
if (test_maybe_timeout_id != 0)
|
||||||
gtk_timeout_remove (test_maybe_timeout_id);
|
gtk_timeout_remove (test_maybe_timeout_id);
|
||||||
|
@ -124,12 +164,16 @@ drawing_area_button_press_event (GtkWidget *widget,
|
||||||
switch (double_click_state) {
|
switch (double_click_state) {
|
||||||
case DOUBLE_CLICK_TEST_OFF:
|
case DOUBLE_CLICK_TEST_OFF:
|
||||||
double_click_state = DOUBLE_CLICK_TEST_MAYBE;
|
double_click_state = DOUBLE_CLICK_TEST_MAYBE;
|
||||||
test_maybe_timeout_id = gtk_timeout_add (double_click_time, test_maybe_timeout, &test_maybe_timeout_id);
|
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);
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_MAYBE:
|
case DOUBLE_CLICK_TEST_MAYBE:
|
||||||
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 = DOUBLE_CLICK_TEST_ON;
|
||||||
test_on_timeout_id = gtk_timeout_add (2500, test_maybe_timeout, &test_on_timeout_id);
|
data.darea = widget;
|
||||||
|
data.timeout_id = &test_on_timeout_id;
|
||||||
|
test_on_timeout_id = gtk_timeout_add (2500, (GtkFunction) test_maybe_timeout, &data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_ON:
|
case DOUBLE_CLICK_TEST_ON:
|
||||||
|
@ -138,27 +182,29 @@ drawing_area_button_press_event (GtkWidget *widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
double_click_timestamp = event->time;
|
double_click_timestamp = event->time;
|
||||||
gtk_widget_queue_draw (darea);
|
gtk_widget_queue_draw (widget);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback to display the appropriate image on the double click testing area. */
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
drawing_area_expose_event (GtkWidget *widget,
|
drawing_area_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event,
|
GdkEventExpose *event,
|
||||||
gpointer data)
|
GConfChangeSet *changeset)
|
||||||
{
|
{
|
||||||
static gboolean first_time = 1;
|
static gboolean first_time = TRUE;
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
if (first_time) {
|
if (first_time) {
|
||||||
gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | GDK_BUTTON_PRESS_MASK);
|
gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | GDK_BUTTON_PRESS_MASK);
|
||||||
g_signal_connect (widget, "button_press_event", (GCallback) drawing_area_button_press_event, NULL);
|
g_signal_connect (G_OBJECT (widget), "button_press_event", (GCallback) drawing_area_button_press_event, changeset);
|
||||||
first_time = 0;
|
first_time = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_draw_rectangle (widget->window,
|
gdk_draw_rectangle (widget->window, widget->style->white_gc,
|
||||||
widget->style->white_gc,
|
|
||||||
TRUE, 0, 0,
|
TRUE, 0, 0,
|
||||||
widget->allocation.width,
|
widget->allocation.width,
|
||||||
widget->allocation.height);
|
widget->allocation.height);
|
||||||
|
@ -175,30 +221,24 @@ drawing_area_expose_event (GtkWidget *widget,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_pixbuf_render_to_drawable_alpha (pixbuf,
|
gdk_pixbuf_render_to_drawable_alpha
|
||||||
widget->window,
|
(pixbuf, widget->window,
|
||||||
0, 0,
|
0, 0,
|
||||||
(widget->allocation.width - gdk_pixbuf_get_width (pixbuf))/2,
|
(widget->allocation.width - gdk_pixbuf_get_width (pixbuf)) / 2,
|
||||||
(widget->allocation.height - gdk_pixbuf_get_height (pixbuf))/2,
|
(widget->allocation.height - gdk_pixbuf_get_height (pixbuf)) / 2,
|
||||||
-1, -1,
|
-1, -1, GDK_PIXBUF_ALPHA_FULL, 0, GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||||
GDK_PIXBUF_ALPHA_FULL,
|
|
||||||
0,
|
|
||||||
GDK_RGB_DITHER_NORMAL,
|
|
||||||
0, 0);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback issued when the user switches between left- and right-handed button
|
||||||
|
* mappings. Updates the appropriate image on the dialog.
|
||||||
/* capplet->gconf settings */
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
left_handed_toggle_callback (GtkWidget *toggle, gpointer data)
|
left_handed_toggle_cb (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *image)
|
||||||
{
|
{
|
||||||
GtkWidget *image;
|
if (gconf_value_get_bool (value))
|
||||||
image = glade_xml_get_widget (xml, "orientation_image");
|
|
||||||
if (GTK_TOGGLE_BUTTON (toggle)->active)
|
|
||||||
g_object_set (G_OBJECT (image),
|
g_object_set (G_OBJECT (image),
|
||||||
"pixbuf", left_handed_pixbuf,
|
"pixbuf", left_handed_pixbuf,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -206,238 +246,170 @@ left_handed_toggle_callback (GtkWidget *toggle, gpointer data)
|
||||||
g_object_set (G_OBJECT (image),
|
g_object_set (G_OBJECT (image),
|
||||||
"pixbuf", right_handed_pixbuf,
|
"pixbuf", right_handed_pixbuf,
|
||||||
NULL);
|
NULL);
|
||||||
gconf_client_set_bool (client, LEFT_HANDED_KEY,
|
|
||||||
GTK_TOGGLE_BUTTON (toggle)->active,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Load the pixbufs we are going to use */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
double_click_callback (GtkAdjustment *adjustment, gpointer data)
|
load_pixbufs (void)
|
||||||
{
|
{
|
||||||
gint double_click;
|
static gboolean called = FALSE;
|
||||||
|
|
||||||
double_click = gtk_adjustment_get_value (adjustment) * 1000;
|
if (called) return;
|
||||||
/* we normalize this to avoid loops */
|
|
||||||
if (double_click != double_click_from_gconf (double_click)) {
|
|
||||||
gtk_adjustment_set_value (adjustment, (double_click_from_gconf (double_click))/1000.0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gconf_client_set_int (client, DOUBLE_CLICK_KEY,
|
left_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-left.png", NULL);
|
||||||
double_click,
|
right_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-right.png", NULL);
|
||||||
NULL);
|
double_click_on_pixbuf = gdk_pixbuf_new_from_file ("double-click-on.png", NULL);
|
||||||
|
double_click_maybe_pixbuf = gdk_pixbuf_new_from_file ("double-click-maybe.png", NULL);
|
||||||
|
double_click_off_pixbuf = gdk_pixbuf_new_from_file ("double-click-off.png", NULL);
|
||||||
|
|
||||||
|
/* Let's be paranoid here. I like this feature :-) */
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (left_handed_pixbuf), (gpointer *) &left_handed_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (right_handed_pixbuf), (gpointer *) &right_handed_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (double_click_on_pixbuf), (gpointer *) &double_click_on_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (double_click_maybe_pixbuf), (gpointer *) &double_click_maybe_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (double_click_off_pixbuf), (gpointer *) &double_click_off_pixbuf);
|
||||||
|
|
||||||
|
called = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/* Set up the property editors in the dialog. */
|
||||||
threshold_callback (GtkAdjustment *adjustment, gpointer key)
|
|
||||||
{
|
|
||||||
gint threshold;
|
|
||||||
|
|
||||||
threshold = (gint) rint (gtk_adjustment_get_value (adjustment));
|
|
||||||
|
|
||||||
gconf_client_set_int (client, (char *) key,
|
|
||||||
threshold,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
acceleration_callback (GtkAdjustment *adjustment, gpointer data)
|
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
|
||||||
{
|
{
|
||||||
gfloat acceleration;
|
GtkWidget *widget;
|
||||||
|
GObject *peditor;
|
||||||
|
GConfValue *value;
|
||||||
|
|
||||||
acceleration = gtk_adjustment_get_value (adjustment);
|
int double_click;
|
||||||
gconf_client_set_float (client, MOTION_ACCELERATION_KEY,
|
int threshold;
|
||||||
motion_acceleration_to_gconf (acceleration),
|
gfloat acceleration;
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* gconf->capplet */
|
|
||||||
static void
|
|
||||||
gconf_changed_callback (GConfClient *client,
|
|
||||||
guint cnxn_id,
|
|
||||||
GConfEntry *entry,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GtkWidget *widget;
|
|
||||||
const gchar *key = gconf_entry_get_key (entry);
|
|
||||||
|
|
||||||
if (! strcmp (key, LEFT_HANDED_KEY)) {
|
|
||||||
gboolean left_handed;
|
|
||||||
|
|
||||||
left_handed = gconf_value_get_bool (gconf_entry_get_value (entry));
|
|
||||||
widget = glade_xml_get_widget (xml, "left_handed_toggle");
|
|
||||||
if (left_handed != GTK_TOGGLE_BUTTON (widget)->active)
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), left_handed);
|
|
||||||
} else if (! strcmp (key, DOUBLE_CLICK_KEY)) {
|
|
||||||
int double_click;
|
|
||||||
|
|
||||||
double_click = gconf_value_get_int (gconf_entry_get_value (entry));
|
|
||||||
double_click = double_click_from_gconf (double_click);
|
|
||||||
widget = glade_xml_get_widget (xml, "delay_scale");
|
|
||||||
if (double_click != (gint) 1000*gtk_range_get_value (GTK_RANGE (widget)))
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)double_click/1000.0);
|
|
||||||
} else if (! strcmp (key, MOTION_ACCELERATION_KEY)) {
|
|
||||||
gfloat acceleration;
|
|
||||||
|
|
||||||
acceleration = gconf_value_get_float (gconf_entry_get_value (entry));
|
|
||||||
acceleration = motion_acceleration_from_gconf (acceleration);
|
|
||||||
widget = glade_xml_get_widget (xml, "accel_scale");
|
|
||||||
if (ABS (acceleration - gtk_range_get_value (GTK_RANGE (widget))) > 0.001)
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), acceleration);
|
|
||||||
} else if (! strcmp (key, MOTION_THRESHOLD_KEY)) {
|
|
||||||
int threshold;
|
|
||||||
|
|
||||||
threshold = gconf_value_get_int (gconf_entry_get_value (entry));
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
widget = glade_xml_get_widget (xml, "sensitivity_scale");
|
|
||||||
if (ABS (threshold - gtk_range_get_value (GTK_RANGE (widget))) > 0.001)
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)threshold);
|
|
||||||
} else if (! strcmp (key, DRAG_THRESHOLD_KEY)) {
|
|
||||||
int threshold;
|
|
||||||
|
|
||||||
threshold = gconf_value_get_int (gconf_entry_get_value (entry));
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
widget = glade_xml_get_widget (xml, "drag_threshold_scale");
|
|
||||||
if (ABS (threshold - gtk_range_get_value (GTK_RANGE (widget))) > 0.001)
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)threshold);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup_dialog (void)
|
|
||||||
{
|
|
||||||
GtkSizeGroup *size_group;
|
|
||||||
GtkWidget *widget;
|
|
||||||
int double_click;
|
|
||||||
int threshold;
|
|
||||||
gfloat acceleration;
|
|
||||||
|
|
||||||
client = gconf_client_get_default ();
|
|
||||||
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
||||||
gconf_client_notify_add (client, "/desktop/gnome/peripherals/mouse",
|
|
||||||
gconf_changed_callback,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* Buttons page
|
/* Buttons page
|
||||||
*/
|
*/
|
||||||
/* Left-handed toggle */
|
/* Left-handed toggle */
|
||||||
left_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-left.png", NULL);
|
peditor = gconf_peditor_new_boolean
|
||||||
right_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-right.png", NULL);
|
(changeset, "/desktop/gnome/peripherals/mouse/left_handed", WID ("left_handed_toggle"));
|
||||||
widget = glade_xml_get_widget (xml, "left_handed_toggle");
|
g_signal_connect (peditor, "value-changed", (GCallback) left_handed_toggle_cb, WID ("orientation_image"));
|
||||||
if (gconf_client_get_bool (client, LEFT_HANDED_KEY, NULL))
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
|
||||||
else
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
|
|
||||||
g_signal_connect (widget, "toggled", (GCallback) left_handed_toggle_callback, NULL);
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "orientation_image");
|
/* Make sure the image gets initialized correctly */
|
||||||
if (gconf_client_get_bool (client, LEFT_HANDED_KEY, NULL))
|
value = gconf_client_get (gconf_client_get_default (), "/desktop/gnome/peripherals/mouse/left_handed", NULL);
|
||||||
g_object_set (G_OBJECT (widget),
|
left_handed_toggle_cb (GCONF_PROPERTY_EDITOR (peditor), NULL, value, WID ("orientation_image"));
|
||||||
"pixbuf", left_handed_pixbuf,
|
gconf_value_free (value);
|
||||||
NULL);
|
|
||||||
else
|
|
||||||
g_object_set (G_OBJECT (widget),
|
|
||||||
"pixbuf", right_handed_pixbuf,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Double-click time */
|
/* Double-click time */
|
||||||
double_click_on_pixbuf = gdk_pixbuf_new_from_file ("double-click-on.png", NULL);
|
g_signal_connect (WID ("double_click_darea"), "expose_event", (GCallback) drawing_area_expose_event, changeset);
|
||||||
double_click_maybe_pixbuf = gdk_pixbuf_new_from_file ("double-click-maybe.png", NULL);
|
|
||||||
double_click_off_pixbuf = gdk_pixbuf_new_from_file ("double-click-off.png", NULL);
|
|
||||||
widget = glade_xml_get_widget (xml, "double_click_darea");
|
|
||||||
g_signal_connect (widget, "expose_event", (GCallback) drawing_area_expose_event, NULL);
|
|
||||||
|
|
||||||
double_click = gconf_client_get_int (client, DOUBLE_CLICK_KEY, NULL);
|
gconf_peditor_new_int_range
|
||||||
double_click = double_click_from_gconf (double_click);
|
(changeset, DOUBLE_CLICK_KEY, WID ("delay_scale"),
|
||||||
widget = glade_xml_get_widget (xml, "delay_scale");
|
double_click_from_gconf, double_click_to_gconf);
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)double_click/1000.0);
|
gconf_peditor_new_float_range
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
(changeset, "/desktop/gnome/peripherals/mouse/motion_acceleration", WID ("accel_scale"),
|
||||||
"value_changed",
|
motion_acceleration_from_gconf, motion_acceleration_to_gconf);
|
||||||
(GCallback) double_click_callback,
|
gconf_peditor_new_float_range
|
||||||
NULL);
|
(changeset, "/desktop/gnome/peripherals/mouse/motion_threshold",
|
||||||
|
WID ("sensitivity_scale"), NULL, NULL);
|
||||||
|
gconf_peditor_new_int_range
|
||||||
|
(changeset, "/desktop/gnome/peripherals/mouse/drag_threshold", WID ("drag_threshold_scale"),
|
||||||
|
threshold_from_gconf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Cursors page */
|
/* Construct the dialog */
|
||||||
widget = glade_xml_get_widget (xml, "main_notebook");
|
|
||||||
|
static GladeXML *
|
||||||
|
create_dialog (void)
|
||||||
|
{
|
||||||
|
GtkWidget *widget;
|
||||||
|
GladeXML *dialog;
|
||||||
|
GtkSizeGroup *size_group;
|
||||||
|
|
||||||
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/mouse-properties.glade", "prefs_widget", NULL);
|
||||||
|
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||||
|
|
||||||
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
|
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"));
|
||||||
|
|
||||||
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
|
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"));
|
||||||
|
|
||||||
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
|
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"));
|
||||||
|
|
||||||
|
/* Remove cursors page */
|
||||||
|
widget = glade_xml_get_widget (dialog, "main_notebook");
|
||||||
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), 1);
|
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), 1);
|
||||||
|
|
||||||
/* Motion page */
|
g_object_weak_ref (G_OBJECT (widget), (GWeakNotify) g_object_unref, dialog);
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "acceleration_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "sensitivity_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "threshold_label"));
|
|
||||||
|
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
return dialog;
|
||||||
gtk_size_group_add_widget (size_group,
|
}
|
||||||
glade_xml_get_widget (xml, "high_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "fast_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "large_label"));
|
|
||||||
|
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
/* Callback issued when a button is clicked on the dialog */
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "low_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "slow_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "small_label"));
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "accel_scale");
|
static void
|
||||||
acceleration = gconf_client_get_float (client, MOTION_ACCELERATION_KEY, NULL);
|
dialog_button_clicked_cb (GnomeDialog *dialog, gint button_number, GConfChangeSet *changeset)
|
||||||
acceleration = motion_acceleration_from_gconf (acceleration);
|
{
|
||||||
gtk_range_set_value (GTK_RANGE (widget), acceleration);
|
if (button_number == 0)
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
gconf_client_commit_change_set (gconf_client_get_default (), changeset, TRUE, NULL);
|
||||||
"value_changed",
|
else if (button_number == 1)
|
||||||
(GCallback) acceleration_callback,
|
gnome_dialog_close (dialog);
|
||||||
NULL);
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "sensitivity_scale");
|
|
||||||
threshold = gconf_client_get_int (client, MOTION_THRESHOLD_KEY, NULL);
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), threshold);
|
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
|
||||||
"value_changed",
|
|
||||||
(GCallback) threshold_callback,
|
|
||||||
MOTION_THRESHOLD_KEY);
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "drag_threshold_scale");
|
|
||||||
threshold = gconf_client_get_int (client, DRAG_THRESHOLD_KEY, NULL);
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), threshold);
|
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
|
||||||
"value_changed",
|
|
||||||
(GCallback) threshold_callback,
|
|
||||||
DRAG_THRESHOLD_KEY);
|
|
||||||
|
|
||||||
/* main dialog */
|
|
||||||
widget = glade_xml_get_widget (xml, "mouse_properties_dialog");
|
|
||||||
g_signal_connect (G_OBJECT (widget),
|
|
||||||
"destroy",
|
|
||||||
gtk_main_quit, NULL);
|
|
||||||
widget = glade_xml_get_widget (xml, "close_button");
|
|
||||||
g_signal_connect (G_OBJECT (widget),
|
|
||||||
"clicked",
|
|
||||||
gtk_main_quit, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
gnome_program_init ("mouse-properties",
|
GConfClient *client;
|
||||||
"0.1",
|
GConfChangeSet *changeset;
|
||||||
gnome_gtk_module_info_get (),
|
GladeXML *dialog;
|
||||||
argc, argv,
|
GtkWidget *dialog_win;
|
||||||
|
|
||||||
|
static gboolean apply_only;
|
||||||
|
static gboolean get_legacy;
|
||||||
|
static struct poptOption cap_options[] = {
|
||||||
|
{ "apply", '\0', POPT_ARG_NONE, &apply_only, 0,
|
||||||
|
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
|
||||||
|
{ "init-session-settings", '\0', POPT_ARG_NONE, &apply_only, 0,
|
||||||
|
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
|
||||||
|
{ "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,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
xml = glade_xml_new ("gnome-mouse-properties.glade", NULL, NULL);
|
client = gconf_client_get_default ();
|
||||||
setup_dialog ();
|
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
||||||
gtk_widget_show_all (glade_xml_get_widget (xml, "mouse_properties_dialog"));
|
|
||||||
|
|
||||||
gtk_main ();
|
if (get_legacy) {
|
||||||
|
get_legacy_settings ();
|
||||||
|
} else {
|
||||||
|
changeset = gconf_change_set_new ();
|
||||||
|
dialog = create_dialog ();
|
||||||
|
load_pixbufs ();
|
||||||
|
setup_dialog (dialog, changeset);
|
||||||
|
|
||||||
|
dialog_win = gnome_dialog_new (_("Mouse properties"), GTK_STOCK_APPLY, GTK_STOCK_CLOSE, NULL);
|
||||||
|
g_signal_connect (G_OBJECT (dialog_win), "clicked", (GCallback) dialog_button_clicked_cb, changeset);
|
||||||
|
g_object_weak_ref (G_OBJECT (dialog_win), (GWeakNotify) gtk_main_quit, NULL);
|
||||||
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog_win)->vbox), WID ("prefs_widget"), TRUE, TRUE, GNOME_PAD_SMALL);
|
||||||
|
gtk_widget_show_all (dialog_win);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
|
gconf_change_set_unref (changeset);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (G_OBJECT (client));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,40 @@
|
||||||
|
/* -*- 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
|
||||||
|
|
||||||
#include <gnome.h>
|
#include <gnome.h>
|
||||||
#include <gconf/gconf-client.h>
|
#include <gconf/gconf-client.h>
|
||||||
#include <glade/glade.h>
|
#include <glade/glade.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "capplet-util.h"
|
||||||
|
#include "gconf-property-editor.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DOUBLE_CLICK_TEST_OFF,
|
DOUBLE_CLICK_TEST_OFF,
|
||||||
|
@ -10,111 +42,119 @@ enum
|
||||||
DOUBLE_CLICK_TEST_ON,
|
DOUBLE_CLICK_TEST_ON,
|
||||||
};
|
};
|
||||||
|
|
||||||
GladeXML *xml;
|
/* 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 */
|
||||||
|
|
||||||
GdkPixbuf *left_handed_pixbuf;
|
GdkPixbuf *left_handed_pixbuf;
|
||||||
GdkPixbuf *right_handed_pixbuf;
|
GdkPixbuf *right_handed_pixbuf;
|
||||||
GdkPixbuf *double_click_on_pixbuf;
|
GdkPixbuf *double_click_on_pixbuf;
|
||||||
GdkPixbuf *double_click_maybe_pixbuf;
|
GdkPixbuf *double_click_maybe_pixbuf;
|
||||||
GdkPixbuf *double_click_off_pixbuf;
|
GdkPixbuf *double_click_off_pixbuf;
|
||||||
GConfClient *client;
|
|
||||||
|
/* State in testing the double-click speed. Global for a great deal of
|
||||||
|
* convenience
|
||||||
|
*/
|
||||||
|
|
||||||
gint double_click_state = DOUBLE_CLICK_TEST_OFF;
|
gint double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||||
guint32 double_click_timestamp = 0;
|
|
||||||
guint test_maybe_timeout_id = 0;
|
|
||||||
guint test_on_timeout_id = 0;
|
|
||||||
|
|
||||||
#define LEFT_HANDED_KEY "/desktop/gnome/peripherals/mouse/left_handed"
|
|
||||||
#define DOUBLE_CLICK_KEY "/desktop/gnome/peripherals/mouse/double_click"
|
|
||||||
#define MOTION_ACCELERATION_KEY "/desktop/gnome/peripherals/mouse/motion_acceleration"
|
|
||||||
#define MOTION_THRESHOLD_KEY "/desktop/gnome/peripherals/mouse/motion_threshold"
|
|
||||||
#define DRAG_THRESHOLD_KEY "/desktop/gnome/peripherals/mouse/drag_threshold"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* normalilzation routines */
|
/* normalilzation routines */
|
||||||
/* All of our scales but double_click are on the range 1->10 as a result, we
|
/* 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.
|
* have a few routines to convert from whatever the gconf key is to our range.
|
||||||
*/
|
*/
|
||||||
static gint
|
static gfloat
|
||||||
double_click_from_gconf (gint double_click)
|
double_click_from_gconf (gfloat double_click)
|
||||||
{
|
{
|
||||||
/* watch me be lazy */
|
return CLAMP (floor ((double_click + 50) / 100) * 100, 0, 1000) / 1000.0;
|
||||||
if (double_click < 150)
|
}
|
||||||
return 100;
|
|
||||||
else if (double_click < 250)
|
static gfloat
|
||||||
return 200;
|
double_click_to_gconf (gfloat double_click)
|
||||||
else if (double_click < 350)
|
{
|
||||||
return 300;
|
return double_click * 1000.0;
|
||||||
else if (double_click < 450)
|
|
||||||
return 400;
|
|
||||||
else if (double_click < 550)
|
|
||||||
return 500;
|
|
||||||
else if (double_click < 650)
|
|
||||||
return 600;
|
|
||||||
else if (double_click < 750)
|
|
||||||
return 700;
|
|
||||||
else if (double_click < 850)
|
|
||||||
return 800;
|
|
||||||
else if (double_click < 950)
|
|
||||||
return 900;
|
|
||||||
else
|
|
||||||
return 1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfloat
|
static gfloat
|
||||||
motion_acceleration_from_gconf (gfloat motion_acceleration)
|
motion_acceleration_from_gconf (gfloat motion_acceleration)
|
||||||
{
|
{
|
||||||
motion_acceleration = CLAMP (motion_acceleration, 0.2, 6.0);
|
motion_acceleration = CLAMP (motion_acceleration, 0.2, 6.0);
|
||||||
if (motion_acceleration >=1)
|
|
||||||
|
if (motion_acceleration >= 1)
|
||||||
return motion_acceleration + 4;
|
return motion_acceleration + 4;
|
||||||
return motion_acceleration * 5;
|
else
|
||||||
|
return motion_acceleration * 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfloat
|
static gfloat
|
||||||
motion_acceleration_to_gconf (gfloat motion_acceleration)
|
motion_acceleration_to_gconf (gfloat motion_acceleration)
|
||||||
{
|
{
|
||||||
motion_acceleration = CLAMP (motion_acceleration, 1.0, 10.0);
|
motion_acceleration = CLAMP (motion_acceleration, 1.0, 10.0);
|
||||||
|
|
||||||
if (motion_acceleration < 5)
|
if (motion_acceleration < 5)
|
||||||
return motion_acceleration / 5.0;
|
return motion_acceleration / 5.0;
|
||||||
return motion_acceleration - 4;
|
else
|
||||||
|
return motion_acceleration - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfloat
|
static gfloat
|
||||||
threshold_from_gconf (gfloat drag_threshold)
|
threshold_from_gconf (gfloat drag_threshold)
|
||||||
{
|
{
|
||||||
return CLAMP (drag_threshold, 1, 10);
|
return CLAMP (drag_threshold, 1, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Retrieve legacy settings */
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_legacy_settings (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* Double Click handling */
|
/* Double Click handling */
|
||||||
|
|
||||||
static gboolean
|
struct test_data_t
|
||||||
test_maybe_timeout (gpointer data)
|
|
||||||
{
|
{
|
||||||
|
gint *timeout_id;
|
||||||
GtkWidget *darea;
|
GtkWidget *darea;
|
||||||
darea = glade_xml_get_widget (xml, "double_click_darea");
|
};
|
||||||
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
|
||||||
gtk_widget_queue_draw (darea);
|
|
||||||
|
|
||||||
*((gint *)data) = 0;
|
/* Timeout for the double click test */
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
test_maybe_timeout (struct test_data_t *data)
|
||||||
|
{
|
||||||
|
double_click_state = DOUBLE_CLICK_TEST_OFF;
|
||||||
|
gtk_widget_queue_draw (data->darea);
|
||||||
|
|
||||||
|
*data->timeout_id = 0;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback issued when the user clicks the double click testing area. */
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
drawing_area_button_press_event (GtkWidget *widget,
|
drawing_area_button_press_event (GtkWidget *widget,
|
||||||
GdkEventButton *event,
|
GdkEventButton *event,
|
||||||
gpointer data)
|
GConfChangeSet *changeset)
|
||||||
{
|
{
|
||||||
GtkWidget *scale;
|
gint double_click_time;
|
||||||
GtkWidget *darea;
|
GConfValue *value;
|
||||||
gint double_click_time;
|
|
||||||
|
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;
|
||||||
|
|
||||||
if (event->type != GDK_BUTTON_PRESS)
|
if (event->type != GDK_BUTTON_PRESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
scale = glade_xml_get_widget (xml, "delay_scale");
|
if (!gconf_change_set_check_value (changeset, DOUBLE_CLICK_KEY, &value))
|
||||||
double_click_time = 1000 * gtk_range_get_value (GTK_RANGE (scale));
|
double_click_time = gconf_client_get_int (gconf_client_get_default (), DOUBLE_CLICK_KEY, NULL);
|
||||||
darea = glade_xml_get_widget (xml, "double_click_darea");
|
else
|
||||||
|
double_click_time = gconf_value_get_int (value);
|
||||||
|
|
||||||
if (test_maybe_timeout_id != 0)
|
if (test_maybe_timeout_id != 0)
|
||||||
gtk_timeout_remove (test_maybe_timeout_id);
|
gtk_timeout_remove (test_maybe_timeout_id);
|
||||||
|
@ -124,12 +164,16 @@ drawing_area_button_press_event (GtkWidget *widget,
|
||||||
switch (double_click_state) {
|
switch (double_click_state) {
|
||||||
case DOUBLE_CLICK_TEST_OFF:
|
case DOUBLE_CLICK_TEST_OFF:
|
||||||
double_click_state = DOUBLE_CLICK_TEST_MAYBE;
|
double_click_state = DOUBLE_CLICK_TEST_MAYBE;
|
||||||
test_maybe_timeout_id = gtk_timeout_add (double_click_time, test_maybe_timeout, &test_maybe_timeout_id);
|
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);
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_MAYBE:
|
case DOUBLE_CLICK_TEST_MAYBE:
|
||||||
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 = DOUBLE_CLICK_TEST_ON;
|
||||||
test_on_timeout_id = gtk_timeout_add (2500, test_maybe_timeout, &test_on_timeout_id);
|
data.darea = widget;
|
||||||
|
data.timeout_id = &test_on_timeout_id;
|
||||||
|
test_on_timeout_id = gtk_timeout_add (2500, (GtkFunction) test_maybe_timeout, &data);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DOUBLE_CLICK_TEST_ON:
|
case DOUBLE_CLICK_TEST_ON:
|
||||||
|
@ -138,27 +182,29 @@ drawing_area_button_press_event (GtkWidget *widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
double_click_timestamp = event->time;
|
double_click_timestamp = event->time;
|
||||||
gtk_widget_queue_draw (darea);
|
gtk_widget_queue_draw (widget);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback to display the appropriate image on the double click testing area. */
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
drawing_area_expose_event (GtkWidget *widget,
|
drawing_area_expose_event (GtkWidget *widget,
|
||||||
GdkEventExpose *event,
|
GdkEventExpose *event,
|
||||||
gpointer data)
|
GConfChangeSet *changeset)
|
||||||
{
|
{
|
||||||
static gboolean first_time = 1;
|
static gboolean first_time = TRUE;
|
||||||
GdkPixbuf *pixbuf;
|
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
if (first_time) {
|
if (first_time) {
|
||||||
gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | GDK_BUTTON_PRESS_MASK);
|
gdk_window_set_events (widget->window, gdk_window_get_events (widget->window) | GDK_BUTTON_PRESS_MASK);
|
||||||
g_signal_connect (widget, "button_press_event", (GCallback) drawing_area_button_press_event, NULL);
|
g_signal_connect (G_OBJECT (widget), "button_press_event", (GCallback) drawing_area_button_press_event, changeset);
|
||||||
first_time = 0;
|
first_time = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_draw_rectangle (widget->window,
|
gdk_draw_rectangle (widget->window, widget->style->white_gc,
|
||||||
widget->style->white_gc,
|
|
||||||
TRUE, 0, 0,
|
TRUE, 0, 0,
|
||||||
widget->allocation.width,
|
widget->allocation.width,
|
||||||
widget->allocation.height);
|
widget->allocation.height);
|
||||||
|
@ -175,30 +221,24 @@ drawing_area_expose_event (GtkWidget *widget,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_pixbuf_render_to_drawable_alpha (pixbuf,
|
gdk_pixbuf_render_to_drawable_alpha
|
||||||
widget->window,
|
(pixbuf, widget->window,
|
||||||
0, 0,
|
0, 0,
|
||||||
(widget->allocation.width - gdk_pixbuf_get_width (pixbuf))/2,
|
(widget->allocation.width - gdk_pixbuf_get_width (pixbuf)) / 2,
|
||||||
(widget->allocation.height - gdk_pixbuf_get_height (pixbuf))/2,
|
(widget->allocation.height - gdk_pixbuf_get_height (pixbuf)) / 2,
|
||||||
-1, -1,
|
-1, -1, GDK_PIXBUF_ALPHA_FULL, 0, GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||||
GDK_PIXBUF_ALPHA_FULL,
|
|
||||||
0,
|
|
||||||
GDK_RGB_DITHER_NORMAL,
|
|
||||||
0, 0);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Callback issued when the user switches between left- and right-handed button
|
||||||
|
* mappings. Updates the appropriate image on the dialog.
|
||||||
/* capplet->gconf settings */
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
left_handed_toggle_callback (GtkWidget *toggle, gpointer data)
|
left_handed_toggle_cb (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *image)
|
||||||
{
|
{
|
||||||
GtkWidget *image;
|
if (gconf_value_get_bool (value))
|
||||||
image = glade_xml_get_widget (xml, "orientation_image");
|
|
||||||
if (GTK_TOGGLE_BUTTON (toggle)->active)
|
|
||||||
g_object_set (G_OBJECT (image),
|
g_object_set (G_OBJECT (image),
|
||||||
"pixbuf", left_handed_pixbuf,
|
"pixbuf", left_handed_pixbuf,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -206,238 +246,170 @@ left_handed_toggle_callback (GtkWidget *toggle, gpointer data)
|
||||||
g_object_set (G_OBJECT (image),
|
g_object_set (G_OBJECT (image),
|
||||||
"pixbuf", right_handed_pixbuf,
|
"pixbuf", right_handed_pixbuf,
|
||||||
NULL);
|
NULL);
|
||||||
gconf_client_set_bool (client, LEFT_HANDED_KEY,
|
|
||||||
GTK_TOGGLE_BUTTON (toggle)->active,
|
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Load the pixbufs we are going to use */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
double_click_callback (GtkAdjustment *adjustment, gpointer data)
|
load_pixbufs (void)
|
||||||
{
|
{
|
||||||
gint double_click;
|
static gboolean called = FALSE;
|
||||||
|
|
||||||
double_click = gtk_adjustment_get_value (adjustment) * 1000;
|
if (called) return;
|
||||||
/* we normalize this to avoid loops */
|
|
||||||
if (double_click != double_click_from_gconf (double_click)) {
|
|
||||||
gtk_adjustment_set_value (adjustment, (double_click_from_gconf (double_click))/1000.0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gconf_client_set_int (client, DOUBLE_CLICK_KEY,
|
left_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-left.png", NULL);
|
||||||
double_click,
|
right_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-right.png", NULL);
|
||||||
NULL);
|
double_click_on_pixbuf = gdk_pixbuf_new_from_file ("double-click-on.png", NULL);
|
||||||
|
double_click_maybe_pixbuf = gdk_pixbuf_new_from_file ("double-click-maybe.png", NULL);
|
||||||
|
double_click_off_pixbuf = gdk_pixbuf_new_from_file ("double-click-off.png", NULL);
|
||||||
|
|
||||||
|
/* Let's be paranoid here. I like this feature :-) */
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (left_handed_pixbuf), (gpointer *) &left_handed_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (right_handed_pixbuf), (gpointer *) &right_handed_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (double_click_on_pixbuf), (gpointer *) &double_click_on_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (double_click_maybe_pixbuf), (gpointer *) &double_click_maybe_pixbuf);
|
||||||
|
g_object_add_weak_pointer (G_OBJECT (double_click_off_pixbuf), (gpointer *) &double_click_off_pixbuf);
|
||||||
|
|
||||||
|
called = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/* Set up the property editors in the dialog. */
|
||||||
threshold_callback (GtkAdjustment *adjustment, gpointer key)
|
|
||||||
{
|
|
||||||
gint threshold;
|
|
||||||
|
|
||||||
threshold = (gint) rint (gtk_adjustment_get_value (adjustment));
|
|
||||||
|
|
||||||
gconf_client_set_int (client, (char *) key,
|
|
||||||
threshold,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
acceleration_callback (GtkAdjustment *adjustment, gpointer data)
|
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
|
||||||
{
|
{
|
||||||
gfloat acceleration;
|
GtkWidget *widget;
|
||||||
|
GObject *peditor;
|
||||||
|
GConfValue *value;
|
||||||
|
|
||||||
acceleration = gtk_adjustment_get_value (adjustment);
|
int double_click;
|
||||||
gconf_client_set_float (client, MOTION_ACCELERATION_KEY,
|
int threshold;
|
||||||
motion_acceleration_to_gconf (acceleration),
|
gfloat acceleration;
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* gconf->capplet */
|
|
||||||
static void
|
|
||||||
gconf_changed_callback (GConfClient *client,
|
|
||||||
guint cnxn_id,
|
|
||||||
GConfEntry *entry,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
GtkWidget *widget;
|
|
||||||
const gchar *key = gconf_entry_get_key (entry);
|
|
||||||
|
|
||||||
if (! strcmp (key, LEFT_HANDED_KEY)) {
|
|
||||||
gboolean left_handed;
|
|
||||||
|
|
||||||
left_handed = gconf_value_get_bool (gconf_entry_get_value (entry));
|
|
||||||
widget = glade_xml_get_widget (xml, "left_handed_toggle");
|
|
||||||
if (left_handed != GTK_TOGGLE_BUTTON (widget)->active)
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), left_handed);
|
|
||||||
} else if (! strcmp (key, DOUBLE_CLICK_KEY)) {
|
|
||||||
int double_click;
|
|
||||||
|
|
||||||
double_click = gconf_value_get_int (gconf_entry_get_value (entry));
|
|
||||||
double_click = double_click_from_gconf (double_click);
|
|
||||||
widget = glade_xml_get_widget (xml, "delay_scale");
|
|
||||||
if (double_click != (gint) 1000*gtk_range_get_value (GTK_RANGE (widget)))
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)double_click/1000.0);
|
|
||||||
} else if (! strcmp (key, MOTION_ACCELERATION_KEY)) {
|
|
||||||
gfloat acceleration;
|
|
||||||
|
|
||||||
acceleration = gconf_value_get_float (gconf_entry_get_value (entry));
|
|
||||||
acceleration = motion_acceleration_from_gconf (acceleration);
|
|
||||||
widget = glade_xml_get_widget (xml, "accel_scale");
|
|
||||||
if (ABS (acceleration - gtk_range_get_value (GTK_RANGE (widget))) > 0.001)
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), acceleration);
|
|
||||||
} else if (! strcmp (key, MOTION_THRESHOLD_KEY)) {
|
|
||||||
int threshold;
|
|
||||||
|
|
||||||
threshold = gconf_value_get_int (gconf_entry_get_value (entry));
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
widget = glade_xml_get_widget (xml, "sensitivity_scale");
|
|
||||||
if (ABS (threshold - gtk_range_get_value (GTK_RANGE (widget))) > 0.001)
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)threshold);
|
|
||||||
} else if (! strcmp (key, DRAG_THRESHOLD_KEY)) {
|
|
||||||
int threshold;
|
|
||||||
|
|
||||||
threshold = gconf_value_get_int (gconf_entry_get_value (entry));
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
widget = glade_xml_get_widget (xml, "drag_threshold_scale");
|
|
||||||
if (ABS (threshold - gtk_range_get_value (GTK_RANGE (widget))) > 0.001)
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)threshold);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup_dialog (void)
|
|
||||||
{
|
|
||||||
GtkSizeGroup *size_group;
|
|
||||||
GtkWidget *widget;
|
|
||||||
int double_click;
|
|
||||||
int threshold;
|
|
||||||
gfloat acceleration;
|
|
||||||
|
|
||||||
client = gconf_client_get_default ();
|
|
||||||
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
|
||||||
gconf_client_notify_add (client, "/desktop/gnome/peripherals/mouse",
|
|
||||||
gconf_changed_callback,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* Buttons page
|
/* Buttons page
|
||||||
*/
|
*/
|
||||||
/* Left-handed toggle */
|
/* Left-handed toggle */
|
||||||
left_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-left.png", NULL);
|
peditor = gconf_peditor_new_boolean
|
||||||
right_handed_pixbuf = gdk_pixbuf_new_from_file ("mouse-right.png", NULL);
|
(changeset, "/desktop/gnome/peripherals/mouse/left_handed", WID ("left_handed_toggle"));
|
||||||
widget = glade_xml_get_widget (xml, "left_handed_toggle");
|
g_signal_connect (peditor, "value-changed", (GCallback) left_handed_toggle_cb, WID ("orientation_image"));
|
||||||
if (gconf_client_get_bool (client, LEFT_HANDED_KEY, NULL))
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
|
|
||||||
else
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
|
|
||||||
g_signal_connect (widget, "toggled", (GCallback) left_handed_toggle_callback, NULL);
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "orientation_image");
|
/* Make sure the image gets initialized correctly */
|
||||||
if (gconf_client_get_bool (client, LEFT_HANDED_KEY, NULL))
|
value = gconf_client_get (gconf_client_get_default (), "/desktop/gnome/peripherals/mouse/left_handed", NULL);
|
||||||
g_object_set (G_OBJECT (widget),
|
left_handed_toggle_cb (GCONF_PROPERTY_EDITOR (peditor), NULL, value, WID ("orientation_image"));
|
||||||
"pixbuf", left_handed_pixbuf,
|
gconf_value_free (value);
|
||||||
NULL);
|
|
||||||
else
|
|
||||||
g_object_set (G_OBJECT (widget),
|
|
||||||
"pixbuf", right_handed_pixbuf,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Double-click time */
|
/* Double-click time */
|
||||||
double_click_on_pixbuf = gdk_pixbuf_new_from_file ("double-click-on.png", NULL);
|
g_signal_connect (WID ("double_click_darea"), "expose_event", (GCallback) drawing_area_expose_event, changeset);
|
||||||
double_click_maybe_pixbuf = gdk_pixbuf_new_from_file ("double-click-maybe.png", NULL);
|
|
||||||
double_click_off_pixbuf = gdk_pixbuf_new_from_file ("double-click-off.png", NULL);
|
|
||||||
widget = glade_xml_get_widget (xml, "double_click_darea");
|
|
||||||
g_signal_connect (widget, "expose_event", (GCallback) drawing_area_expose_event, NULL);
|
|
||||||
|
|
||||||
double_click = gconf_client_get_int (client, DOUBLE_CLICK_KEY, NULL);
|
gconf_peditor_new_int_range
|
||||||
double_click = double_click_from_gconf (double_click);
|
(changeset, DOUBLE_CLICK_KEY, WID ("delay_scale"),
|
||||||
widget = glade_xml_get_widget (xml, "delay_scale");
|
double_click_from_gconf, double_click_to_gconf);
|
||||||
gtk_range_set_value (GTK_RANGE (widget), (gfloat)double_click/1000.0);
|
gconf_peditor_new_float_range
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
(changeset, "/desktop/gnome/peripherals/mouse/motion_acceleration", WID ("accel_scale"),
|
||||||
"value_changed",
|
motion_acceleration_from_gconf, motion_acceleration_to_gconf);
|
||||||
(GCallback) double_click_callback,
|
gconf_peditor_new_float_range
|
||||||
NULL);
|
(changeset, "/desktop/gnome/peripherals/mouse/motion_threshold",
|
||||||
|
WID ("sensitivity_scale"), NULL, NULL);
|
||||||
|
gconf_peditor_new_int_range
|
||||||
|
(changeset, "/desktop/gnome/peripherals/mouse/drag_threshold", WID ("drag_threshold_scale"),
|
||||||
|
threshold_from_gconf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Cursors page */
|
/* Construct the dialog */
|
||||||
widget = glade_xml_get_widget (xml, "main_notebook");
|
|
||||||
|
static GladeXML *
|
||||||
|
create_dialog (void)
|
||||||
|
{
|
||||||
|
GtkWidget *widget;
|
||||||
|
GladeXML *dialog;
|
||||||
|
GtkSizeGroup *size_group;
|
||||||
|
|
||||||
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/mouse-properties.glade", "prefs_widget", NULL);
|
||||||
|
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||||
|
|
||||||
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
|
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"));
|
||||||
|
|
||||||
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
|
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"));
|
||||||
|
|
||||||
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
|
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"));
|
||||||
|
|
||||||
|
/* Remove cursors page */
|
||||||
|
widget = glade_xml_get_widget (dialog, "main_notebook");
|
||||||
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), 1);
|
gtk_notebook_remove_page (GTK_NOTEBOOK (widget), 1);
|
||||||
|
|
||||||
/* Motion page */
|
g_object_weak_ref (G_OBJECT (widget), (GWeakNotify) g_object_unref, dialog);
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "acceleration_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "sensitivity_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "threshold_label"));
|
|
||||||
|
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
return dialog;
|
||||||
gtk_size_group_add_widget (size_group,
|
}
|
||||||
glade_xml_get_widget (xml, "high_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "fast_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "large_label"));
|
|
||||||
|
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
/* Callback issued when a button is clicked on the dialog */
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "low_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "slow_label"));
|
|
||||||
gtk_size_group_add_widget (size_group,
|
|
||||||
glade_xml_get_widget (xml, "small_label"));
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "accel_scale");
|
static void
|
||||||
acceleration = gconf_client_get_float (client, MOTION_ACCELERATION_KEY, NULL);
|
dialog_button_clicked_cb (GnomeDialog *dialog, gint button_number, GConfChangeSet *changeset)
|
||||||
acceleration = motion_acceleration_from_gconf (acceleration);
|
{
|
||||||
gtk_range_set_value (GTK_RANGE (widget), acceleration);
|
if (button_number == 0)
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
gconf_client_commit_change_set (gconf_client_get_default (), changeset, TRUE, NULL);
|
||||||
"value_changed",
|
else if (button_number == 1)
|
||||||
(GCallback) acceleration_callback,
|
gnome_dialog_close (dialog);
|
||||||
NULL);
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "sensitivity_scale");
|
|
||||||
threshold = gconf_client_get_int (client, MOTION_THRESHOLD_KEY, NULL);
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), threshold);
|
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
|
||||||
"value_changed",
|
|
||||||
(GCallback) threshold_callback,
|
|
||||||
MOTION_THRESHOLD_KEY);
|
|
||||||
|
|
||||||
widget = glade_xml_get_widget (xml, "drag_threshold_scale");
|
|
||||||
threshold = gconf_client_get_int (client, DRAG_THRESHOLD_KEY, NULL);
|
|
||||||
threshold = threshold_from_gconf (threshold);
|
|
||||||
gtk_range_set_value (GTK_RANGE (widget), threshold);
|
|
||||||
g_signal_connect (G_OBJECT (gtk_range_get_adjustment (GTK_RANGE (widget))),
|
|
||||||
"value_changed",
|
|
||||||
(GCallback) threshold_callback,
|
|
||||||
DRAG_THRESHOLD_KEY);
|
|
||||||
|
|
||||||
/* main dialog */
|
|
||||||
widget = glade_xml_get_widget (xml, "mouse_properties_dialog");
|
|
||||||
g_signal_connect (G_OBJECT (widget),
|
|
||||||
"destroy",
|
|
||||||
gtk_main_quit, NULL);
|
|
||||||
widget = glade_xml_get_widget (xml, "close_button");
|
|
||||||
g_signal_connect (G_OBJECT (widget),
|
|
||||||
"clicked",
|
|
||||||
gtk_main_quit, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
gnome_program_init ("mouse-properties",
|
GConfClient *client;
|
||||||
"0.1",
|
GConfChangeSet *changeset;
|
||||||
gnome_gtk_module_info_get (),
|
GladeXML *dialog;
|
||||||
argc, argv,
|
GtkWidget *dialog_win;
|
||||||
|
|
||||||
|
static gboolean apply_only;
|
||||||
|
static gboolean get_legacy;
|
||||||
|
static struct poptOption cap_options[] = {
|
||||||
|
{ "apply", '\0', POPT_ARG_NONE, &apply_only, 0,
|
||||||
|
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
|
||||||
|
{ "init-session-settings", '\0', POPT_ARG_NONE, &apply_only, 0,
|
||||||
|
N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
|
||||||
|
{ "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,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
xml = glade_xml_new ("gnome-mouse-properties.glade", NULL, NULL);
|
client = gconf_client_get_default ();
|
||||||
setup_dialog ();
|
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
|
||||||
gtk_widget_show_all (glade_xml_get_widget (xml, "mouse_properties_dialog"));
|
|
||||||
|
|
||||||
gtk_main ();
|
if (get_legacy) {
|
||||||
|
get_legacy_settings ();
|
||||||
|
} else {
|
||||||
|
changeset = gconf_change_set_new ();
|
||||||
|
dialog = create_dialog ();
|
||||||
|
load_pixbufs ();
|
||||||
|
setup_dialog (dialog, changeset);
|
||||||
|
|
||||||
|
dialog_win = gnome_dialog_new (_("Mouse properties"), GTK_STOCK_APPLY, GTK_STOCK_CLOSE, NULL);
|
||||||
|
g_signal_connect (G_OBJECT (dialog_win), "clicked", (GCallback) dialog_button_clicked_cb, changeset);
|
||||||
|
g_object_weak_ref (G_OBJECT (dialog_win), (GWeakNotify) gtk_main_quit, NULL);
|
||||||
|
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog_win)->vbox), WID ("prefs_widget"), TRUE, TRUE, GNOME_PAD_SMALL);
|
||||||
|
gtk_widget_show_all (dialog_win);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
|
gconf_change_set_unref (changeset);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (G_OBJECT (client));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue