gpointing-device-settings r87 - trunk/modules
- From: hiikezoe svn gnome org
- To: svn-commits-list gnome org
- Subject: gpointing-device-settings r87 - trunk/modules
- Date: Mon, 2 Mar 2009 03:26:55 +0000 (UTC)
Author: hiikezoe
Date: Mon Mar 2 03:26:55 2009
New Revision: 87
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=87&view=rev
Log:
Add utility functions for obtain property name and format type of XInput extension.
Added:
trunk/modules/gpds-trackpoint-xinput.c
trunk/modules/gpds-trackpoint-xinput.h
Modified:
trunk/modules/Makefile.am
trunk/modules/gpds-trackpoint-definitions.h
trunk/modules/gpds-trackpoint-ui.c
trunk/modules/gsd-trackpoint-manager.c
Modified: trunk/modules/Makefile.am
==============================================================================
--- trunk/modules/Makefile.am (original)
+++ trunk/modules/Makefile.am Mon Mar 2 03:26:55 2009
@@ -25,9 +25,14 @@
$(GCONF2_LIBS) \
$(GNOME_SETTINGS_DAEMON_LIBS)
+trackpoint_common_SOURCES = \
+ gpds-trackpoint-xinput.c \
+ gpds-trackpoint-xinput.h \
+ gpds-trackpoint-definitions.h
+
trackpoint_la_SOURCES = \
gpds-trackpoint-ui.c \
- gpds-trackpoint-definitions.h
+ $(trackpoint_common_SOURCES)
touchpad_la_SOURCES = \
gpds-touchpad-ui.c \
@@ -47,7 +52,8 @@
libtrackpoint_la_SOURCES = \
gsd-trackpoint-plugin.c \
gsd-trackpoint-manager.h \
- gsd-trackpoint-manager.c
+ gsd-trackpoint-manager.c \
+ $(trackpoint_common_SOURCES)
libtouchpad_la_CFLAGS = $(gsd_plugin_CFLAGS)
libtouchpad_la_SOURCES = \
Modified: trunk/modules/gpds-trackpoint-definitions.h
==============================================================================
--- trunk/modules/gpds-trackpoint-definitions.h (original)
+++ trunk/modules/gpds-trackpoint-definitions.h Mon Mar 2 03:26:55 2009
@@ -22,17 +22,6 @@
#define GPDS_TRACK_POINT_DEVICE_NAME "TPPS/2 IBM TrackPoint"
-#define GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION "Evdev Middle Button Emulation"
-#define GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT "Evdev Middle Button Timeout"
-#define GPDS_TRACK_POINT_WHEEL_EMULATION "Evdev Wheel Emulation"
-#define GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA "Evdev Wheel Emulation Inertia"
-#define GPDS_TRACK_POINT_WHEEL_EMULATION_X_AXIS "Evdev Wheel Emulation X Axis"
-#define GPDS_TRACK_POINT_WHEEL_EMULATION_Y_AXIS "Evdev Wheel Emulation Y Axis"
-#define GPDS_TRACK_POINT_WHEEL_EMULATION_AXES "Evdev Wheel Emulation Axes"
-#define GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT "Evdev Wheel Emulation Timeout"
-#define GPDS_TRACK_POINT_WHEEL_EMULATION_BUTTON "Evdev Wheel Emulation Button"
-#define GPDS_TRACK_POINT_DRAG_LOCK_BUTTONS "Evdev Drag Lock Buttons"
-
#define GPDS_TRACK_POINT_GCONF_DIR "/desktop/gnome/peripherals/trackpoint"
#define GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION_KEY GPDS_TRACK_POINT_GCONF_DIR "/middle_button_emulation"
#define GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT_KEY GPDS_TRACK_POINT_GCONF_DIR "/middle_button_timeoue"
Modified: trunk/modules/gpds-trackpoint-ui.c
==============================================================================
--- trunk/modules/gpds-trackpoint-ui.c (original)
+++ trunk/modules/gpds-trackpoint-ui.c Mon Mar 2 03:26:55 2009
@@ -28,6 +28,7 @@
#include <gconf/gconf-client.h>
#include "gpds-trackpoint-definitions.h"
+#include "gpds-trackpoint-xinput.h"
#define GPDS_TYPE_TRACK_POINT_UI (gpds_track_point_ui_get_type())
#define GPDS_TRACK_POINT_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUI))
@@ -151,15 +152,20 @@
}
static void
-set_toggle_property (GpdsXInput *xinput, GtkToggleButton *button, const gchar *property_name)
+set_toggle_property (GpdsXInput *xinput, GtkToggleButton *button, GpdsTrackPointProperty property)
{
GError *error = NULL;
gboolean active;
+ const gchar *property_name;
+ gint format_type;
active = gtk_toggle_button_get_active(button);
+ property_name = gpds_track_point_xinput_get_name(property);
+ format_type = gpds_track_point_xinput_get_format_type(property);
+
gpds_xinput_set_property(xinput,
property_name,
- 8,
+ format_type,
&error,
active ? 1 : 0,
NULL);
@@ -170,15 +176,20 @@
}
static void
-set_spin_property (GpdsXInput *xinput, GtkSpinButton *button, const gchar *property_name)
+set_spin_property (GpdsXInput *xinput, GtkSpinButton *button, GpdsTrackPointProperty property)
{
GError *error = NULL;
gdouble value;
+ const gchar *property_name;
+ gint format_type;
value = gtk_spin_button_get_value(button);
+ property_name = gpds_track_point_xinput_get_name(property);
+ format_type = gpds_track_point_xinput_get_format_type(property);
+
gpds_xinput_set_property(xinput,
property_name,
- 16,
+ format_type,
&error,
(gint)value,
NULL);
@@ -240,6 +251,8 @@
GError *error = NULL;
gboolean horizontal_scroll_active;
gboolean vertical_scroll_active;
+ const gchar *property_name;
+ gint format_type;
builder = gpds_ui_get_builder(GPDS_UI(ui));
@@ -249,9 +262,12 @@
button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "wheel_emulation_horizontal"));
horizontal_scroll_active = gtk_toggle_button_get_active(button);
+ property_name = gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_WHEEL_EMULATION_AXES);
+ format_type = gpds_track_point_xinput_get_format_type(GPDS_TRACK_POINT_WHEEL_EMULATION_AXES);
+
gpds_xinput_set_property(ui->xinput,
- GPDS_TRACK_POINT_WHEEL_EMULATION_AXES,
- 8,
+ property_name,
+ format_type,
&error,
vertical_scroll_active ? 6 : -1,
vertical_scroll_active ? 7 : -1,
@@ -364,7 +380,7 @@
static void
set_integer_property_from_preference (GpdsTrackPointUI *ui,
- const gchar *property_name,
+ GpdsTrackPointProperty property,
const gchar *gconf_key_name,
GtkBuilder *builder,
const gchar *object_name)
@@ -374,6 +390,9 @@
gulong n_values;
gint value;
gboolean dir_exists;
+ const gchar *property_name;
+
+ property_name = gpds_track_point_xinput_get_name(property);
if (!get_integer_property(ui->xinput, property_name,
&values, &n_values)) {
@@ -393,7 +412,7 @@
static void
set_boolean_property_from_preference (GpdsTrackPointUI *ui,
- const gchar *property_name,
+ GpdsTrackPointProperty property,
const gchar *gconf_key_name,
GtkBuilder *builder,
const gchar *object_name)
@@ -402,6 +421,9 @@
gint *values;
gulong n_values;
gboolean enable, dir_exists;
+ const gchar *property_name;
+
+ property_name = gpds_track_point_xinput_get_name(property);
if (!get_integer_property(ui->xinput, property_name,
&values, &n_values)) {
@@ -421,13 +443,15 @@
static void
set_scroll_axes_property_from_preference (GpdsTrackPointUI *ui,
- const gchar *property_name,
GtkBuilder *builder)
{
GObject *object;
gint *values;
gulong n_values;
gboolean horizontal_enable = FALSE, vertical_enable = FALSE, dir_exists;
+ const gchar *property_name;
+
+ property_name = gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_WHEEL_EMULATION_AXES);
if (!get_integer_property(ui->xinput, property_name,
&values, &n_values)) {
@@ -489,7 +513,6 @@
"wheel_emulation_inertia");
set_scroll_axes_property_from_preference(track_point_ui,
- GPDS_TRACK_POINT_WHEEL_EMULATION_AXES,
builder);
}
Added: trunk/modules/gpds-trackpoint-xinput.c
==============================================================================
--- (empty file)
+++ trunk/modules/gpds-trackpoint-xinput.c Mon Mar 2 03:26:55 2009
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2009 Hiroyuki Ikezoe <poincare ikezoe net>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gsd-trackpoint-manager.h"
+#include <glib/gi18n.h>
+#include <gconf/gconf-client.h>
+#include <gpds-xinput.h>
+
+#include "gpds-trackpoint-xinput.h"
+
+static GpdsTrackPointXInputProperty properties[] = {
+ {GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION, "Evdev Middle Button Emulation", 8, 1},
+ {GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT, "Evdev Middle Button Timeout", 32, 1},
+ {GPDS_TRACK_POINT_WHEEL_EMULATION, "Evdev Wheel Emulation", 8, 1},
+ {GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA, "Evdev Wheel Emulation Inertia", 16, 1},
+ {GPDS_TRACK_POINT_WHEEL_EMULATION_AXES, "Evdev Wheel Emulation Axes", 8, 4},
+ {GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT, "Evdev Wheel Emulation Timeout", 16, 1},
+ {GPDS_TRACK_POINT_WHEEL_EMULATION_BUTTON, "Evdev Wheel Emulation Button", 8, 1},
+ {GPDS_TRACK_POINT_DRAG_LOCK_BUTTONS, "Evdev Drag Lock Buttons", 8, 2}
+};
+
+static const gint n_properties = G_N_ELEMENTS(properties);
+
+const gchar *
+gpds_track_point_xinput_get_name (GpdsTrackPointProperty property)
+{
+ gint i;
+
+ for (i = 0; i < n_properties; i++) {
+ if (property == properties[i].property)
+ return properties[i].name;
+ }
+
+ return NULL;
+}
+
+gint
+gpds_track_point_xinput_get_format_type (GpdsTrackPointProperty property)
+{
+ gint i;
+
+ for (i = 0; i < n_properties; i++) {
+ if (property == properties[i].property)
+ return properties[i].format_type;
+ }
+
+ return -1;
+}
+
+gint
+gpds_track_point_xinput_get_max_value_count (GpdsTrackPointProperty property)
+{
+ gint i;
+
+ for (i = 0; i < n_properties; i++) {
+ if (property == properties[i].property)
+ return properties[i].max_value_count;
+ }
+
+ return -1;
+}
+
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Added: trunk/modules/gpds-trackpoint-xinput.h
==============================================================================
--- (empty file)
+++ trunk/modules/gpds-trackpoint-xinput.h Mon Mar 2 03:26:55 2009
@@ -0,0 +1,51 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2009 Hiroyuki Ikezoe <poincare ikezoe net>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __GPDS_TRACK_POINT_XINPUT_H__
+#define __GPDS_TRACK_POINT_XINPUT_H__
+
+typedef enum {
+ GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION,
+ GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT,
+ GPDS_TRACK_POINT_WHEEL_EMULATION,
+ GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA,
+ GPDS_TRACK_POINT_WHEEL_EMULATION_AXES,
+ GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT,
+ GPDS_TRACK_POINT_WHEEL_EMULATION_BUTTON,
+ GPDS_TRACK_POINT_DRAG_LOCK_BUTTONS,
+} GpdsTrackPointProperty;
+
+typedef struct _GpdsTrackPointXInputProperty GpdsTrackPointXInputProperty;
+struct _GpdsTrackPointXInputProperty
+{
+ GpdsTrackPointProperty property;
+ const gchar *name;
+ gint format_type;
+ gint max_value_count;
+};
+
+const gchar *gpds_track_point_xinput_get_name (GpdsTrackPointProperty property);
+gint gpds_track_point_xinput_get_format_type (GpdsTrackPointProperty property);
+gint gpds_track_point_xinput_get_max_value_count (GpdsTrackPointProperty property);
+
+
+#endif /* __GPDS_TRACK_POINT_XINPUT_H__ */
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Modified: trunk/modules/gsd-trackpoint-manager.c
==============================================================================
--- trunk/modules/gsd-trackpoint-manager.c (original)
+++ trunk/modules/gsd-trackpoint-manager.c Mon Mar 2 03:26:55 2009
@@ -27,6 +27,7 @@
#include <gpds-xinput.h>
#include "gpds-trackpoint-definitions.h"
+#include "gpds-trackpoint-xinput.h"
#define GSD_TRACK_POINT_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSD_TYPE_TRACK_POINT_MANAGER, GsdTrackPointManagerPrivate))
@@ -95,15 +96,15 @@
case GCONF_VALUE_BOOL:
if (!strcmp(key, GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION_KEY)) {
gpds_xinput_set_property(xinput,
- GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION,
- 8,
+ gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION),
+ gpds_track_point_xinput_get_format_type(GPDS_TRACK_POINT_MIDDLE_BUTTON_EMULATION),
NULL,
gconf_value_get_bool(value),
NULL);
} else if (!strcmp(key, GPDS_TRACK_POINT_WHEEL_EMULATION_KEY)) {
gpds_xinput_set_property(xinput,
- GPDS_TRACK_POINT_WHEEL_EMULATION,
- 8,
+ gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_WHEEL_EMULATION),
+ gpds_track_point_xinput_get_format_type(GPDS_TRACK_POINT_WHEEL_EMULATION),
NULL,
gconf_value_get_bool(value),
NULL);
@@ -117,8 +118,8 @@
GPDS_TRACK_POINT_WHEEL_EMULATION_X_AXIS_KEY,
NULL);
gpds_xinput_set_property(xinput,
- GPDS_TRACK_POINT_WHEEL_EMULATION_AXES,
- 8,
+ gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_WHEEL_EMULATION_AXES),
+ gpds_track_point_xinput_get_format_type(GPDS_TRACK_POINT_WHEEL_EMULATION_AXES),
NULL,
enable_vertical ? 6 : -1,
enable_vertical ? 7 : -1,
@@ -130,22 +131,22 @@
case GCONF_VALUE_INT:
if (!strcmp(key, GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT_KEY)) {
gpds_xinput_set_property(xinput,
- GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT,
- 32,
+ gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT),
+ gpds_track_point_xinput_get_format_type(GPDS_TRACK_POINT_MIDDLE_BUTTON_TIMEOUT),
NULL,
gconf_value_get_int(value),
NULL);
} else if (!strcmp(key, GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT_KEY)) {
gpds_xinput_set_property(xinput,
- GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT,
- 16,
+ gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT),
+ gpds_track_point_xinput_get_format_type(GPDS_TRACK_POINT_WHEEL_EMULATION_TIMEOUT),
NULL,
gconf_value_get_int(value),
NULL);
} else if (!strcmp(key, GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA_KEY)) {
gpds_xinput_set_property(xinput,
- GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA,
- 16,
+ gpds_track_point_xinput_get_name(GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA),
+ gpds_track_point_xinput_get_format_type(GPDS_TRACK_POINT_WHEEL_EMULATION_INERTIA),
NULL,
gconf_value_get_int(value),
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]