2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-06-06 12:06:56 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-06-06 12:06:56 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1998-06-06 12:06:56 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1998-06-06 12:06:56 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2010-05-30 23:19:47 +08:00
|
|
|
#undef GSEAL_ENABLE
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2010-02-13 23:21:26 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "widgets-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2010-02-16 06:06:19 +08:00
|
|
|
#include "core/gimpcurve.h"
|
2010-02-16 20:27:46 +08:00
|
|
|
#include "core/gimpcurve-map.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdatafactory.h"
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "gimpdeviceinfo.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#define GIMP_DEVICE_INFO_DATA_KEY "gimp-device-info"
|
1998-08-01 06:44:26 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
enum
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
CHANGED,
|
|
|
|
LAST_SIGNAL
|
1998-06-06 12:06:56 +08:00
|
|
|
};
|
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2010-02-13 00:10:54 +08:00
|
|
|
PROP_DEVICE,
|
|
|
|
PROP_DISPLAY,
|
2002-05-24 21:07:12 +08:00
|
|
|
PROP_MODE,
|
|
|
|
PROP_AXES,
|
2010-02-19 04:35:45 +08:00
|
|
|
PROP_KEYS,
|
|
|
|
PROP_PRESSURE_CURVE
|
2002-05-24 21:07:12 +08:00
|
|
|
};
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
/* local function prototypes */
|
2001-01-08 05:07:14 +08:00
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
static GObject * gimp_device_info_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
static void gimp_device_info_finalize (GObject *object);
|
|
|
|
static void gimp_device_info_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_device_info_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2010-02-13 23:21:26 +08:00
|
|
|
static void gimp_device_info_guess_icon (GimpDeviceInfo *info);
|
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpDeviceInfo, gimp_device_info, GIMP_TYPE_CONTEXT)
|
2005-12-20 06:37:49 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_device_info_parent_class
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
static guint device_info_signals[LAST_SIGNAL] = { 0 };
|
2001-02-11 03:35:29 +08:00
|
|
|
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
static void
|
|
|
|
gimp_device_info_class_init (GimpDeviceInfoClass *klass)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2010-02-13 23:21:26 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
|
|
|
GParamSpec *param_spec;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info_signals[CHANGED] =
|
|
|
|
g_signal_new ("changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDeviceInfoClass, changed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-12-02 05:02:34 +08:00
|
|
|
|
2010-02-13 23:21:26 +08:00
|
|
|
object_class->constructor = gimp_device_info_constructor;
|
|
|
|
object_class->finalize = gimp_device_info_finalize;
|
|
|
|
object_class->set_property = gimp_device_info_set_property;
|
|
|
|
object_class->get_property = gimp_device_info_get_property;
|
|
|
|
|
2010-02-20 04:23:02 +08:00
|
|
|
viewable_class->default_stock_id = GIMP_STOCK_INPUT_DEVICE;
|
2002-05-24 21:07:12 +08:00
|
|
|
|
2010-02-13 00:10:54 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_DEVICE,
|
|
|
|
g_param_spec_object ("device",
|
|
|
|
NULL, NULL,
|
|
|
|
GDK_TYPE_DEVICE,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS |
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_DISPLAY,
|
|
|
|
g_param_spec_object ("display",
|
|
|
|
NULL, NULL,
|
|
|
|
GDK_TYPE_DISPLAY,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS |
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
|
|
|
|
2002-11-28 23:19:19 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MODE, "mode", NULL,
|
2002-05-24 21:07:12 +08:00
|
|
|
GDK_TYPE_INPUT_MODE,
|
2002-11-21 03:09:40 +08:00
|
|
|
GDK_MODE_DISABLED,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
param_spec = g_param_spec_enum ("axis",
|
|
|
|
NULL, NULL,
|
|
|
|
GDK_TYPE_AXIS_USE,
|
|
|
|
GDK_AXIS_IGNORE,
|
|
|
|
GIMP_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (object_class, PROP_AXES,
|
|
|
|
g_param_spec_value_array ("axes",
|
|
|
|
NULL, NULL,
|
|
|
|
param_spec,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS |
|
|
|
|
GIMP_CONFIG_PARAM_FLAGS));
|
|
|
|
|
|
|
|
param_spec = g_param_spec_string ("key",
|
|
|
|
NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE);
|
|
|
|
g_object_class_install_property (object_class, PROP_KEYS,
|
|
|
|
g_param_spec_value_array ("keys",
|
|
|
|
NULL, NULL,
|
|
|
|
param_spec,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS |
|
|
|
|
GIMP_CONFIG_PARAM_FLAGS));
|
2010-02-19 04:35:45 +08:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_PRESSURE_CURVE,
|
|
|
|
"pressure-curve", NULL,
|
|
|
|
GIMP_TYPE_CURVE,
|
|
|
|
GIMP_CONFIG_PARAM_AGGREGATE);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_init (GimpDeviceInfo *info)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2010-02-13 23:24:01 +08:00
|
|
|
info->device = NULL;
|
|
|
|
info->display = NULL;
|
|
|
|
info->mode = GDK_MODE_DISABLED;
|
|
|
|
info->n_axes = 0;
|
|
|
|
info->axes = NULL;
|
|
|
|
info->n_keys = 0;
|
|
|
|
info->keys = NULL;
|
|
|
|
|
2010-02-16 06:06:19 +08:00
|
|
|
info->pressure_curve = GIMP_CURVE (gimp_curve_new ("pressure curve"));
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
g_signal_connect (info, "notify::name",
|
2010-02-13 23:21:26 +08:00
|
|
|
G_CALLBACK (gimp_device_info_guess_icon),
|
|
|
|
NULL);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_device_info_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
2010-02-13 00:10:54 +08:00
|
|
|
GObject *object;
|
|
|
|
GimpDeviceInfo *info;
|
|
|
|
Gimp *gimp;
|
2002-05-29 00:41:56 +08:00
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
2010-02-13 00:10:54 +08:00
|
|
|
info = GIMP_DEVICE_INFO (object);
|
|
|
|
|
|
|
|
g_assert ((info->device == NULL && info->display == NULL) ||
|
|
|
|
(GDK_IS_DEVICE (info->device) && GDK_IS_DISPLAY (info->display)));
|
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
gimp = GIMP_CONTEXT (object)->gimp;
|
|
|
|
|
|
|
|
g_assert (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2010-02-13 00:10:54 +08:00
|
|
|
if (info->device)
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (info->device), GIMP_DEVICE_INFO_DATA_KEY,
|
|
|
|
info);
|
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (info), info->device->name);
|
|
|
|
|
|
|
|
info->mode = info->device->mode;
|
|
|
|
info->n_axes = info->device->num_axes;
|
|
|
|
info->n_keys = info->device->num_keys;
|
|
|
|
}
|
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
gimp_context_define_properties (GIMP_CONTEXT (object),
|
|
|
|
GIMP_DEVICE_INFO_CONTEXT_MASK,
|
|
|
|
FALSE);
|
|
|
|
gimp_context_copy_properties (gimp_get_user_context (gimp),
|
|
|
|
GIMP_CONTEXT (object),
|
|
|
|
GIMP_DEVICE_INFO_CONTEXT_MASK);
|
|
|
|
|
2004-07-04 04:27:28 +08:00
|
|
|
gimp_context_set_serialize_properties (GIMP_CONTEXT (object),
|
|
|
|
GIMP_DEVICE_INFO_CONTEXT_MASK);
|
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
/* FIXME: this is ugly and needs to be done via "notify" once
|
|
|
|
* the contexts' properties are dynamic.
|
|
|
|
*/
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (object, "foreground-changed",
|
2002-05-29 00:41:56 +08:00
|
|
|
G_CALLBACK (gimp_device_info_changed),
|
|
|
|
NULL);
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (object, "background-changed",
|
2002-05-29 00:41:56 +08:00
|
|
|
G_CALLBACK (gimp_device_info_changed),
|
|
|
|
NULL);
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (object, "tool-changed",
|
2002-05-29 00:41:56 +08:00
|
|
|
G_CALLBACK (gimp_device_info_changed),
|
|
|
|
NULL);
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (object, "brush-changed",
|
2002-05-29 00:41:56 +08:00
|
|
|
G_CALLBACK (gimp_device_info_changed),
|
|
|
|
NULL);
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (object, "pattern-changed",
|
2002-05-29 00:41:56 +08:00
|
|
|
G_CALLBACK (gimp_device_info_changed),
|
|
|
|
NULL);
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (object, "gradient-changed",
|
2002-05-29 00:41:56 +08:00
|
|
|
G_CALLBACK (gimp_device_info_changed),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
static void
|
|
|
|
gimp_device_info_finalize (GObject *object)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2010-02-13 23:24:01 +08:00
|
|
|
GimpDeviceInfo *info = GIMP_DEVICE_INFO (object);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
if (info->axes)
|
2010-02-16 06:06:19 +08:00
|
|
|
{
|
|
|
|
g_free (info->axes);
|
|
|
|
info->axes = NULL;
|
|
|
|
}
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
if (info->keys)
|
2010-02-16 06:06:19 +08:00
|
|
|
{
|
|
|
|
g_free (info->keys);
|
|
|
|
info->keys = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info->pressure_curve)
|
|
|
|
{
|
|
|
|
g_object_unref (info->pressure_curve);
|
|
|
|
info->pressure_curve = NULL;
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
static void
|
|
|
|
gimp_device_info_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2010-02-19 04:35:45 +08:00
|
|
|
GimpDeviceInfo *info = GIMP_DEVICE_INFO (object);
|
|
|
|
GdkDevice *device = info->device;
|
|
|
|
GimpCurve *src_curve = NULL;
|
|
|
|
GimpCurve *dest_curve = NULL;
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2010-02-13 00:10:54 +08:00
|
|
|
case PROP_DEVICE:
|
2010-02-13 23:24:01 +08:00
|
|
|
info->device = g_value_get_object (value);
|
2010-02-13 00:10:54 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_DISPLAY:
|
2010-02-13 23:24:01 +08:00
|
|
|
info->display = g_value_get_object (value);
|
2010-02-13 00:10:54 +08:00
|
|
|
break;
|
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
case PROP_MODE:
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_set_mode (info, g_value_get_enum (value));
|
2002-05-24 21:07:12 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_AXES:
|
|
|
|
{
|
2004-07-04 04:27:28 +08:00
|
|
|
GValueArray *array = g_value_get_boxed (value);
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
if (array)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gint n_device_values;
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
{
|
|
|
|
n_device_values = MIN (array->n_values, device->num_axes);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n_device_values = array->n_values;
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
info->n_axes = n_device_values;
|
2010-02-16 02:58:02 +08:00
|
|
|
info->axes = g_renew (GdkAxisUse, info->axes, info->n_axes);
|
2002-05-24 21:07:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n_device_values; i++)
|
|
|
|
{
|
|
|
|
GdkAxisUse axis_use;
|
|
|
|
|
|
|
|
axis_use = g_value_get_enum (g_value_array_get_nth (array, i));
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_set_axis_use (info, i, axis_use);
|
2002-05-24 21:07:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_KEYS:
|
|
|
|
{
|
2004-07-04 04:27:28 +08:00
|
|
|
GValueArray *array = g_value_get_boxed (value);
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
if (array)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
gint n_device_values;
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
{
|
|
|
|
n_device_values = MIN (array->n_values, device->num_keys);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n_device_values = array->n_values;
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
info->n_keys = n_device_values;
|
2010-02-16 02:58:02 +08:00
|
|
|
info->keys = g_renew (GdkDeviceKey, info->keys, info->n_keys);
|
2002-05-24 21:07:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n_device_values; i++)
|
|
|
|
{
|
|
|
|
const gchar *accel;
|
|
|
|
guint keyval;
|
|
|
|
GdkModifierType modifiers;
|
|
|
|
|
|
|
|
accel = g_value_get_string (g_value_array_get_nth (array, i));
|
|
|
|
|
|
|
|
gtk_accelerator_parse (accel, &keyval, &modifiers);
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_set_key (info, i, keyval, modifiers);
|
2002-05-24 21:07:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-02-19 04:35:45 +08:00
|
|
|
case PROP_PRESSURE_CURVE:
|
|
|
|
src_curve = g_value_get_object (value);
|
|
|
|
dest_curve = info->pressure_curve;
|
|
|
|
break;
|
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2010-02-19 04:35:45 +08:00
|
|
|
|
|
|
|
if (src_curve && dest_curve)
|
|
|
|
{
|
|
|
|
gimp_config_copy (GIMP_CONFIG (src_curve),
|
|
|
|
GIMP_CONFIG (dest_curve),
|
|
|
|
GIMP_CONFIG_PARAM_SERIALIZE);
|
|
|
|
}
|
2002-05-24 21:07:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_info_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2010-02-13 23:24:01 +08:00
|
|
|
GimpDeviceInfo *info = GIMP_DEVICE_INFO (object);
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2010-02-13 00:10:54 +08:00
|
|
|
case PROP_DEVICE:
|
2010-02-13 23:24:01 +08:00
|
|
|
g_value_set_object (value, info->device);
|
2010-02-13 00:10:54 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_DISPLAY:
|
2010-02-13 23:24:01 +08:00
|
|
|
g_value_set_object (value, info->display);
|
2010-02-13 00:10:54 +08:00
|
|
|
break;
|
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
case PROP_MODE:
|
2010-02-13 23:24:01 +08:00
|
|
|
g_value_set_enum (value, gimp_device_info_get_mode (info));
|
2002-05-24 21:07:12 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_AXES:
|
|
|
|
{
|
|
|
|
GValueArray *array;
|
|
|
|
GValue enum_value = { 0, };
|
2010-02-12 22:46:07 +08:00
|
|
|
gint n_axes;
|
2002-05-24 21:07:12 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
array = g_value_array_new (6);
|
|
|
|
g_value_init (&enum_value, GDK_TYPE_AXIS_USE);
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
n_axes = gimp_device_info_get_n_axes (info);
|
2010-02-12 22:46:07 +08:00
|
|
|
|
|
|
|
for (i = 0; i < n_axes; i++)
|
2002-05-24 21:07:12 +08:00
|
|
|
{
|
|
|
|
g_value_set_enum (&enum_value,
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_get_axis_use (info, i));
|
2010-02-12 22:46:07 +08:00
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
g_value_array_append (array, &enum_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&enum_value);
|
|
|
|
|
2004-05-12 01:19:24 +08:00
|
|
|
g_value_take_boxed (value, array);
|
2002-05-24 21:07:12 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_KEYS:
|
|
|
|
{
|
|
|
|
GValueArray *array;
|
|
|
|
GValue string_value = { 0, };
|
2010-02-12 22:46:07 +08:00
|
|
|
gint n_keys;
|
2002-05-24 21:07:12 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
array = g_value_array_new (32);
|
|
|
|
g_value_init (&string_value, G_TYPE_STRING);
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
n_keys = gimp_device_info_get_n_keys (info);
|
2010-02-12 22:46:07 +08:00
|
|
|
|
|
|
|
for (i = 0; i < n_keys; i++)
|
2002-05-24 21:07:12 +08:00
|
|
|
{
|
2010-02-12 22:46:07 +08:00
|
|
|
guint keyval;
|
|
|
|
GdkModifierType modifiers;
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_get_key (info, i, &keyval, &modifiers);
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
if (keyval)
|
|
|
|
{
|
2005-11-27 22:10:19 +08:00
|
|
|
gchar *accel;
|
2002-05-24 21:07:12 +08:00
|
|
|
gchar *escaped;
|
|
|
|
|
2005-11-27 22:10:19 +08:00
|
|
|
accel = gtk_accelerator_name (keyval, modifiers);
|
2002-05-24 21:07:12 +08:00
|
|
|
escaped = g_strescape (accel, NULL);
|
2005-11-27 22:10:19 +08:00
|
|
|
g_free (accel);
|
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
g_value_set_string (&string_value, escaped);
|
|
|
|
g_free (escaped);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_value_set_string (&string_value, "");
|
|
|
|
}
|
2004-05-12 01:19:24 +08:00
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
g_value_array_append (array, &string_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_unset (&string_value);
|
|
|
|
|
2004-05-12 01:19:24 +08:00
|
|
|
g_value_take_boxed (value, array);
|
2002-05-24 21:07:12 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-02-19 04:35:45 +08:00
|
|
|
case PROP_PRESSURE_CURVE:
|
|
|
|
g_value_set_object (value, info->pressure_curve);
|
|
|
|
break;
|
|
|
|
|
2002-05-24 21:07:12 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-13 23:21:26 +08:00
|
|
|
static void
|
|
|
|
gimp_device_info_guess_icon (GimpDeviceInfo *info)
|
|
|
|
{
|
|
|
|
GimpViewable *viewable = GIMP_VIEWABLE (info);
|
|
|
|
|
|
|
|
if (gimp_object_get_name (viewable) &&
|
|
|
|
! strcmp (gimp_viewable_get_stock_id (viewable),
|
|
|
|
GIMP_VIEWABLE_GET_CLASS (viewable)->default_stock_id))
|
|
|
|
{
|
|
|
|
const gchar *stock_id = NULL;
|
|
|
|
gchar *down = g_ascii_strdown (gimp_object_get_name (viewable),
|
|
|
|
-1);
|
|
|
|
|
|
|
|
if (strstr (down, "eraser"))
|
|
|
|
{
|
|
|
|
stock_id = GIMP_STOCK_TOOL_ERASER;
|
|
|
|
}
|
|
|
|
else if (strstr (down, "pen"))
|
|
|
|
{
|
|
|
|
stock_id = GIMP_STOCK_TOOL_PAINTBRUSH;
|
|
|
|
}
|
|
|
|
else if (strstr (down, "airbrush"))
|
|
|
|
{
|
|
|
|
stock_id = GIMP_STOCK_TOOL_AIRBRUSH;
|
|
|
|
}
|
|
|
|
else if (strstr (down, "cursor") ||
|
|
|
|
strstr (down, "mouse") ||
|
|
|
|
strstr (down, "pointer") ||
|
|
|
|
strstr (down, "touchpad") ||
|
|
|
|
strstr (down, "trackpoint"))
|
|
|
|
{
|
|
|
|
stock_id = GIMP_STOCK_CURSOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (down);
|
|
|
|
|
|
|
|
if (stock_id)
|
|
|
|
gimp_viewable_set_stock_id (viewable, stock_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-12 22:46:07 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceInfo *
|
2010-02-13 00:10:54 +08:00
|
|
|
gimp_device_info_new (Gimp *gimp,
|
|
|
|
GdkDevice *device,
|
|
|
|
GdkDisplay *display)
|
2001-12-08 01:39:51 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
2010-02-13 00:10:54 +08:00
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
|
|
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
2001-12-08 01:39:51 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
return g_object_new (GIMP_TYPE_DEVICE_INFO,
|
2010-02-13 00:10:54 +08:00
|
|
|
"gimp", gimp,
|
|
|
|
"device", device,
|
|
|
|
"display", display,
|
2005-11-28 01:20:40 +08:00
|
|
|
NULL);
|
1998-08-13 23:25:41 +08:00
|
|
|
}
|
|
|
|
|
2010-02-14 00:31:33 +08:00
|
|
|
GdkDevice *
|
|
|
|
gimp_device_info_get_device (GimpDeviceInfo *info,
|
|
|
|
GdkDisplay **display)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), NULL);
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
*display = info->display;
|
|
|
|
|
|
|
|
return info->device;
|
|
|
|
}
|
|
|
|
|
2010-02-13 00:10:54 +08:00
|
|
|
void
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_set_device (GimpDeviceInfo *info,
|
2010-02-13 00:10:54 +08:00
|
|
|
GdkDevice *device,
|
|
|
|
GdkDisplay *display)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
|
2010-02-16 02:58:02 +08:00
|
|
|
g_return_if_fail ((device == NULL && display == NULL) ||
|
|
|
|
(GDK_IS_DEVICE (device) && GDK_IS_DISPLAY (display)));
|
|
|
|
g_return_if_fail ((info->device == NULL && GDK_IS_DEVICE (device)) ||
|
|
|
|
(GDK_IS_DEVICE (info->device) && device == NULL));
|
|
|
|
g_return_if_fail (device == NULL ||
|
|
|
|
strcmp (device->name,
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_object_get_name (info)) == 0);
|
2010-02-13 00:10:54 +08:00
|
|
|
|
2010-02-16 02:58:02 +08:00
|
|
|
if (device)
|
|
|
|
{
|
|
|
|
info->device = device;
|
|
|
|
info->display = display;
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (device), GIMP_DEVICE_INFO_DATA_KEY, info);
|
|
|
|
|
|
|
|
gimp_device_info_set_mode (info, info->mode);
|
|
|
|
|
|
|
|
if (info->n_axes != device->num_axes)
|
|
|
|
g_printerr ("%s: stored 'num-axes' for device '%s' doesn't match "
|
|
|
|
"number of axes present in device\n",
|
|
|
|
G_STRFUNC, device->name);
|
|
|
|
|
|
|
|
for (i = 0; i < MIN (info->n_axes, device->num_axes); i++)
|
|
|
|
gimp_device_info_set_axis_use (info, i,
|
|
|
|
info->axes[i]);
|
|
|
|
|
|
|
|
if (info->n_keys != device->num_keys)
|
|
|
|
g_printerr ("%s: stored 'num-keys' for device '%s' doesn't match "
|
|
|
|
"number of keys present in device\n",
|
|
|
|
G_STRFUNC, device->name);
|
2010-02-13 00:10:54 +08:00
|
|
|
|
2010-02-16 02:58:02 +08:00
|
|
|
for (i = 0; i < MIN (info->n_keys, device->num_keys); i++)
|
|
|
|
gimp_device_info_set_key (info, i,
|
|
|
|
info->keys[i].keyval,
|
|
|
|
info->keys[i].modifiers);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device = info->device;
|
|
|
|
display = info->display;
|
|
|
|
|
|
|
|
info->device = NULL;
|
|
|
|
info->display = NULL;
|
2010-02-13 00:10:54 +08:00
|
|
|
|
2010-02-16 02:58:02 +08:00
|
|
|
g_object_set_data (G_OBJECT (info->device), GIMP_DEVICE_INFO_DATA_KEY,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_device_info_set_mode (info, device->mode);
|
2010-02-13 00:10:54 +08:00
|
|
|
|
2010-02-16 02:58:02 +08:00
|
|
|
info->n_axes = device->num_axes;
|
|
|
|
info->axes = g_renew (GdkAxisUse, info->axes, info->n_axes);
|
2010-02-13 00:10:54 +08:00
|
|
|
|
2010-02-16 02:58:02 +08:00
|
|
|
for (i = 0; i < device->num_axes; i++)
|
|
|
|
gimp_device_info_set_axis_use (info, i,
|
|
|
|
device->axes[i].use);
|
2010-02-13 00:10:54 +08:00
|
|
|
|
2010-02-16 02:58:02 +08:00
|
|
|
info->n_keys = device->num_keys;
|
|
|
|
info->keys = g_renew (GdkDeviceKey, info->keys, info->n_keys);
|
2010-02-13 00:10:54 +08:00
|
|
|
|
2010-02-16 02:58:02 +08:00
|
|
|
for (i = 0; i < MIN (info->n_keys, device->num_keys); i++)
|
|
|
|
gimp_device_info_set_key (info, i,
|
|
|
|
device->keys[i].keyval,
|
|
|
|
device->keys[i].modifiers);
|
|
|
|
}
|
2010-02-15 05:08:32 +08:00
|
|
|
|
|
|
|
/* sort order depends on device presence */
|
|
|
|
gimp_object_name_changed (GIMP_OBJECT (info));
|
2010-02-13 00:10:54 +08:00
|
|
|
}
|
|
|
|
|
2010-02-12 22:46:07 +08:00
|
|
|
GdkInputMode
|
|
|
|
gimp_device_info_get_mode (GimpDeviceInfo *info)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), GDK_MODE_DISABLED);
|
|
|
|
|
|
|
|
if (info->device)
|
|
|
|
return info->device->mode;
|
|
|
|
else
|
|
|
|
return info->mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_device_info_set_mode (GimpDeviceInfo *info,
|
|
|
|
GdkInputMode mode)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
|
|
|
|
|
|
|
|
if (mode != gimp_device_info_get_mode (info))
|
|
|
|
{
|
|
|
|
if (info->device)
|
|
|
|
gdk_device_set_mode (info->device, mode);
|
|
|
|
else
|
|
|
|
info->mode = mode;
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (info), "mode");
|
|
|
|
gimp_device_info_changed (info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-16 19:11:22 +08:00
|
|
|
gboolean
|
|
|
|
gimp_device_info_has_cursor (GimpDeviceInfo *info)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), FALSE);
|
|
|
|
|
|
|
|
if (info->device)
|
|
|
|
return info->device->has_cursor;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-02-12 22:46:07 +08:00
|
|
|
gint
|
|
|
|
gimp_device_info_get_n_axes (GimpDeviceInfo *info)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), 0);
|
|
|
|
|
|
|
|
if (info->device)
|
|
|
|
return info->device->num_axes;
|
|
|
|
else
|
|
|
|
return info->n_axes;
|
|
|
|
}
|
|
|
|
|
|
|
|
GdkAxisUse
|
|
|
|
gimp_device_info_get_axis_use (GimpDeviceInfo *info,
|
|
|
|
gint axis)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), GDK_AXIS_IGNORE);
|
|
|
|
g_return_val_if_fail (axis >= 0 && axis < gimp_device_info_get_n_axes (info),
|
|
|
|
GDK_AXIS_IGNORE);
|
|
|
|
|
|
|
|
if (info->device)
|
|
|
|
return info->device->axes[axis].use;
|
|
|
|
else
|
|
|
|
return info->axes[axis];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_device_info_set_axis_use (GimpDeviceInfo *info,
|
|
|
|
gint axis,
|
|
|
|
GdkAxisUse use)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
|
|
|
|
g_return_if_fail (axis >= 0 && axis < gimp_device_info_get_n_axes (info));
|
|
|
|
|
|
|
|
if (use != gimp_device_info_get_axis_use (info, axis))
|
|
|
|
{
|
|
|
|
if (info->device)
|
|
|
|
gdk_device_set_axis_use (info->device, axis, use);
|
|
|
|
else
|
|
|
|
info->axes[axis] = use;
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (info), "axes");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_device_info_get_n_keys (GimpDeviceInfo *info)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), 0);
|
|
|
|
|
|
|
|
if (info->device)
|
|
|
|
return info->device->num_keys;
|
|
|
|
else
|
|
|
|
return info->n_keys;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_device_info_get_key (GimpDeviceInfo *info,
|
|
|
|
gint key,
|
|
|
|
guint *keyval,
|
|
|
|
GdkModifierType *modifiers)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
|
|
|
|
g_return_if_fail (key >= 0 && key < gimp_device_info_get_n_keys (info));
|
|
|
|
g_return_if_fail (keyval != NULL);
|
|
|
|
g_return_if_fail (modifiers != NULL);
|
|
|
|
|
|
|
|
if (info->device)
|
|
|
|
{
|
|
|
|
*keyval = info->device->keys[key].keyval;
|
|
|
|
*modifiers = info->device->keys[key].modifiers;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*keyval = info->keys[key].keyval;
|
|
|
|
*modifiers = info->keys[key].modifiers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_device_info_set_key (GimpDeviceInfo *info,
|
|
|
|
gint key,
|
|
|
|
guint keyval,
|
|
|
|
GdkModifierType modifiers)
|
|
|
|
{
|
|
|
|
guint old_keyval;
|
|
|
|
GdkModifierType old_modifiers;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
|
|
|
|
g_return_if_fail (key >= 0 && key < gimp_device_info_get_n_keys (info));
|
|
|
|
|
|
|
|
gimp_device_info_get_key (info, key, &old_keyval, &old_modifiers);
|
|
|
|
|
|
|
|
if (keyval != old_keyval ||
|
|
|
|
modifiers != old_modifiers)
|
|
|
|
{
|
|
|
|
if (info->device)
|
|
|
|
{
|
|
|
|
gdk_device_set_key (info->device, key, keyval, modifiers);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
info->keys[key].keyval = keyval;
|
|
|
|
info->keys[key].modifiers = modifiers;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (info), "keys");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-16 06:06:19 +08:00
|
|
|
GimpCurve *
|
|
|
|
gimp_device_info_get_curve (GimpDeviceInfo *info,
|
|
|
|
GdkAxisUse use)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), NULL);
|
|
|
|
|
|
|
|
switch (use)
|
|
|
|
{
|
|
|
|
case GDK_AXIS_PRESSURE:
|
|
|
|
return info->pressure_curve;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-16 20:27:46 +08:00
|
|
|
gdouble
|
|
|
|
gimp_device_info_map_axis (GimpDeviceInfo *info,
|
|
|
|
GdkAxisUse use,
|
2010-02-17 02:29:37 +08:00
|
|
|
gdouble value)
|
2010-02-16 20:27:46 +08:00
|
|
|
{
|
|
|
|
GimpCurve *curve;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), value);
|
|
|
|
|
|
|
|
curve = gimp_device_info_get_curve (info, use);
|
|
|
|
|
|
|
|
if (curve)
|
|
|
|
return gimp_curve_map_value (curve, value);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
void
|
2010-02-13 23:24:01 +08:00
|
|
|
gimp_device_info_changed (GimpDeviceInfo *info)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2010-02-13 23:24:01 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2010-02-13 23:24:01 +08:00
|
|
|
g_signal_emit (info, device_info_signals[CHANGED], 0);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceInfo *
|
|
|
|
gimp_device_info_get_by_device (GdkDevice *device)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
return g_object_get_data (G_OBJECT (device), GIMP_DEVICE_INFO_DATA_KEY);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
2010-02-15 05:08:32 +08:00
|
|
|
|
|
|
|
gint
|
|
|
|
gimp_device_info_compare (GimpDeviceInfo *a,
|
|
|
|
GimpDeviceInfo *b)
|
|
|
|
{
|
|
|
|
if (a->device && ! b->device)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else if (! a->device && b->device)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return - strcmp (gimp_object_get_name (a),
|
|
|
|
gimp_object_get_name (b));
|
|
|
|
}
|
|
|
|
}
|