Commit 84fed896 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added GdkDisplay member since there is no way fo figure the display a

2005-11-27  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdeviceinfo.[ch]: added GdkDisplay member since
	there is no way fo figure the display a GdkDevice exists on.
	Minor cleanups.

	* app/widgets/gimpdevices.[ch]: connect to the GdkDeviceManager
	and add input devices when displays are opened. Added API to get
	the GimpContainer of devices.

	* app/widgets/gimpdevicestatus.[ch]: don't just show the devices
	of the default display. Instead get the device container from the
	new API above and update the GUI when devices are added/removed.
	Cleaned up the whole file quite a bit.
parent ae78c0eb
2005-11-27 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdeviceinfo.[ch]: added GdkDisplay member since
there is no way fo figure the display a GdkDevice exists on.
Minor cleanups.
* app/widgets/gimpdevices.[ch]: connect to the GdkDeviceManager
and add input devices when displays are opened. Added API to get
the GimpContainer of devices.
* app/widgets/gimpdevicestatus.[ch]: don't just show the devices
of the default display. Instead get the device container from the
new API above and update the GUI when devices are added/removed.
Cleaned up the whole file quite a bit.
2005-11-27 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdeviceinfo.c (gimp_device_info_get_property):
......
......@@ -155,6 +155,7 @@ static void
gimp_device_info_init (GimpDeviceInfo *device_info)
{
device_info->device = NULL;
device_info->display = NULL;
device_info->mode = GDK_MODE_DISABLED;
device_info->num_axes = 0;
device_info->axes = NULL;
......@@ -237,8 +238,8 @@ gimp_device_info_set_property (GObject *object,
switch (property_id)
{
case PROP_MODE:
if (device_info->device)
gdk_device_set_mode (device_info->device, g_value_get_enum (value));
if (device)
gdk_device_set_mode (device, g_value_get_enum (value));
else
device_info->mode = g_value_get_enum (value);
break;
......@@ -423,29 +424,28 @@ GimpDeviceInfo *
gimp_device_info_new (Gimp *gimp,
const gchar *name)
{
GimpDeviceInfo *device_info;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (name != NULL, NULL);
device_info = g_object_new (GIMP_TYPE_DEVICE_INFO,
"name", name,
"gimp", gimp,
NULL);
return device_info;
return g_object_new (GIMP_TYPE_DEVICE_INFO,
"name", name,
"gimp", gimp,
NULL);
}
GimpDeviceInfo *
gimp_device_info_set_from_device (GimpDeviceInfo *device_info,
GdkDevice *device)
GdkDevice *device,
GdkDisplay *display)
{
g_return_val_if_fail (GIMP_IS_DEVICE_INFO (device_info), NULL);
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_object_set_data (G_OBJECT (device), GIMP_DEVICE_INFO_DATA_KEY, device_info);
device_info->device = device;
device_info->display = display;
device_info->mode = device->mode;
......@@ -481,7 +481,7 @@ gimp_device_info_changed_by_device (GdkDevice *device)
g_return_if_fail (GDK_IS_DEVICE (device));
device_info = g_object_get_data (G_OBJECT (device), GIMP_DEVICE_INFO_DATA_KEY);
device_info = gimp_device_info_get_by_device (device);
if (device_info)
gimp_device_info_changed (device_info);
......
......@@ -51,6 +51,7 @@ struct _GimpDeviceInfo
GimpContext parent_instance;
GdkDevice *device;
GdkDisplay *display;
/* either "device" or the options below are set */
......@@ -75,7 +76,8 @@ GimpDeviceInfo * gimp_device_info_new (Gimp *gimp,
const gchar *name);
GimpDeviceInfo * gimp_device_info_set_from_device (GimpDeviceInfo *device_info,
GdkDevice *device);
GdkDevice *device,
GdkDisplay *display);
void gimp_device_info_changed (GimpDeviceInfo *device_info);
GimpDeviceInfo * gimp_device_info_get_by_device (GdkDevice *device);
......
......@@ -57,6 +57,7 @@ typedef struct _GimpDeviceManager GimpDeviceManager;
struct _GimpDeviceManager
{
Gimp *gimp;
GimpContainer *device_info_list;
GdkDevice *current_device;
GimpDeviceChangeNotify change_notify;
......@@ -69,6 +70,13 @@ struct _GimpDeviceManager
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);
/* public functions */
......@@ -76,9 +84,11 @@ void
gimp_devices_init (Gimp *gimp,
GimpDeviceChangeNotify change_notify)
{
GdkDisplayManager *disp_manager = gdk_display_manager_get ();
GimpDeviceManager *manager;
GList *list;
GdkDisplay *display;
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);
......@@ -89,31 +99,44 @@ gimp_devices_init (Gimp *gimp,
GIMP_DEVICE_MANAGER_DATA_KEY, manager,
(GDestroyNotify) gimp_device_manager_free);
display = gdk_display_get_default ();
gdk_display = gdk_display_get_default ();
manager->gimp = gimp;
manager->device_info_list = gimp_list_new (GIMP_TYPE_DEVICE_INFO, FALSE);
manager->current_device = gdk_display_get_core_pointer (display);
manager->current_device = gdk_display_get_core_pointer (gdk_display);
manager->change_notify = change_notify;
/* create device info structures for present devices */
for (list = gdk_display_list_devices (display); list; list = list->next)
{
GdkDevice *device = list->data;
GimpDeviceInfo *device_info;
displays = gdk_display_manager_list_displays (disp_manager);
device_info = gimp_device_info_new (gimp, device->name);
gimp_container_add (manager->device_info_list, GIMP_OBJECT (device_info));
g_object_unref (device_info);
/* present displays in the order in which they were opened */
displays = g_slist_reverse (displays);
gimp_device_info_set_from_device (device_info, device);
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);
}
void
gimp_devices_exit (Gimp *gimp)
{
GimpDeviceManager *manager;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (gimp_device_manager_get (gimp) != NULL);
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);
g_object_set_data (G_OBJECT (gimp), GIMP_DEVICE_MANAGER_DATA_KEY, NULL);
}
......@@ -246,6 +269,20 @@ gimp_devices_clear (Gimp *gimp,
return success;
}
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;
}
GdkDevice *
gimp_devices_get_current (Gimp *gimp)
{
......@@ -374,3 +411,36 @@ gimp_device_manager_free (GimpDeviceManager *manager)
g_free (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;
GimpDeviceInfo *device_info;
device_info = gimp_device_info_new (manager->gimp, device->name);
gimp_device_info_set_from_device (device_info, device, gdk_display);
gimp_container_add (manager->device_info_list, GIMP_OBJECT (device_info));
g_object_unref (device_info);
}
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)
{
}
......@@ -23,23 +23,24 @@
typedef void (* GimpDeviceChangeNotify) (Gimp *gimp);
void gimp_devices_init (Gimp *gimp,
GimpDeviceChangeNotify change_notify);
void gimp_devices_exit (Gimp *gimp);
void gimp_devices_init (Gimp *gimp,
GimpDeviceChangeNotify callback);
void gimp_devices_exit (Gimp *gimp);
void gimp_devices_restore (Gimp *gimp);
void gimp_devices_save (Gimp *gimp,
gboolean always_save);
void gimp_devices_restore (Gimp *gimp);
void gimp_devices_save (Gimp *gimp,
gboolean always_save);
gboolean gimp_devices_clear (Gimp *gimp,
GError **error);
gboolean gimp_devices_clear (Gimp *gimp,
GError **error);
GdkDevice * gimp_devices_get_current (Gimp *gimp);
GimpContainer * gimp_devices_get_list (Gimp *gimp);
GdkDevice * gimp_devices_get_current (Gimp *gimp);
gboolean gimp_devices_check_change (Gimp *gimp,
GdkEvent *event);
void gimp_devices_select_device (Gimp *gimp,
GdkDevice *device);
gboolean gimp_devices_check_change (Gimp *gimp,
GdkEvent *event);
void gimp_devices_select_device (Gimp *gimp,
GdkDevice *device);
#endif /* __GIMP_DEVICES_H__ */
This diff is collapsed.
......@@ -39,18 +39,17 @@ typedef struct _GimpDeviceStatusClass GimpDeviceStatusClass;
struct _GimpDeviceStatus
{
GimpEditor parent_instance;
GimpEditor parent_instance;
Gimp *gimp;
GdkDevice *current_device;
Gimp *gimp;
GdkDevice *current_device;
gint num_devices;
GimpDeviceStatusEntry *entries;
GList *devices;
GtkWidget *table;
GtkWidget *vbox;
GtkWidget *save_button;
GtkWidget *edit_button;
GtkWidget *save_button;
GtkWidget *edit_button;
};
struct _GimpDeviceStatusClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment