wacom: Split off the stylus page creation

Show configuration for multiple styli in the configuration UI.
This commit is contained in:
Bastien Nocera 2012-01-16 17:18:32 +00:00
parent 5d680981de
commit b732da14d8
6 changed files with 888 additions and 535 deletions

View file

@ -23,6 +23,8 @@ libwacom_properties_la_SOURCES = \
cc-wacom-panel.h \
cc-wacom-page.c \
cc-wacom-page.h \
cc-wacom-stylus-page.c \
cc-wacom-stylus-page.h \
gsd-wacom-device.c \
gsd-wacom-device.h \
gsd-input-helper.c \
@ -39,6 +41,8 @@ test_wacom_SOURCES = \
test-wacom.c \
cc-wacom-page.c \
cc-wacom-page.h \
cc-wacom-stylus-page.c \
cc-wacom-stylus-page.h \
cc-wacom-nav-button.c \
cc-wacom-nav-button.h \
gsd-wacom-device.c \
@ -61,7 +65,7 @@ pixmap_DATA = \
wacom-tablet-pc.svg
uidir = $(pkgdatadir)/ui
ui_DATA = gnome-wacom-properties.ui
ui_DATA = gnome-wacom-properties.ui wacom-stylus-page.ui
desktopdir = $(datadir)/applications
desktop_in_files = gnome-wacom-panel.desktop.in

View file

