[gnome-control-center] wacom: Create CcWacomPage from GsdWacomDevices
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] wacom: Create CcWacomPage from GsdWacomDevices
- Date: Thu, 24 Nov 2011 19:15:56 +0000 (UTC)
commit 8f6fc0e3170947d8a6d98a6d0e39fa9cab33e587
Author: Bastien Nocera <hadess hadess net>
Date: Thu Nov 24 18:58:29 2011 +0000
wacom: Create CcWacomPage from GsdWacomDevices
Instead of hard-coding the location of settings.
panels/wacom/cc-wacom-page.c | 63 ++++++++++++++++++++++++-----------------
panels/wacom/cc-wacom-page.h | 5 ++-
2 files changed, 41 insertions(+), 27 deletions(-)
---
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index 61f05ce..8b598b6 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -40,10 +40,11 @@ G_DEFINE_TYPE (CcWacomPage, cc_wacom_page, GTK_TYPE_BOX)
struct _CcWacomPagePrivate
{
- GtkBuilder *builder;
- GSettings *wacom_settings;
- GSettings *stylus_settings;
- GSettings *eraser_settings;
+ GsdWacomDevice *pad, *stylus, *eraser;
+ GtkBuilder *builder;
+ GSettings *wacom_settings;
+ GSettings *stylus_settings;
+ GSettings *eraser_settings;
/* The UI doesn't support cursor/pad at the moment */
};
@@ -336,24 +337,6 @@ cc_wacom_page_dispose (GObject *object)
priv->builder = NULL;
}
- if (priv->wacom_settings)
- {
- g_object_unref (priv->wacom_settings);
- priv->wacom_settings = NULL;
- }
-
- if (priv->stylus_settings)
- {
- g_object_unref (priv->stylus_settings);
- priv->stylus_settings = NULL;
- }
-
- if (priv->eraser_settings)
- {
- g_object_unref (priv->eraser_settings);
- priv->eraser_settings = NULL;
- }
-
G_OBJECT_CLASS (cc_wacom_page_parent_class)->dispose (object);
}
@@ -440,20 +423,48 @@ cc_wacom_page_init (CcWacomPage *self)
gtk_image_set_from_file (GTK_IMAGE (WID ("image-stylus")), PIXMAP_DIR "/wacom-stylus.svg");
}
+static GSettings *
+get_first_stylus_setting (GsdWacomDevice *device)
+{
+ GList *styli;
+ GsdWacomStylus *stylus;
+
+ styli = gsd_wacom_device_list_styli (device);
+ stylus = styli->data;
+ g_list_free (styli);
+
+ return gsd_wacom_stylus_get_settings (stylus);
+}
+
GtkWidget *
-cc_wacom_page_new (void)
+cc_wacom_page_new (GsdWacomDevice *pad,
+ GsdWacomDevice *stylus,
+ GsdWacomDevice *eraser)
{
CcWacomPage *page;
CcWacomPagePrivate *priv;
+ g_return_val_if_fail (GSD_IS_WACOM_DEVICE (pad), NULL);
+ g_return_val_if_fail (gsd_wacom_device_get_device_type (pad) == WACOM_TYPE_PAD, NULL);
+
+ g_return_val_if_fail (GSD_IS_WACOM_DEVICE (stylus), NULL);
+ g_return_val_if_fail (gsd_wacom_device_get_device_type (stylus) == WACOM_TYPE_STYLUS, NULL);
+
+ g_return_val_if_fail (GSD_IS_WACOM_DEVICE (eraser), NULL);
+ g_return_val_if_fail (gsd_wacom_device_get_device_type (eraser) == WACOM_TYPE_ERASER, NULL);
+
page = g_object_new (CC_TYPE_WACOM_PAGE, NULL);
priv = page->priv;
+ priv->pad = pad;
+ priv->stylus = stylus;
+ priv->eraser = eraser;
/* FIXME move this to construct */
- priv->wacom_settings = g_settings_new (WACOM_SCHEMA);
- priv->stylus_settings = g_settings_new (WACOM_STYLUS_SCHEMA);
- priv->eraser_settings = g_settings_new (WACOM_ERASER_SCHEMA);
+ priv->wacom_settings = gsd_wacom_device_get_settings (pad);
+
+ priv->stylus_settings = get_first_stylus_setting (stylus);
+ priv->eraser_settings = get_first_stylus_setting (eraser);
set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-topbutton")), priv->stylus_settings, 3);
set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-bottombutton")), priv->stylus_settings, 2);
diff --git a/panels/wacom/cc-wacom-page.h b/panels/wacom/cc-wacom-page.h
index 1618f8c..48ecdc0 100644
--- a/panels/wacom/cc-wacom-page.h
+++ b/panels/wacom/cc-wacom-page.h
@@ -24,6 +24,7 @@
#define _CC_WACOM_PAGE_H
#include <gtk/gtk.h>
+#include "gsd-wacom-device.h"
G_BEGIN_DECLS
@@ -67,7 +68,9 @@ struct _CcWacomPageClass
GType cc_wacom_page_get_type (void) G_GNUC_CONST;
-GtkWidget * cc_wacom_page_new (void);
+GtkWidget * cc_wacom_page_new (GsdWacomDevice *pad,
+ GsdWacomDevice *stylus,
+ GsdWacomDevice *eraser);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]