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.
|
|
|
|
*/
|
1999-03-07 20:56:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
#include <string.h>
|
1998-06-08 16:38:16 +08:00
|
|
|
#include <stdio.h>
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "actionarea.h"
|
1999-09-01 08:12:33 +08:00
|
|
|
#include "gimpcontextpreview.h"
|
1999-09-04 11:36:54 +08:00
|
|
|
#include "gimpdnd.h"
|
1998-06-06 12:06:56 +08:00
|
|
|
#include "devices.h"
|
|
|
|
#include "interface.h"
|
|
|
|
#include "gimprc.h"
|
|
|
|
#include "palette.h"
|
1998-07-21 08:15:24 +08:00
|
|
|
#include "session.h"
|
1998-06-06 12:06:56 +08:00
|
|
|
#include "tools.h"
|
1999-01-11 07:20:33 +08:00
|
|
|
#include "dialog_handler.h"
|
1999-06-02 13:55:02 +08:00
|
|
|
#include "indicator_area.h"
|
1998-06-06 12:06:56 +08:00
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "libgimp/gimpenv.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
1998-08-01 06:44:26 +08:00
|
|
|
#define CELL_SIZE 20 /* The size of the preview cells */
|
1999-08-31 04:14:49 +08:00
|
|
|
#define PREVIEW_EVENT_MASK GDK_BUTTON_PRESS_MASK | \
|
1999-08-13 01:53:51 +08:00
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
GDK_ENTER_NOTIFY_MASK | \
|
|
|
|
GDK_LEAVE_NOTIFY_MASK
|
1998-08-01 06:44:26 +08:00
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
typedef struct _DeviceInfo DeviceInfo;
|
|
|
|
|
|
|
|
struct _DeviceInfo {
|
|
|
|
guint32 device; /* device ID */
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
short is_init; /* has the user used it? */
|
|
|
|
short is_present; /* is the device currently present */
|
|
|
|
|
|
|
|
/* gdk_input options - for not present devices */
|
|
|
|
|
|
|
|
GdkInputMode mode;
|
|
|
|
gint num_axes;
|
|
|
|
GdkAxisUse *axes;
|
|
|
|
gint num_keys;
|
|
|
|
GdkDeviceKey *keys;
|
|
|
|
|
1998-07-09 13:31:06 +08:00
|
|
|
GimpBrushP brush;
|
1998-08-01 06:44:26 +08:00
|
|
|
GPatternP pattern;
|
1998-06-06 12:06:56 +08:00
|
|
|
ToolType tool;
|
|
|
|
unsigned char foreground[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _DeviceInfoDialog DeviceInfoDialog;
|
|
|
|
|
|
|
|
struct _DeviceInfoDialog {
|
|
|
|
int num_devices;
|
|
|
|
guint32 current;
|
|
|
|
guint32 *ids;
|
|
|
|
|
|
|
|
GtkWidget *shell;
|
|
|
|
GtkWidget *table;
|
|
|
|
|
|
|
|
GtkWidget **frames;
|
|
|
|
GtkWidget **tools;
|
|
|
|
GtkWidget **colors;
|
|
|
|
GtkWidget **brushes;
|
1998-08-01 06:44:26 +08:00
|
|
|
GtkWidget **patterns;
|
1998-08-13 23:25:41 +08:00
|
|
|
GtkWidget **eventboxes;
|
1998-06-06 12:06:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Local Data */
|
|
|
|
|
|
|
|
GList *devices_info = NULL;
|
|
|
|
DeviceInfoDialog *deviceD = NULL;
|
|
|
|
/* If true, don't update device information dialog */
|
|
|
|
int suppress_update = FALSE;
|
|
|
|
|
|
|
|
/* Local functions */
|
1999-09-04 11:36:54 +08:00
|
|
|
static void input_dialog_destroy_callback (GtkWidget *, gpointer);
|
|
|
|
void input_dialog_able_callback (GtkWidget *w, guint32 deviceid,
|
|
|
|
gpointer data);
|
|
|
|
static void devices_save_current_info (void);
|
|
|
|
static void devices_write_rc_device (DeviceInfo *device_info, FILE *fp);
|
|
|
|
static void devices_write_rc (void);
|
1998-06-06 12:06:56 +08:00
|
|
|
static void device_status_destroy_callback (void);
|
1999-09-04 11:36:54 +08:00
|
|
|
static void devices_close_callback (GtkWidget *, gpointer);
|
|
|
|
static void device_status_update_current ();
|
|
|
|
|
|
|
|
static void device_status_drag_color (GtkWidget *,
|
|
|
|
guchar *, guchar *, guchar *, gpointer);
|
|
|
|
static void device_status_drop_color (GtkWidget *,
|
|
|
|
guchar, guchar, guchar, gpointer);
|
1999-09-05 18:45:07 +08:00
|
|
|
static void device_status_drop_brush (GtkWidget *,
|
|
|
|
GdkDragContext *, gint, gint, guint, gpointer);
|
|
|
|
static void device_status_drop_pattern (GtkWidget *,
|
|
|
|
GdkDragContext *, gint, gint, guint, gpointer);
|
1999-09-04 11:36:54 +08:00
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
/* Global data */
|
|
|
|
int current_device = GDK_CORE_POINTER;
|
|
|
|
|
|
|
|
/* the action area structure */
|
|
|
|
static ActionAreaItem action_items[] =
|
|
|
|
{
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
{ N_("Save"), (ActionCallback)devices_write_rc, NULL, NULL },
|
1999-03-28 02:16:30 +08:00
|
|
|
{ N_("Close"), devices_close_callback, NULL, NULL }
|
1998-06-06 12:06:56 +08:00
|
|
|
};
|
|
|
|
|
1999-09-04 11:36:54 +08:00
|
|
|
/* dnd stuff */
|
|
|
|
static GtkTargetEntry color_area_target_table[] =
|
|
|
|
{
|
|
|
|
GIMP_TARGET_COLOR
|
|
|
|
};
|
|
|
|
static guint n_color_area_targets = (sizeof (color_area_target_table) /
|
|
|
|
sizeof (color_area_target_table[0]));
|
1999-09-04 22:56:50 +08:00
|
|
|
static GtkTargetEntry brush_area_target_table[] =
|
|
|
|
{
|
|
|
|
GIMP_TARGET_BRUSH
|
|
|
|
};
|
|
|
|
static guint n_brush_area_targets = (sizeof (brush_area_target_table) /
|
|
|
|
sizeof (brush_area_target_table[0]));
|
|
|
|
static GtkTargetEntry pattern_area_target_table[] =
|
|
|
|
{
|
|
|
|
GIMP_TARGET_PATTERN
|
|
|
|
};
|
|
|
|
static guint n_pattern_area_targets = (sizeof (pattern_area_target_table) /
|
|
|
|
sizeof (pattern_area_target_table[0]));
|
1999-09-04 11:36:54 +08:00
|
|
|
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
void
|
|
|
|
create_input_dialog (void)
|
|
|
|
{
|
|
|
|
static GtkWidget *inputd = NULL;
|
1999-04-05 20:48:48 +08:00
|
|
|
GtkWidget *hbbox;
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
if (!inputd)
|
|
|
|
{
|
|
|
|
inputd = gtk_input_dialog_new();
|
1999-01-11 07:20:33 +08:00
|
|
|
|
|
|
|
/* register this one only */
|
|
|
|
dialog_register(inputd);
|
|
|
|
|
1999-04-05 20:48:48 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG(inputd)->action_area), 2);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (inputd)->action_area),
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
hbbox = gtk_hbutton_box_new();
|
|
|
|
gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbbox), 4);
|
|
|
|
|
|
|
|
gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->save_button, hbbox);
|
|
|
|
GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->save_button,
|
|
|
|
GTK_CAN_DEFAULT);
|
|
|
|
gtk_widget_reparent (GTK_INPUT_DIALOG (inputd)->close_button, hbbox);
|
|
|
|
GTK_WIDGET_SET_FLAGS (GTK_INPUT_DIALOG (inputd)->close_button,
|
|
|
|
GTK_CAN_DEFAULT);
|
|
|
|
|
|
|
|
gtk_box_pack_end(GTK_BOX (GTK_DIALOG (inputd)->action_area), hbbox,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_grab_default (GTK_INPUT_DIALOG (inputd)->close_button);
|
|
|
|
gtk_widget_show(hbbox);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->save_button),
|
|
|
|
"clicked",
|
|
|
|
GTK_SIGNAL_FUNC(devices_write_rc), NULL);
|
|
|
|
gtk_signal_connect (GTK_OBJECT(GTK_INPUT_DIALOG(inputd)->close_button),
|
|
|
|
"clicked",
|
|
|
|
GTK_SIGNAL_FUNC(devices_close_callback), inputd);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT(inputd), "destroy",
|
|
|
|
(GtkSignalFunc)input_dialog_destroy_callback,
|
|
|
|
&inputd);
|
|
|
|
gtk_signal_connect (GTK_OBJECT(inputd), "enable_device",
|
|
|
|
GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL);
|
|
|
|
gtk_signal_connect (GTK_OBJECT(inputd), "disable_device",
|
|
|
|
GTK_SIGNAL_FUNC(input_dialog_able_callback), NULL);
|
|
|
|
gtk_widget_show (inputd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_MAPPED(inputd))
|
|
|
|
gtk_widget_show(inputd);
|
|
|
|
else
|
|
|
|
gdk_window_raise(inputd->window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-13 01:53:51 +08:00
|
|
|
input_dialog_able_callback (GtkWidget *w,
|
|
|
|
guint32 deviceid,
|
|
|
|
gpointer data)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
|
|
|
device_status_update (deviceid);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
input_dialog_destroy_callback (GtkWidget *w,
|
1999-08-13 01:53:51 +08:00
|
|
|
gpointer call_data)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
|
|
|
*((GtkWidget **)call_data) = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
devices_init (void)
|
|
|
|
{
|
|
|
|
GList *tmp_list;
|
|
|
|
|
|
|
|
/* Create device info structures for present devices */
|
|
|
|
|
|
|
|
tmp_list = gdk_input_list_devices ();
|
|
|
|
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
GdkDeviceInfo *gdk_info = (GdkDeviceInfo *)tmp_list->data;
|
|
|
|
DeviceInfo *device_info = g_new (DeviceInfo, 1);
|
|
|
|
|
|
|
|
device_info->device = gdk_info->deviceid;
|
|
|
|
device_info->name = g_strdup (gdk_info->name);
|
|
|
|
|
|
|
|
device_info->is_init = FALSE;
|
|
|
|
device_info->is_present = TRUE;
|
|
|
|
|
|
|
|
device_info->mode = gdk_info->mode;
|
|
|
|
device_info->num_axes = gdk_info->num_axes;
|
|
|
|
device_info->axes = NULL;
|
|
|
|
|
|
|
|
device_info->brush = NULL;
|
1998-08-01 06:44:26 +08:00
|
|
|
device_info->pattern = NULL;
|
1998-06-06 12:06:56 +08:00
|
|
|
device_info->tool = RECT_SELECT;
|
|
|
|
device_info->foreground[0] = 0;
|
|
|
|
device_info->foreground[1] = 0;
|
|
|
|
device_info->foreground[2] = 0;
|
|
|
|
|
|
|
|
devices_info = g_list_append (devices_info, device_info);
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
1998-08-13 23:25:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-13 01:53:51 +08:00
|
|
|
devices_restore (void)
|
1998-08-13 23:25:41 +08:00
|
|
|
{
|
1999-03-07 20:56:03 +08:00
|
|
|
char *filename;
|
1998-08-13 23:25:41 +08:00
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info;
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
/* Augment with information from rc file */
|
1999-03-07 20:56:03 +08:00
|
|
|
filename = gimp_personal_rc_file ("devicerc");
|
|
|
|
parse_gimprc_file (filename);
|
|
|
|
g_free (filename);
|
1998-08-13 23:25:41 +08:00
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
device_info = NULL;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
if (((DeviceInfo *)tmp_list->data)->device == current_device)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
1998-11-28 03:49:53 +08:00
|
|
|
g_return_if_fail (device_info != NULL);
|
1998-11-26 14:07:22 +08:00
|
|
|
|
1998-08-13 23:25:41 +08:00
|
|
|
suppress_update = TRUE;
|
|
|
|
|
|
|
|
if (device_info->is_init)
|
|
|
|
{
|
|
|
|
gtk_widget_activate (tool_info[(int) device_info->tool].tool_widget);
|
|
|
|
|
|
|
|
palette_set_foreground (device_info->foreground[0],
|
|
|
|
device_info->foreground[1],
|
|
|
|
device_info->foreground[2]);
|
|
|
|
|
1999-08-31 04:14:49 +08:00
|
|
|
if (device_info->brush)
|
|
|
|
select_brush (device_info->brush);
|
1998-08-13 23:25:41 +08:00
|
|
|
if (device_info->pattern)
|
1999-09-05 18:45:07 +08:00
|
|
|
select_pattern (device_info->pattern);
|
1998-08-13 23:25:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
suppress_update = FALSE;
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-31 04:14:49 +08:00
|
|
|
devices_rc_update (gchar *name,
|
|
|
|
DeviceValues values,
|
|
|
|
GdkInputMode mode,
|
|
|
|
gint num_axes,
|
|
|
|
GdkAxisUse *axes,
|
|
|
|
gint num_keys,
|
|
|
|
GdkDeviceKey *keys,
|
|
|
|
gchar *brush_name,
|
|
|
|
ToolType tool,
|
|
|
|
guchar foreground[],
|
|
|
|
gchar *pattern_name)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info;
|
|
|
|
|
|
|
|
/* Find device if we have it */
|
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
device_info = NULL;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
if (!strcmp (((DeviceInfo *)tmp_list->data)->name, name))
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!device_info)
|
|
|
|
{
|
|
|
|
device_info = g_new (DeviceInfo, 1);
|
|
|
|
device_info->name = g_strdup (name);
|
|
|
|
device_info->is_present = FALSE;
|
|
|
|
|
|
|
|
if (values & DEVICE_AXES)
|
|
|
|
{
|
|
|
|
device_info->num_axes = num_axes;
|
|
|
|
device_info->axes = g_new (GdkAxisUse, num_axes);
|
|
|
|
memcpy (device_info->axes, axes, num_axes * sizeof (GdkAxisUse));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device_info->num_axes = 0;
|
|
|
|
device_info->axes = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (values & DEVICE_KEYS)
|
|
|
|
{
|
|
|
|
device_info->num_keys = num_keys;
|
|
|
|
device_info->keys = g_new (GdkDeviceKey, num_keys);
|
|
|
|
memcpy (device_info->keys, axes, num_keys * sizeof (GdkDeviceKey));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (values & DEVICE_MODE)
|
|
|
|
device_info->mode = mode;
|
|
|
|
else
|
|
|
|
device_info->mode = GDK_MODE_DISABLED;
|
|
|
|
|
|
|
|
device_info->brush = NULL;
|
1998-08-01 06:44:26 +08:00
|
|
|
device_info->pattern = NULL;
|
1998-06-06 12:06:56 +08:00
|
|
|
device_info->tool = RECT_SELECT;
|
|
|
|
device_info->foreground[0] = 0;
|
|
|
|
device_info->foreground[1] = 0;
|
|
|
|
device_info->foreground[2] = 0;
|
|
|
|
|
|
|
|
devices_info = g_list_append (devices_info, device_info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GdkDeviceInfo *gdk_info = NULL; /* Quiet gcc */
|
|
|
|
|
|
|
|
tmp_list = gdk_input_list_devices();
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (info->deviceid == device_info->device)
|
|
|
|
{
|
|
|
|
gdk_info = info;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gdk_info != NULL)
|
|
|
|
{
|
|
|
|
if (values & DEVICE_MODE)
|
|
|
|
gdk_input_set_mode (gdk_info->deviceid, mode);
|
|
|
|
|
|
|
|
if ((values & DEVICE_AXES) && num_axes >= gdk_info->num_axes)
|
|
|
|
gdk_input_set_axes (gdk_info->deviceid, axes);
|
|
|
|
|
|
|
|
if ((values & DEVICE_KEYS) && num_keys >= gdk_info->num_keys)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i<MAX (num_keys, gdk_info->num_keys); i++)
|
|
|
|
gdk_input_set_key (gdk_info->deviceid, i,
|
|
|
|
keys[i].keyval, keys[i].modifiers);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
g_warning (_("devices_rc_update called multiple times for not present device\n"));
|
1998-06-06 12:06:56 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-01 06:44:26 +08:00
|
|
|
if (values & (DEVICE_PATTERN | DEVICE_BRUSH | DEVICE_TOOL | DEVICE_FOREGROUND))
|
1998-06-06 12:06:56 +08:00
|
|
|
device_info->is_init = TRUE;
|
|
|
|
|
1998-08-01 06:44:26 +08:00
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
if (values & DEVICE_BRUSH)
|
|
|
|
{
|
1999-08-13 01:53:51 +08:00
|
|
|
device_info->brush = gimp_brush_list_get_brush (brush_list, brush_name);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
1998-08-01 06:44:26 +08:00
|
|
|
if (values & DEVICE_PATTERN)
|
|
|
|
{
|
1999-08-31 04:14:49 +08:00
|
|
|
device_info->pattern = pattern_list_get_pattern (pattern_list, pattern_name);
|
1998-08-01 06:44:26 +08:00
|
|
|
}
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
if (values & DEVICE_TOOL)
|
|
|
|
device_info->tool = tool;
|
|
|
|
|
|
|
|
if (values & DEVICE_FOREGROUND)
|
|
|
|
{
|
|
|
|
device_info->foreground[0] = foreground[0];
|
|
|
|
device_info->foreground[1] = foreground[1];
|
|
|
|
device_info->foreground[2] = foreground[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
select_device (guint32 new_device)
|
|
|
|
{
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info;
|
|
|
|
|
|
|
|
suppress_update = TRUE;
|
|
|
|
|
|
|
|
/* store old information */
|
|
|
|
|
|
|
|
devices_save_current_info();
|
|
|
|
|
|
|
|
/* Now see if there is already information about the new device */
|
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
device_info = NULL;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
if (((DeviceInfo *)tmp_list->data)->device == new_device)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_device = new_device;
|
|
|
|
|
|
|
|
if (device_info->is_init)
|
|
|
|
{
|
1998-06-22 04:17:21 +08:00
|
|
|
gtk_widget_activate (tool_info[(int) device_info->tool].tool_widget);
|
1998-06-06 12:06:56 +08:00
|
|
|
palette_set_foreground (device_info->foreground[0],
|
|
|
|
device_info->foreground[1],
|
|
|
|
device_info->foreground[2]);
|
1999-08-31 04:14:49 +08:00
|
|
|
if (device_info->brush)
|
|
|
|
select_brush (device_info->brush);
|
1998-08-01 06:44:26 +08:00
|
|
|
if (device_info->pattern)
|
1999-08-31 04:14:49 +08:00
|
|
|
select_pattern (device_info->pattern);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
suppress_update = FALSE;
|
|
|
|
|
|
|
|
device_status_update_current ();
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
devices_check_change (GdkEvent *event)
|
|
|
|
{
|
|
|
|
guint32 device;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
device = ((GdkEventMotion *)event)->deviceid;
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
device = ((GdkEventButton *)event)->deviceid;
|
|
|
|
break;
|
|
|
|
case GDK_PROXIMITY_OUT:
|
|
|
|
device = ((GdkEventProximity *)event)->deviceid;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
device = current_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device != current_device)
|
|
|
|
{
|
|
|
|
select_device (device);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
devices_save_current_info (void)
|
|
|
|
{
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info;
|
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
device_info = NULL;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
if (((DeviceInfo *)tmp_list->data)->device == current_device)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_info->is_init = TRUE;
|
|
|
|
device_info->device = current_device;
|
|
|
|
device_info->brush = get_active_brush ();
|
1998-08-01 06:44:26 +08:00
|
|
|
device_info->pattern = get_active_pattern();
|
1999-06-20 04:20:59 +08:00
|
|
|
if (active_tool)
|
|
|
|
device_info->tool = active_tool->type;
|
1998-06-06 12:06:56 +08:00
|
|
|
else
|
|
|
|
device_info->tool = RECT_SELECT;
|
|
|
|
palette_get_foreground (&device_info->foreground[0],
|
|
|
|
&device_info->foreground[1],
|
|
|
|
&device_info->foreground[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-08-13 01:53:51 +08:00
|
|
|
devices_write_rc_device (DeviceInfo *device_info,
|
|
|
|
FILE *fp)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
|
|
|
GdkDeviceInfo *gdk_info;
|
|
|
|
GList *tmp_list;
|
|
|
|
gchar *mode = NULL; /* Quiet gcc */
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gdk_info = NULL;
|
|
|
|
if (device_info->is_present)
|
|
|
|
{
|
|
|
|
/* gdk_input_list_devices returns an internal list, so we shouldn't
|
|
|
|
free it afterwards */
|
|
|
|
tmp_list = gdk_input_list_devices();
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
GdkDeviceInfo *info = (GdkDeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (info->deviceid == device_info->device)
|
|
|
|
{
|
|
|
|
gdk_info = info;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, "(device \"%s\"",device_info->name);
|
|
|
|
|
|
|
|
switch (gdk_info ? gdk_info->mode : device_info->mode)
|
|
|
|
{
|
|
|
|
case GDK_MODE_DISABLED:
|
|
|
|
mode = "disabled";
|
|
|
|
break;
|
|
|
|
case GDK_MODE_SCREEN:
|
|
|
|
mode = "screen";
|
|
|
|
break;
|
|
|
|
case GDK_MODE_WINDOW:
|
|
|
|
mode = "window";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, "\n (mode %s)",mode);
|
|
|
|
|
|
|
|
fprintf(fp, "\n (axes %d",gdk_info ? gdk_info->num_axes : device_info->num_axes);
|
|
|
|
|
|
|
|
for (i=0; i<(gdk_info ? gdk_info->num_axes : device_info->num_axes); i++)
|
|
|
|
{
|
|
|
|
gchar *axis_type = NULL; /* Quiet gcc */
|
|
|
|
|
|
|
|
switch (gdk_info ? gdk_info->axes[i] : device_info->axes[i])
|
|
|
|
{
|
|
|
|
case GDK_AXIS_IGNORE:
|
|
|
|
axis_type = "ignore";
|
|
|
|
break;
|
|
|
|
case GDK_AXIS_X:
|
|
|
|
axis_type = "x";
|
|
|
|
break;
|
|
|
|
case GDK_AXIS_Y:
|
|
|
|
axis_type = "y";
|
|
|
|
break;
|
|
|
|
case GDK_AXIS_PRESSURE:
|
|
|
|
axis_type = "pressure";
|
|
|
|
break;
|
|
|
|
case GDK_AXIS_XTILT:
|
|
|
|
axis_type = "xtilt";
|
|
|
|
break;
|
|
|
|
case GDK_AXIS_YTILT:
|
|
|
|
axis_type = "ytilt";
|
|
|
|
break;
|
1999-09-04 22:42:43 +08:00
|
|
|
#ifdef GTK_HAVE_SIX_VALUATORS
|
|
|
|
case GDK_AXIS_WHEEL:
|
|
|
|
axis_type = "wheel";
|
|
|
|
break;
|
|
|
|
#endif /* GTK_HAVE_SIX_VALUATORS */
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
fprintf(fp, " %s",axis_type);
|
|
|
|
}
|
|
|
|
fprintf(fp,")");
|
|
|
|
|
|
|
|
fprintf(fp, "\n (keys %d", gdk_info ? gdk_info->num_keys : device_info->num_keys);
|
|
|
|
|
|
|
|
for (i=0; i<(gdk_info ? gdk_info->num_keys : device_info->num_keys); i++)
|
|
|
|
{
|
|
|
|
GdkModifierType modifiers = gdk_info ? gdk_info->keys[i].modifiers :
|
|
|
|
device_info->keys[i].modifiers;
|
|
|
|
guint keyval = gdk_info ? gdk_info->keys[i].keyval :
|
|
|
|
device_info->keys[i].keyval;
|
|
|
|
|
|
|
|
if (keyval)
|
|
|
|
{
|
|
|
|
/* FIXME: integrate this back with menus_install_accelerator */
|
|
|
|
char accel[64];
|
|
|
|
char t2[2];
|
|
|
|
|
|
|
|
accel[0] = '\0';
|
|
|
|
if (modifiers & GDK_CONTROL_MASK)
|
|
|
|
strcat (accel, "<control>");
|
|
|
|
if (modifiers & GDK_SHIFT_MASK)
|
|
|
|
strcat (accel, "<shift>");
|
|
|
|
if (modifiers & GDK_MOD1_MASK)
|
|
|
|
strcat (accel, "<alt>");
|
|
|
|
|
|
|
|
t2[0] = keyval;
|
|
|
|
t2[1] = '\0';
|
|
|
|
strcat (accel, t2);
|
|
|
|
fprintf (fp, " \"%s\"",accel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf (fp, " \"\"");
|
|
|
|
}
|
|
|
|
fprintf(fp,")");
|
|
|
|
|
|
|
|
if (device_info->is_init)
|
|
|
|
{
|
1998-10-05 18:05:29 +08:00
|
|
|
if (device_info->brush)
|
|
|
|
fprintf(fp, "\n (brush \"%s\")",device_info->brush->name);
|
|
|
|
if (device_info->pattern)
|
|
|
|
fprintf(fp, "\n (pattern \"%s\")",device_info->pattern->name);
|
1999-02-07 00:34:16 +08:00
|
|
|
/* Fixme: hard coded last tool.... see gimprc */
|
|
|
|
if (device_info->tool && device_info->tool <= LAST_TOOLBOX_TOOL)
|
1998-10-05 18:05:29 +08:00
|
|
|
fprintf(fp, "\n (tool \"%s\")",
|
1998-06-06 12:06:56 +08:00
|
|
|
tool_info[device_info->tool].tool_name);
|
|
|
|
fprintf(fp, "\n (foreground %d %d %d)",
|
|
|
|
device_info->foreground[0],
|
|
|
|
device_info->foreground[1],
|
|
|
|
device_info->foreground[2]);
|
|
|
|
}
|
|
|
|
fprintf(fp,")\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
devices_write_rc (void)
|
|
|
|
{
|
1999-03-07 20:56:03 +08:00
|
|
|
char *filename;
|
1998-06-06 12:06:56 +08:00
|
|
|
FILE *fp;
|
|
|
|
|
1999-03-09 05:59:55 +08:00
|
|
|
devices_save_current_info ();
|
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
filename = gimp_personal_rc_file ("devicerc");
|
|
|
|
fp = fopen (filename, "wb");
|
|
|
|
g_free (filename);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
if (!fp)
|
|
|
|
return;
|
1998-06-06 12:06:56 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
g_list_foreach (devices_info, (GFunc)devices_write_rc_device, fp);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
fclose (fp);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
create_device_status (void)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (deviceD == NULL)
|
|
|
|
{
|
|
|
|
deviceD = g_new (DeviceInfoDialog, 1);
|
|
|
|
deviceD->shell = gtk_dialog_new ();
|
|
|
|
|
1999-01-11 07:20:33 +08:00
|
|
|
/* register this one only */
|
|
|
|
dialog_register(deviceD->shell);
|
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW(deviceD->shell), _("Device Status"));
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_window_set_policy (GTK_WINDOW (deviceD->shell), FALSE, FALSE, TRUE);
|
1999-03-12 01:16:18 +08:00
|
|
|
/* don't set the dialog's size, as the number of devices may have
|
|
|
|
* changed since the last session
|
|
|
|
*/
|
|
|
|
session_set_window_geometry (deviceD->shell,
|
|
|
|
&device_status_session_info, FALSE);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
deviceD->num_devices = 0;
|
|
|
|
tmp_list = devices_info;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
if (((DeviceInfo *)tmp_list->data)->is_present)
|
|
|
|
deviceD->num_devices++;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
1999-06-02 13:55:02 +08:00
|
|
|
/* devices table */
|
1998-08-01 06:44:26 +08:00
|
|
|
deviceD->table = gtk_table_new (deviceD->num_devices, 5, FALSE);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER(deviceD->table), 3);
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER(GTK_DIALOG(deviceD->shell)->vbox),
|
|
|
|
deviceD->table);
|
|
|
|
gtk_widget_realize (deviceD->table);
|
|
|
|
gtk_widget_show (deviceD->table);
|
|
|
|
|
|
|
|
deviceD->ids = g_new (guint32, deviceD->num_devices);
|
|
|
|
deviceD->frames = g_new (GtkWidget *, deviceD->num_devices);
|
|
|
|
deviceD->tools = g_new (GtkWidget *, deviceD->num_devices);
|
|
|
|
deviceD->colors = g_new (GtkWidget *, deviceD->num_devices);
|
|
|
|
deviceD->brushes = g_new (GtkWidget *, deviceD->num_devices);
|
1998-08-01 06:44:26 +08:00
|
|
|
deviceD->patterns = g_new (GtkWidget *, deviceD->num_devices);
|
1998-08-13 23:25:41 +08:00
|
|
|
deviceD->eventboxes = g_new (GtkWidget *, deviceD->num_devices);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
i=0;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
if (!((DeviceInfo *)tmp_list->data)->is_present)
|
|
|
|
{
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
deviceD->ids[i] = device_info->device;
|
|
|
|
|
|
|
|
deviceD->frames[i] = gtk_frame_new (NULL);
|
|
|
|
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME(deviceD->frames[i]), GTK_SHADOW_OUT);
|
|
|
|
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->frames[i],
|
|
|
|
0, 1, i, i+1,
|
|
|
|
GTK_FILL, GTK_FILL, 2, 0);
|
|
|
|
|
|
|
|
label = gtk_label_new (device_info->name);
|
|
|
|
gtk_misc_set_padding (GTK_MISC(label), 2, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER(deviceD->frames[i]), label);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
|
1998-08-13 23:25:41 +08:00
|
|
|
deviceD->eventboxes[i] = gtk_event_box_new();
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
deviceD->tools[i] = gtk_pixmap_new (create_tool_pixmap(deviceD->table,
|
|
|
|
RECT_SELECT),
|
|
|
|
NULL);
|
1998-08-13 23:25:41 +08:00
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (deviceD->eventboxes[i]),deviceD->tools[i]);
|
|
|
|
|
|
|
|
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->eventboxes[i],
|
1998-06-06 12:06:56 +08:00
|
|
|
1, 2, i, i+1,
|
|
|
|
0, 0, 2, 2);
|
|
|
|
|
|
|
|
deviceD->colors[i] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
1998-08-13 23:25:41 +08:00
|
|
|
gtk_widget_set_events (deviceD->colors[i], PREVIEW_EVENT_MASK);
|
1998-08-01 06:44:26 +08:00
|
|
|
gtk_preview_size (GTK_PREVIEW (deviceD->colors[i]), CELL_SIZE, CELL_SIZE);
|
1999-09-04 11:36:54 +08:00
|
|
|
/* dnd stuff */
|
|
|
|
gtk_drag_source_set (deviceD->colors[i],
|
1999-09-05 18:45:07 +08:00
|
|
|
GDK_BUTTON1_MASK,
|
1999-09-04 11:36:54 +08:00
|
|
|
color_area_target_table, n_color_area_targets,
|
1999-09-04 22:56:50 +08:00
|
|
|
GDK_ACTION_COPY);
|
1999-09-04 11:36:54 +08:00
|
|
|
gimp_dnd_color_source_set (deviceD->colors[i], device_status_drag_color,
|
|
|
|
GUINT_TO_POINTER (device_info->device));
|
|
|
|
gtk_drag_dest_set (deviceD->colors[i],
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
1999-09-05 18:45:07 +08:00
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
1999-09-04 11:36:54 +08:00
|
|
|
GTK_DEST_DEFAULT_DROP,
|
|
|
|
color_area_target_table, n_color_area_targets,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_color_dest_set (deviceD->colors[i], device_status_drop_color,
|
|
|
|
GUINT_TO_POINTER (device_info->device));
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->colors[i],
|
|
|
|
2, 3, i, i+1,
|
|
|
|
0, 0, 2, 2);
|
|
|
|
|
1999-09-01 08:12:33 +08:00
|
|
|
deviceD->brushes[i] = gimp_context_preview_new (GCP_BRUSH,
|
|
|
|
CELL_SIZE, CELL_SIZE,
|
1999-09-04 22:56:50 +08:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gtk_drag_dest_set (deviceD->brushes[i],
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
1999-09-05 18:45:07 +08:00
|
|
|
GTK_DEST_DEFAULT_DROP,
|
1999-09-04 22:56:50 +08:00
|
|
|
brush_area_target_table, n_brush_area_targets,
|
1999-09-05 18:45:07 +08:00
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (deviceD->brushes[i]), "drag_drop",
|
|
|
|
GTK_SIGNAL_FUNC (device_status_drop_brush),
|
|
|
|
GUINT_TO_POINTER (device_info->device));
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->brushes[i],
|
|
|
|
3, 4, i, i+1,
|
|
|
|
0, 0, 2, 2);
|
|
|
|
|
1999-09-01 08:12:33 +08:00
|
|
|
deviceD->patterns[i] = gimp_context_preview_new (GCP_PATTERN,
|
|
|
|
CELL_SIZE, CELL_SIZE,
|
1999-09-04 22:56:50 +08:00
|
|
|
FALSE, TRUE, TRUE);
|
|
|
|
gtk_drag_dest_set (deviceD->patterns[i],
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
1999-09-05 18:45:07 +08:00
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
1999-09-04 22:56:50 +08:00
|
|
|
pattern_area_target_table, n_pattern_area_targets,
|
|
|
|
GDK_ACTION_COPY);
|
1999-09-05 18:45:07 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (deviceD->patterns[i]), "drag_drop",
|
|
|
|
GTK_SIGNAL_FUNC (device_status_drop_pattern),
|
|
|
|
GUINT_TO_POINTER (device_info->device));
|
1998-08-01 06:44:26 +08:00
|
|
|
gtk_table_attach (GTK_TABLE(deviceD->table), deviceD->patterns[i],
|
|
|
|
4, 5, i, i+1,
|
|
|
|
0, 0, 2, 2);
|
|
|
|
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
if (device_info->is_present)
|
|
|
|
device_status_update (device_info->device);
|
|
|
|
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
1999-03-28 02:16:30 +08:00
|
|
|
action_items[1].user_data = deviceD->shell;
|
|
|
|
build_action_area (GTK_DIALOG (deviceD->shell), action_items, 2, 1);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
deviceD->current = 0xffffffff; /* random, but doesn't matter */
|
|
|
|
device_status_update_current ();
|
|
|
|
|
|
|
|
gtk_widget_show (deviceD->shell);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (deviceD->shell), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC(device_status_destroy_callback),
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_MAPPED(deviceD->shell))
|
|
|
|
gtk_widget_show(deviceD->shell);
|
|
|
|
else
|
|
|
|
gdk_window_raise(deviceD->shell->window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
device_status_destroy_callback (void)
|
|
|
|
{
|
|
|
|
g_free(deviceD->ids);
|
|
|
|
g_free(deviceD->frames);
|
|
|
|
g_free(deviceD->tools);
|
1998-08-13 23:25:41 +08:00
|
|
|
g_free(deviceD->eventboxes);
|
1998-06-06 12:06:56 +08:00
|
|
|
g_free(deviceD->colors);
|
|
|
|
g_free(deviceD->brushes);
|
1998-08-01 06:44:26 +08:00
|
|
|
g_free(deviceD->patterns);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
|
|
|
g_free(deviceD);
|
|
|
|
deviceD = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
devices_close_callback (GtkWidget *w,
|
1999-08-13 01:53:51 +08:00
|
|
|
gpointer data)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
|
|
|
gtk_widget_hide (GTK_WIDGET(data));
|
|
|
|
}
|
|
|
|
|
1998-07-21 08:15:24 +08:00
|
|
|
void
|
|
|
|
device_status_free (void)
|
|
|
|
{
|
1998-08-13 23:25:41 +08:00
|
|
|
/* Save device status on exit */
|
|
|
|
if(save_device_status)
|
|
|
|
devices_write_rc();
|
|
|
|
|
1998-07-21 08:15:24 +08:00
|
|
|
if (deviceD)
|
|
|
|
{
|
|
|
|
session_get_window_info (deviceD->shell, &device_status_session_info);
|
|
|
|
device_status_destroy_callback ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
static void
|
|
|
|
device_status_update_current ()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (deviceD)
|
|
|
|
{
|
|
|
|
for (i=0; i<deviceD->num_devices; i++)
|
|
|
|
{
|
|
|
|
if (deviceD->ids[i] == deviceD->current)
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME(deviceD->frames[i]),
|
|
|
|
GTK_SHADOW_OUT);
|
|
|
|
else if (deviceD->ids[i] == current_device)
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME(deviceD->frames[i]),
|
|
|
|
GTK_SHADOW_IN);
|
|
|
|
}
|
|
|
|
deviceD->current = current_device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-01 06:44:26 +08:00
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
void
|
|
|
|
device_status_update (guint32 deviceid)
|
|
|
|
{
|
|
|
|
int i, j;
|
1998-08-01 06:44:26 +08:00
|
|
|
guchar buffer[CELL_SIZE*3];
|
1998-08-13 23:25:41 +08:00
|
|
|
gchar ttbuf[20]; /* [xxx,xxx,xxx] + null */
|
1998-06-06 12:06:56 +08:00
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info;
|
|
|
|
GdkDeviceInfo *gdk_info;
|
|
|
|
|
|
|
|
if (deviceD && !suppress_update)
|
|
|
|
{
|
|
|
|
if (deviceid == current_device)
|
|
|
|
{
|
|
|
|
devices_save_current_info();
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (device_info->device == deviceid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_if_fail (tmp_list != NULL);
|
|
|
|
|
|
|
|
tmp_list = gdk_input_list_devices();
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
gdk_info = (GdkDeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (gdk_info->deviceid == deviceid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_if_fail (tmp_list != NULL);
|
|
|
|
|
|
|
|
for (i=0; i<deviceD->num_devices; i++)
|
|
|
|
{
|
|
|
|
if (deviceD->ids[i] == deviceid)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_if_fail (i<deviceD->num_devices);
|
|
|
|
|
|
|
|
if (gdk_info->mode == GDK_MODE_DISABLED)
|
|
|
|
{
|
|
|
|
gtk_widget_hide (deviceD->frames[i]);
|
|
|
|
gtk_widget_hide (deviceD->tools[i]);
|
1998-08-13 23:25:41 +08:00
|
|
|
gtk_widget_hide (deviceD->eventboxes[i]);
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_widget_hide (deviceD->colors[i]);
|
|
|
|
gtk_widget_hide (deviceD->brushes[i]);
|
1998-08-01 06:44:26 +08:00
|
|
|
gtk_widget_hide (deviceD->patterns[i]);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_widget_show (deviceD->frames[i]);
|
|
|
|
|
|
|
|
gtk_pixmap_set (GTK_PIXMAP (deviceD->tools[i]),
|
|
|
|
create_tool_pixmap (deviceD->table,
|
|
|
|
device_info->tool),
|
|
|
|
NULL);
|
1998-08-13 23:25:41 +08:00
|
|
|
|
1998-06-22 04:17:21 +08:00
|
|
|
gtk_widget_draw (deviceD->tools[i], NULL);
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_widget_show (deviceD->tools[i]);
|
1998-08-13 23:25:41 +08:00
|
|
|
gtk_widget_show (deviceD->eventboxes[i]);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
1998-08-13 23:25:41 +08:00
|
|
|
gtk_tooltips_set_tip(tool_tips,deviceD->eventboxes[i],
|
|
|
|
tool_info[(int) device_info->tool].tool_desc,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if(!device_info->is_init)
|
|
|
|
return; /* None of the entries have been set */
|
|
|
|
|
1998-08-01 06:44:26 +08:00
|
|
|
for (j=0;j<CELL_SIZE*3;j+=3)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
|
|
|
buffer[j] = device_info->foreground[0];
|
|
|
|
buffer[j+1] = device_info->foreground[1];
|
|
|
|
buffer[j+2] = device_info->foreground[2];
|
|
|
|
}
|
|
|
|
|
1998-08-01 06:44:26 +08:00
|
|
|
for (j=0;j<CELL_SIZE;j++)
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW(deviceD->colors[i]), buffer,
|
1998-08-01 06:44:26 +08:00
|
|
|
0, j, CELL_SIZE);
|
1998-06-06 12:06:56 +08:00
|
|
|
gtk_widget_draw (deviceD->colors[i], NULL);
|
|
|
|
gtk_widget_show (deviceD->colors[i]);
|
|
|
|
|
1998-08-13 23:25:41 +08:00
|
|
|
/* Set the tip to be the RGB value */
|
|
|
|
sprintf(ttbuf,"[%3d,%3d,%3d]",
|
|
|
|
device_info->foreground[0],
|
|
|
|
device_info->foreground[1],
|
|
|
|
device_info->foreground[2]);
|
|
|
|
|
1999-08-31 04:14:49 +08:00
|
|
|
gtk_tooltips_set_tip(tool_tips, deviceD->colors[i], ttbuf, NULL);
|
1998-08-13 23:25:41 +08:00
|
|
|
|
1999-08-31 04:14:49 +08:00
|
|
|
if (device_info->brush)
|
|
|
|
{
|
1999-09-01 08:12:33 +08:00
|
|
|
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (deviceD->brushes[i]),
|
|
|
|
device_info->brush);
|
1999-08-31 04:14:49 +08:00
|
|
|
gtk_widget_show (deviceD->brushes[i]);
|
|
|
|
}
|
|
|
|
if (device_info->pattern)
|
|
|
|
{
|
1999-09-01 08:12:33 +08:00
|
|
|
gimp_context_preview_update (GIMP_CONTEXT_PREVIEW (deviceD->patterns[i]),
|
1999-08-31 04:14:49 +08:00
|
|
|
device_info->pattern);
|
|
|
|
gtk_widget_show (deviceD->patterns[i]);
|
|
|
|
}
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
}
|
1999-08-13 01:53:51 +08:00
|
|
|
|
|
|
|
if (show_indicators)
|
|
|
|
{
|
|
|
|
brush_area_update();
|
|
|
|
pattern_area_update();
|
|
|
|
}
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
1999-09-01 08:12:33 +08:00
|
|
|
|
1999-09-04 11:36:54 +08:00
|
|
|
|
|
|
|
/* dnd stuff */
|
|
|
|
static void
|
|
|
|
device_status_drag_color (GtkWidget *widget,
|
|
|
|
guchar *r,
|
|
|
|
guchar *g,
|
|
|
|
guchar *b,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
guint32 deviceid;
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info = NULL;
|
|
|
|
|
|
|
|
deviceid = GPOINTER_TO_UINT (data);
|
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (device_info->device == deviceid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device_info)
|
|
|
|
{
|
|
|
|
*r = device_info->foreground[0];
|
|
|
|
*g = device_info->foreground[1];
|
|
|
|
*b = device_info->foreground[2];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*r = *g = *b = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
device_status_drop_color (GtkWidget *widget,
|
|
|
|
guchar r,
|
|
|
|
guchar g,
|
|
|
|
guchar b,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
guint32 deviceid;
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info = NULL;
|
|
|
|
|
|
|
|
deviceid = GPOINTER_TO_UINT (data);
|
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (device_info->device == deviceid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
if (device_info && device_info->is_present)
|
|
|
|
{
|
|
|
|
if (device_info->device == current_device)
|
|
|
|
{
|
|
|
|
palette_set_foreground (r, g, b);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device_info->foreground[0] = r;
|
|
|
|
device_info->foreground[1] = g;
|
|
|
|
device_info->foreground[2] = b;
|
|
|
|
device_status_update (device_info->device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-05 18:45:07 +08:00
|
|
|
static void
|
|
|
|
device_status_drop_brush (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *src;
|
|
|
|
GimpBrush *brush;
|
|
|
|
guint32 deviceid;
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info = NULL;
|
|
|
|
|
|
|
|
src = gtk_drag_get_source_widget (context);
|
|
|
|
if (!GIMP_IS_CONTEXT_PREVIEW (src) || !GIMP_CONTEXT_PREVIEW (src)->data)
|
|
|
|
return;
|
|
|
|
brush = GIMP_BRUSH (GIMP_CONTEXT_PREVIEW (src)->data);
|
|
|
|
deviceid = GPOINTER_TO_UINT (data);
|
|
|
|
|
|
|
|
tmp_list = devices_info;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (device_info->device == deviceid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
if (device_info && device_info->is_present)
|
|
|
|
{
|
|
|
|
device_info->brush = brush;
|
|
|
|
if (device_info->device == current_device)
|
|
|
|
select_brush (device_info->brush);
|
|
|
|
else
|
|
|
|
device_status_update (device_info->device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
device_status_drop_pattern (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
guint time,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *src;
|
|
|
|
GPattern *pattern;
|
|
|
|
guint32 deviceid;
|
|
|
|
GList *tmp_list;
|
|
|
|
DeviceInfo *device_info = NULL;
|
|
|
|
|
|
|
|
src = gtk_drag_get_source_widget (context);
|
|
|
|
if (!GIMP_IS_CONTEXT_PREVIEW (src) || !GIMP_CONTEXT_PREVIEW (src)->data)
|
|
|
|
return;
|
|
|
|
pattern = (GPattern *)(GIMP_CONTEXT_PREVIEW (src)->data);
|
|
|
|
deviceid = GPOINTER_TO_UINT (data);
|
1999-09-04 11:36:54 +08:00
|
|
|
|
1999-09-05 18:45:07 +08:00
|
|
|
tmp_list = devices_info;
|
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
device_info = (DeviceInfo *)tmp_list->data;
|
|
|
|
|
|
|
|
if (device_info->device == deviceid)
|
|
|
|
break;
|
|
|
|
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
if (device_info && device_info->is_present)
|
|
|
|
{
|
|
|
|
device_info->pattern = pattern;
|
|
|
|
if (device_info->device == current_device)
|
|
|
|
select_pattern (device_info->pattern);
|
|
|
|
else
|
|
|
|
device_status_update (device_info->device);
|
|
|
|
}
|
|
|
|
}
|