@ -24,6 +24,7 @@
#include "cc-wacom-page.h"
#include "cc-wacom-nav-button.h"
#include "cc-wacom-stylus-page.h"
#include "gui_gtk.h"
#include <gtk/gtk.h>
@ -39,16 +40,14 @@ G_DEFINE_TYPE (CcWacomPage, cc_wacom_page, GTK_TYPE_BOX)
#define THRESHOLD_MISCLICK 15
#define THRESHOLD_DOUBLECLICK 7
struct _CcWacomPagePrivate
{
GsdWacomDevice *stylus, *eraser;
GtkBuilder *builder;
GtkWidget *nav;
GtkWidget *notebook;
CalibArea *area;
GSettings *wacom_settings;
GSettings *stylus_settings;
GSettings *eraser_settings;
/* The UI doesn't support cursor/pad at the moment */
};
@ -72,49 +71,6 @@ enum {
MODE_RELATIVE, /* stylus + eraser relative */
};
/* 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.
*/
#define N_PRESSURE_CURVES 7
static const gint32 PRESSURE_CURVES[N_PRESSURE_CURVES][4] = {
{ 0, 75, 25, 100 }, /* soft */
{ 0, 50, 50, 100 },
{ 0, 25, 75, 100 },
{ 0, 0, 100, 100 }, /* neutral */
{ 25, 0, 100, 75 },
{ 50, 0, 100, 50 },
{ 75, 0, 100, 25 } /* firm */
};
static void
set_pressurecurve (GtkRange *range, GSettings *settings)
{
gint slider_val = gtk_range_get_value (range);
GVariant *values[4],
*array;
int i;
for (i = 0; i < G_N_ELEMENTS (values); i++)
values[i] = g_variant_new_int32 (PRESSURE_CURVES[slider_val][i]);
array = g_variant_new_array (G_VARIANT_TYPE_INT32, values, G_N_ELEMENTS (values));
g_settings_set_value (settings, "pressurecurve", array);
}
static void
tip_feel_value_changed_cb (GtkRange *range, gpointer user_data)
{
set_pressurecurve (range, CC_WACOM_PAGE(user_data)->priv->stylus_settings);
}
static void
eraser_feel_value_changed_cb (GtkRange *range, gpointer user_data)
{
set_pressurecurve (range, CC_WACOM_PAGE(user_data)->priv->eraser_settings);
}
static void
set_calibration (gint *cal,
gsize ncal,
@ -228,30 +184,6 @@ calibrate_button_clicked_cb (GtkButton *button,
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
}
static void
set_feel_from_gsettings (GtkAdjustment *adjustment, GSettings *settings)
{
GVariant *variant;
const gint32 *values;
gsize nvalues;
int i;
variant = g_settings_get_value (settings, "pressurecurve");
values = g_variant_get_fixed_array (variant, &nvalues, sizeof (gint32));
if (nvalues != 4) {
g_warning ("Invalid pressure curve format, expected 4 values (got %"G_GSIZE_FORMAT")", nvalues);
return;
}
for (i = 0; i < N_PRESSURE_CURVES; i++) {
if (memcmp (PRESSURE_CURVES[i], values, sizeof (gint32) * 4) == 0) {
gtk_adjustment_set_value (adjustment, i);
break;
}
}
}
static void
tabletmode_changed_cb (GtkComboBox *combo, gpointer user_data)
{
@ -307,100 +239,6 @@ set_mode_from_gsettings (GtkComboBox *combo, CcWacomPage *page)
gtk_combo_box_set_active (combo, is_absolute ? MODE_ABSOLUTE : MODE_RELATIVE);
}
static void
set_button_mapping_from_gsettings (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);
/* Currently button values match logical X buttons. If we
* introduce things like double-click, this code must
* change. Recommendation: use negative buttons numbers for
* special ones.
*/
/* 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);
}
}
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);
g_free (tmp);
}
static void
button_changed_cb (GtkComboBox *combo, gpointer user_data)
{
CcWacomPagePrivate *priv = CC_WACOM_PAGE(user_data)->priv;
GtkTreeIter iter;
GtkListStore *liststore;
gint mapping_b2,
mapping_b3;
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("combo-bottombutton")), &iter))
return;
liststore = GTK_LIST_STORE (WID ("liststore-buttons"));
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 (priv->stylus_settings, mapping_b2, mapping_b3);
}
static void
combobox_text_cellrenderer (GtkComboBox *combo, int name_column)
{
@ -507,24 +345,11 @@ cc_wacom_page_init (CcWacomPage *self)
gtk_container_add (GTK_CONTAINER (self), box);
gtk_widget_set_vexpand (GTK_WIDGET (box), TRUE);
g_signal_connect (WID ("scale-tip-feel"), "value-changed",
G_CALLBACK (tip_feel_value_changed_cb), self);
g_signal_connect (WID ("scale-eraser-feel"), "value-changed",
G_CALLBACK (eraser_feel_value_changed_cb), self);
self->priv->notebook = WID ("stylus-notebook");
g_signal_connect (WID ("button-calibrate"), "clicked",
G_CALLBACK (calibrate_button_clicked_cb), self);
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), self);
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), self);
combo = GTK_COMBO_BOX (WID ("combo-tabletmode"));
combobox_text_cellrenderer (combo, MODELABEL_COLUMN);
g_signal_connect (G_OBJECT (combo), "changed",
@ -538,19 +363,6 @@ cc_wacom_page_init (CcWacomPage *self)
gtk_grid_attach (GTK_GRID (box), priv->nav, 0, 0, 1, 1);
}
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);
}
static void
set_icon_name (CcWacomPage *page,
const char *widget_name,
@ -569,17 +381,42 @@ set_icon_name (CcWacomPage *page,
g_free (path);
}
static void
set_first_stylus_icon (CcWacomPage *page)
{
GList *styli;
typedef struct {
GsdWacomStylus *stylus;
GsdWacomStylus *eraser;
} StylusPair;
styli = gsd_wacom_device_list_styli (page->priv->stylus);
stylus = styli->data;
static void
add_styli (CcWacomPage *page)
{
GList *styli, *l;
CcWacomPagePrivate *priv;
priv = page->priv;
styli = gsd_wacom_device_list_styli (priv->stylus);
for (l = styli; l; l = l->next) {
GsdWacomStylus *stylus, *eraser;
GtkWidget *page;
stylus = l->data;
if (gsd_wacom_stylus_get_has_eraser (stylus)) {
GsdWacomDeviceType type;
type = gsd_wacom_stylus_get_stylus_type (stylus);
eraser = gsd_wacom_device_get_stylus_for_type (priv->eraser, type);
} else {
eraser = NULL;
}
page = cc_wacom_stylus_page_new (stylus, eraser);
cc_wacom_stylus_page_set_navigation (CC_WACOM_STYLUS_PAGE (page), GTK_NOTEBOOK (priv->notebook));
gtk_widget_show (page);
gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, NULL);
}
g_list_free (styli);
set_icon_name (page, "image-stylus", gsd_wacom_stylus_get_icon_name (stylus));
/*FIXME: Set the page with the last used item */
}
GtkWidget *
@ -624,15 +461,8 @@ cc_wacom_page_new (GsdWacomDevice *stylus,
/* Tablet icon */
set_icon_name (page, "image-tablet", gsd_wacom_device_get_icon_name (stylus));
/* Stylus/Eraser */
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);
set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-tip-feel")), priv->stylus_settings);
set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-eraser-feel")), priv->eraser_settings);
set_first_stylus_icon (page);
/* Add styli */
add_styli (page);
return GTK_WIDGET (page);
}

