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"
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
#include <errno.h>
|
2005-02-07 09:24:22 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2005-02-07 09:24:22 +08:00
|
|
|
#include <glib/gstdio.h>
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 02:49:44 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include "libgimpbase/gimpwin32-io.h"
|
|
|
|
#endif
|
|
|
|
|
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/gimpdatafactory.h"
|
|
|
|
#include "core/gimpgradient.h"
|
2002-05-24 10:53:20 +08:00
|
|
|
#include "core/gimplist.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimppattern.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#include "gimpdeviceinfo.h"
|
|
|
|
#include "gimpdevices.h"
|
2001-04-11 09:13:53 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
#define GIMP_DEVICE_MANAGER_DATA_KEY "gimp-device-manager"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
typedef struct _GimpDeviceManager GimpDeviceManager;
|
1998-08-01 06:44:26 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
struct _GimpDeviceManager
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
Gimp *gimp;
|
2002-05-24 10:53:20 +08:00
|
|
|
GimpContainer *device_info_list;
|
2010-02-16 20:00:46 +08:00
|
|
|
GimpDeviceInfo *current_device;
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceChangeNotify change_notify;
|
2004-07-22 00:11:31 +08:00
|
|
|
gboolean devicerc_deleted;
|
1998-06-06 12:06:56 +08:00
|
|
|
};
|
|
|
|
|
2001-01-08 05:07:14 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
/* local function prototypes */
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2003-11-14 20:38:01 +08:00
|
|
|
static GimpDeviceManager * gimp_device_manager_get (Gimp *gimp);
|
|
|
|
static void gimp_device_manager_free (GimpDeviceManager *manager);
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
static void gimp_devices_display_opened (GdkDisplayManager *disp_manager,
|
|
|
|
GdkDisplay *display,
|
|
|
|
GimpDeviceManager *manager);
|
|
|
|
static void gimp_devices_display_closed (GdkDisplay *display,
|
|
|
|
gboolean is_error,
|
|
|
|
GimpDeviceManager *manager);
|
|
|
|
|
2010-02-13 00:10:54 +08:00
|
|
|
static void gimp_devices_device_added (GdkDisplay *gdk_display,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpDeviceManager *manager);
|
|
|
|
static void gimp_devices_device_removed (GdkDisplay *gdk_display,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpDeviceManager *manager);
|
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
/* public functions */
|
2001-02-11 03:35:29 +08:00
|
|
|
|
2003-11-14 20:38:01 +08:00
|
|
|
void
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_devices_init (Gimp *gimp,
|
|
|
|
GimpDeviceChangeNotify change_notify)
|
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GdkDisplayManager *disp_manager = gdk_display_manager_get ();
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceManager *manager;
|
2005-11-28 01:20:40 +08:00
|
|
|
GSList *displays;
|
|
|
|
GSList *list;
|
|
|
|
GdkDisplay *gdk_display;
|
2001-12-02 05:02:34 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (gimp_device_manager_get (gimp) == NULL);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2007-05-23 00:18:32 +08:00
|
|
|
manager = g_slice_new0 (GimpDeviceManager);
|
2001-01-08 05:07:14 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
g_object_set_data_full (G_OBJECT (gimp),
|
|
|
|
GIMP_DEVICE_MANAGER_DATA_KEY, manager,
|
2003-11-14 20:38:01 +08:00
|
|
|
(GDestroyNotify) gimp_device_manager_free);
|
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
manager->gimp = gimp;
|
2004-05-24 18:49:34 +08:00
|
|
|
manager->device_info_list = gimp_list_new (GIMP_TYPE_DEVICE_INFO, FALSE);
|
2002-05-24 10:53:20 +08:00
|
|
|
manager->change_notify = change_notify;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2010-02-15 05:08:32 +08:00
|
|
|
gimp_list_set_sort_func (GIMP_LIST (manager->device_info_list),
|
|
|
|
(GCompareFunc) gimp_device_info_compare);
|
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
displays = gdk_display_manager_list_displays (disp_manager);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
/* present displays in the order in which they were opened */
|
|
|
|
displays = g_slist_reverse (displays);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
for (list = displays; list; list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
gimp_devices_display_opened (disp_manager, list->data, manager);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
g_slist_free (displays);
|
|
|
|
|
|
|
|
g_signal_connect (disp_manager, "display-opened",
|
|
|
|
G_CALLBACK (gimp_devices_display_opened),
|
|
|
|
manager);
|
2010-02-16 20:00:46 +08:00
|
|
|
|
|
|
|
gdk_display = gdk_display_get_default ();
|
|
|
|
|
|
|
|
manager->current_device =
|
|
|
|
gimp_device_info_get_by_device (gdk_display_get_core_pointer (gdk_display));
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
void
|
|
|
|
gimp_devices_exit (Gimp *gimp)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2005-11-28 01:20:40 +08:00
|
|
|
GimpDeviceManager *manager;
|
|
|
|
|
2001-11-18 00:32:34 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
manager = gimp_device_manager_get (gimp);
|
|
|
|
|
|
|
|
g_return_if_fail (manager != NULL);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (gdk_display_manager_get (),
|
|
|
|
gimp_devices_display_opened,
|
|
|
|
manager);
|
2001-11-18 00:32:34 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
g_object_set_data (G_OBJECT (gimp), GIMP_DEVICE_MANAGER_DATA_KEY, NULL);
|
1998-08-13 23:25:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_devices_restore (Gimp *gimp)
|
2002-05-24 10:53:20 +08:00
|
|
|
{
|
|
|
|
GimpDeviceManager *manager;
|
2002-05-27 22:04:21 +08:00
|
|
|
GimpContext *user_context;
|
2005-09-04 18:44:04 +08:00
|
|
|
GList *list;
|
2002-05-24 10:53:20 +08:00
|
|
|
gchar *filename;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
manager = gimp_device_manager_get (gimp);
|
|
|
|
|
|
|
|
g_return_if_fail (manager != NULL);
|
|
|
|
|
2005-09-04 18:44:04 +08:00
|
|
|
user_context = gimp_get_user_context (gimp);
|
|
|
|
|
|
|
|
for (list = GIMP_LIST (manager->device_info_list)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpDeviceInfo *device_info = list->data;
|
|
|
|
|
|
|
|
gimp_context_copy_properties (user_context, GIMP_CONTEXT (device_info),
|
|
|
|
GIMP_DEVICE_INFO_CONTEXT_MASK);
|
|
|
|
}
|
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
filename = gimp_personal_rc_file ("devicerc");
|
2002-05-24 10:53:20 +08:00
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_deserialize_file (GIMP_CONFIG (manager->device_info_list),
|
2004-07-04 04:27:28 +08:00
|
|
|
filename,
|
|
|
|
gimp,
|
|
|
|
&error))
|
2002-05-27 22:04:21 +08:00
|
|
|
{
|
2002-05-29 02:49:45 +08:00
|
|
|
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
2002-05-27 22:04:21 +08:00
|
|
|
|
2002-05-29 02:49:45 +08:00
|
|
|
g_error_free (error);
|
2002-05-29 00:41:56 +08:00
|
|
|
/* don't bail out here */
|
2002-05-27 22:04:21 +08:00
|
|
|
}
|
|
|
|
|
2002-05-24 10:53:20 +08:00
|
|
|
g_free (filename);
|
2002-05-27 22:04:21 +08:00
|
|
|
|
2002-06-08 04:23:33 +08:00
|
|
|
gimp_list_reverse (GIMP_LIST (manager->device_info_list));
|
2002-05-29 00:41:56 +08:00
|
|
|
|
2010-02-16 20:00:46 +08:00
|
|
|
gimp_context_copy_properties (GIMP_CONTEXT (manager->current_device),
|
|
|
|
user_context,
|
2004-07-04 04:27:28 +08:00
|
|
|
GIMP_DEVICE_INFO_CONTEXT_MASK);
|
2010-02-16 20:00:46 +08:00
|
|
|
gimp_context_set_parent (GIMP_CONTEXT (manager->current_device),
|
|
|
|
user_context);
|
2002-05-24 10:53:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-22 00:11:31 +08:00
|
|
|
gimp_devices_save (Gimp *gimp,
|
|
|
|
gboolean always_save)
|
2002-05-24 10:53:20 +08:00
|
|
|
{
|
|
|
|
GimpDeviceManager *manager;
|
|
|
|
gchar *filename;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
|
|
|
manager = gimp_device_manager_get (gimp);
|
|
|
|
|
|
|
|
g_return_if_fail (manager != NULL);
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
if (manager->devicerc_deleted && ! always_save)
|
|
|
|
return;
|
|
|
|
|
2002-05-29 00:41:56 +08:00
|
|
|
filename = gimp_personal_rc_file ("devicerc");
|
2002-05-24 10:53:20 +08:00
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager->device_info_list),
|
2004-07-04 04:27:28 +08:00
|
|
|
filename,
|
|
|
|
"GIMP devicerc",
|
|
|
|
"end of devicerc",
|
|
|
|
NULL,
|
|
|
|
&error))
|
2002-05-24 10:53:20 +08:00
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
|
2002-05-29 02:49:45 +08:00
|
|
|
g_error_free (error);
|
2002-05-24 10:53:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (filename);
|
2004-07-22 00:11:31 +08:00
|
|
|
|
|
|
|
manager->devicerc_deleted = FALSE;
|
2002-05-24 10:53:20 +08:00
|
|
|
}
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
gboolean
|
|
|
|
gimp_devices_clear (Gimp *gimp,
|
|
|
|
GError **error)
|
2003-10-26 22:01:33 +08:00
|
|
|
{
|
2004-07-22 00:11:31 +08:00
|
|
|
GimpDeviceManager *manager;
|
|
|
|
gchar *filename;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
|
|
|
|
manager = gimp_device_manager_get (gimp);
|
|
|
|
|
|
|
|
g_return_val_if_fail (manager != NULL, FALSE);
|
|
|
|
|
|
|
|
filename = gimp_personal_rc_file ("devicerc");
|
|
|
|
|
2005-02-07 09:24:22 +08:00
|
|
|
if (g_unlink (filename) != 0 && errno != ENOENT)
|
2004-07-22 00:11:31 +08:00
|
|
|
{
|
2008-11-12 18:56:06 +08:00
|
|
|
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
|
|
|
|
_("Deleting \"%s\" failed: %s"),
|
2004-07-22 00:11:31 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
manager->devicerc_deleted = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (filename);
|
2003-10-26 22:01:33 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
return success;
|
2003-10-26 22:01:33 +08:00
|
|
|
}
|
|
|
|
|
2005-11-28 01:20:40 +08:00
|
|
|
GimpContainer *
|
|
|
|
gimp_devices_get_list (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpDeviceManager *manager;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
|
|
|
manager = gimp_device_manager_get (gimp);
|
|
|
|
|
|
|
|
g_return_val_if_fail (manager != NULL, NULL);
|
|
|
|
|
|
|
|
return manager->device_info_list;
|
|
|
|
}
|
|
|
|
|
2010-02-16 20:00:46 +08:00
|
|
|
GimpDeviceInfo *
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_devices_get_current (Gimp *gimp)
|
|
|
|
{
|
|
|
|
GimpDeviceManager *manager;
|
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);
|
1998-08-01 06:44:26 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
manager = gimp_device_manager_get (gimp);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
g_return_val_if_fail (manager != NULL, NULL);
|
1998-08-01 06:44:26 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
return manager->current_device;
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
void
|
2010-02-16 20:00:46 +08:00
|
|
|
gimp_devices_select_device (Gimp *gimp,
|
|
|
|
GimpDeviceInfo *new_device_info)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceManager *manager;
|
|
|
|
GimpContext *user_context;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-02 05:02:34 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2010-02-16 20:00:46 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DEVICE_INFO (new_device_info));
|
2001-12-02 05:02:34 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
manager = gimp_device_manager_get (gimp);
|
|
|
|
|
|
|
|
g_return_if_fail (manager != NULL);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2010-02-16 20:00:46 +08:00
|
|
|
gimp_context_set_parent (GIMP_CONTEXT (manager->current_device), NULL);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2010-02-16 20:00:46 +08:00
|
|
|
manager->current_device = new_device_info;
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
user_context = gimp_get_user_context (gimp);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_context_copy_properties (GIMP_CONTEXT (new_device_info), user_context,
|
2004-07-04 04:27:28 +08:00
|
|
|
GIMP_DEVICE_INFO_CONTEXT_MASK);
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_context_set_parent (GIMP_CONTEXT (new_device_info), user_context);
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
if (manager->change_notify)
|
|
|
|
manager->change_notify (gimp);
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
gboolean
|
2001-12-08 01:39:51 +08:00
|
|
|
gimp_devices_check_change (Gimp *gimp,
|
|
|
|
GdkEvent *event)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
GimpDeviceManager *manager;
|
|
|
|
GdkDevice *device;
|
2010-02-16 20:00:46 +08:00
|
|
|
GimpDeviceInfo *device_info;
|
2004-07-11 11:01:05 +08:00
|
|
|
GtkWidget *source;
|
1998-06-06 12:06:56 +08:00
|
|
|
|
2001-12-02 05:02:34 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
manager = gimp_device_manager_get (gimp);
|
|
|
|
|
|
|
|
g_return_val_if_fail (manager != NULL, FALSE);
|
|
|
|
|
2004-07-11 11:01:05 +08:00
|
|
|
/* It is possible that the event was propagated from a widget that does not
|
|
|
|
want extension events and therefore always sends core pointer events.
|
|
|
|
This can cause a false switch to the core pointer device. */
|
|
|
|
|
|
|
|
source = gtk_get_event_widget (event);
|
|
|
|
|
|
|
|
if (source &&
|
|
|
|
gtk_widget_get_extension_events (source) == GDK_EXTENSION_EVENTS_NONE)
|
|
|
|
return FALSE;
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_MOTION_NOTIFY:
|
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
|
|
|
device = ((GdkEventMotion *) event)->device;
|
1998-06-06 12:06:56 +08:00
|
|
|
break;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
2001-11-09 03:14:51 +08:00
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
case GDK_3BUTTON_PRESS:
|
1998-06-06 12:06:56 +08:00
|
|
|
case GDK_BUTTON_RELEASE:
|
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
|
|
|
device = ((GdkEventButton *) event)->device;
|
1998-06-06 12:06:56 +08:00
|
|
|
break;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
|
|
|
case GDK_PROXIMITY_IN:
|
1998-06-06 12:06:56 +08:00
|
|
|
case GDK_PROXIMITY_OUT:
|
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
|
|
|
device = ((GdkEventProximity *) event)->device;
|
1998-06-06 12:06:56 +08:00
|
|
|
break;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
|
|
|
case GDK_SCROLL:
|
|
|
|
device = ((GdkEventScroll *) event)->device;
|
|
|
|
break;
|
|
|
|
|
1998-06-06 12:06:56 +08:00
|
|
|
default:
|
2010-02-16 20:00:46 +08:00
|
|
|
device = manager->current_device->device;
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2010-02-16 20:00:46 +08:00
|
|
|
device_info = gimp_device_info_get_by_device (device);
|
|
|
|
|
|
|
|
if (device_info != manager->current_device)
|
1998-06-06 12:06:56 +08:00
|
|
|
{
|
2010-02-16 20:00:46 +08:00
|
|
|
gimp_devices_select_device (gimp, device_info);
|
1998-06-06 12:06:56 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
return FALSE;
|
1998-06-06 12:06:56 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
/* private functions */
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-12-08 01:39:51 +08:00
|
|
|
static GimpDeviceManager *
|
|
|
|
gimp_device_manager_get (Gimp *gimp)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-12-08 01:39:51 +08:00
|
|
|
return g_object_get_data (G_OBJECT (gimp), GIMP_DEVICE_MANAGER_DATA_KEY);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
2003-11-14 20:38:01 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_device_manager_free (GimpDeviceManager *manager)
|
|
|
|
{
|
|
|
|
if (manager->device_info_list)
|
|
|
|
g_object_unref (manager->device_info_list);
|
|
|
|
|
2007-05-23 00:18:32 +08:00
|
|
|
g_slice_free (GimpDeviceManager, manager);
|
2003-11-14 20:38:01 +08:00
|
|
|
}
|
2005-11-28 01:20:40 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_devices_display_opened (GdkDisplayManager *disp_manager,
|
|
|
|
GdkDisplay *gdk_display,
|
|
|
|
GimpDeviceManager *manager)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
/* create device info structures for present devices */
|
|
|
|
for (list = gdk_display_list_devices (gdk_display); list; list = list->next)
|
|
|
|
{
|
2010-02-13 00:10:54 +08:00
|
|
|
GdkDevice *device = list->data;
|
2005-11-28 01:20:40 +08:00
|
|
|
|
2010-02-13 00:10:54 +08:00
|
|
|
gimp_devices_device_added (gdk_display, device, manager);
|
2005-11-28 01:20:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_connect (gdk_display, "closed",
|
|
|
|
G_CALLBACK (gimp_devices_display_closed),
|
|
|
|
manager);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_devices_display_closed (GdkDisplay *gdk_display,
|
|
|
|
gboolean is_error,
|
|
|
|
GimpDeviceManager *manager)
|
2010-02-13 00:10:54 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
for (list = gdk_display_list_devices (gdk_display); list; list = list->next)
|
|
|
|
{
|
|
|
|
GdkDevice *device = list->data;
|
|
|
|
|
|
|
|
gimp_devices_device_removed (gdk_display, device, manager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_devices_device_added (GdkDisplay *gdk_display,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpDeviceManager *manager)
|
|
|
|
{
|
|
|
|
GimpDeviceInfo *device_info;
|
|
|
|
|
|
|
|
device_info =
|
|
|
|
GIMP_DEVICE_INFO (gimp_container_get_child_by_name (manager->device_info_list,
|
|
|
|
device->name));
|
|
|
|
|
|
|
|
if (device_info)
|
|
|
|
{
|
|
|
|
gimp_device_info_set_device (device_info, device, gdk_display);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device_info = gimp_device_info_new (manager->gimp, device, gdk_display);
|
|
|
|
|
|
|
|
gimp_container_add (manager->device_info_list, GIMP_OBJECT (device_info));
|
|
|
|
g_object_unref (device_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_devices_device_removed (GdkDisplay *gdk_display,
|
|
|
|
GdkDevice *device,
|
|
|
|
GimpDeviceManager *manager)
|
2005-11-28 01:20:40 +08:00
|
|
|
{
|
2010-02-16 03:00:26 +08:00
|
|
|
GimpDeviceInfo *device_info;
|
|
|
|
|
|
|
|
device_info =
|
|
|
|
GIMP_DEVICE_INFO (gimp_container_get_child_by_name (manager->device_info_list,
|
|
|
|
device->name));
|
|
|
|
|
|
|
|
if (device_info)
|
|
|
|
{
|
|
|
|
gimp_device_info_set_device (device_info, NULL, NULL);
|
2010-02-16 20:00:46 +08:00
|
|
|
|
|
|
|
if (device_info == manager->current_device)
|
|
|
|
{
|
|
|
|
device = gdk_display_get_core_pointer (gdk_display);
|
|
|
|
device_info = gimp_device_info_get_by_device (device);
|
|
|
|
|
|
|
|
gimp_devices_select_device (manager->gimp, device_info);
|
|
|
|
}
|
2010-02-16 03:00:26 +08:00
|
|
|
}
|
2005-11-28 01:20:40 +08:00
|
|
|
}
|