[gnome-settings-daemon] wacom: Add function to set the next mode



commit a3b3a1f97251b3402807044918b67f9c0810a47b
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Feb 27 17:26:17 2012 +0100

    wacom: Add function to set the next mode
    
    And return the new mode index. This means that the g-s-d wacom
    manager doesn't need to track the state of each mode for each
    tablet itself.

 plugins/wacom/gsd-wacom-device.c |   24 ++++++++++++++++++++++++
 plugins/wacom/gsd-wacom-device.h |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index 0a2b6a4..f10f04c 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -851,6 +851,30 @@ add_stylus_to_device (GsdWacomDevice *device,
 	}
 }
 
+int
+gsd_wacom_device_set_next_mode (GsdWacomDevice *device,
+				int             group_id)
+{
+	int current_idx;
+	int num_modes;
+
+	g_return_val_if_fail (GSD_IS_WACOM_DEVICE (device), -1);
+	current_idx = GPOINTER_TO_INT (g_hash_table_lookup (device->priv->modes, GINT_TO_POINTER(group_id)));
+	/* That means that the mode doesn't exist, see gsd_wacom_device_add_modes() */
+	g_return_val_if_fail (current_idx != 0, -1);
+
+	current_idx++;
+
+	num_modes = GPOINTER_TO_INT (g_hash_table_lookup (device->priv->num_modes, GINT_TO_POINTER(group_id)));
+
+	if (current_idx > num_modes)
+		current_idx = 1;
+
+	g_hash_table_insert (device->priv->modes, GINT_TO_POINTER (group_id), GINT_TO_POINTER (current_idx));
+
+	return current_idx;
+}
+
 static int
 flags_to_group (WacomButtonFlags flags)
 {
diff --git a/plugins/wacom/gsd-wacom-device.h b/plugins/wacom/gsd-wacom-device.h
index 1c1196b..f7b239f 100644
--- a/plugins/wacom/gsd-wacom-device.h
+++ b/plugins/wacom/gsd-wacom-device.h
@@ -150,6 +150,8 @@ GsdWacomTabletButton *gsd_wacom_device_get_button   (GsdWacomDevice   *device,
 						     int               button,
 						     int               index,
 						     GtkDirectionType *dir);
+int gsd_wacom_device_set_next_mode                  (GsdWacomDevice *device,
+						     int             group_id);
 
 /* Helper and debug functions */
 GsdWacomDevice * gsd_wacom_device_create_fake (GsdWacomDeviceType  type,



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