added enum GimpCursorFormat which can be one of { BITMAP, PIXBUF,

2004-06-13  Michael Natterer  <mitch@gimp.org>

	* app/widgets/widgets-enums.[ch]: added enum GimpCursorFormat
	which can be one of { BITMAP, PIXBUF, PIXBUF-PREMULTIPLY } to
	work around broken X servers.

	* app/config/gimpguiconfig.[ch]
	* app/config/gimprc-blurbs.h: added GimpGuiConfig::cursor-format.

	* app/gui/preferences-dialog.c: added a GUI for the new option.

	* app/widgets/gimpcursor.[ch]: added cursor_format parameter
	to gimp_cursor_new() and _set().

	* app/display/gimpdisplayshell-cursor.c
	* app/tools/gimpcurvestool.c
	* app/widgets/gimpdialogfactory.c: pass an appropriate cursor_mode.
This commit is contained in:
Michael Natterer 2004-06-13 02:08:54 +00:00 committed by Michael Natterer
parent a6801996e4
commit 2498adc5f6
13 changed files with 122 additions and 14 deletions

View File

@ -1,3 +1,21 @@
2004-06-13 Michael Natterer <mitch@gimp.org>
* app/widgets/widgets-enums.[ch]: added enum GimpCursorFormat
which can be one of { BITMAP, PIXBUF, PIXBUF-PREMULTIPLY } to
work around broken X servers.
* app/config/gimpguiconfig.[ch]
* app/config/gimprc-blurbs.h: added GimpGuiConfig::cursor-format.
* app/gui/preferences-dialog.c: added a GUI for the new option.
* app/widgets/gimpcursor.[ch]: added cursor_format parameter
to gimp_cursor_new() and _set().
* app/display/gimpdisplayshell-cursor.c
* app/tools/gimpcurvestool.c
* app/widgets/gimpdialogfactory.c: pass an appropriate cursor_mode.
2004-06-12 Philip Lafleur <plafleur@cvs.gnome.org>
* app/core/gimpdrawable-blend.c: added missing semicolon.

View File

@ -89,7 +89,8 @@ enum
PROP_HELP_BROWSER,
PROP_WEB_BROWSER,
PROP_TOOLBOX_WINDOW_HINT,
PROP_DOCK_WINDOW_HINT
PROP_DOCK_WINDOW_HINT,
PROP_CURSOR_FORMAT
};
static GObjectClass *parent_class = NULL;
@ -263,6 +264,11 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_TYPE_WINDOW_HINT,
GIMP_WINDOW_HINT_NORMAL,
GIMP_PARAM_RESTART);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CURSOR_FORMAT,
"cursor-format", CURSOR_FORMAT_BLURB,
GIMP_TYPE_CURSOR_FORMAT,
GIMP_CURSOR_FORMAT_PIXBUF,
0);
}
static void
@ -376,6 +382,9 @@ gimp_gui_config_set_property (GObject *object,
case PROP_DOCK_WINDOW_HINT:
gui_config->dock_window_hint = g_value_get_enum (value);
break;
case PROP_CURSOR_FORMAT:
gui_config->cursor_format = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -477,6 +486,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_DOCK_WINDOW_HINT:
g_value_set_enum (value, gui_config->dock_window_hint);
break;
case PROP_CURSOR_FORMAT:
g_value_set_enum (value, gui_config->cursor_format);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);

View File

@ -68,6 +68,7 @@ struct _GimpGuiConfig
gchar *web_browser;
GimpWindowHint toolbox_window_hint;
GimpWindowHint dock_window_hint;
GimpCursorFormat cursor_format;
gint last_tip; /* saved in sessionrc */
};

View File

