added a GdkDisplay parameter and added the convenience function

2003-11-01  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpcursor.[ch] (gimp_cursor_new): added a
	GdkDisplay parameter and added the convenience function
	gimp_cursor_set().

	* app/display/gimpdisplayshell-cursor.c
	* app/tools/gimpcurvestool.c
	* app/widgets/gimpdialogfactory.c: changed accordingly.
This commit is contained in:
Sven Neumann 2003-11-01 20:53:18 +00:00 committed by Sven Neumann
parent 12f91643ab
commit c40a8121bc
6 changed files with 73 additions and 38 deletions

View File

@ -1,3 +1,13 @@
2003-11-01 Sven Neumann <sven@gimp.org>
* app/widgets/gimpcursor.[ch] (gimp_cursor_new): added a
GdkDisplay parameter and added the convenience function
gimp_cursor_set().
* app/display/gimpdisplayshell-cursor.c
* app/tools/gimpcurvestool.c
* app/widgets/gimpdialogfactory.c: changed accordingly.
2003-11-01 Manish Singh <yosh@gimp.org>
* app/core/gimppalette.c (gimp_palette_load): plug a memleak

View File

@ -78,16 +78,13 @@ gimp_display_shell_set_override_cursor (GimpDisplayShell *shell,
(shell->using_override_cursor &&
shell->override_cursor != cursor_type))
{
GdkCursor *cursor;
shell->override_cursor = cursor_type;
shell->using_override_cursor = TRUE;
cursor = gimp_cursor_new (cursor_type,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
gdk_window_set_cursor (shell->canvas->window, cursor);
gdk_cursor_unref (cursor);
gimp_cursor_set (shell->canvas,
cursor_type,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
}
}
@ -110,7 +107,7 @@ gimp_display_shell_unset_override_cursor (GimpDisplayShell *shell)
void
gimp_display_shell_update_cursor (GimpDisplayShell *shell,
gint x,
gint x,
gint y)
{
GimpImage *gimage;
@ -158,8 +155,8 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
t_y >= gimage->height)
{
info_window_update_extended (shell->gdisp, -1, -1);
}
else
}
else
{
info_window_update_extended (shell->gdisp, t_x, t_y);
}
@ -202,16 +199,10 @@ gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
shell->cursor_modifier != modifier ||
always_install)
{
GdkCursor *cursor;
shell->current_cursor = cursor_type;
shell->tool_cursor = tool_cursor;
shell->cursor_modifier = modifier;
cursor = gimp_cursor_new (cursor_type,
tool_cursor,
modifier);
gdk_window_set_cursor (shell->canvas->window, cursor);
gdk_cursor_unref (cursor);
gimp_cursor_set (shell->canvas, cursor_type, tool_cursor, modifier);
}
}

View File

@ -1019,15 +1019,12 @@ curves_graph_events (GtkWidget *widget,
if (new_cursor != cursor_type)
{
GdkCursor *cursor;
cursor_type = new_cursor;
cursor = gimp_cursor_new (cursor_type,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
gdk_window_set_cursor (c_tool->graph->window, cursor);
gdk_cursor_unref (cursor);
gimp_cursor_set (c_tool->graph,
cursor_type,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
}
curves_update (c_tool, XRANGE_TOP);

View File

@ -420,7 +420,8 @@ create_cursor_bitmaps (GimpBitmapCursor *bmcursor)
}
GdkCursor *
gimp_cursor_new (GimpCursorType cursor_type,
gimp_cursor_new (GdkDisplay *display,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
{
@ -437,10 +438,11 @@ gimp_cursor_new (GimpCursorType cursor_type,
static GdkGC *gc = NULL;
static GdkColor fg, bg;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (cursor_type < GIMP_LAST_CURSOR_ENTRY, NULL);
if (cursor_type <= GDK_LAST_CURSOR)
return gdk_cursor_new_for_display (gdk_display_get_default (), cursor_type);
return gdk_cursor_new_for_display (display, cursor_type);
g_return_val_if_fail (cursor_type >= GIMP_MOUSE_CURSOR, NULL);
@ -563,3 +565,22 @@ gimp_cursor_new (GimpCursorType cursor_type,
return cursor;
}
void
gimp_cursor_set (GtkWidget *widget,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
{
GdkCursor *cursor;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (GTK_WIDGET_REALIZED (widget));
cursor = gimp_cursor_new (gtk_widget_get_display (widget),
cursor_type,
tool_cursor,
modifier);
gdk_window_set_cursor (widget->window, cursor);
gdk_cursor_unref (cursor);
}

View File

@ -19,11 +19,14 @@
#ifndef __GIMP_CURSOR_H__
#define __GIMP_CURSOR_H__
#ifdef __GNUC__
#warning FIXME: need a new API that passes a display for gimp_cursor_new()
#endif
GdkCursor * gimp_cursor_new (GimpCursorType curtype,
GdkCursor * gimp_cursor_new (GdkDisplay *display,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_cursor_set (GtkWidget *widget,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);

View File

@ -1303,12 +1303,9 @@ gimp_dialog_factories_set_busy_foreach (gconstpointer key,
GimpDialogFactory *factory,
gpointer data)
{
GdkCursor *cursor;
GList *list;
cursor = gimp_cursor_new (GDK_WATCH,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
GdkDisplay *display = NULL;
GdkCursor *cursor = NULL;
GList *list;
for (list = factory->open_dialogs; list; list = g_list_next (list))
{
@ -1316,11 +1313,27 @@ gimp_dialog_factories_set_busy_foreach (gconstpointer key,
GTK_WIDGET_TOPLEVEL (list->data) &&
GTK_WIDGET_VISIBLE (list->data))
{
gdk_window_set_cursor (GTK_WIDGET (list->data)->window, cursor);
GtkWidget *widget = GTK_WIDGET (list->data);
if (!display || display != gtk_widget_get_display (widget))
{
display = gtk_widget_get_display (widget);
if (cursor)
gdk_cursor_unref (cursor);
cursor = gimp_cursor_new (display,
GDK_WATCH,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
}
gdk_window_set_cursor (widget->window, cursor);
}
}
gdk_cursor_unref (cursor);
if (cursor)
gdk_cursor_unref (cursor);
}
static void