View file

@ -0,0 +1,421 @@
/*
* Copyright © 2011 Red Hat, 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: Peter Hutterer <peter.hutterer@redhat.com>
* Bastien Nocera <hadess@hadess.net>
*
*/
#include <config.h>
#include <glib/gi18n.h>
#include "cc-wacom-stylus-page.h"
#include "cc-wacom-nav-button.h"
#include <gtk/gtk.h>
#include <string.h>
#define WID(x) (GtkWidget *) gtk_builder_get_object (priv->builder, x)
G_DEFINE_TYPE (CcWacomStylusPage, cc_wacom_stylus_page, GTK_TYPE_BOX)
#define WACOM_STYLUS_PAGE_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPagePrivate))
struct _CcWacomStylusPagePrivate
{
GsdWacomStylus *stylus, *eraser;
GtkBuilder *builder;
GtkWidget *nav;
GSettings *stylus_settings, *eraser_settings;
};
/* Button combo box storage columns */
enum {
BUTTONNUMBER_COLUMN,
BUTTONNAME_COLUMN,
N_BUTTONCOLUMNS
};
/* 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.
*/
#define N_PRESSURE_CURVES 7
static const gint32 PRESSURE_CURVES[N_PRESSURE_CURVES][4] = {
{ 0, 75, 25, 100 }, /* soft */
{ 0, 50, 50, 100 },
{ 0, 25, 75, 100 },
{ 0, 0, 100, 100 }, /* neutral */
{ 25, 0, 100, 75 },
{ 50, 0, 100, 50 },
{ 75, 0, 100, 25 } /* firm */
};
static void
set_pressurecurve (GtkRange *range, GSettings *settings)
{
gint slider_val = gtk_range_get_value (range);
GVariant *values[4],
*array;
int i;
for (i = 0; i < G_N_ELEMENTS (values); i++)
values[i] = g_variant_new_int32 (PRESSURE_CURVES[slider_val][i]);
array = g_variant_new_array (G_VARIANT_TYPE_INT32, values, G_N_ELEMENTS (values));
g_settings_set_value (settings, "pressurecurve", array);
}
static void
tip_feel_value_changed_cb (GtkRange *range, gpointer user_data)
{
set_pressurecurve (range, CC_WACOM_STYLUS_PAGE(user_data)->priv->stylus_settings);
}
static void
eraser_feel_value_changed_cb (GtkRange *range, gpointer user_data)
{
set_pressurecurve (range, CC_WACOM_STYLUS_PAGE(user_data)->priv->eraser_settings);
}
static void
set_feel_from_gsettings (GtkAdjustment *adjustment, GSettings *settings)
{
GVariant *variant;
const gint32 *values;
gsize nvalues;
int i;
variant = g_settings_get_value (settings, "pressurecurve");
values = g_variant_get_fixed_array (variant, &nvalues, sizeof (gint32));
if (nvalues != 4) {
g_warning ("Invalid pressure curve format, expected 4 values (got %"G_GSIZE_FORMAT")", nvalues);
return;
}
for (i = 0; i < N_PRESSURE_CURVES; i++) {
if (memcmp (PRESSURE_CURVES[i], values, sizeof (gint32) * 4) == 0) {
gtk_adjustment_set_value (adjustment, i);
break;
}
}
}
static void
set_button_mapping_from_gsettings (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);
/* Currently button values match logical X buttons. If we
* introduce things like double-click, this code must
* change. Recommendation: use negative buttons numbers for
* special ones.
*/
/* 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);
}
}
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);
g_free (tmp);
}
static void
button_changed_cb (GtkComboBox *combo, gpointer user_data)
{
CcWacomStylusPagePrivate *priv = CC_WACOM_STYLUS_PAGE(user_data)->priv;
GtkTreeIter iter;
GtkListStore *liststore;
gint mapping_b2,
mapping_b3;
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (WID ("combo-bottombutton")), &iter))
return;
liststore = GTK_LIST_STORE (WID ("liststore-buttons"));
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 (priv->stylus_settings, mapping_b2, mapping_b3);
}
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);
}
/* Boilerplate code goes below */
static void
cc_wacom_stylus_page_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_stylus_page_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_stylus_page_dispose (GObject *object)
{
CcWacomStylusPagePrivate *priv = CC_WACOM_STYLUS_PAGE (object)->priv;
if (priv->builder) {
g_object_unref (priv->builder);
priv->builder = NULL;
}
G_OBJECT_CLASS (cc_wacom_stylus_page_parent_class)->dispose (object);
}
static void
cc_wacom_stylus_page_class_init (CcWacomStylusPageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcWacomStylusPagePrivate));
object_class->get_property = cc_wacom_stylus_page_get_property;
object_class->set_property = cc_wacom_stylus_page_set_property;
object_class->dispose = cc_wacom_stylus_page_dispose;
}
static void
cc_wacom_stylus_page_init (CcWacomStylusPage *self)
{
CcWacomStylusPagePrivate *priv;
GError *error = NULL;
GtkComboBox *combo;
GtkWidget *box;
char *objects[] = {
"stylus-grid",
"liststore-buttons",
"adjustment-tip-feel",
"adjustment-eraser-feel",
NULL
};
priv = self->priv = WACOM_STYLUS_PAGE_PRIVATE (self);
priv->builder = gtk_builder_new ();
gtk_builder_add_objects_from_file (priv->builder,
GNOMECC_UI_DIR "/wacom-stylus-page.ui",
objects,
&error);
if (error != NULL) {
g_warning ("Error loading UI file: %s", error->message);
g_object_unref (priv->builder);
g_error_free (error);
return;
}
box = WID ("stylus-grid");
gtk_container_add (GTK_CONTAINER (self), box);
gtk_widget_set_vexpand (GTK_WIDGET (box), TRUE);
g_signal_connect (WID ("scale-tip-feel"), "value-changed",
G_CALLBACK (tip_feel_value_changed_cb), self);
g_signal_connect (WID ("scale-eraser-feel"), "value-changed",
G_CALLBACK (eraser_feel_value_changed_cb), self);
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), self);
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), self);
priv->nav = cc_wacom_nav_button_new ();
gtk_grid_attach (GTK_GRID (box), priv->nav, 0, 0, 1, 1);
}
static void
set_icon_name (CcWacomStylusPage *page,
const char *widget_name,
const char *icon_name)
{
CcWacomStylusPagePrivate *priv;
char *filename, *path;
priv = page->priv;
filename = g_strdup_printf ("%s.svg", icon_name);
path = g_build_filename (PIXMAP_DIR, filename, NULL);
g_free (filename);
gtk_image_set_from_file (GTK_IMAGE (WID (widget_name)), path);
g_free (path);
}
GtkWidget *
cc_wacom_stylus_page_new (GsdWacomStylus *stylus,
GsdWacomStylus *eraser)
{
CcWacomStylusPage *page;
CcWacomStylusPagePrivate *priv;
int num_buttons;
g_return_val_if_fail (GSD_IS_WACOM_STYLUS (stylus), NULL);
page = g_object_new (CC_TYPE_WACOM_STYLUS_PAGE, NULL);
priv = page->priv;
priv->stylus = stylus;
priv->eraser = eraser;
/* Icon */
set_icon_name (page, "image-stylus", gsd_wacom_stylus_get_icon_name (stylus));
/* Settings */
priv->stylus_settings = gsd_wacom_stylus_get_settings (stylus);
if (eraser != NULL)
priv->eraser_settings = gsd_wacom_stylus_get_settings (eraser);
/* Stylus name */
gtk_label_set_text (GTK_LABEL (WID ("label-stylus")), gsd_wacom_stylus_get_name (stylus));
num_buttons = gsd_wacom_stylus_get_num_buttons (stylus);
if (num_buttons == 0) {
gtk_widget_hide (WID ("combo-topbutton"));
gtk_widget_hide (WID ("combo-bottombutton"));
gtk_widget_hide (WID ("label-top-button"));
gtk_widget_hide (WID ("label-lower-button"));
} else if (num_buttons == 1) {
gtk_widget_hide (WID ("combo-topbutton"));
gtk_widget_hide (WID ("label-top-button"));
gtk_label_set_text (GTK_LABEL (WID ("label-lower-button")), _("Button"));
} else if (num_buttons > 2) {
g_warning ("Unhandled number of buttons on stylus '%s'", gsd_wacom_stylus_get_name (stylus));
}
if (num_buttons == 2)
set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-topbutton")), priv->stylus_settings, 3);
if (num_buttons > 1)
set_button_mapping_from_gsettings (GTK_COMBO_BOX (WID ("combo-bottombutton")), priv->stylus_settings, 2);
set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-tip-feel")), priv->stylus_settings);
if (eraser != NULL) {
set_feel_from_gsettings (GTK_ADJUSTMENT (WID ("adjustment-eraser-feel")), priv->eraser_settings);
} else {
gtk_widget_hide (WID ("eraser-box"));
gtk_widget_hide (WID ("label-eraser-feel"));
}
return GTK_WIDGET (page);
}
void
cc_wacom_stylus_page_set_navigation (CcWacomStylusPage *page,
GtkNotebook *notebook)
{
CcWacomStylusPagePrivate *priv;
g_return_if_fail (CC_IS_WACOM_STYLUS_PAGE (page));
priv = page->priv;
g_object_set (G_OBJECT (priv->nav),
"notebook", notebook,
NULL);
}

