diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-01-07 21:04:07 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-06-22 16:23:42 +1000 |
commit | 4d150ac5d953a06d3ffa037a30a8c2605252cc77 (patch) | |
tree | 5b26d6403a0f6150498ac2c5284e08b69787100c | |
parent | 721f36087a656aff4c07b7e84abc71e28d8ba3ad (diff) |
Add a wacom control panelwacom
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | panels/Makefile.am | 3 | ||||
-rw-r--r-- | panels/wacom/Makefile.am | 44 | ||||
-rw-r--r-- | panels/wacom/cc-wacom-panel.c | 137 | ||||
-rw-r--r-- | panels/wacom/cc-wacom-panel.h | 73 | ||||
-rw-r--r-- | panels/wacom/gnome-wacom-panel.desktop.in.in | 17 | ||||
-rw-r--r-- | panels/wacom/gnome-wacom-properties.c | 452 | ||||
-rw-r--r-- | panels/wacom/gnome-wacom-properties.h | 28 | ||||
-rw-r--r-- | panels/wacom/gnome-wacom-properties.ui | 511 | ||||
-rw-r--r-- | panels/wacom/wacom-module.c | 41 | ||||
-rw-r--r-- | panels/wacom/wacom-stylus.png | bin | 0 -> 3165 bytes | |||
-rw-r--r-- | panels/wacom/wacom-tablet.png | bin | 0 -> 2301 bytes |
12 files changed, 1309 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 82d81d9ac..c9cf22000 100644 --- a/configure.ac +++ b/configure.ac @@ -119,6 +119,8 @@ PKG_CHECK_MODULES(USER_ACCOUNTS_PANEL, $COMMON_MODULES dbus-glib-1 polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION gnome-desktop-3.0 gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION) +PKG_CHECK_MODULES(WACOM_PANEL, $COMMON_MODULES xi >= 1.2 + gnome-settings-daemon >= $GSD_REQUIRED_VERSION x11) GDESKTOP_PREFIX=`$PKG_CONFIG --variable prefix gsettings-desktop-schemas` AC_SUBST(GDESKTOP_PREFIX) @@ -367,6 +369,8 @@ panels/user-accounts/data/Makefile panels/user-accounts/data/gnome-user-accounts-panel.desktop.in panels/user-accounts/data/faces/Makefile panels/user-accounts/data/icons/Makefile +panels/wacom/Makefile +panels/wacom/gnome-wacom-panel.desktop.in po/Makefile.in shell/Makefile shell/gnome-control-center.desktop.in diff --git a/panels/Makefile.am b/panels/Makefile.am index 06f9fdc13..6e186e4ef 100644 --- a/panels/Makefile.am +++ b/panels/Makefile.am @@ -12,7 +12,8 @@ SUBDIRS= \ keyboard \ universal-access \ user-accounts \ - datetime + datetime \ + wacom if BUILD_PRINTERS SUBDIRS += printers diff --git a/panels/wacom/Makefile.am b/panels/wacom/Makefile.am new file mode 100644 index 000000000..9cc4042d9 --- /dev/null +++ b/panels/wacom/Makefile.am @@ -0,0 +1,44 @@ +# This is used in PANEL_CFLAGS +cappletname = wacom + +INCLUDES = \ + $(PANEL_CFLAGS) \ + $(WACOM_PANEL_CFLAGS) \ + -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ + -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \ + -DGNOMECC_UI_DIR="\"$(uidir)\"" \ + -DPIXMAP_DIR=\""$(datadir)/gnome-control-center/pixmaps"\" \ + $(NULL) + + +ccpanelsdir = $(PANELS_DIR) +ccpanels_LTLIBRARIES = libwacom-properties.la + +libwacom_properties_la_SOURCES = \ + wacom-module.c \ + cc-wacom-panel.c \ + cc-wacom-panel.h \ + gnome-wacom-properties.c \ + gnome-wacom-properties.h + +libwacom_properties_la_LIBADD = $(PANEL_LIBS) $(WACOM_PANEL_LIBS) +libwacom_properties_la_LDFLAGS = $(PANEL_LDFLAGS) + +@INTLTOOL_DESKTOP_RULE@ + +pixmapdir = $(pkgdatadir)/pixmaps +pixmap_DATA = \ + wacom-tablet.png \ + wacom-stylus.png + +uidir = $(pkgdatadir)/ui +ui_DATA = gnome-wacom-properties.ui + +desktopdir = $(datadir)/applications +Desktop_in_files = gnome-wacom-panel.desktop.in +desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop) + +CLEANFILES = $(Desktop_in_files) $(desktop_DATA) +EXTRA_DIST = $(ui_DATA) $(pixmap_DATA) + +-include $(top_srcdir)/git.mk diff --git a/panels/wacom/cc-wacom-panel.c b/panels/wacom/cc-wacom-panel.c new file mode 100644 index 000000000..b1794dcf6 --- /dev/null +++ b/panels/wacom/cc-wacom-panel.c @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2010 Intel, Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Authors: Thomas Wood <thomas.wood@intel.com> + * Rodrigo Moya <rodrigo@gnome.org> + * + */ + +#include "cc-wacom-panel.h" +#include "gnome-wacom-properties.h" +#include <gtk/gtk.h> + +G_DEFINE_DYNAMIC_TYPE (CcWacomPanel, cc_wacom_panel, CC_TYPE_PANEL) + +#define WACOM_PANEL_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_WACOM_PANEL, CcWacomPanelPrivate)) + +struct _CcWacomPanelPrivate +{ + GtkBuilder *builder; +}; + + +static void +cc_wacom_panel_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +cc_wacom_panel_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) + { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +cc_wacom_panel_dispose (GObject *object) +{ + CcWacomPanelPrivate *priv = CC_WACOM_PANEL (object)->priv; + + if (priv->builder) + { + g_object_unref (priv->builder); + priv->builder = NULL; + } + + G_OBJECT_CLASS (cc_wacom_panel_parent_class)->dispose (object); +} + +static void +cc_wacom_panel_finalize (GObject *object) +{ + G_OBJECT_CLASS (cc_wacom_panel_parent_class)->finalize (object); +} + +static void +cc_wacom_panel_class_init (CcWacomPanelClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (CcWacomPanelPrivate)); + + object_class->get_property = cc_wacom_panel_get_property; + object_class->set_property = cc_wacom_panel_set_property; + object_class->dispose = cc_wacom_panel_dispose; + object_class->finalize = cc_wacom_panel_finalize; +} + +static void +cc_wacom_panel_class_finalize (CcWacomPanelClass *klass) +{ +} + +static void +cc_wacom_panel_init (CcWacomPanel *self) +{ + CcWacomPanelPrivate *priv; + GtkWidget *grid; + GError *error = NULL; + + priv = self->priv = WACOM_PANEL_PRIVATE (self); + + priv->builder = gtk_builder_new (); + + gtk_builder_add_from_file (priv->builder, + GNOMECC_UI_DIR "/gnome-wacom-properties.ui", + &error); + if (error != NULL) + { + g_warning ("Error loading UI file: %s", error->message); + return; + } + + gnome_wacom_properties_init (priv->builder); + + grid = (GtkWidget*) gtk_builder_get_object (priv->builder, + "grid1"); + + gtk_widget_reparent (grid, GTK_WIDGET (self)); +} + +void +cc_wacom_panel_register (GIOModule *module) +{ + cc_wacom_panel_register_type (G_TYPE_MODULE (module)); + g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT, + CC_TYPE_WACOM_PANEL, + "wacom", 0); +} diff --git a/panels/wacom/cc-wacom-panel.h b/panels/wacom/cc-wacom-panel.h new file mode 100644 index 000000000..9b04bfd51 --- /dev/null +++ b/panels/wacom/cc-wacom-panel.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2010 Intel, Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Author: Thomas Wood <thomas.wood@intel.com> + */ + + +#ifndef _CC_WACOM_PANEL_H +#define _CC_WACOM_PANEL_H + +#include <libgnome-control-center/cc-panel.h> + +G_BEGIN_DECLS + +#define CC_TYPE_WACOM_PANEL cc_wacom_panel_get_type() + +#define CC_WACOM_PANEL(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + CC_TYPE_WACOM_PANEL, CcWacomPanel)) + +#define CC_WACOM_PANEL_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + CC_TYPE_WACOM_PANEL, CcWacomPanelClass)) + +#define CC_IS_WACOM_PANEL(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + CC_TYPE_WACOM_PANEL)) + +#define CC_IS_WACOM_PANEL_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + CC_TYPE_WACOM_PANEL)) + +#define CC_WACOM_PANEL_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + CC_TYPE_WACOM_PANEL, CcWacomPanelClass)) + +typedef struct _CcWacomPanel CcWacomPanel; +typedef struct _CcWacomPanelClass CcWacomPanelClass; +typedef struct _CcWacomPanelPrivate CcWacomPanelPrivate; + +struct _CcWacomPanel +{ + CcPanel parent; + + CcWacomPanelPrivate *priv; +}; + +struct _CcWacomPanelClass +{ + CcPanelClass parent_class; +}; + +GType cc_wacom_panel_get_type (void) G_GNUC_CONST; + +void cc_wacom_panel_register (GIOModule *module); + +G_END_DECLS + +#endif /* _CC_WACOM_PANEL_H */ diff --git a/panels/wacom/gnome-wacom-panel.desktop.in.in b/panels/wacom/gnome-wacom-panel.desktop.in.in new file mode 100644 index 000000000..97bef9b0a --- /dev/null +++ b/panels/wacom/gnome-wacom-panel.desktop.in.in @@ -0,0 +1,17 @@ +[Desktop Entry] +_Name=Wacom +_Comment=Set your Wacom tablet preferences +Exec=gnome-control-center wacom +Icon=input-tablet +Terminal=false +Type=Application +StartupNotify=true +Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel; +OnlyShowIn=GNOME; +X-GNOME-Bugzilla-Bugzilla=GNOME +X-GNOME-Bugzilla-Product=gnome-control-center +X-GNOME-Bugzilla-Component=wacom +X-GNOME-Bugzilla-Version=@VERSION@ +X-GNOME-Settings-Panel=wacom +# Translators: those are keywords for the wacom tablet control-center panel +_X-GNOME-Keywords=Tablet;Wacom;Stylus; diff --git a/panels/wacom/gnome-wacom-properties.c b/panels/wacom/gnome-wacom-properties.c new file mode 100644 index 000000000..1167de8b3 --- /dev/null +++ b/panels/wacom/gnome-wacom-properties.c @@ -0,0 +1,452 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2001 Red Hat, Inc. + * Copyright (C) 2001 Ximian, Inc. + * Copyright (C) 2011 Red Hat, Inc. + * + * Written by: Peter Hutterer <peter.hutterer@redhat.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <config.h> + +#include <glib/gi18n.h> +#include <string.h> +#include <gdk/gdkx.h> +#include <gnome-settings-daemon/gsd-enums.h> +#include <math.h> + +#include "gnome-wacom-properties.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <dirent.h> + +#include <X11/Xatom.h> +#include <X11/extensions/XInput.h> + +#define WID(x) (GtkWidget*) gtk_builder_get_object (dialog, x) + +#define MAX_BUTTONS 8 /* max number of buttons in UI */ + +/* Note: currently we only support one configuration for wacom devices, not + * per-tablet configuration. (we do allow per-tool configuration though). + * The GUI will only display the tool _types_ found. + * i.e. if you have two styli, two erasers and one pad, you'll see stylus, + * eraser, pad in the GUI. + */ + +static GSettings *wacom_settings = NULL; +static GSettings *stylus_settings = NULL; +static GSettings *eraser_settings = NULL; +static GSettings *cursor_settings = NULL; +static GSettings *pad_settings = NULL; + +/* Button combo box storage columns */ +enum { + BUTTONNUMBER_COLUMN, + BUTTONNAME_COLUMN, + N_BUTTONCOLUMNS +}; + +/* Tablet mode combo box storage columns + * MODEID_COLUMN is special, it's a string that double-functions as ID + * and as data on what to set. + * Values are single chars for each device in the order + * <stylus><eraser><cursor> + * With values of + * - 'a' for absolute + * - 'r' for relative + * - 'u' for undefined/do not modify + * + * e.g. aau means absolute stylus and eraser, don't change cursor. + */ +enum { + MODENUMBER_COLUMN, + MODELABEL_COLUMN, + MODEID_COLUMN, + N_MODECOLUMNS +}; + +#define N_PRESSURE_CURVES 7 + +/* gsettings stores pressurecurve as 4 values like the driver. we map slider + * scale to these values given the array below. These settings were taken from + * wacomcpl, where they've been around for years. Presumably they're good + * enough. */ +static const gint32 PRESSURECURVE_DEFAULTS[N_PRESSURE_CURVES][4] = { + { 0, 75, 25, 100 }, + { 0, 50, 50, 100 }, + { 0, 25, 75, 100 }, + { 0, 0, 100, 100 }, + { 25, 0, 100, 75 }, + { 50, 0, 100, 50 }, + { 75, 0, 100, 25 } +}; + +/* + * Pressurecurve in the GUI is a slider that selects from the + * PRESSURECURVE_DEFAULTS defined above. Pressurecurve in gsettings is a + * 4-value integer array. + */ +static void +set_pressurecurve (GtkRange *range, GSettings *settings) +{ + gint value = gtk_range_get_value (range); + GVariant *values[4], *array; + int i; + + for (i = 0; i < 4; i++) + values[i] = g_variant_new_int32 (PRESSURECURVE_DEFAULTS[value][i]); + + array = g_variant_new_array (G_VARIANT_TYPE_INT32, values, 4); + + g_settings_set_value (settings, "pressurecurve", array); + + /* FIXME: why does this crash? + for (i = 0; i < 4; i++) + g_variant_unref (values[i]); + */ + g_variant_unref (array); +} + +static void +tip_feel_value_changed_cb (GtkRange *range, gpointer user_data) +{ + set_pressurecurve (range, stylus_settings); +} + +static void +eraser_feel_value_changed_cb (GtkRange *range, gpointer user_data) +{ + set_pressurecurve (range, eraser_settings); +} + +static void +preselect_feel (GtkAdjustment *adjustment, GSettings *settings) +{ + GVariant *value; + const gint32 *v; + gsize nvalues; + int i; + + value = g_settings_get_value (settings, "pressurecurve"); + v = g_variant_get_fixed_array (value, &nvalues, sizeof (gint32)); + + if (nvalues != 4) { + g_warning ("Invalid pressure curve format, expected 4 values (got %ld)", nvalues); + return; + } + + for (i = 0; i < N_PRESSURE_CURVES; i++) { + if (memcmp (PRESSURECURVE_DEFAULTS[i], v, sizeof (gint32) * 4) == 0) + gtk_adjustment_set_value (adjustment, i); + } +} + +/* Search the X input device list for wacom tablets. + * + * @return True if at least one compatible tablet was found, False otherwise. + */ +static Bool +find_tablets (void) +{ + Bool found = False; + int numdevices; + XDeviceInfo *devicelist; + Atom realtype, + prop; + int realformat; + unsigned long nitems, + bytes_after; + unsigned char *data; + int i; + XExtensionVersion *version; + + /* Input device properties require version 1.5 or higher */ + version = XGetExtensionVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "XInputExtension"); + if (!version->present || + (version->major_version * 1000 + version->minor_version) < 1005) + goto out; + + prop = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), "Wacom Tool Type", True); + if (!prop) + goto out; + + devicelist = XListInputDevices (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), &numdevices); + for (i = 0; !found && i < numdevices; i++) { + XDevice *device; + + gdk_error_trap_push (); + + device = XOpenDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), + devicelist[i].id); + if (gdk_error_trap_pop ()) + continue; + + gdk_error_trap_push (); + if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), + device, prop, 0, 1, False, + XA_ATOM, &realtype, &realformat, &nitems, + &bytes_after, &data) == Success) && (realtype != None)) { + found = True; + XFree (data); + } + gdk_error_trap_pop_ignored (); + + XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); + } + +out: + XFree (version); + XFreeDeviceList (devicelist); + + return found; +} + +static void +set_mode (GSettings *settings, int is_absolute) +{ + GVariant *value; + + value = g_variant_new_boolean (!!is_absolute); + g_settings_set_value (settings, "is-absolute", value); +} + +static void +tabletmode_changed_cb (GtkComboBox *combo, gpointer user_data) +{ + GtkBuilder *dialog = GTK_BUILDER (user_data); + GtkListStore *liststore; + GtkTreeIter iter; + gint mode; + + liststore = GTK_LIST_STORE (WID ("liststore-tabletmode")); + + if (!gtk_combo_box_get_active_iter (combo, &iter)) + return; + + gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter, + MODENUMBER_COLUMN, &mode, + -1); + + /* This must be kept in sync with the .ui file */ + switch (mode) + { + case 0: /* Stylus absolute */ + set_mode (stylus_settings, Absolute); + set_mode (eraser_settings, Absolute); + break; + case 1: /* Stylus relative */ + set_mode (stylus_settings, Relative); + set_mode (eraser_settings, Relative); + break; + default: + g_warning ("Ignoring unknown tablet mode %d.\n", mode); + break; + } +} + +static void +preselect_mode (GtkComboBox *combo) +{ + GSettings *settings; + int stylus_is_absolute, eraser_is_absolute; + + settings = stylus_settings; + stylus_is_absolute = g_settings_get_boolean (settings, "is-absolute"); + + settings = eraser_settings; + eraser_is_absolute = g_settings_get_boolean (settings, "is-absolute"); + + /* this must be kept in sync with the .ui file */ + if (stylus_is_absolute && eraser_is_absolute) + gtk_combo_box_set_active_id (combo, "aau"); + else if (!stylus_is_absolute && !eraser_is_absolute) + gtk_combo_box_set_active_id (combo, "rru"); +} + +/* Select the right value for current_button (1-indexed) in the provided button combo. + */ +static void +preselect_buttons (GtkComboBox *combo, GSettings* settings, gint current_button) +{ + GVariant *current; + gsize nvalues; + const gint *values; + GtkTreeModel *model; + GtkTreeIter iter; + gboolean valid; + + current = g_settings_get_value (settings, "buttonmapping"); + values = g_variant_get_fixed_array (current, &nvalues, sizeof (gint32)); + model = gtk_combo_box_get_model (combo); + valid = gtk_tree_model_get_iter_first (model, &iter); + + while (valid) { + gint button; + + gtk_tree_model_get (model, &iter, + BUTTONNUMBER_COLUMN, &button, + -1); + + /* 0 vs 1-indexed array/button numbers */ + if (button == values[current_button - 1]) { + gtk_combo_box_set_active_iter (combo, &iter); + break; + } + + valid = gtk_tree_model_iter_next (model, &iter); + } +} + +/* Map the button in gsettings by getting the current values, flipping the + * button given to the given mapping. + */ +static void +map_button (GSettings *settings, int button2, int button3) +{ + GVariant *current; /* current mapping */ + GVariant *array; /* new mapping */ + GVariant **tmp; + gsize nvalues; + const gint *values; + gint i; + + current = g_settings_get_value (settings, "buttonmapping"); + values = g_variant_get_fixed_array (current, &nvalues, sizeof (gint32)); + + tmp = g_malloc (nvalues * sizeof (GVariant*)); + for (i = 0; i < nvalues; i++) { + if (i == 1) /* zero indexed array vs one-indexed buttons */ + tmp[i] = g_variant_new_int32 (button2); + else if (i == 2) + tmp[i] = g_variant_new_int32 (button3); + else + tmp[i] = g_variant_new_int32 (values[i]); + } + + array = g_variant_new_array (G_VARIANT_TYPE_INT32, tmp, nvalues); + g_settings_set_value (settings, "buttonmapping", array); + + /* FIXME: why does this crash? + for (i = 0; i < nvalues; i++) + g_variant_unref (tmp[i]); + */ + g_free (tmp); + g_variant_unref (array); +} + +/** + * Callback for button mapping combo boxes + * We only allow buttons 2 and 3 to be mapped in the GUI. + */ +static void +button_changed_cb (GtkComboBox *combo, gpointer user_data) +{ + GtkBuilder *dialog = GTK_BUILDER (user_data); + GtkTreeIter iter; + GtkListStore *liststore; + gint mapping_b2, mapping_b3; + + liststore = GTK_LIST_STORE (WID ("liststore-buttons")); + + if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("combo-bottombutton")), &iter)) + return; + + gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter, + BUTTONNUMBER_COLUMN, &mapping_b2, + -1); + + if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("combo-topbutton")), &iter)) + return; + gtk_tree_model_get (GTK_TREE_MODEL (liststore), &iter, + BUTTONNUMBER_COLUMN, &mapping_b3, + -1); + + map_button (stylus_settings, mapping_b2, mapping_b3); +} + +/* Called for all button combo boxes. + Set up a cell renderer for the combo box with the given name. Hook up the + button_changed_cb callback for the changed signal. + */ +static void +combobox_text_cellrenderer (GtkComboBox *combo, int name_column) +{ + GtkCellRenderer *renderer; + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, + "text", BUTTONNAME_COLUMN, NULL); +} + +/* Set up the property editors in the dialog. */ +static void +setup_dialog (GtkBuilder *dialog) +{ + GtkComboBox *combo; + + /* tip feel slider */ + g_signal_connect (WID ("scale-tip-feel"), "value-changed", + G_CALLBACK (tip_feel_value_changed_cb), dialog); + g_signal_connect (WID ("scale-eraser-feel"), "value-changed", + G_CALLBACK (eraser_feel_value_changed_cb), dialog); + + combo = GTK_COMBO_BOX (WID ("combo-topbutton")); + combobox_text_cellrenderer (combo, BUTTONNAME_COLUMN); + g_signal_connect (G_OBJECT (combo), "changed", + G_CALLBACK (button_changed_cb), dialog); + + combo = GTK_COMBO_BOX (WID ("combo-bottombutton")); + combobox_text_cellrenderer (combo, BUTTONNAME_COLUMN); + g_signal_connect (G_OBJECT (combo), "changed", + G_CALLBACK (button_changed_cb), dialog); + + combo = GTK_COMBO_BOX (WID ("combo-tabletmode")); + combobox_text_cellrenderer (combo, MODELABEL_COLUMN); + g_signal_connect (G_OBJECT (combo), "changed", + G_CALLBACK (tabletmode_changed_cb), dialog); + gtk_combo_box_set_id_column (combo, MODEID_COLUMN); + + preselect_buttons (GTK_COMBO_BOX (WID ("combo-topbutton")), stylus_settings, 3); + preselect_buttons (GTK_COMBO_BOX (WID ("combo-bottombutton")), stylus_settings, 2); + preselect_mode (GTK_COMBO_BOX (WID ("combo-tabletmode"))); + preselect_feel (GTK_ADJUSTMENT (WID ("adjustment-tip-feel")), stylus_settings); + preselect_feel (GTK_ADJUSTMENT (WID ("adjustment-eraser-feel")), eraser_settings); + + gtk_image_set_from_file (GTK_IMAGE (WID ("image-tablet")), PIXMAP_DIR "/wacom-tablet.png"); + gtk_image_set_from_file (GTK_IMAGE (WID ("image-stylus")), PIXMAP_DIR "/wacom-stylus.png"); +} + +GtkWidget * +gnome_wacom_properties_init (GtkBuilder *dialog) +{ + GtkWidget *dialog_win; + + wacom_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.wacom"); + stylus_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.wacom.stylus"); + eraser_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.wacom.eraser"); + cursor_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.wacom.cursor"); + pad_settings = g_settings_new ("org.gnome.settings-daemon.peripherals.wacom.pad"); + + setup_dialog (dialog); + dialog_win = WID ("wacom_properties_dialog"); + + return dialog_win; +} diff --git a/panels/wacom/gnome-wacom-properties.h b/panels/wacom/gnome-wacom-properties.h new file mode 100644 index 000000000..0d5dc71cf --- /dev/null +++ b/panels/wacom/gnome-wacom-properties.h @@ -0,0 +1,28 @@ +/* -*- mode: c; style: linux -*- */ + +/* wacom-properties-capplet.c + * Copyright (C) 2001 Red Hat, Inc. + * Copyright (C) 2001 Ximian, Inc. + * + * Written by: Jonathon Blandford <jrb@redhat.com>, + * Bradford Hovinen <hovinen@ximian.com>, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include <gtk/gtk.h> + +GtkWidget *gnome_wacom_properties_init (GtkBuilder *dialog); diff --git a/panels/wacom/gnome-wacom-properties.ui b/panels/wacom/gnome-wacom-properties.ui new file mode 100644 index 000000000..64a97367d --- /dev/null +++ b/panels/wacom/gnome-wacom-properties.ui @@ -0,0 +1,511 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkAdjustment" id="adjustment-eraser-feel"> + <property name="upper">6</property> + <property name="step_increment">1</property> + <property name="page_increment">5</property> + </object> + <object class="GtkAdjustment" id="adjustment-tip-feel"> + <property name="upper">6</property> + <property name="step_increment">1</property> + <property name="page_increment">5</property> + </object> + <object class="GtkListStore" id="liststore-buttons"> + <columns> + <!-- column-name button --> + <column type="guint"/> + <!-- column-name button-label --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0">0</col> + <col id="1" translatable="yes">No Action</col> + </row> + <row> + <col id="0">1</col> + <col id="1" translatable="yes">Left Mouse Button Click</col> + </row> + <row> + <col id="0">2</col> + <col id="1" translatable="yes">Middle Mouse Button Click</col> + </row> + <row> + <col id="0">3</col> + <col id="1" translatable="yes">Right Mouse Button Click</col> + </row> + </data> + </object> + <object class="GtkListStore" id="liststore-tabletmode"> + <columns> + <!-- column-name tabletmode --> + <column type="guint"/> + <!-- column-name tabletmode-label --> + <column type="gchararray"/> + <!-- column-name device --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0">0</col> + <col id="1" translatable="yes">Tablet (absolute)</col> + <col id="2">aau</col> + </row> + <row> + <col id="0">1</col> + <col id="1" translatable="yes">Touchpad (relative)</col> + <col id="2">rru</col> + </row> + </data> + </object> + <object class="GtkDialog" id="wacom_properties_dialog"> + <property name="width_request">675</property> + <property name="height_request">465</property> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="title" translatable="yes">Tablet Preferences</property> + <property name="resizable">False</property> + <property name="default_width">675</property> + <property name="default_height">460</property> + <property name="icon_name">input-tablet</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="helpbutton1"> + <property name="label">gtk-help</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="closebutton1"> + <property name="label">gtk-close</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="receives_default">False</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="n_rows">8</property> + <property name="n_columns">4</property> + <child> + <object class="GtkImage" id="image-tablet"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="icon_name">input-tablet</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">3</property> + </packing> + </child> + <child> + <object class="GtkImage" id="image-stylus"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="stock">gtk-missing-image</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + <property name="width">2</property> + <property name="height">4</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="combo-tabletmode"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="model">liststore-tabletmode</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-trackingmode"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="margin_right">10</property> + <property name="xpad">3</property> + <property name="label" translatable="yes">Tracking Mode</property> + <property name="justify">right</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button-calibrate"> + <property name="label" translatable="yes">Calibrate...</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="halign">start</property> + <property name="valign">center</property> + <property name="use_action_appearance">False</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel" id="label-eraser-soft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Soft</property> + <attributes> + <attribute name="style" value="italic"/> + <attribute name="scale" value="0.82999999999999996"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScale" id="scale-eraser-feel"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="valign">center</property> + <property name="margin_left">10</property> + <property name="margin_right">10</property> + <property name="adjustment">adjustment-eraser-feel</property> + <property name="digits">0</property> + <property name="draw_value">False</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-eraser-firm"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Firm</property> + <attributes> + <attribute name="style" value="italic"/> + <attribute name="scale" value="0.82999999999999996"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-eraser-feel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="margin_right">10</property> + <property name="label" translatable="yes">Eraser Pressure Feel</property> + <property name="justify">right</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">4</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="combo-topbutton"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="model">liststore-buttons</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">5</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="combo-bottombutton"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">center</property> + <property name="model">liststore-buttons</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel" id="label-tip-soft"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Soft</property> + <attributes> + <attribute name="style" value="italic"/> + <attribute name="scale" value="0.82999999999999996"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkScale" id="scale-tip-feel"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="margin_left">10</property> + <property name="margin_right">10</property> + <property name="adjustment">adjustment-tip-feel</property> + <property name="digits">0</property> + <property name="draw_value">False</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-tip-firm"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Firm</property> + <attributes> + <attribute name="style" value="italic"/> + <attribute name="scale" value="0.82999999999999996"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">7</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-lower-button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="margin_right">10</property> + <property name="label" translatable="yes">Lower Button</property> + <property name="justify">right</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-tip-feel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="margin_right">10</property> + <property name="label" translatable="yes">Tip Pressure Feel</property> + <property name="justify">right</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">7</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-top-button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">end</property> + <property name="valign">center</property> + <property name="margin_right">10</property> + <property name="label" translatable="yes">Top Button</property> + <property name="justify">right</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">5</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label-stylus"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">center</property> + <property name="margin_left">10</property> + <property name="label" translatable="yes">Stylus</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + <child> + <object class="GtkLabel" id="label-tabletmodel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="valign">center</property> + <property name="margin_left">10</property> + <property name="xpad">3</property> + <property name="label" translatable="yes">Wacom Tablet (Unknown Model)</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">2</property> + <property name="height">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="0">helpbutton1</action-widget> + <action-widget response="0">closebutton1</action-widget> + </action-widgets> + </object> +</interface> diff --git a/panels/wacom/wacom-module.c b/panels/wacom/wacom-module.c new file mode 100644 index 000000000..d364efb6f --- /dev/null +++ b/panels/wacom/wacom-module.c @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010 Intel, Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Author: Thomas Wood <thomas.wood@intel.com> + * + */ + +#include <config.h> + +#include "cc-wacom-panel.h" + +#include <glib/gi18n-lib.h> + +void +g_io_module_load (GIOModule *module) +{ + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + + /* register the panel */ + cc_wacom_panel_register (module); +} + +void +g_io_module_unload (GIOModule *module) +{ +} diff --git a/panels/wacom/wacom-stylus.png b/panels/wacom/wacom-stylus.png Binary files differnew file mode 100644 index 000000000..0f9fde8f6 --- /dev/null +++ b/panels/wacom/wacom-stylus.png diff --git a/panels/wacom/wacom-tablet.png b/panels/wacom/wacom-tablet.png Binary files differnew file mode 100644 index 000000000..73697e7ff --- /dev/null +++ b/panels/wacom/wacom-tablet.png |