app: add gimp_devices_check_callback() with the signature of an event callback

and use it in the toolbox. Will soon be used in more places.
This commit is contained in:
Michael Natterer 2010-12-06 10:23:15 +01:00
parent e50f6aaf0f
commit 0ba0b637f2
3 changed files with 29 additions and 26 deletions

View File

@ -311,6 +311,19 @@ gimp_devices_get_current (Gimp *gimp)
return manager->current_device;
}
gboolean
gimp_devices_check_callback (GtkWidget *widget,
GdkEvent *event,
Gimp *gimp)
{
g_return_val_if_fail (event != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
gimp_devices_check_change (gimp, event);
return FALSE;
}
gboolean
gimp_devices_check_change (Gimp *gimp,
GdkEvent *event)

View File

@ -22,22 +22,25 @@
typedef void (* GimpDeviceChangeNotify) (Gimp *gimp);
void gimp_devices_init (Gimp *gimp,
GimpDeviceChangeNotify callback);
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);
GimpContainer * gimp_devices_get_list (Gimp *gimp);
GimpDeviceInfo * gimp_devices_get_current (Gimp *gimp);
GimpContainer * gimp_devices_get_list (Gimp *gimp);
GimpDeviceInfo * gimp_devices_get_current (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__ */

View File

@ -144,9 +144,6 @@ static void toolbox_area_notify (GimpGuiConfig *config,
static void toolbox_wilber_notify (GimpGuiConfig *config,
GParamSpec *pspec,
GtkWidget *wilber);
static gboolean toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
Gimp *gimp);
static void toolbox_paste_received (GtkClipboard *clipboard,
const gchar *text,
gpointer data);
@ -309,7 +306,7 @@ gimp_toolbox_constructed (GObject *object)
if (! list) /* all devices have cursor */
{
g_signal_connect (toolbox, "motion-notify-event",
G_CALLBACK (toolbox_check_device),
G_CALLBACK (gimp_devices_check_callback),
toolbox->p->context->gimp);
gtk_widget_add_events (GTK_WIDGET (toolbox), GDK_POINTER_MOTION_MASK);
@ -839,16 +836,6 @@ toolbox_wilber_notify (GimpGuiConfig *config,
g_object_set (wilber, "visible", visible, NULL);
}
static gboolean
toolbox_check_device (GtkWidget *widget,
GdkEvent *event,
Gimp *gimp)
{
gimp_devices_check_change (gimp, event);
return FALSE;
}
static void
toolbox_paste_received (GtkClipboard *clipboard,
const gchar *text,