gnome-control-center/capplets/mouse/gnome-mouse-properties.c

500 lines
15 KiB
C
Raw Normal View History

/* -*- 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.
*/
#include <config.h>
#include <string.h>
2001-12-16 08:23:09 +00:00
#include <gnome.h>
#include <gconf/gconf-client.h>
#include <glade/glade.h>
#include <gdk/gdkx.h>
2001-12-16 08:23:09 +00:00
#include <math.h>
#include "capplet-util.h"
#include "gconf-property-editor.h"
#include "activate-settings-daemon.h"
#include "capplet-stock-icons.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#ifdef HAVE_XCURSOR
#include <X11/Xcursor/Xcursor.h>
#endif
/******************************************************************************/
/* A quick custom widget to ensure that the left handed toggle works no matter
* which button is pressed.
*/
typedef struct { GtkCheckButton parent; } MouseCappletCheckButton;
typedef struct { GtkCheckButtonClass parent; } MouseCappletCheckButtonClass;
GNOME_CLASS_BOILERPLATE (MouseCappletCheckButton, mouse_capplet_check_button,
GtkCheckButton, GTK_TYPE_CHECK_BUTTON)
static void mouse_capplet_check_button_instance_init (MouseCappletCheckButton *obj) { }
static gboolean
mouse_capplet_check_button_button_press (GtkWidget *widget, GdkEventButton *event)
{
if (event->type == GDK_BUTTON_PRESS) {
if (!GTK_WIDGET_HAS_FOCUS (widget))
gtk_widget_grab_focus (widget);
gtk_button_pressed (GTK_BUTTON (widget));
}
return TRUE;
}
static gboolean
mouse_capplet_check_button_button_release (GtkWidget *widget, GdkEventButton *event)
{
gtk_button_released (GTK_BUTTON (widget));
return TRUE;
}
static void
mouse_capplet_check_button_class_init (MouseCappletCheckButtonClass *klass)
{
GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
widget_class->button_press_event = mouse_capplet_check_button_button_press;
widget_class->button_release_event = mouse_capplet_check_button_button_release;
}
/******************************************************************************/
2001-12-16 08:23:09 +00:00
enum
{
DOUBLE_CLICK_TEST_OFF,
DOUBLE_CLICK_TEST_MAYBE,
DOUBLE_CLICK_TEST_ON
2001-12-16 08:23:09 +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"
/* State in testing the double-click speed. Global for a great deal of
* convenience
*/
static gint double_click_state = DOUBLE_CLICK_TEST_OFF;
2001-12-16 08:23:09 +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.
*/
static GConfValue *
double_click_from_gconf (GConfPropertyEditor *peditor, const GConfValue *value)
{
GConfValue *new_value;
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));
return new_value;
}
static gboolean
delay_value_changed_cb (GtkWidget *range, GtkScrollType scroll, gdouble value,
gpointer dialog)
{
gchar *message;
if (value < 100)
value = 100;
else if (value > 1000)
value = 1000;
message = g_strdup_printf (ngettext ("%d millisecond","%d milliseconds", CLAMP ((int) floor ((value+50)/100.0) * 100, 100, 1000)), CLAMP ((int) floor ((value+50)/100.0) * 100, 100, 1000));
gtk_label_set_label ((GtkLabel*) WID ("delay_label"), message);
g_free (message);
return FALSE;
2001-12-16 08:23:09 +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;
/* 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;
}
static GConfValue *
motion_acceleration_from_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
2001-12-16 08:23:09 +00:00
{
GConfValue *new_value;
gfloat motion_acceleration;
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
if (gconf_value_get_float (value) == -1.0) {
int numerator, denominator;
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);
}
if (motion_acceleration >= 1)
gconf_value_set_float (new_value, motion_acceleration + 4);
else
gconf_value_set_float (new_value, motion_acceleration * 5);
return new_value;
2001-12-16 08:23:09 +00:00
}
Added exception RollbackDataNotFound Added exception LocationNotFound 2001-08-21 Bradford Hovinen <hovinen@ximian.com> * idl/ConfigArchiver.idl: Added exception RollbackDataNotFound Added exception LocationNotFound * archive.c (archive_get_current_location_id): Use archive_create_location rather than location_new (archive_get_current_location_id): Unref the location once we have created it * archiver-client.c (location_client_load_rollback_data): Don't try to parse the XML file if there was an exception * bonobo-config-archiver.c (bonobo_config_archiver_new): Make sure to release_unref location and archive if aborting (bonobo_config_archiver_new): Reinitialize exception structure after we have succeeded * location.c (location_get_rollback_filename): Recurse on parent location if parent_chain is set to TRUE * archive.c (impl_ConfigArchiver_Archive_getLocation): Set the LocationNotFound exception if the location returned was NULL * location.c (impl_ConfigArchiver_Location_getRollbackFilename): Don't try * archive.c (impl_ConfigArchiver_Archive_getLocation): Don't try to CORBA_Object_duplicate the result if it is NULL (archive_get_location): Don't try to cast the result of location_open before we know whether it is non-NULL (impl_ConfigArchiver_Archive_createLocation): Call bonobo_object_from_servant on parent_ref->servant * location.c (location_destroy): Remove debugging message; make remaining debugging message more enlightening * archive.c (archive_get_child_locations): Rename from archive_foreach_child_location; rewrite to return a GList of child locations (impl_ConfigArchiver_Archive_getChildLocations): Use archive_get_child_locations (archive_destroy): Remove debugging message * bonobo-moniker-archiver.c (archive_resolve): Remove debugging messages * archive.c (archive_get_location): Remove debugging messages * config-log.c (dump_log): Remove debugging messages * archive.c (archive_foreach_child_location): Build a list first and then traverse it to avoid screwing up the tree traversal * mouse-properties-capplet.c (apply_settings): Use a CORBA exception structure
2001-08-22 13:56:23 +00:00
static GConfValue *
motion_acceleration_to_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
2001-12-16 08:23:09 +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-16 08:23:09 +00:00
if (motion_acceleration < 5)
gconf_value_set_float (new_value, motion_acceleration / 5.0);
else
gconf_value_set_float (new_value, motion_acceleration - 4);
return new_value;
2001-12-16 08:23:09 +00:00
}
static GConfValue *
threshold_from_gconf (GConfPropertyEditor *peditor,
const GConfValue *value)
2001-12-16 08:23:09 +00:00
{
GConfValue *new_value;
new_value = gconf_value_new (GCONF_VALUE_FLOAT);
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));
}
return new_value;
2001-12-16 08:23:09 +00:00
}
static GConfValue *
drag_threshold_from_gconf (GConfPropertyEditor *peditor,
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 */
Added exception RollbackDataNotFound Added exception LocationNotFound 2001-08-21 Bradford Hovinen <hovinen@ximian.com> * idl/ConfigArchiver.idl: Added exception RollbackDataNotFound Added exception LocationNotFound * archive.c (archive_get_current_location_id): Use archive_create_location rather than location_new (archive_get_current_location_id): Unref the location once we have created it * archiver-client.c (location_client_load_rollback_data): Don't try to parse the XML file if there was an exception * bonobo-config-archiver.c (bonobo_config_archiver_new): Make sure to release_unref location and archive if aborting (bonobo_config_archiver_new): Reinitialize exception structure after we have succeeded * location.c (location_get_rollback_filename): Recurse on parent location if parent_chain is set to TRUE * archive.c (impl_ConfigArchiver_Archive_getLocation): Set the LocationNotFound exception if the location returned was NULL * location.c (impl_ConfigArchiver_Location_getRollbackFilename): Don't try * archive.c (impl_ConfigArchiver_Archive_getLocation): Don't try to CORBA_Object_duplicate the result if it is NULL (archive_get_location): Don't try to cast the result of location_open before we know whether it is non-NULL (impl_ConfigArchiver_Archive_createLocation): Call bonobo_object_from_servant on parent_ref->servant * location.c (location_destroy): Remove debugging message; make remaining debugging message more enlightening * archive.c (archive_get_child_locations): Rename from archive_foreach_child_location; rewrite to return a GList of child locations (impl_ConfigArchiver_Archive_getChildLocations): Use archive_get_child_locations (archive_destroy): Remove debugging message * bonobo-moniker-archiver.c (archive_resolve): Remove debugging messages * archive.c (archive_get_location): Remove debugging messages * config-log.c (dump_log): Remove debugging messages * archive.c (archive_foreach_child_location): Build a list first and then traverse it to avoid screwing up the tree traversal * mouse-properties-capplet.c (apply_settings): Use a CORBA exception structure
2001-08-22 13:56:23 +00:00
struct test_data_t
2001-12-16 08:23:09 +00:00
{
gint *timeout_id;
GtkWidget *image;
};
/* 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;
gtk_image_set_from_stock (GTK_IMAGE (data->image),
MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size());
*data->timeout_id = 0;
Added exception RollbackDataNotFound Added exception LocationNotFound 2001-08-21 Bradford Hovinen <hovinen@ximian.com> * idl/ConfigArchiver.idl: Added exception RollbackDataNotFound Added exception LocationNotFound * archive.c (archive_get_current_location_id): Use archive_create_location rather than location_new (archive_get_current_location_id): Unref the location once we have created it * archiver-client.c (location_client_load_rollback_data): Don't try to parse the XML file if there was an exception * bonobo-config-archiver.c (bonobo_config_archiver_new): Make sure to release_unref location and archive if aborting (bonobo_config_archiver_new): Reinitialize exception structure after we have succeeded * location.c (location_get_rollback_filename): Recurse on parent location if parent_chain is set to TRUE * archive.c (impl_ConfigArchiver_Archive_getLocation): Set the LocationNotFound exception if the location returned was NULL * location.c (impl_ConfigArchiver_Location_getRollbackFilename): Don't try * archive.c (impl_ConfigArchiver_Archive_getLocation): Don't try to CORBA_Object_duplicate the result if it is NULL (archive_get_location): Don't try to cast the result of location_open before we know whether it is non-NULL (impl_ConfigArchiver_Archive_createLocation): Call bonobo_object_from_servant on parent_ref->servant * location.c (location_destroy): Remove debugging message; make remaining debugging message more enlightening * archive.c (archive_get_child_locations): Rename from archive_foreach_child_location; rewrite to return a GList of child locations (impl_ConfigArchiver_Archive_getChildLocations): Use archive_get_child_locations (archive_destroy): Remove debugging message * bonobo-moniker-archiver.c (archive_resolve): Remove debugging messages * archive.c (archive_get_location): Remove debugging messages * config-log.c (dump_log): Remove debugging messages * archive.c (archive_foreach_child_location): Build a list first and then traverse it to avoid screwing up the tree traversal * mouse-properties-capplet.c (apply_settings): Use a CORBA exception structure
2001-08-22 13:56:23 +00:00
2001-12-16 08:23:09 +00:00
return FALSE;
}
/* Callback issued when the user clicks the double click testing area. */
static gboolean
event_box_button_press_event (GtkWidget *widget,
GdkEventButton *event,
GConfChangeSet *changeset)
{
gint double_click_time;
GConfValue *value;
static struct test_data_t data;
static gint test_on_timeout_id = 0;
static gint test_maybe_timeout_id = 0;
static guint32 double_click_timestamp = 0;
GtkWidget *image;
Cleanup of gconf and a few other things, patch from Kjartan Maraas 2005-05-22 Sebastien Bacher <seb128@debian.org> * ChangeLog capplets/about-me/e-image-chooser.c capplets/accessibility/at-properties/at-startup-session.h capplets/accessibility/keyboard/accessibility-keyboard.c capplets/background/gnome-wp-info.c capplets/common/gconf-property-editor.c capplets/common/gnome-theme-apply.c capplets/default-applications/gnome-default-applications-properties.c capplets/keybindings/gnome-keybinding-properties.c capplets/keyboard/gnome-keyboard-properties.c capplets/mouse/gnome-mouse-properties.c capplets/network/gnome-network-preferences.c capplets/sound/sound-properties-capplet.c capplets/theme-switcher/gnome-theme-details.c capplets/theme-switcher/gnome-theme-manager.c capplets/ui-properties/gnome-ui-properties.c capplets/windows/gnome-window-properties.c gnome-settings-daemon/factory.c gnome-settings-daemon/gnome-settings-accessibility-keyboard.c gnome-settings-daemon/gnome-settings-background.c gnome-settings-daemon/gnome-settings-daemon.c gnome-settings-daemon/gnome-settings-daemon.h gnome-settings-daemon/gnome-settings-font.c gnome-settings-daemon/gnome-settings-keybindings.c gnome-settings-daemon/gnome-settings-keybindings.h gnome-settings-daemon/gnome-settings-keyboard-xkb.c gnome-settings-daemon/gnome-settings-keyboard.c gnome-settings-daemon/gnome-settings-locate-pointer.h gnome-settings-daemon/gnome-settings-mouse.c gnome-settings-daemon/gnome-settings-multimedia-keys.c gnome-settings-daemon/gnome-settings-screensaver.c gnome-settings-daemon/gnome-settings-sound.c gnome-settings-daemon/gnome-settings-xmodmap.c gnome-settings-daemon/gnome-settings-xrdb.c gnome-settings-daemon/gnome-settings-xsettings.c libbackground/applier.c libbackground/applier.h libbackground/preferences.c libsounds/sound-properties.c libsounds/sound-view.h libwindow-settings/gnome-wm-manager.c libwindow-settings/metacity-window-manager.c typing-break/drw-break-window.c typing-break/drw-utils.h typing-break/drwright.c vfs-methods/fontilus/font-view.c vfs-methods/themus/themus-theme-applier.c: Cleanup of gconf and a few other things, patch from Kjartan Maraas <kmaraas@gnome.org> (Closes: #301945).
2005-05-22 15:46:45 +00:00
GConfClient *client;
2001-12-16 08:23:09 +00:00
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
image = g_object_get_data (G_OBJECT (widget), "image");
Cleanup of gconf and a few other things, patch from Kjartan Maraas 2005-05-22 Sebastien Bacher <seb128@debian.org> * ChangeLog capplets/about-me/e-image-chooser.c capplets/accessibility/at-properties/at-startup-session.h capplets/accessibility/keyboard/accessibility-keyboard.c capplets/background/gnome-wp-info.c capplets/common/gconf-property-editor.c capplets/common/gnome-theme-apply.c capplets/default-applications/gnome-default-applications-properties.c capplets/keybindings/gnome-keybinding-properties.c capplets/keyboard/gnome-keyboard-properties.c capplets/mouse/gnome-mouse-properties.c capplets/network/gnome-network-preferences.c capplets/sound/sound-properties-capplet.c capplets/theme-switcher/gnome-theme-details.c capplets/theme-switcher/gnome-theme-manager.c capplets/ui-properties/gnome-ui-properties.c capplets/windows/gnome-window-properties.c gnome-settings-daemon/factory.c gnome-settings-daemon/gnome-settings-accessibility-keyboard.c gnome-settings-daemon/gnome-settings-background.c gnome-settings-daemon/gnome-settings-daemon.c gnome-settings-daemon/gnome-settings-daemon.h gnome-settings-daemon/gnome-settings-font.c gnome-settings-daemon/gnome-settings-keybindings.c gnome-settings-daemon/gnome-settings-keybindings.h gnome-settings-daemon/gnome-settings-keyboard-xkb.c gnome-settings-daemon/gnome-settings-keyboard.c gnome-settings-daemon/gnome-settings-locate-pointer.h gnome-settings-daemon/gnome-settings-mouse.c gnome-settings-daemon/gnome-settings-multimedia-keys.c gnome-settings-daemon/gnome-settings-screensaver.c gnome-settings-daemon/gnome-settings-sound.c gnome-settings-daemon/gnome-settings-xmodmap.c gnome-settings-daemon/gnome-settings-xrdb.c gnome-settings-daemon/gnome-settings-xsettings.c libbackground/applier.c libbackground/applier.h libbackground/preferences.c libsounds/sound-properties.c libsounds/sound-view.h libwindow-settings/gnome-wm-manager.c libwindow-settings/metacity-window-manager.c typing-break/drw-break-window.c typing-break/drw-utils.h typing-break/drwright.c vfs-methods/fontilus/font-view.c vfs-methods/themus/themus-theme-applier.c: Cleanup of gconf and a few other things, patch from Kjartan Maraas <kmaraas@gnome.org> (Closes: #301945).
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
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;
data.image = image;
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;
data.image = image;
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-12-16 08:23:09 +00:00
double_click_timestamp = event->time;
switch (double_click_state) {
case DOUBLE_CLICK_TEST_ON:
gtk_image_set_from_stock (GTK_IMAGE (image),
MOUSE_DBLCLCK_ON, mouse_capplet_dblclck_icon_get_size());
2001-12-16 08:23:09 +00:00
break;
case DOUBLE_CLICK_TEST_MAYBE:
gtk_image_set_from_stock (GTK_IMAGE (image),
MOUSE_DBLCLCK_MAYBE, mouse_capplet_dblclck_icon_get_size());
2001-12-16 08:23:09 +00:00
break;
case DOUBLE_CLICK_TEST_OFF:
gtk_image_set_from_stock (GTK_IMAGE (image),
MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size());
2001-12-16 08:23:09 +00:00
break;
}
2001-12-16 08:23:09 +00:00
return TRUE;
}
/* Callback issued when the user switches between left- and right-handed button
* mappings. Updates the appropriate image on the dialog.
*/
2001-12-16 08:23:09 +00:00
static void
left_handed_toggle_cb (GConfPropertyEditor *peditor, const gchar *key, const GConfValue *value, GtkWidget *image)
{
if (value && gconf_value_get_bool (value)) {
gtk_image_set_from_stock (GTK_IMAGE (image), MOUSE_LEFT_HANDED, mouse_capplet_icon_get_size ());
}
else {
gtk_image_set_from_stock (GTK_IMAGE (image), MOUSE_RIGHT_HANDED, mouse_capplet_icon_get_size ());
}
2001-12-16 08:23:09 +00:00
}
/* Set up the property editors in the dialog. */
2001-12-16 08:23:09 +00:00
static void
setup_dialog (GladeXML *dialog, GConfChangeSet *changeset)
2001-12-16 08:23:09 +00:00
{
GObject *peditor;
GConfValue *value;
gchar *message;
Cleanup of gconf and a few other things, patch from Kjartan Maraas 2005-05-22 Sebastien Bacher <seb128@debian.org> * ChangeLog capplets/about-me/e-image-chooser.c capplets/accessibility/at-properties/at-startup-session.h capplets/accessibility/keyboard/accessibility-keyboard.c capplets/background/gnome-wp-info.c capplets/common/gconf-property-editor.c capplets/common/gnome-theme-apply.c capplets/default-applications/gnome-default-applications-properties.c capplets/keybindings/gnome-keybinding-properties.c capplets/keyboard/gnome-keyboard-properties.c capplets/mouse/gnome-mouse-properties.c capplets/network/gnome-network-preferences.c capplets/sound/sound-properties-capplet.c capplets/theme-switcher/gnome-theme-details.c capplets/theme-switcher/gnome-theme-manager.c capplets/ui-properties/gnome-ui-properties.c capplets/windows/gnome-window-properties.c gnome-settings-daemon/factory.c gnome-settings-daemon/gnome-settings-accessibility-keyboard.c gnome-settings-daemon/gnome-settings-background.c gnome-settings-daemon/gnome-settings-daemon.c gnome-settings-daemon/gnome-settings-daemon.h gnome-settings-daemon/gnome-settings-font.c gnome-settings-daemon/gnome-settings-keybindings.c gnome-settings-daemon/gnome-settings-keybindings.h gnome-settings-daemon/gnome-settings-keyboard-xkb.c gnome-settings-daemon/gnome-settings-keyboard.c gnome-settings-daemon/gnome-settings-locate-pointer.h gnome-settings-daemon/gnome-settings-mouse.c gnome-settings-daemon/gnome-settings-multimedia-keys.c gnome-settings-daemon/gnome-settings-screensaver.c gnome-settings-daemon/gnome-settings-sound.c gnome-settings-daemon/gnome-settings-xmodmap.c gnome-settings-daemon/gnome-settings-xrdb.c gnome-settings-daemon/gnome-settings-xsettings.c libbackground/applier.c libbackground/applier.h libbackground/preferences.c libsounds/sound-properties.c libsounds/sound-view.h libwindow-settings/gnome-wm-manager.c libwindow-settings/metacity-window-manager.c typing-break/drw-break-window.c typing-break/drw-utils.h typing-break/drwright.c vfs-methods/fontilus/font-view.c vfs-methods/themus/themus-theme-applier.c: Cleanup of gconf and a few other things, patch from Kjartan Maraas <kmaraas@gnome.org> (Closes: #301945).
2005-05-22 15:46:45 +00:00
GConfClient *client = gconf_client_get_default ();
/* Buttons page */
2001-12-16 08:23:09 +00:00
/* Left-handed toggle */
peditor = gconf_peditor_new_boolean
(changeset, "/desktop/gnome/peripherals/mouse/left_handed", WID ("left_handed_toggle"), NULL);
g_signal_connect (peditor, "value-changed", (GCallback) left_handed_toggle_cb, WID ("orientation_image"));
2001-12-16 08:23:09 +00:00
/* Make sure the image gets initialized correctly */
Cleanup of gconf and a few other things, patch from Kjartan Maraas 2005-05-22 Sebastien Bacher <seb128@debian.org> * ChangeLog capplets/about-me/e-image-chooser.c capplets/accessibility/at-properties/at-startup-session.h capplets/accessibility/keyboard/accessibility-keyboard.c capplets/background/gnome-wp-info.c capplets/common/gconf-property-editor.c capplets/common/gnome-theme-apply.c capplets/default-applications/gnome-default-applications-properties.c capplets/keybindings/gnome-keybinding-properties.c capplets/keyboard/gnome-keyboard-properties.c capplets/mouse/gnome-mouse-properties.c capplets/network/gnome-network-preferences.c capplets/sound/sound-properties-capplet.c capplets/theme-switcher/gnome-theme-details.c capplets/theme-switcher/gnome-theme-manager.c capplets/ui-properties/gnome-ui-properties.c capplets/windows/gnome-window-properties.c gnome-settings-daemon/factory.c gnome-settings-daemon/gnome-settings-accessibility-keyboard.c gnome-settings-daemon/gnome-settings-background.c gnome-settings-daemon/gnome-settings-daemon.c gnome-settings-daemon/gnome-settings-daemon.h gnome-settings-daemon/gnome-settings-font.c gnome-settings-daemon/gnome-settings-keybindings.c gnome-settings-daemon/gnome-settings-keybindings.h gnome-settings-daemon/gnome-settings-keyboard-xkb.c gnome-settings-daemon/gnome-settings-keyboard.c gnome-settings-daemon/gnome-settings-locate-pointer.h gnome-settings-daemon/gnome-settings-mouse.c gnome-settings-daemon/gnome-settings-multimedia-keys.c gnome-settings-daemon/gnome-settings-screensaver.c gnome-settings-daemon/gnome-settings-sound.c gnome-settings-daemon/gnome-settings-xmodmap.c gnome-settings-daemon/gnome-settings-xrdb.c gnome-settings-daemon/gnome-settings-xsettings.c libbackground/applier.c libbackground/applier.h libbackground/preferences.c libsounds/sound-properties.c libsounds/sound-view.h libwindow-settings/gnome-wm-manager.c libwindow-settings/metacity-window-manager.c typing-break/drw-break-window.c typing-break/drw-utils.h typing-break/drwright.c vfs-methods/fontilus/font-view.c vfs-methods/themus/themus-theme-applier.c: Cleanup of gconf and a few other things, patch from Kjartan Maraas <kmaraas@gnome.org> (Closes: #301945).
2005-05-22 15:46:45 +00:00
value = gconf_client_get (client, "/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 */
peditor = gconf_peditor_new_numeric_range
(changeset, DOUBLE_CLICK_KEY, WID ("delay_scale"),
"conv-to-widget-cb", double_click_from_gconf,
NULL);
g_signal_connect (G_OBJECT (WID ("delay_scale")), "change_value", (GCallback) delay_value_changed_cb, dialog);
gtk_widget_set_size_request (WID ("delay_scale"), 150, -1);
gtk_image_set_from_stock (GTK_IMAGE (WID ("double_click_image")), MOUSE_DBLCLCK_OFF, mouse_capplet_dblclck_icon_get_size ());
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);
/* set the timeout value label with correct value of timeout */
message = g_strdup_printf (ngettext ("%d millisecond", "%d milliseconds", (int) gtk_range_get_value (GTK_RANGE (WID ("delay_scale")))), (int) gtk_range_get_value (GTK_RANGE (WID ("delay_scale"))));
gtk_label_set_label ((GtkLabel*) WID ("delay_label"), message);
g_free (message);
/* Motion page */
/* speed */
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);
gconf_peditor_new_numeric_range
(changeset, "/desktop/gnome/peripherals/mouse/motion_threshold", WID ("sensitivity_scale"),
"conv-to-widget-cb", threshold_from_gconf,
NULL);
/* DnD threshold */
gconf_peditor_new_numeric_range
(changeset, "/desktop/gnome/peripherals/mouse/drag_threshold", WID ("drag_threshold_scale"),
"conv-to-widget-cb", drag_threshold_from_gconf,
NULL);
}
/* Construct the dialog */
static GladeXML *
create_dialog (void)
{
GladeXML *dialog;
GtkSizeGroup *size_group;
/* register the custom type */
(void) mouse_capplet_check_button_get_type ();
Don't define directories in configure. Remove some obsolete defines, and 2007-02-02 Christian Persch <chpe@svn.gnome.org> * Makefile.am: * capplets/about-me/Makefile.am: * capplets/about-me/gnome-about-me-password.c: (passdlg_init): * capplets/about-me/gnome-about-me.c: (about_me_setup_dialog): * capplets/accessibility/at-properties/Makefile.am: * capplets/accessibility/keyboard/Makefile.am: * capplets/accessibility/keyboard/accessibility-keyboard.c: (setup_accessX_dialog): * capplets/background/Makefile.am: * capplets/background/gnome-wp-capplet.c: (gnome_wp_create_dialog): * capplets/common/Makefile.am: * capplets/common/capplet-util.c: (capplet_set_icon): * capplets/default-applications/Makefile.am: * capplets/display/Makefile.am: * capplets/file-types/Makefile.am: * capplets/file-types/file-types-capplet.c: (create_dialog): * capplets/file-types/mime-category-edit-dialog.c: (mime_category_edit_dialog_init): * capplets/file-types/mime-edit-dialog.c: (mime_edit_dialog_init): * capplets/file-types/service-edit-dialog.c: (service_edit_dialog_init): * capplets/font/Makefile.am: * capplets/keybindings/Makefile.am: * capplets/keybindings/gnome-keybinding-properties.c: (create_dialog): * capplets/keyboard/Makefile.am: * capplets/keyboard/gnome-keyboard-properties-xkblt.c: (xkb_layout_choose): * capplets/keyboard/gnome-keyboard-properties-xkbmc.c: (choose_model): * capplets/keyboard/gnome-keyboard-properties.c: (create_dialog): * capplets/localization/Makefile.am: * capplets/localization/gnome-localization-properties.c: (create_dialog): * capplets/mime-type/Makefile.am: * capplets/mouse/Makefile.am: * capplets/mouse/gnome-mouse-properties.c: (create_dialog): * capplets/network/Makefile.am: * capplets/network/gnome-network-preferences.c: (cb_http_details_button_clicked), (main): * capplets/rollback/Makefile.am: * capplets/sound/Makefile.am: * capplets/sound/sound-properties-capplet.c: (create_dialog), (device_test_button_clicked): * capplets/theme-switcher/Makefile.am: * capplets/ui-properties/Makefile.am: * capplets/ui-properties/gnome-ui-properties.c: (create_dialog): * capplets/url-properties/Makefile.am: * capplets/windows/Makefile.am: * capplets/wm-properties/wm-desktops/Makefile.am: * configure.in: * gnome-settings-daemon/Makefile.am: * gnome-settings-daemon/actions/Makefile.am: * gnome-settings-daemon/gnome-settings-xmodmap.c: (gnome_settings_modmap_dialog_call): * gnome-settings-daemon/gnome-settings-xrdb.c: * gnome-settings-daemon/gsd-media-keys-window.c: (action_changed), (gsd_media_keys_window_init): * gnome-settings-daemon/xrdb/Makefile.am: * typing-break/Makefile.am: * vfs-methods/themus/Makefile.am: Don't define directories in configure. Remove some obsolete defines, and use the standard installation paths. Bug #395383. svn path=/trunk/; revision=7226
2007-02-02 18:12:40 +00:00
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/gnome-mouse-properties.glade", "mouse_properties_dialog", NULL);
if (!dialog)
return NULL;
2001-12-16 08:23:09 +00:00
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"));
2001-12-16 08:23:09 +00:00
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"));
2001-12-16 08:23:09 +00:00
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"));
return dialog;
}
/* Callback issued when a button is clicked on the dialog */
static void
dialog_response_cb (GtkDialog *dialog, gint response_id, GConfChangeSet *changeset)
{
if (response_id == GTK_RESPONSE_HELP)
capplet_help (GTK_WINDOW (dialog),
"user-guide.xml",
"goscustperiph-5");
else
gtk_main_quit ();
}
int
main (int argc, char **argv)
{
GnomeProgram *program;
GConfClient *client;
GladeXML *dialog;
GtkWidget *dialog_win;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
program = gnome_program_init ("gnome-mouse-properties", VERSION,
LIBGNOMEUI_MODULE, argc, argv,
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
NULL);
2001-12-16 08:23:09 +00:00
capplet_init_stock_icons ();
activate_settings_daemon ();
client = gconf_client_get_default ();
gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
Cleanup of gconf and a few other things, patch from Kjartan Maraas 2005-05-22 Sebastien Bacher <seb128@debian.org> * ChangeLog capplets/about-me/e-image-chooser.c capplets/accessibility/at-properties/at-startup-session.h capplets/accessibility/keyboard/accessibility-keyboard.c capplets/background/gnome-wp-info.c capplets/common/gconf-property-editor.c capplets/common/gnome-theme-apply.c capplets/default-applications/gnome-default-applications-properties.c capplets/keybindings/gnome-keybinding-properties.c capplets/keyboard/gnome-keyboard-properties.c capplets/mouse/gnome-mouse-properties.c capplets/network/gnome-network-preferences.c capplets/sound/sound-properties-capplet.c capplets/theme-switcher/gnome-theme-details.c capplets/theme-switcher/gnome-theme-manager.c capplets/ui-properties/gnome-ui-properties.c capplets/windows/gnome-window-properties.c gnome-settings-daemon/factory.c gnome-settings-daemon/gnome-settings-accessibility-keyboard.c gnome-settings-daemon/gnome-settings-background.c gnome-settings-daemon/gnome-settings-daemon.c gnome-settings-daemon/gnome-settings-daemon.h gnome-settings-daemon/gnome-settings-font.c gnome-settings-daemon/gnome-settings-keybindings.c gnome-settings-daemon/gnome-settings-keybindings.h gnome-settings-daemon/gnome-settings-keyboard-xkb.c gnome-settings-daemon/gnome-settings-keyboard.c gnome-settings-daemon/gnome-settings-locate-pointer.h gnome-settings-daemon/gnome-settings-mouse.c gnome-settings-daemon/gnome-settings-multimedia-keys.c gnome-settings-daemon/gnome-settings-screensaver.c gnome-settings-daemon/gnome-settings-sound.c gnome-settings-daemon/gnome-settings-xmodmap.c gnome-settings-daemon/gnome-settings-xrdb.c gnome-settings-daemon/gnome-settings-xsettings.c libbackground/applier.c libbackground/applier.h libbackground/preferences.c libsounds/sound-properties.c libsounds/sound-view.h libwindow-settings/gnome-wm-manager.c libwindow-settings/metacity-window-manager.c typing-break/drw-break-window.c typing-break/drw-utils.h typing-break/drwright.c vfs-methods/fontilus/font-view.c vfs-methods/themus/themus-theme-applier.c: Cleanup of gconf and a few other things, patch from Kjartan Maraas <kmaraas@gnome.org> (Closes: #301945).
2005-05-22 15:46:45 +00:00
g_object_unref (client);
dialog = create_dialog ();
if (dialog) {
setup_dialog (dialog, NULL);
dialog_win = WID ("mouse_properties_dialog");
g_signal_connect (dialog_win, "response",
G_CALLBACK (dialog_response_cb), NULL);
2004-08-20 16:50:57 +00:00
capplet_set_icon (dialog_win, "gnome-dev-mouse-optical");
gtk_widget_show (dialog_win);
gtk_main ();
g_object_unref (dialog);
}
g_object_unref (program);
return 0;
}