[gimp] app: device manager refactoring part one
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: device manager refactoring part one
- Date: Mon, 28 Feb 2011 11:58:30 +0000 (UTC)
commit 21a0e55005d63c42189534a1181e731c3fc9cb8f
Author: Michael Natterer <mitch gimp org>
Date: Mon Feb 28 12:57:15 2011 +0100
app: device manager refactoring part one
Add a GimpDeviceManager object and take over most code from
gimpdevices.c, but leave all functions in gimpdevices.c there as
wrappers in order to make rebasing in gtk3-port simpler.
app/gui/gui.c | 20 ++-
app/widgets/Makefile.am | 2 +
app/widgets/gimpdevicemanager.c | 362 +++++++++++++++++++++++++++++++++++++++
app/widgets/gimpdevicemanager.h | 63 +++++++
app/widgets/gimpdevices.c | 214 ++---------------------
app/widgets/gimpdevices.h | 36 ++---
app/widgets/widgets-types.h | 1 +
7 files changed, 480 insertions(+), 218 deletions(-)
---
diff --git a/app/gui/gui.c b/app/gui/gui.c
index 323aca5..5f45d26 100644
--- a/app/gui/gui.c
+++ b/app/gui/gui.c
@@ -120,7 +120,9 @@ static void gui_single_window_mode_notify (GimpGuiConfig *gui_config,
static void gui_tearoff_menus_notify (GimpGuiConfig *gui_config,
GParamSpec *pspec,
GtkUIManager *manager);
-static void gui_device_change_notify (Gimp *gimp);
+static void gui_device_change_notify (GimpDeviceManager *manager,
+ const GParamSpec *pspec,
+ Gimp *gimp);
static void gui_global_buffer_changed (Gimp *gimp);
@@ -412,7 +414,12 @@ gui_restore_callback (Gimp *gimp,
G_CALLBACK (gui_global_buffer_changed),
NULL);
- gimp_devices_init (gimp, gui_device_change_notify);
+ gimp_devices_init (gimp);
+
+ g_signal_connect (gimp_devices_get_list (gimp), "notify::current-device",
+ G_CALLBACK (gui_device_change_notify),
+ gimp);
+
gimp_controllers_init (gimp);
session_init (gimp);
@@ -628,6 +635,11 @@ gui_exit_after_callback (Gimp *gimp,
gimp_render_exit (gimp);
gimp_controllers_exit (gimp);
+
+ g_signal_handlers_disconnect_by_func (gimp_devices_get_list (gimp),
+ gui_device_change_notify,
+ gimp);
+
gimp_devices_exit (gimp);
dialogs_exit (gimp);
@@ -688,7 +700,9 @@ gui_tearoff_menus_notify (GimpGuiConfig *gui_config,
}
static void
-gui_device_change_notify (Gimp *gimp)
+gui_device_change_notify (GimpDeviceManager *manager,
+ const GParamSpec *pspec,
+ Gimp *gimp)
{
GimpSessionInfo *session_info;
diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am
index 408bb67..9960922 100644
--- a/app/widgets/Makefile.am
+++ b/app/widgets/Makefile.am
@@ -126,6 +126,8 @@ libappwidgets_a_sources = \
gimpdeviceinfo-coords.h \
gimpdeviceinfoeditor.c \
gimpdeviceinfoeditor.h \
+ gimpdevicemanager.c \
+ gimpdevicemanager.h \
gimpdevices.c \
gimpdevices.h \
gimpdevicestatus.c \
diff --git a/app/widgets/gimpdevicemanager.c b/app/widgets/gimpdevicemanager.c
new file mode 100644
index 0000000..6c7a91c
--- /dev/null
+++ b/app/widgets/gimpdevicemanager.c
@@ -0,0 +1,362 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpdevicemanager.c
+ * Copyright (C) 2011 Michael Natterer
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#undef GSEAL_ENABLE
+
+#include <gtk/gtk.h>
+
+#include "widgets-types.h"
+
+#include "core/gimp.h"
+#include "core/gimpmarshal.h"
+
+#include "gimpdeviceinfo.h"
+#include "gimpdevicemanager.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_GIMP,
+ PROP_CURRENT_DEVICE
+};
+
+
+typedef struct _GimpDeviceManagerPrivate GimpDeviceManagerPrivate;
+
+struct _GimpDeviceManagerPrivate
+{
+ Gimp *gimp;
+ GimpDeviceInfo *current_device;
+};
+
+#define GET_PRIVATE(manager) \
+ G_TYPE_INSTANCE_GET_PRIVATE (manager, \
+ GIMP_TYPE_DEVICE_MANAGER, \
+ GimpDeviceManagerPrivate)
+
+
+static void gimp_device_manager_constructed (GObject *object);
+static void gimp_device_manager_dispose (GObject *object);
+static void gimp_device_manager_finalize (GObject *object);
+static void gimp_device_manager_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_device_manager_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gimp_device_manager_display_opened (GdkDisplayManager *disp_manager,
+ GdkDisplay *display,
+ GimpDeviceManager *manager);
+static void gimp_device_manager_display_closed (GdkDisplay *display,
+ gboolean is_error,
+ GimpDeviceManager *manager);
+
+static void gimp_device_manager_device_added (GdkDisplay *gdk_display,
+ GdkDevice *device,
+ GimpDeviceManager *manager);
+static void gimp_device_manager_device_removed (GdkDisplay *gdk_display,
+ GdkDevice *device,
+ GimpDeviceManager *manager);
+
+
+G_DEFINE_TYPE (GimpDeviceManager, gimp_device_manager, GIMP_TYPE_LIST)
+
+#define parent_class gimp_device_manager_parent_class
+
+
+static void
+gimp_device_manager_class_init (GimpDeviceManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = gimp_device_manager_constructed;
+ object_class->dispose = gimp_device_manager_dispose;
+ object_class->finalize = gimp_device_manager_finalize;
+ object_class->set_property = gimp_device_manager_set_property;
+ object_class->get_property = gimp_device_manager_get_property;
+
+ g_object_class_install_property (object_class, PROP_GIMP,
+ g_param_spec_object ("gimp",
+ NULL, NULL,
+ GIMP_TYPE_GIMP,
+ GIMP_PARAM_STATIC_STRINGS |
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class, PROP_CURRENT_DEVICE,
+ g_param_spec_object ("current-device",
+ NULL, NULL,
+ GIMP_TYPE_DEVICE_INFO,
+ GIMP_PARAM_STATIC_STRINGS |
+ G_PARAM_READABLE));
+
+ g_type_class_add_private (object_class, sizeof (GimpDeviceManagerPrivate));
+}
+
+static void
+gimp_device_manager_init (GimpDeviceManager *manager)
+{
+ gimp_list_set_sort_func (GIMP_LIST (manager),
+ (GCompareFunc) gimp_device_info_compare);
+}
+
+static void
+gimp_device_manager_constructed (GObject *object)
+{
+ GimpDeviceManager *manager = GIMP_DEVICE_MANAGER (object);
+ GimpDeviceManagerPrivate *private = GET_PRIVATE (object);
+ GdkDisplayManager *disp_manager;
+ GSList *displays;
+ GSList *list;
+ GdkDisplay *display;
+
+ if (G_OBJECT_CLASS (parent_class)->constructed)
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ g_assert (GIMP_IS_GIMP (private->gimp));
+
+ disp_manager = gdk_display_manager_get ();
+
+ displays = gdk_display_manager_list_displays (disp_manager);
+
+ /* present displays in the order in which they were opened */
+ displays = g_slist_reverse (displays);
+
+ for (list = displays; list; list = g_slist_next (list))
+ {
+ gimp_device_manager_display_opened (disp_manager, list->data, manager);
+ }
+
+ g_slist_free (displays);
+
+ g_signal_connect (disp_manager, "display-opened",
+ G_CALLBACK (gimp_device_manager_display_opened),
+ manager);
+
+ display = gdk_display_get_default ();
+
+ private->current_device =
+ gimp_device_info_get_by_device (gdk_display_get_core_pointer (display));
+}
+
+static void
+gimp_device_manager_dispose (GObject *object)
+{
+ g_signal_handlers_disconnect_by_func (gdk_display_manager_get (),
+ gimp_device_manager_display_opened,
+ object);
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+gimp_device_manager_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gimp_device_manager_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDeviceManagerPrivate *private = GET_PRIVATE (object);
+
+ switch (property_id)
+ {
+ case PROP_GIMP:
+ private->gimp = g_value_get_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_device_manager_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDeviceManagerPrivate *private = GET_PRIVATE (object);
+
+ switch (property_id)
+ {
+ case PROP_GIMP:
+ g_value_set_object (value, private->gimp);
+ break;
+
+ case PROP_CURRENT_DEVICE:
+ g_value_set_object (value, private->current_device);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+/* public functions */
+
+GimpDeviceManager *
+gimp_device_manager_new (Gimp *gimp)
+{
+ g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+
+ return g_object_new (GIMP_TYPE_DEVICE_MANAGER,
+ "gimp", gimp,
+ "children-type", GIMP_TYPE_DEVICE_INFO,
+ "policy", GIMP_CONTAINER_POLICY_STRONG,
+ "unique-names", FALSE,
+ NULL);
+}
+
+GimpDeviceInfo *
+gimp_device_manager_get_current_device (GimpDeviceManager *manager)
+{
+ g_return_val_if_fail (GIMP_IS_DEVICE_MANAGER (manager), NULL);
+
+ return GET_PRIVATE (manager)->current_device;
+}
+
+void
+gimp_device_manager_set_current_device (GimpDeviceManager *manager,
+ GimpDeviceInfo *info)
+{
+ GimpDeviceManagerPrivate *private;
+ GimpContext *user_context;
+
+ g_return_if_fail (GIMP_IS_DEVICE_MANAGER (manager));
+ g_return_if_fail (GIMP_IS_DEVICE_INFO (info));
+
+ private = GET_PRIVATE (manager);
+
+ gimp_context_set_parent (GIMP_CONTEXT (private->current_device), NULL);
+
+ private->current_device = info;
+
+ user_context = gimp_get_user_context (private->gimp);
+
+ gimp_context_copy_properties (GIMP_CONTEXT (info), user_context,
+ GIMP_DEVICE_INFO_CONTEXT_MASK);
+ gimp_context_set_parent (GIMP_CONTEXT (info), user_context);
+
+ g_object_notify (G_OBJECT (manager), "current-device");
+}
+
+
+/* private functions */
+
+
+static void
+gimp_device_manager_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)
+ {
+ GdkDevice *device = list->data;
+
+ gimp_device_manager_device_added (gdk_display, device, manager);
+ }
+
+ g_signal_connect (gdk_display, "closed",
+ G_CALLBACK (gimp_device_manager_display_closed),
+ manager);
+}
+
+static void
+gimp_device_manager_display_closed (GdkDisplay *gdk_display,
+ gboolean is_error,
+ GimpDeviceManager *manager)
+{
+ GList *list;
+
+ for (list = gdk_display_list_devices (gdk_display); list; list = list->next)
+ {
+ GdkDevice *device = list->data;
+
+ gimp_device_manager_device_removed (gdk_display, device, manager);
+ }
+}
+
+static void
+gimp_device_manager_device_added (GdkDisplay *gdk_display,
+ GdkDevice *device,
+ GimpDeviceManager *manager)
+{
+ GimpDeviceManagerPrivate *private = GET_PRIVATE (manager);
+ GimpDeviceInfo *device_info;
+
+ device_info =
+ GIMP_DEVICE_INFO (gimp_container_get_child_by_name (GIMP_CONTAINER (manager),
+ device->name));
+
+ if (device_info)
+ {
+ gimp_device_info_set_device (device_info, device, gdk_display);
+ }
+ else
+ {
+ device_info = gimp_device_info_new (private->gimp, device, gdk_display);
+
+ gimp_container_add (GIMP_CONTAINER (manager), GIMP_OBJECT (device_info));
+ g_object_unref (device_info);
+ }
+}
+
+static void
+gimp_device_manager_device_removed (GdkDisplay *gdk_display,
+ GdkDevice *device,
+ GimpDeviceManager *manager)
+{
+ GimpDeviceManagerPrivate *private = GET_PRIVATE (manager);
+ GimpDeviceInfo *device_info;
+
+ device_info =
+ GIMP_DEVICE_INFO (gimp_container_get_child_by_name (GIMP_CONTAINER (manager),
+ device->name));
+
+ if (device_info)
+ {
+ gimp_device_info_set_device (device_info, NULL, NULL);
+
+ if (device_info == private->current_device)
+ {
+ device = gdk_display_get_core_pointer (gdk_display);
+ device_info = gimp_device_info_get_by_device (device);
+
+ gimp_device_manager_set_current_device (manager, device_info);
+ }
+ }
+}
diff --git a/app/widgets/gimpdevicemanager.h b/app/widgets/gimpdevicemanager.h
new file mode 100644
index 0000000..8bd723a
--- /dev/null
+++ b/app/widgets/gimpdevicemanager.h
@@ -0,0 +1,63 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpdevicemanager.h
+ * Copyright (C) 2011 Michael Natterer
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_DEVICE_MANAGER_H__
+#define __GIMP_DEVICE_MANAGER_H__
+
+
+#include "core/gimplist.h"
+
+
+G_BEGIN_DECLS
+
+
+#define GIMP_TYPE_DEVICE_MANAGER (gimp_device_manager_get_type ())
+#define GIMP_DEVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DEVICE_MANAGER, GimpDeviceManager))
+#define GIMP_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DEVICE_MANAGER, GimpDeviceManagerClass))
+#define GIMP_IS_DEVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DEVICE_MANAGER))
+#define GIMP_IS_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DEVICE_MANAGER))
+#define GIMP_DEVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DEVICE_MANAGER, GimpDeviceManagerClass))
+
+
+typedef struct _GimpDeviceManagerClass GimpDeviceManagerClass;
+
+struct _GimpDeviceManager
+{
+ GimpList parent_instance;
+};
+
+struct _GimpDeviceManagerClass
+{
+ GimpListClass parent_class;
+};
+
+
+GType gimp_device_manager_get_type (void) G_GNUC_CONST;
+
+GimpDeviceManager * gimp_device_manager_new (Gimp *gimp);
+
+GimpDeviceInfo * gimp_device_manager_get_current_device (GimpDeviceManager *manager);
+void gimp_device_manager_set_current_device (GimpDeviceManager *manager,
+ GimpDeviceInfo *info);
+
+
+G_END_DECLS
+
+#endif /* __GIMP_DEVICE_MANAGER_H__ */
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index b09a9ac..0f9fc95 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -46,6 +46,7 @@
#include "core/gimptoolinfo.h"
#include "gimpdeviceinfo.h"
+#include "gimpdevicemanager.h"
#include "gimpdevices.h"
#include "gimp-intl.h"
@@ -54,89 +55,29 @@
#define GIMP_DEVICE_MANAGER_DATA_KEY "gimp-device-manager"
-typedef struct _GimpDeviceManager GimpDeviceManager;
-
-struct _GimpDeviceManager
-{
- Gimp *gimp;
- GimpContainer *device_info_list;
- GimpDeviceInfo *current_device;
- GimpDeviceChangeNotify change_notify;
- gboolean devicerc_deleted;
-};
-
-
/* local function prototypes */
-static GimpDeviceManager * gimp_device_manager_get (Gimp *gimp);
-static void gimp_device_manager_free (GimpDeviceManager *manager);
-
-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);
+static GimpDeviceManager * gimp_device_manager_get (Gimp *gimp);
-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);
-static void gimp_devices_select_device (GimpDeviceManager *manager,
- GimpDeviceInfo *info);
+static gboolean devicerc_deleted = FALSE;
/* public functions */
void
-gimp_devices_init (Gimp *gimp,
- GimpDeviceChangeNotify change_notify)
+gimp_devices_init (Gimp *gimp)
{
- GdkDisplayManager *disp_manager = gdk_display_manager_get ();
GimpDeviceManager *manager;
- GSList *displays;
- GSList *list;
- GdkDisplay *gdk_display;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimp_device_manager_get (gimp) == NULL);
- manager = g_slice_new0 (GimpDeviceManager);
+ manager = gimp_device_manager_new (gimp);
g_object_set_data_full (G_OBJECT (gimp),
GIMP_DEVICE_MANAGER_DATA_KEY, manager,
- (GDestroyNotify) gimp_device_manager_free);
-
- manager->gimp = gimp;
- manager->device_info_list = gimp_list_new (GIMP_TYPE_DEVICE_INFO, FALSE);
- manager->change_notify = change_notify;
-
- gimp_list_set_sort_func (GIMP_LIST (manager->device_info_list),
- (GCompareFunc) gimp_device_info_compare);
-
- displays = gdk_display_manager_list_displays (disp_manager);
-
- /* present displays in the order in which they were opened */
- displays = g_slist_reverse (displays);
-
- for (list = displays; list; list = g_slist_next (list))
- {
- gimp_devices_display_opened (disp_manager, list->data, manager);
- }
-
- g_slist_free (displays);
-
- g_signal_connect (disp_manager, "display-opened",
- G_CALLBACK (gimp_devices_display_opened),
- manager);
-
- gdk_display = gdk_display_get_default ();
-
- manager->current_device =
- gimp_device_info_get_by_device (gdk_display_get_core_pointer (gdk_display));
+ (GDestroyNotify) g_object_unref);
}
void
@@ -150,10 +91,6 @@ gimp_devices_exit (Gimp *gimp)
g_return_if_fail (manager != NULL);
- g_signal_handlers_disconnect_by_func (gdk_display_manager_get (),
- gimp_devices_display_opened,
- manager);
-
g_object_set_data (G_OBJECT (gimp), GIMP_DEVICE_MANAGER_DATA_KEY, NULL);
}
@@ -174,7 +111,7 @@ gimp_devices_restore (Gimp *gimp)
user_context = gimp_get_user_context (gimp);
- for (list = GIMP_LIST (manager->device_info_list)->list;
+ for (list = GIMP_LIST (manager)->list;
list;
list = g_list_next (list))
{
@@ -189,7 +126,7 @@ gimp_devices_restore (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
- if (! gimp_config_deserialize_file (GIMP_CONFIG (manager->device_info_list),
+ if (! gimp_config_deserialize_file (GIMP_CONFIG (manager),
filename,
gimp,
&error))
@@ -203,10 +140,10 @@ gimp_devices_restore (Gimp *gimp)
g_free (filename);
- gimp_context_copy_properties (GIMP_CONTEXT (manager->current_device),
+ gimp_context_copy_properties (GIMP_CONTEXT (gimp_device_manager_get_current_device (manager)),
user_context,
GIMP_DEVICE_INFO_CONTEXT_MASK);
- gimp_context_set_parent (GIMP_CONTEXT (manager->current_device),
+ gimp_context_set_parent (GIMP_CONTEXT (gimp_device_manager_get_current_device (manager)),
user_context);
}
@@ -224,7 +161,7 @@ gimp_devices_save (Gimp *gimp,
g_return_if_fail (manager != NULL);
- if (manager->devicerc_deleted && ! always_save)
+ if (devicerc_deleted && ! always_save)
return;
filename = gimp_personal_rc_file ("devicerc");
@@ -232,7 +169,7 @@ gimp_devices_save (Gimp *gimp,
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
- if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager->device_info_list),
+ if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager),
filename,
"GIMP devicerc",
"end of devicerc",
@@ -245,7 +182,7 @@ gimp_devices_save (Gimp *gimp,
g_free (filename);
- manager->devicerc_deleted = FALSE;
+ devicerc_deleted = FALSE;
}
gboolean
@@ -273,7 +210,7 @@ gimp_devices_clear (Gimp *gimp,
}
else
{
- manager->devicerc_deleted = TRUE;
+ devicerc_deleted = TRUE;
}
g_free (filename);
@@ -292,7 +229,7 @@ gimp_devices_get_list (Gimp *gimp)
g_return_val_if_fail (manager != NULL, NULL);
- return manager->device_info_list;
+ return GIMP_CONTAINER (manager);
}
GimpDeviceInfo *
@@ -306,7 +243,7 @@ gimp_devices_get_current (Gimp *gimp)
g_return_val_if_fail (manager != NULL, NULL);
- return manager->current_device;
+ return gimp_device_manager_get_current_device (manager);
}
void
@@ -386,15 +323,15 @@ gimp_devices_check_change (Gimp *gimp,
break;
default:
- device = manager->current_device->device;
+ device = gimp_device_manager_get_current_device (manager)->device;
break;
}
device_info = gimp_device_info_get_by_device (device);
- if (device_info != manager->current_device)
+ if (device_info != gimp_device_manager_get_current_device (manager))
{
- gimp_devices_select_device (manager, device_info);
+ gimp_device_manager_set_current_device (manager, device_info);
return TRUE;
}
@@ -409,116 +346,3 @@ gimp_device_manager_get (Gimp *gimp)
{
return g_object_get_data (G_OBJECT (gimp), GIMP_DEVICE_MANAGER_DATA_KEY);
}
-
-static void
-gimp_device_manager_free (GimpDeviceManager *manager)
-{
- if (manager->device_info_list)
- g_object_unref (manager->device_info_list);
-
- g_slice_free (GimpDeviceManager, manager);
-}
-
-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)
- {
- GdkDevice *device = list->data;
-
- gimp_devices_device_added (gdk_display, device, manager);
- }
-
- 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)
-{
- 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)
-{
- 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);
-
- 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, device_info);
- }
- }
-}
-
-static void
-gimp_devices_select_device (GimpDeviceManager *manager,
- GimpDeviceInfo *info)
-{
- GimpContext *user_context;
-
- gimp_context_set_parent (GIMP_CONTEXT (manager->current_device), NULL);
-
- manager->current_device = info;
-
- user_context = gimp_get_user_context (manager->gimp);
-
- gimp_context_copy_properties (GIMP_CONTEXT (info), user_context,
- GIMP_DEVICE_INFO_CONTEXT_MASK);
- gimp_context_set_parent (GIMP_CONTEXT (info), user_context);
-
- if (manager->change_notify)
- manager->change_notify (manager->gimp);
-}
diff --git a/app/widgets/gimpdevices.h b/app/widgets/gimpdevices.h
index b07b8c6..cffa71d 100644
--- a/app/widgets/gimpdevices.h
+++ b/app/widgets/gimpdevices.h
@@ -19,31 +19,27 @@
#define __GIMP_DEVICES_H__
-typedef void (* GimpDeviceChangeNotify) (Gimp *gimp);
+void gimp_devices_init (Gimp *gimp);
+void gimp_devices_exit (Gimp *gimp);
+void gimp_devices_restore (Gimp *gimp);
+void gimp_devices_save (Gimp *gimp,
+ gboolean always_save);
-void gimp_devices_init (Gimp *gimp,
- GimpDeviceChangeNotify callback);
-void gimp_devices_exit (Gimp *gimp);
+gboolean gimp_devices_clear (Gimp *gimp,
+ GError **error);
-void gimp_devices_restore (Gimp *gimp);
-void gimp_devices_save (Gimp *gimp,
- gboolean always_save);
+GimpContainer * gimp_devices_get_list (Gimp *gimp);
+GimpDeviceInfo * gimp_devices_get_current (Gimp *gimp);
-gboolean gimp_devices_clear (Gimp *gimp,
- GError **error);
+void gimp_devices_add_widget (Gimp *gimp,
+ GtkWidget *widget);
-GimpContainer * gimp_devices_get_list (Gimp *gimp);
-GimpDeviceInfo * gimp_devices_get_current (Gimp *gimp);
-
-void gimp_devices_add_widget (Gimp *gimp,
- GtkWidget *widget);
-
-gboolean gimp_devices_check_callback (GtkWidget *widget,
- GdkEvent *event,
- Gimp *gimp);
-gboolean gimp_devices_check_change (Gimp *gimp,
- GdkEvent *event);
+gboolean gimp_devices_check_callback (GtkWidget *widget,
+ GdkEvent *event,
+ Gimp *gimp);
+gboolean gimp_devices_check_change (Gimp *gimp,
+ GdkEvent *event);
#endif /* __GIMP_DEVICES_H__ */
diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h
index fcd8af6..1336512 100644
--- a/app/widgets/widgets-types.h
+++ b/app/widgets/widgets-types.h
@@ -28,6 +28,7 @@
/* input devices & controllers */
+typedef struct _GimpDeviceManager GimpDeviceManager;
typedef struct _GimpDeviceInfo GimpDeviceInfo;
typedef struct _GimpControllerInfo GimpControllerInfo;
typedef struct _GimpControllerKeyboard GimpControllerKeyboard;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]