[gimp] Bug 641187 - GIMP needs a left-handed cursor option
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 641187 - GIMP needs a left-handed cursor option
- Date: Sun, 24 Jul 2011 20:10:53 +0000 (UTC)
commit 421ca4114e8ac85cd4c2dba16e897bcf2af7c9e3
Author: Alexander HÃmmerle <Alexander Haemmerle gmx de>
Date: Sun Jul 24 22:09:21 2011 +0200
Bug 641187 - GIMP needs a left-handed cursor option
Add a cursor-handedness setting and flip the cursor when it's set to
left-handed.
app/config/config-enums.c | 29 +++++++++++++++++
app/config/config-enums.h | 11 ++++++
app/config/gimpguiconfig.c | 12 +++++++
app/config/gimpguiconfig.h | 1 +
app/config/gimprc-blurbs.h | 3 ++
app/dialogs/preferences-dialog.c | 5 ++-
app/display/gimpdisplayshell-cursor.c | 26 +++++++++------
app/display/gimpdisplayshell.c | 11 +++---
app/display/gimpdisplayshell.h | 3 +-
app/widgets/gimpcursor.c | 57 +++++++++++++++++++++++++++++++--
app/widgets/gimpcursor.h | 2 +
app/widgets/gimpdialogfactory.c | 1 +
12 files changed, 141 insertions(+), 20 deletions(-)
---
diff --git a/app/config/config-enums.c b/app/config/config-enums.c
index 4844f87..2a3d6b5 100644
--- a/app/config/config-enums.c
+++ b/app/config/config-enums.c
@@ -221,6 +221,35 @@ gimp_cursor_format_get_type (void)
return type;
}
+GType
+gimp_handedness_get_type (void)
+{
+ static const GEnumValue values[] =
+ {
+ { GIMP_HANDEDNESS_LEFT, "GIMP_HANDEDNESS_LEFT", "left" },
+ { GIMP_HANDEDNESS_RIGHT, "GIMP_HANDEDNESS_RIGHT", "right" },
+ { 0, NULL, NULL }
+ };
+
+ static const GimpEnumDesc descs[] =
+ {
+ { GIMP_HANDEDNESS_LEFT, NC_("handedness", "Left-handed"), NULL },
+ { GIMP_HANDEDNESS_RIGHT, NC_("handedness", "Right-handed"), NULL },
+ { 0, NULL, NULL }
+ };
+
+ static GType type = 0;
+
+ if (G_UNLIKELY (! type))
+ {
+ type = g_enum_register_static ("GimpHandedness", values);
+ gimp_type_set_translation_context (type, "handedness");
+ gimp_enum_set_value_descriptions (type, descs);
+ }
+
+ return type;
+}
+
/* Generated data ends here */
diff --git a/app/config/config-enums.h b/app/config/config-enums.h
index 0bb4778..ea433de 100644
--- a/app/config/config-enums.h
+++ b/app/config/config-enums.h
@@ -102,4 +102,15 @@ typedef enum
} GimpCursorFormat;
+#define GIMP_TYPE_HANDEDNESS (gimp_handedness_get_type ())
+
+GType gimp_handedness_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_HANDEDNESS_LEFT, /*< desc="Left-handed" >*/
+ GIMP_HANDEDNESS_RIGHT /*< desc="Right-handed" >*/
+} GimpHandedness;
+
+
#endif /* __CONFIG_ENUMS_H__ */
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index 56f5a13..f267b4e 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -73,6 +73,7 @@ enum
PROP_USER_MANUAL_ONLINE_URI,
PROP_DOCK_WINDOW_HINT,
PROP_CURSOR_FORMAT,
+ PROP_CURSOR_HANDEDNESS,
/* ignored, only for backward compatibility: */
PROP_INFO_WINDOW_PER_DISPLAY,
@@ -256,6 +257,11 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_TYPE_CURSOR_FORMAT,
GIMP_CURSOR_FORMAT_PIXBUF,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CURSOR_HANDEDNESS,
+ "cursor-handedness", CURSOR_HANDEDNESS_BLURB,
+ GIMP_TYPE_HANDEDNESS,
+ GIMP_HANDEDNESS_RIGHT,
+ GIMP_PARAM_STATIC_STRINGS);
/* only for backward compatibility: */
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY,
@@ -421,6 +427,9 @@ gimp_gui_config_set_property (GObject *object,
case PROP_CURSOR_FORMAT:
gui_config->cursor_format = g_value_get_enum (value);
break;
+ case PROP_CURSOR_HANDEDNESS:
+ gui_config->cursor_handedness = g_value_get_enum (value);
+ break;
case PROP_INFO_WINDOW_PER_DISPLAY:
case PROP_MENU_MNEMONICS:
@@ -538,6 +547,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_CURSOR_FORMAT:
g_value_set_enum (value, gui_config->cursor_format);
break;
+ case PROP_CURSOR_HANDEDNESS:
+ g_value_set_enum (value, gui_config->cursor_handedness);
+ break;
case PROP_INFO_WINDOW_PER_DISPLAY:
case PROP_MENU_MNEMONICS:
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index b3efbe3..b8e9fed 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -68,6 +68,7 @@ struct _GimpGuiConfig
gchar *user_manual_online_uri;
GimpWindowHint dock_window_hint;
GimpCursorFormat cursor_format;
+ GimpHandedness cursor_handedness;
gint last_tip; /* saved in sessionrc */
};
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 796b4e8..a1afdd0 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -51,6 +51,9 @@ N_("Sets the pixel format to use for mouse pointers.")
#define CURSOR_MODE_BLURB \
N_("Sets the type of mouse pointers to use.")
+#define CURSOR_HANDEDNESS_BLURB \
+N_("Sets the handedness for cursor positioning.")
+
#define CURSOR_UPDATING_BLURB \
N_("Context-dependent mouse pointers are helpful. They are enabled by " \
"default. However, they require overhead that you may want to do without.")
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 5c27ad9..872f7f9 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -2112,7 +2112,7 @@ prefs_dialog_new (Gimp *gimp,
_("Show pointer for paint _tools"),
GTK_BOX (vbox2));
- table = prefs_table_new (2, GTK_CONTAINER (vbox2));
+ table = prefs_table_new (3, GTK_CONTAINER (vbox2));
prefs_enum_combo_box_add (object, "cursor-mode", 0, 0,
_("Pointer _mode:"),
@@ -2120,6 +2120,9 @@ prefs_dialog_new (Gimp *gimp,
prefs_enum_combo_box_add (object, "cursor-format", 0, 0,
_("Pointer re_ndering:"),
GTK_TABLE (table), 1, size_group);
+ prefs_enum_combo_box_add (object, "cursor-handedness", 0, 0,
+ _("Pointer _handedness:"),
+ GTK_TABLE (table), 2, NULL);
g_object_unref (size_group);
size_group = NULL;
diff --git a/app/display/gimpdisplayshell-cursor.c b/app/display/gimpdisplayshell-cursor.c
index 4c43f2b..b7087cb 100644
--- a/app/display/gimpdisplayshell-cursor.c
+++ b/app/display/gimpdisplayshell-cursor.c
@@ -93,6 +93,7 @@ gimp_display_shell_set_override_cursor (GimpDisplayShell *shell,
gimp_cursor_set (shell->canvas,
shell->cursor_format,
+ shell->cursor_handedness,
cursor_type,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
@@ -221,6 +222,7 @@ gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
gboolean always_install)
{
GimpCursorFormat cursor_format;
+ GimpHandedness cursor_handedness;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
@@ -266,20 +268,24 @@ gimp_display_shell_real_set_cursor (GimpDisplayShell *shell,
}
}
- cursor_format = GIMP_GUI_CONFIG (shell->display->config)->cursor_format;
+ cursor_format = GIMP_GUI_CONFIG (shell->display->config)->cursor_format;
+ cursor_handedness = GIMP_GUI_CONFIG (shell->display->config)->cursor_handedness;
- if (shell->cursor_format != cursor_format ||
- shell->current_cursor != cursor_type ||
- shell->tool_cursor != tool_cursor ||
- shell->cursor_modifier != modifier ||
+ if (shell->cursor_format != cursor_format ||
+ shell->cursor_handedness != cursor_handedness ||
+ shell->current_cursor != cursor_type ||
+ shell->tool_cursor != tool_cursor ||
+ shell->cursor_modifier != modifier ||
always_install)
{
- shell->cursor_format = cursor_format;
- shell->current_cursor = cursor_type;
- shell->tool_cursor = tool_cursor;
- shell->cursor_modifier = modifier;
+ shell->cursor_format = cursor_format;
+ shell->cursor_handedness = cursor_handedness;
+ shell->current_cursor = cursor_type;
+ shell->tool_cursor = tool_cursor;
+ shell->cursor_modifier = modifier;
- gimp_cursor_set (shell->canvas, cursor_format,
+ gimp_cursor_set (shell->canvas,
+ cursor_format, cursor_handedness,
cursor_type, tool_cursor, modifier);
}
}
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index b628478..8a64fcb 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -299,11 +299,12 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->icon_size = 32;
- shell->cursor_format = GIMP_CURSOR_FORMAT_BITMAP;
- shell->current_cursor = (GimpCursorType) -1;
- shell->tool_cursor = GIMP_TOOL_CURSOR_NONE;
- shell->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
- shell->override_cursor = (GimpCursorType) -1;
+ shell->cursor_format = GIMP_CURSOR_FORMAT_BITMAP;
+ shell->cursor_handedness = GIMP_HANDEDNESS_RIGHT;
+ shell->current_cursor = (GimpCursorType) -1;
+ shell->tool_cursor = GIMP_TOOL_CURSOR_NONE;
+ shell->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
+ shell->override_cursor = (GimpCursorType) -1;
shell->motion_buffer = gimp_motion_buffer_new ();
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 5f64131..6b7b247 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -138,11 +138,12 @@ struct _GimpDisplayShell
guint fill_idle_id; /* display_shell_fill() idle ID */
GimpCursorFormat cursor_format; /* Currently used cursor format */
+ GimpHandedness cursor_handedness;/* Handedness for cursor display */
GimpCursorType current_cursor; /* Currently installed main cursor */
GimpToolCursorType tool_cursor; /* Current Tool cursor */
GimpCursorModifier cursor_modifier; /* Cursor modifier (plus, minus, ...) */
- GimpCursorType override_cursor; /* Overriding cursor */
+ GimpCursorType override_cursor; /* Overriding cursor */
gboolean using_override_cursor;
gboolean draw_cursor; /* should we draw software cursor ? */
diff --git a/app/widgets/gimpcursor.c b/app/widgets/gimpcursor.c
index 21118b1..9c47bd3 100644
--- a/app/widgets/gimpcursor.c
+++ b/app/widgets/gimpcursor.c
@@ -247,6 +247,7 @@ get_cursor_pixbuf (GimpCursor *cursor,
GdkCursor *
gimp_cursor_new (GdkDisplay *display,
GimpCursorFormat cursor_format,
+ GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
@@ -293,6 +294,38 @@ gimp_cursor_new (GdkDisplay *display,
modifier = GIMP_CURSOR_MODIFIER_NONE;
}
+ /* when cursor is "corner" or "side" sides must be exchanged for
+ * left-hand-mice-flipping of pixbuf below
+ */
+
+ if (cursor_handedness == GIMP_HANDEDNESS_LEFT)
+ {
+ if (cursor_type == GIMP_CURSOR_CORNER_TOP_LEFT)
+ {
+ cursor_type = GIMP_CURSOR_CORNER_TOP_RIGHT;
+ }
+ else if (cursor_type == GIMP_CURSOR_CORNER_TOP_RIGHT)
+ {
+ cursor_type = GIMP_CURSOR_CORNER_TOP_LEFT;
+ }
+ else if (cursor_type == GIMP_CURSOR_CORNER_BOTTOM_LEFT)
+ {
+ cursor_type = GIMP_CURSOR_CORNER_BOTTOM_RIGHT;
+ }
+ else if (cursor_type == GIMP_CURSOR_CORNER_BOTTOM_RIGHT)
+ {
+ cursor_type = GIMP_CURSOR_CORNER_BOTTOM_LEFT;
+ }
+ else if (cursor_type == GIMP_CURSOR_SIDE_LEFT)
+ {
+ cursor_type = GIMP_CURSOR_SIDE_RIGHT;
+ }
+ else if (cursor_type == GIMP_CURSOR_SIDE_RIGHT)
+ {
+ cursor_type = GIMP_CURSOR_SIDE_LEFT;
+ }
+ }
+
/* prepare the main cursor */
cursor_type -= GIMP_CURSOR_NONE;
@@ -345,9 +378,25 @@ gimp_cursor_new (GdkDisplay *display,
GDK_INTERP_NEAREST, bw ? 255 : 200);
}
- cursor = gdk_cursor_new_from_pixbuf (display, pixbuf,
- bmcursor->x_hot,
- bmcursor->y_hot);
+ /* flip the cursor if mouse setting is left-handed */
+
+ if (cursor_handedness == GIMP_HANDEDNESS_LEFT)
+ {
+ GdkPixbuf *flipped = gdk_pixbuf_flip (pixbuf, TRUE);
+ gint width = gdk_pixbuf_get_width (flipped);
+
+ cursor = gdk_cursor_new_from_pixbuf (display, flipped,
+ (width - 1) - bmcursor->x_hot,
+ bmcursor->y_hot);
+ g_object_unref (flipped);
+ }
+ else
+ {
+ cursor = gdk_cursor_new_from_pixbuf (display, pixbuf,
+ bmcursor->x_hot,
+ bmcursor->y_hot);
+ }
+
g_object_unref (pixbuf);
return cursor;
@@ -356,6 +405,7 @@ gimp_cursor_new (GdkDisplay *display,
void
gimp_cursor_set (GtkWidget *widget,
GimpCursorFormat cursor_format,
+ GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier)
@@ -367,6 +417,7 @@ gimp_cursor_set (GtkWidget *widget,
cursor = gimp_cursor_new (gtk_widget_get_display (widget),
cursor_format,
+ cursor_handedness,
cursor_type,
tool_cursor,
modifier);
diff --git a/app/widgets/gimpcursor.h b/app/widgets/gimpcursor.h
index c8886ad..bd8769e 100644
--- a/app/widgets/gimpcursor.h
+++ b/app/widgets/gimpcursor.h
@@ -21,11 +21,13 @@
GdkCursor * gimp_cursor_new (GdkDisplay *display,
GimpCursorFormat cursor_format,
+ GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
void gimp_cursor_set (GtkWidget *widget,
GimpCursorFormat cursor_format,
+ GimpHandedness cursor_handedness,
GimpCursorType cursor_type,
GimpToolCursorType tool_cursor,
GimpCursorModifier modifier);
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index 3fc17f3..8150024 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -1503,6 +1503,7 @@ gimp_dialog_factory_set_busy (GimpDialogFactory *factory)
cursor = gimp_cursor_new (display,
GIMP_CURSOR_FORMAT_BITMAP,
+ GIMP_HANDEDNESS_RIGHT,
GDK_WATCH,
GIMP_TOOL_CURSOR_NONE,
GIMP_CURSOR_MODIFIER_NONE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]