View file

@ -0,0 +1,79 @@
/*
* Copyright © 2011 Red Hat, 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: Peter Hutterer <peter.hutterer@redhat.com>
* Bastien Nocera <hadess@hadess.net>
*/
#ifndef _CC_WACOM_STYLUS_PAGE_H
#define _CC_WACOM_STYLUS_PAGE_H
#include <gtk/gtk.h>
#include "gsd-wacom-device.h"
G_BEGIN_DECLS
#define CC_TYPE_WACOM_STYLUS_PAGE cc_wacom_stylus_page_get_type()
#define CC_WACOM_STYLUS_PAGE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPage))
#define CC_WACOM_STYLUS_PAGE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPageClass))
#define CC_IS_WACOM_STYLUS_PAGE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
CC_TYPE_WACOM_STYLUS_PAGE))
#define CC_IS_WACOM_STYLUS_PAGE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
CC_TYPE_WACOM_STYLUS_PAGE))
#define CC_WACOM_STYLUS_PAGE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CC_TYPE_WACOM_STYLUS_PAGE, CcWacomStylusPageClass))
typedef struct _CcWacomStylusPage CcWacomStylusPage;
typedef struct _CcWacomStylusPageClass CcWacomStylusPageClass;
typedef struct _CcWacomStylusPagePrivate CcWacomStylusPagePrivate;
struct _CcWacomStylusPage
{
GtkBox parent;
CcWacomStylusPagePrivate *priv;
};
struct _CcWacomStylusPageClass
{
GtkBoxClass parent_class;
};
GType cc_wacom_stylus_page_get_type (void) G_GNUC_CONST;
GtkWidget * cc_wacom_stylus_page_new (GsdWacomStylus *stylus,
GsdWacomStylus *eraser);
void cc_wacom_stylus_page_set_navigation (CcWacomStylusPage *page,
GtkNotebook *notebook);
G_END_DECLS
#endif /* _CC_WACOM_STYLUS_PAGE_H */

