[gnome-control-center/wip/garnacho/wayland-tablet: 20/31] wacom: Add cc_wacom_device_get_button_settings()



commit d39bd31cdf518dc060618f67d77c9c0fa32a3ee1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 23 16:50:58 2016 +0200

    wacom: Add cc_wacom_device_get_button_settings()
    
    This function retrieves the GSettings pointing to the configuration
    of the given button, or NULL if not found.

 panels/wacom/cc-wacom-device.c |   25 +++++++++++++++++++++++++
 panels/wacom/cc-wacom-device.h |    2 ++
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-device.c b/panels/wacom/cc-wacom-device.c
index 5371da7..c97c8bd 100644
--- a/panels/wacom/cc-wacom-device.c
+++ b/panels/wacom/cc-wacom-device.c
@@ -374,3 +374,28 @@ cc_wacom_device_get_num_buttons (CcWacomDevice *device)
 
        return libwacom_get_num_buttons (device->wdevice);
 }
+
+GSettings *
+cc_wacom_device_get_button_settings (CcWacomDevice *device,
+                                    guint          button)
+{
+       GSettings *tablet_settings, *settings;
+       gchar *path, *button_path;
+
+       g_return_val_if_fail (CC_IS_WACOM_DEVICE (device), NULL);
+
+       if (button > cc_wacom_device_get_num_buttons (device))
+               return NULL;
+
+       tablet_settings = cc_wacom_device_get_settings (device);
+       g_object_get (tablet_settings, "path", &path, NULL);
+
+       button_path = g_strdup_printf ("%sbutton%c/", path, 'A' + button);
+       settings = g_settings_new_with_path ("org.gnome.desktop.peripherals.tablet.pad-button",
+                                            button_path);
+       g_free (path);
+       g_free (button_path);
+       g_object_unref (tablet_settings);
+
+       return settings;
+}
diff --git a/panels/wacom/cc-wacom-device.h b/panels/wacom/cc-wacom-device.h
index 62bf656..756f746 100644
--- a/panels/wacom/cc-wacom-device.h
+++ b/panels/wacom/cc-wacom-device.h
@@ -59,5 +59,7 @@ void            cc_wacom_device_set_output      (CcWacomDevice *wacom_device,
 
 guint           cc_wacom_device_get_num_buttons (CcWacomDevice *wacom_device);
 
+GSettings     * cc_wacom_device_get_button_settings (CcWacomDevice *device,
+                                                    guint          button);
 
 #endif /* __CC_WACOM_DEVICE_H__ */


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