1998-06-06 12:06:56 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
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>
|
|
|
|
|
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"
|
|
|
|
|
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"
|
|
|
|
#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,
|
|
|
|
PROP_MODE,
|
|
|
|
PROP_AXES,
|
|
|
|
PROP_KEYS
|
|
|
|
};
|
|
|
|
|
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-24 21:07:12 +08:00
|
|
|
static void gimp_device_info_class_init (GimpDeviceInfoClass *klass);
|
|
|
|
static void gimp_device_info_init (GimpDeviceInfo *device_info);
|
2001-02-11 03:35:29 +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
|
|
|
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
static GimpContextClass *parent_class = NULL;
|
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
|
|
|
GType
|
|
|
|
gimp_device_info_get_type (void)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
static GType device_info_type = 0;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
if (! device_info_type)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
static const GTypeInfo device_info_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpDeviceInfoClass),
|
2004-07-04 04:27:28 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_device_info_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpDeviceInfo),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_device_info_init,
|
2001-12-08 01:39:51 +08:00
|
|
|
};
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info_type = g_type_register_static (GIMP_TYPE_CONTEXT,
|
|
|
|
"GimpDeviceInfo",
|
|
|
|
&device_info_info, 0);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
return device_info_type;
|
1999-10-27 02:27:27 +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
|
|
|
{
|
2004-07-05 05:27:09 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2002-05-24 21:07:12 +08:00
|
|
|
GParamSpec *array_spec;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1998-06-06 12:06:56 +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
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
object_class->constructor = gimp_device_info_constructor;
|
2002-05-24 21:07:12 +08:00
|
|
|
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;
|
|
|
|
|
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,
|
|
|
|
0);
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
array_spec = g_param_spec_value_array ("axes",
|
|
|
|
NULL, NULL,
|
|
|
|
g_param_spec_enum ("axis",
|
|
|
|
NULL, NULL,
|
|
|
|
GDK_TYPE_AXIS_USE,
|
|
|
|
GDK_AXIS_IGNORE,
|
|
|
|
G_PARAM_READWRITE),
|
|
|
|
GIMP_CONFIG_PARAM_FLAGS);
|
|
|
|
g_object_class_install_property (object_class, PROP_AXES, array_spec);
|
|
|
|
|
|
|
|
array_spec = g_param_spec_value_array ("keys",
|
|
|
|
NULL, NULL,
|
|
|
|
g_param_spec_string ("key",
|
|
|
|
NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
G_PARAM_READWRITE),
|
|
|
|
GIMP_CONFIG_PARAM_FLAGS);
|
|
|
|
g_object_class_install_property (object_class, PROP_KEYS, array_spec);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_device_info_init (GimpDeviceInfo *device_info)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info->device = NULL;
|
|
|
|
device_info->mode = GDK_MODE_DISABLED;
|
|
|
|
device_info->num_axes = 0;
|
|
|
|
device_info->axes = NULL;
|
|
|
|
device_info->num_keys = 0;
|
|
|
|
device_info->keys = 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)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
Gimp *gimp;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
gimp = GIMP_CONTEXT (object)->gimp;
|
|
|
|
|
|
|
|
g_assert (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2004-07-04 04:27:28 +08:00
|
|
|
GimpDeviceInfo *device_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
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
if (device_info->axes)
|
|
|
|
g_free (device_info->axes);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
if (device_info->keys)
|
|
|
|
g_free (device_info->keys);
|
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)
|
|
|
|
{
|
2004-07-04 04:27:28 +08:00
|
|
|
GimpDeviceInfo *device_info = GIMP_DEVICE_INFO (object);
|
|
|
|
GdkDevice *device = device_info->device;
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_MODE:
|
|
|
|
if (device_info->device)
|
|
|
|
gdk_device_set_mode (device_info->device, g_value_get_enum (value));
|
|
|
|
else
|
|
|
|
device_info->mode = g_value_get_enum (value);
|
|
|
|
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;
|
|
|
|
|
|
|
|
device_info->num_axes = n_device_values;
|
|
|
|
device_info->axes = g_new0 (GdkAxisUse, n_device_values);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n_device_values; i++)
|
|
|
|
{
|
|
|
|
GdkAxisUse axis_use;
|
|
|
|
|
|
|
|
axis_use = g_value_get_enum (g_value_array_get_nth (array, i));
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
gdk_device_set_axis_use (device, i, axis_use);
|
|
|
|
else
|
|
|
|
device_info->axes[i] = axis_use;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
device_info->num_keys = n_device_values;
|
|
|
|
device_info->keys = g_new0 (GdkDeviceKey, n_device_values);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
{
|
|
|
|
gdk_device_set_key (device, i, keyval, modifiers);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device_info->keys[i].keyval = keyval;
|
|
|
|
device_info->keys[i].modifiers = modifiers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_info_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-07-04 04:27:28 +08:00
|
|
|
GimpDeviceInfo *device_info = GIMP_DEVICE_INFO (object);
|
|
|
|
GdkDevice *device = device_info->device;
|
2002-05-24 21:07:12 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_MODE:
|
|
|
|
if (device)
|
|
|
|
g_value_set_enum (value, device->mode);
|
|
|
|
else
|
|
|
|
g_value_set_enum (value, device_info->mode);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_AXES:
|
|
|
|
{
|
|
|
|
GValueArray *array;
|
|
|
|
GValue enum_value = { 0, };
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
array = g_value_array_new (6);
|
|
|
|
g_value_init (&enum_value, GDK_TYPE_AXIS_USE);
|
|
|
|
|
|
|
|
for (i = 0; i < (device ? device->num_axes : device_info->num_axes); i++)
|
|
|
|
{
|
|
|
|
g_value_set_enum (&enum_value,
|
|
|
|
device ?
|
|
|
|
device->axes[i].use : device_info->axes[i]);
|
|
|
|
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, };
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
array = g_value_array_new (32);
|
|
|
|
g_value_init (&string_value, G_TYPE_STRING);
|
|
|
|
|
|
|
|
for (i = 0; i < (device ? device->num_keys : device_info->num_keys); i++)
|
|
|
|
{
|
|
|
|
GdkModifierType modifiers = (device ? device->keys[i].modifiers :
|
|
|
|
device_info->keys[i].modifiers);
|
|
|
|
guint keyval = (device ? device->keys[i].keyval :
|
|
|
|
device_info->keys[i].keyval);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceInfo *
|
|
|
|
gimp_device_info_new (Gimp *gimp,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GimpDeviceInfo *device_info;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
device_info = g_object_new (GIMP_TYPE_DEVICE_INFO,
|
|
|
|
"name", name,
|
|
|
|
"gimp", gimp,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return device_info;
|
1998-08-13 23:25:41 +08:00
|
|
|
}
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceInfo *
|
|
|
|
gimp_device_info_set_from_device (GimpDeviceInfo *device_info,
|
|
|
|
GdkDevice *device)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (device_info), NULL);
|
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
g_object_set_data (G_OBJECT (device), GIMP_DEVICE_INFO_DATA_KEY, device_info);
|
1998-08-13 23:25:41 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info->device = device;
|
1998-11-26 14:07:22 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info->mode = device->mode;
|
1998-08-13 23:25:41 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info->num_axes = device->num_axes;
|
|
|
|
device_info->axes = NULL;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info->num_keys = device->num_keys;
|
|
|
|
device_info->keys = NULL;
|
2001-01-15 09:48:53 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
return device_info;
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
void
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_device_info_changed (GimpDeviceInfo *device_info)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (device_info));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (device_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
|
|
|
}
|
|
|
|
|
1998-07-21 08:15:24 +08:00
|
|
|
void
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_device_info_changed_by_device (GdkDevice *device)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceInfo *device_info;
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
g_return_if_fail (GDK_IS_DEVICE (device));
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
device_info = g_object_get_data (G_OBJECT (device), GIMP_DEVICE_INFO_DATA_KEY);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
if (device_info)
|
|
|
|
gimp_device_info_changed (device_info);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|