View file

@ -1,66 +1,6 @@
<?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">3</property>
</object>
<object class="GtkAdjustment" id="adjustment-tip-feel">
<property name="upper">6</property>
<property name="step_increment">1</property>
<property name="page_increment">3</property>
</object>
<object class="GtkListStore" id="liststore-buttons">
<columns>
<!-- column-name button -->
<column type="gint"/>
<!-- 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>
<row>
<col id="0">4</col>
<col id="1" translatable="yes">Scroll Down</col>
</row>
<row>
<col id="0">5</col>
<col id="1" translatable="yes">Scroll Up</col>
</row>
<row>
<col id="0">6</col>
<col id="1" translatable="yes">Scroll Left</col>
</row>
<row>
<col id="0">7</col>
<col id="1" translatable="yes">Scroll Right</col>
</row>
<row>
<col id="0">7</col>
<col id="1" translatable="yes">Back</col>
</row>
<row>
<col id="0">8</col>
<col id="1" translatable="yes">Forward</col>
</row>
</data>
</object>
<object class="GtkListStore" id="liststore-tabletmode">
<columns>
<!-- column-name tabletmode -->
@ -237,21 +177,6 @@
<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">5</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>
@ -337,256 +262,6 @@
<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">5</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>
<style>
<class name="dim-label"/>
</style>
</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="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">6</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">7</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">8</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>
<style>
<class name="dim-label"/>
</style>
</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-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>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">8</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>
<style>
<class name="dim-label"/>
</style>
</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-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="margin_top">16</property>
<property name="margin_bottom">16</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">4</property>
<property name="width">3</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label-tabletmodel">
<property name="visible">True</property>
@ -608,7 +283,18 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkNotebook" id="stylus-notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="show_tabs">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">4</property>
<property name="height">1</property>
</packing>
</child>
<child>
<placeholder/>