@ -29,6 +29,9 @@ N_("Sets the canvas padding color used if the padding mode is set to " \
#define CONFIRM_ON_CLOSE_BLURB \
N_("Ask for confirmation before closing an image without saving.")
#define CURSOR_FORMAT_BLURB \
N_("Sets the pixel format of cursors the GIMP will use.")
#define CURSOR_MODE_BLURB \
N_("Sets the mode of cursor the GIMP will use.")

View File

@ -1460,15 +1460,18 @@ prefs_dialog_new (Gimp *gimp,
prefs_check_button_add (object, "show-brush-outline",
_("Show _Brush Outline"),
GTK_BOX (vbox2));
prefs_check_button_add (object, "show-paint-tool-cursor",
_("Show Paint _Tool Cursor"),
prefs_check_button_add (object, "show-paint-tool-cursor",
_("Show Paint _Tool Cursor"),
GTK_BOX (vbox2));
table = prefs_table_new (1, GTK_CONTAINER (vbox2));
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
prefs_enum_combo_box_add (object, "cursor-mode", 0, 0,
_("Cursor M_ode:"),
GTK_TABLE (table), 0, size_group);
prefs_enum_combo_box_add (object, "cursor-format", 0, 0,
_("Cursor Re_ndering:"),
GTK_TABLE (table), 1, size_group);
g_object_unref (size_group);
size_group = NULL;

View File

@ -27,7 +27,7 @@
#endif
#include "gui/gui-types.h"
#include "config/gimpdisplayconfig.h"
#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimpimage.h"
@ -82,6 +82,7 @@ gimp_display_shell_set_override_cursor (GimpDisplayShell *shell,
shell->using_override_cursor = TRUE;
gimp_cursor_set (shell->canvas,
GIMP_GUI_CONFIG (shell->gdisp->gimage->gimp->config)->cursor_format,
cursor_type,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
@ -220,6 +221,8 @@ gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
shell->tool_cursor = tool_cursor;
shell->cursor_modifier = modifier;
gimp_cursor_set (shell->canvas, cursor_type, tool_cursor, modifier);
gimp_cursor_set (shell->canvas,
GIMP_GUI_CONFIG (config)->cursor_format,
cursor_type, tool_cursor, modifier);
}
}

View File

@ -1460,15 +1460,18 @@ prefs_dialog_new (Gimp *gimp,
prefs_check_button_add (object, "show-brush-outline",
_("Show _Brush Outline"),
GTK_BOX (vbox2));
prefs_check_button_add (object, "show-paint-tool-cursor",
_("Show Paint _Tool Cursor"),
prefs_check_button_add (object, "show-paint-tool-cursor",
_("Show Paint _Tool Cursor"),
GTK_BOX (vbox2));
table = prefs_table_new (1, GTK_CONTAINER (vbox2));
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
prefs_enum_combo_box_add (object, "cursor-mode", 0, 0,
_("Cursor M_ode:"),
GTK_TABLE (table), 0, size_group);
prefs_enum_combo_box_add (object, "cursor-format", 0, 0,
_("Cursor Re_ndering:"),
GTK_TABLE (table), 1, size_group);
g_object_unref (size_group);
size_group = NULL;

View File

@ -30,6 +30,7 @@
#include "tools-types.h"
#include "config/gimpbaseconfig.h"
#include "config/gimpguiconfig.h"
#include "base/curves.h"
#include "base/gimphistogram.h"
@ -1069,6 +1070,7 @@ curves_graph_events (GtkWidget *widget,
cursor_type = new_cursor;
gimp_cursor_set (tool->graph,
GIMP_GUI_CONFIG (GIMP_TOOL (tool)->tool_info->gimp->config)->cursor_format,
cursor_type,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);

View File

@ -499,6 +499,7 @@ get_cursor_pixbuf (GimpCursor *cursor)
GdkCursor *
gimp_cursor_new (GdkDisplay *display,
GimpCursorFormat cursor_format,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
@ -557,7 +558,8 @@ gimp_cursor_new (GdkDisplay *display,
if (modifier != GIMP_CURSOR_MODIFIER_NONE)
bmmodifier = &gimp_cursor_modifiers[modifier];
if (gdk_display_supports_cursor_alpha (display) &&
if (cursor_format != GIMP_CURSOR_FORMAT_BITMAP &&
gdk_display_supports_cursor_alpha (display) &&
gdk_display_supports_cursor_color (display))
{
GdkPixbuf *pixbuf;
@ -571,13 +573,37 @@ gimp_cursor_new (GdkDisplay *display,
gdk_pixbuf_composite (get_cursor_pixbuf (bmmodifier), pixbuf,
0, 0, width, height,
0.0, 0.0, 1.0, 1.0,
GDK_INTERP_NEAREST, 180);
GDK_INTERP_NEAREST, 200);
if (bmtool)
gdk_pixbuf_composite (get_cursor_pixbuf (bmtool), pixbuf,
0, 0, width, height,
0.0, 0.0, 1.0, 1.0,
GDK_INTERP_NEAREST, 180);
GDK_INTERP_NEAREST, 200);
if (cursor_format == GIMP_CURSOR_FORMAT_PIXBUF_PREMULTIPLY)
{
guint rowstride;
guchar *pixels, *p;
gint x, y;
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
for (y = 0; y < height; y++)
{
p = pixels + y * rowstride;
for (x = 0; x < width; x++)
{
p[0] = (p[0] * p[3]) >> 8;
p[1] = (p[1] * p[3]) >> 8;
p[2] = (p[2] * p[3]) >> 8;
p += 4;
}
}
}
cursor = gdk_cursor_new_from_pixbuf (display, pixbuf,
bmcursor->x_hot,
@ -654,6 +680,7 @@ gimp_cursor_new (GdkDisplay *display,
void
gimp_cursor_set (GtkWidget *widget,
GimpCursorFormat cursor_format,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
@ -664,6 +691,7 @@ gimp_cursor_set (GtkWidget *widget,
g_return_if_fail (GTK_WIDGET_REALIZED (widget));
cursor = gimp_cursor_new (gtk_widget_get_display (widget),
cursor_format,
cursor_type,
tool_cursor,
modifier);

View File

@ -21,10 +21,12 @@
GdkCursor * gimp_cursor_new (GdkDisplay *display,
GimpCursorFormat cursor_format,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_cursor_set (GtkWidget *widget,
GimpCursorFormat cursor_format,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);

View File

@ -1376,6 +1376,7 @@ gimp_dialog_factories_set_busy_foreach (gconstpointer key,
gdk_cursor_unref (cursor);
cursor = gimp_cursor_new (display,
GIMP_CURSOR_FORMAT_BITMAP,
GDK_WATCH,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);

View File

@ -68,6 +68,26 @@ gimp_color_frame_mode_get_type (void)
}
static const GEnumValue gimp_cursor_format_enum_values[] =
{
{ GIMP_CURSOR_FORMAT_BITMAP, N_("Black & White"), "bitmap" },
{ GIMP_CURSOR_FORMAT_PIXBUF, N_("RGBA"), "pixbuf" },
{ GIMP_CURSOR_FORMAT_PIXBUF_PREMULTIPLY, N_("RGBA Premultiplied"), "pixbuf-premultiply" },
{ 0, NULL, NULL }
};
GType
gimp_cursor_format_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpCursorFormat", gimp_cursor_format_enum_values);
return enum_type;
}
static const GEnumValue gimp_help_browser_type_enum_values[] =
{
{ GIMP_HELP_BROWSER_GIMP, N_("Internal"), "gimp" },

View File

@ -60,6 +60,18 @@ typedef enum
} GimpColorFrameMode;
#define GIMP_TYPE_CURSOR_FORMAT (gimp_cursor_format_get_type ())
GType gimp_cursor_format_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_CURSOR_FORMAT_BITMAP, /*< desc="Black & White" >*/
GIMP_CURSOR_FORMAT_PIXBUF, /*< desc="RGBA" >*/
GIMP_CURSOR_FORMAT_PIXBUF_PREMULTIPLY /*< desc="RGBA Premultiplied" >*/
} GimpCursorFormat;
#define GIMP_TYPE_HELP_BROWSER_TYPE (gimp_help_browser_type_get_type ())
GType gimp_help_browser_type_get_type (void) G_GNUC_CONST;