[gnome-settings-daemon] wacom: Add index parameter to _get_button()



commit 63f3d53f7fce38205a5f963e82bf631a971b5c10
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 27 16:54:20 2012 +0100

    wacom: Add index parameter to _get_button()

 plugins/wacom/gsd-wacom-device.c |   26 +++++++++++++++++++++-----
 plugins/wacom/gsd-wacom-device.h |    1 +
 2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index 2821aaf..fbd37a5 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -1514,9 +1514,25 @@ find_button_with_id (GsdWacomDevice *device,
 	return NULL;
 }
 
+static GsdWacomTabletButton *
+find_button_with_index (GsdWacomDevice *device,
+			const char     *id,
+			int             index)
+{
+	GsdWacomTabletButton *button;
+	char *str;
+
+	str = g_strdup_printf ("%s-mode-%d", id, index + 1);
+	button = find_button_with_id (device, str);
+	g_free (str);
+
+	return button;
+}
+
 GsdWacomTabletButton *
 gsd_wacom_device_get_button (GsdWacomDevice   *device,
 			     int               button,
+			     int               index,
 			     GtkDirectionType *dir)
 {
 	if (button <= 26) {
@@ -1554,20 +1570,20 @@ gsd_wacom_device_get_button (GsdWacomDevice   *device,
 		;;
 	}
 
-	/* FIXME handle the mode */
+	/* The group ID is implied by the button number */
 	switch (button) {
 	case 90:
 	case 91:
-		return find_button_with_id (device, "left-ring-mode-1");
+		return find_button_with_index (device, "left-ring", index);
 	case 92:
 	case 93:
-		return find_button_with_id (device, "right-ring-mode-1");
+		return find_button_with_index (device, "right-ring", index);
 	case 94:
 	case 95:
-		return find_button_with_id (device, "left-strip-mode-1");
+		return find_button_with_index (device, "left-strip", index);
 	case 96:
 	case 97:
-		return find_button_with_id (device, "right-strip-mode-1");
+		return find_button_with_index (device, "right-strip", index);
 	default:
 		return NULL;
 	}
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index c07f48d..1c1196b 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -148,6 +148,7 @@ const char     * gsd_wacom_device_type_to_string    (GsdWacomDeviceType type);
 GList          * gsd_wacom_device_get_buttons       (GsdWacomDevice *device);
 GsdWacomTabletButton *gsd_wacom_device_get_button   (GsdWacomDevice   *device,
 						     int               button,
+						     int               index,
 						     GtkDirectionType *dir);
 
 /* Helper and debug functions */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]