View file

@ -0,0 +1,333 @@
<?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">3</property>
</object>
<object class="GtkAdjustment" id="adjustment-tip-feel">
<property name="upper">6</property>
<property name="step_increment">1</property>
<property name="page_increment">3</property>
</object>
<object class="GtkListStore" id="liststore-buttons">
<columns>
<!-- column-name button -->
<column type="gint"/>
<!-- 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>
<row>
<col id="0">4</col>
<col id="1" translatable="yes">Scroll Down</col>
</row>
<row>
<col id="0">5</col>
<col id="1" translatable="yes">Scroll Up</col>
</row>
<row>
<col id="0">6</col>
<col id="1" translatable="yes">Scroll Left</col>
</row>
<row>
<col id="0">7</col>
<col id="1" translatable="yes">Scroll Right</col>
</row>
<row>
<col id="0">7</col>
<col id="1" translatable="yes">Back</col>
</row>
<row>
<col id="0">8</col>
<col id="1" translatable="yes">Forward</col>
</row>
</data>
</object>
<object class="GtkGrid" id="stylus-grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<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">5</property>
<property name="width">2</property>
<property name="height">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="eraser-box">
<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">5</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">5</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">6</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">7</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">8</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">7</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">8</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">6</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="margin_top">16</property>
<property name="margin_bottom">16</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">4</property>
<property name="width">3</property>
<property name="height">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>