app/tools/gimptool.[ch] added boolean return value to

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

	* app/tools/gimptool.[ch]
	* app/tools/tool_manager.[ch]: added boolean return value to
	GimpTool::key_press() which indicates if the event was handled.

	* app/tools/gimpcroptool.c
	* app/tools/gimpeditselectiontool.[ch]
	* app/tools/gimptransformtool.c
	* app/tools/gimpvectortool.c: return TRUE if the key event was handled.

	* app/tools/gimppainttool.c: removed key_press() implementation.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpcontrollerkeyboard.[ch]: new controller class
	which takes GdkEventKey and emits controller events for all
	combinations of modifiers and cursor keys.

	* app/widgets/gimpcontrollers.[ch]: added new function
	gimp_controllers_get_keyboard().

	* app/display/gimpdisplayshell-callbacks.c: if a key event was not
	handled by the active tool, dispatch it to the keyboard controller.

	* etc/controllerrc: add a keyboard controller which is configured
	to do the same as the removed gimp_paint_tool_key_press().
This commit is contained in:
Michael Natterer 2004-06-24 10:16:08 +00:00 committed by Michael Natterer
parent ffe9ac0772
commit 02b91f6628
20 changed files with 665 additions and 317 deletions

View File

@ -1,3 +1,31 @@
2004-06-24 Michael Natterer <mitch@gimp.org>
* app/tools/gimptool.[ch]
* app/tools/tool_manager.[ch]: added boolean return value to
GimpTool::key_press() which indicates if the event was handled.
* app/tools/gimpcroptool.c
* app/tools/gimpeditselectiontool.[ch]
* app/tools/gimptransformtool.c
* app/tools/gimpvectortool.c: return TRUE if the key event was handled.
* app/tools/gimppainttool.c: removed key_press() implementation.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h
* app/widgets/gimpcontrollerkeyboard.[ch]: new controller class
which takes GdkEventKey and emits controller events for all
combinations of modifiers and cursor keys.
* app/widgets/gimpcontrollers.[ch]: added new function
gimp_controllers_get_keyboard().
* app/display/gimpdisplayshell-callbacks.c: if a key event was not
handled by the active tool, dispatch it to the keyboard controller.
* etc/controllerrc: add a keyboard controller which is configured
to do the same as the removed gimp_paint_tool_key_press().
2004-06-23 Bill Skaggs <weskaggs@primate.ucdavis.edu> 2004-06-23 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* libgimp/gimpdrawable.c: added some documentation for * libgimp/gimpdrawable.c: added some documentation for

View File

@ -46,6 +46,7 @@
#include "widgets/gimpactiongroup.h" #include "widgets/gimpactiongroup.h"
#include "widgets/gimpcontrollers.h" #include "widgets/gimpcontrollers.h"
#include "widgets/gimpcontrollerkeyboard.h"
#include "widgets/gimpcontrollerwheel.h" #include "widgets/gimpcontrollerwheel.h"
#include "widgets/gimpcursor.h" #include "widgets/gimpcursor.h"
#include "widgets/gimpdevices.h" #include "widgets/gimpdevices.h"
@ -1129,11 +1130,18 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
case GDK_Right: case GDK_Right:
case GDK_Up: case GDK_Up:
case GDK_Down: case GDK_Down:
if (! gimp_image_is_empty (gimage)) if (gimp_image_is_empty (gimage) ||
! tool_manager_key_press_active (gimp,
kevent,
gdisp))
{ {
tool_manager_key_press_active (gimp, GimpController *keyboard;
kevent,
gdisp); keyboard = gimp_controllers_get_keyboard (gimp);
if (keyboard)
gimp_controller_keyboard_key_press (GIMP_CONTROLLER_KEYBOARD (keyboard),
kevent);
} }
return_val = TRUE; return_val = TRUE;

View File

@ -86,9 +86,6 @@ static void gimp_paint_tool_motion (GimpTool *tool,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_paint_tool_modifier_key (GimpTool *tool, static void gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key, GdkModifierType key,
gboolean press, gboolean press,
@ -169,7 +166,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
tool_class->button_press = gimp_paint_tool_button_press; tool_class->button_press = gimp_paint_tool_button_press;
tool_class->button_release = gimp_paint_tool_button_release; tool_class->button_release = gimp_paint_tool_button_release;
tool_class->motion = gimp_paint_tool_motion; tool_class->motion = gimp_paint_tool_motion;
tool_class->key_press = gimp_paint_tool_key_press;
tool_class->modifier_key = gimp_paint_tool_modifier_key; tool_class->modifier_key = gimp_paint_tool_modifier_key;
tool_class->oper_update = gimp_paint_tool_oper_update; tool_class->oper_update = gimp_paint_tool_oper_update;
tool_class->cursor_update = gimp_paint_tool_cursor_update; tool_class->cursor_update = gimp_paint_tool_cursor_update;
@ -548,40 +544,6 @@ gimp_paint_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
} }
static void
gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
{
if (tool->gdisp)
{
GimpContext *context = GIMP_CONTEXT (tool->tool_info->tool_options);
gdouble opacity;
opacity = gimp_context_get_opacity (context);
switch (kevent->keyval)
{
case GDK_Left:
opacity = CLAMP (opacity - 0.01, 0, 1);
break;
case GDK_Right:
opacity = CLAMP (opacity + 0.01, 0, 1);
break;
case GDK_Up:
opacity = CLAMP (opacity + 0.1, 0, 1);
break;
case GDK_Down:
opacity = CLAMP (opacity - 0.1, 0, 1);
break;
default:
break;
}
gimp_context_set_opacity (context, opacity);
}
}
static void static void
gimp_paint_tool_modifier_key (GimpTool *tool, gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key, GdkModifierType key,

View File

@ -70,79 +70,79 @@ enum
}; };
static void gimp_crop_tool_class_init (GimpCropToolClass *klass); static void gimp_crop_tool_class_init (GimpCropToolClass *klass);
static void gimp_crop_tool_init (GimpCropTool *crop_tool); static void gimp_crop_tool_init (GimpCropTool *crop_tool);
static void gimp_crop_tool_finalize (GObject *object); static void gimp_crop_tool_finalize (GObject *object);
static void gimp_crop_tool_control (GimpTool *tool, static void gimp_crop_tool_control (GimpTool *tool,
GimpToolAction action, GimpToolAction action,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_button_press (GimpTool *tool, static void gimp_crop_tool_button_press (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_button_release (GimpTool *tool, static void gimp_crop_tool_button_release (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_motion (GimpTool *tool, static void gimp_crop_tool_motion (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_key_press (GimpTool *tool, static gboolean gimp_crop_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_modifier_key (GimpTool *tool, static void gimp_crop_tool_modifier_key (GimpTool *tool,
GdkModifierType key, GdkModifierType key,
gboolean press, gboolean press,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_oper_update (GimpTool *tool, static void gimp_crop_tool_oper_update (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_cursor_update (GimpTool *tool, static void gimp_crop_tool_cursor_update (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_crop_tool_draw (GimpDrawTool *draw_tool); static void gimp_crop_tool_draw (GimpDrawTool *draw_tool);
/* Crop helper functions */ /* Crop helper functions */
static void crop_tool_crop_image (GimpImage *gimage, static void crop_tool_crop_image (GimpImage *gimage,
GimpContext *context, GimpContext *context,
gint x1, gint x1,
gint y1, gint y1,
gint x2, gint x2,
gint y2, gint y2,
gboolean layer_only, gboolean layer_only,
GimpCropMode crop_mode); GimpCropMode crop_mode);
static void crop_recalc (GimpCropTool *crop); static void crop_recalc (GimpCropTool *crop);
static void crop_start (GimpCropTool *crop); static void crop_start (GimpCropTool *crop);
/* Crop dialog functions */ /* Crop dialog functions */
static void crop_info_update (GimpCropTool *crop); static void crop_info_update (GimpCropTool *crop);
static void crop_info_create (GimpCropTool *crop); static void crop_info_create (GimpCropTool *crop);
static void crop_response (GtkWidget *widget, static void crop_response (GtkWidget *widget,
gint response_id, gint response_id,
GimpCropTool *crop); GimpCropTool *crop);
static void crop_selection_callback (GtkWidget *widget, static void crop_selection_callback (GtkWidget *widget,
GimpCropTool *crop); GimpCropTool *crop);
static void crop_automatic_callback (GtkWidget *widget, static void crop_automatic_callback (GtkWidget *widget,
GimpCropTool *crop); GimpCropTool *crop);
static void crop_origin_changed (GtkWidget *widget, static void crop_origin_changed (GtkWidget *widget,
GimpCropTool *crop); GimpCropTool *crop);
static void crop_size_changed (GtkWidget *widget, static void crop_size_changed (GtkWidget *widget,
GimpCropTool *crop); GimpCropTool *crop);
static void crop_aspect_changed (GtkWidget *widget, static void crop_aspect_changed (GtkWidget *widget,
GimpCropTool *crop); GimpCropTool *crop);
static GimpDrawToolClass *parent_class = NULL; static GimpDrawToolClass *parent_class = NULL;
@ -514,7 +514,7 @@ gimp_crop_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
} }
static void static gboolean
gimp_crop_tool_key_press (GimpTool *tool, gimp_crop_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp) GimpDisplay *gdisp)
@ -527,7 +527,7 @@ gimp_crop_tool_key_press (GimpTool *tool,
gint max_x, max_y; gint max_x, max_y;
if (gdisp != tool->gdisp) if (gdisp != tool->gdisp)
return; return FALSE;
inc_x = inc_y = 0; inc_x = inc_y = 0;
@ -545,12 +545,14 @@ gimp_crop_tool_key_press (GimpTool *tool,
case GDK_Down: case GDK_Down:
inc_y = 1; inc_y = 1;
break; break;
case GDK_KP_Enter: case GDK_KP_Enter:
case GDK_Return: case GDK_Return:
crop_response (NULL, options->crop_mode, crop); crop_response (NULL, options->crop_mode, crop);
return; return TRUE;
default: default:
return; return FALSE;
} }
/* If the shift key is down, move by an accelerated increment */ /* If the shift key is down, move by an accelerated increment */
@ -606,6 +608,8 @@ gimp_crop_tool_key_press (GimpTool *tool,
crop_recalc (crop); crop_recalc (crop);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
return TRUE;
} }
static void static void

View File

@ -113,9 +113,6 @@ static void gimp_edit_selection_tool_motion (GimpTool *tool,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
void gimp_edit_selection_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_edit_selection_tool_draw (GimpDrawTool *tool); static void gimp_edit_selection_tool_draw (GimpDrawTool *tool);
@ -1051,7 +1048,7 @@ process_event_queue_keys (GdkEventKey *kevent,
#undef FILTER_MAX_KEYS #undef FILTER_MAX_KEYS
} }
void gboolean
gimp_edit_selection_tool_key_press (GimpTool *tool, gimp_edit_selection_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp) GimpDisplay *gdisp)
@ -1071,7 +1068,7 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
kevent->keyval != GDK_Right && kevent->keyval != GDK_Right &&
kevent->keyval != GDK_Up && kevent->keyval != GDK_Up &&
kevent->keyval != GDK_Down) kevent->keyval != GDK_Down)
return; return FALSE;
/* check for mask translation first because the translate_layer /* check for mask translation first because the translate_layer
* modifiers match the translate_mask ones... * modifiers match the translate_mask ones...
@ -1216,7 +1213,7 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
} }
if (! item) if (! item)
return; return TRUE;
switch (edit_type) switch (edit_type)
{ {
@ -1297,4 +1294,6 @@ gimp_edit_selection_tool_key_press (GimpTool *tool,
gimp_undo_refresh_preview (undo); gimp_undo_refresh_preview (undo);
gimp_image_flush (gdisp->gimage); gimp_image_flush (gdisp->gimage);
return TRUE;
} }

View File

@ -33,15 +33,15 @@ typedef enum
} EditType; } EditType;
void init_edit_selection (GimpTool *tool, void init_edit_selection (GimpTool *tool,
GimpDisplay *gdisp, GimpDisplay *gdisp,
GimpCoords *coords, GimpCoords *coords,
EditType edit_type); EditType edit_type);
void gimp_edit_selection_tool_key_press (GimpTool *tool, gboolean gimp_edit_selection_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);
#endif /* __GIMP_EDIT_SELECTION_TOOL_H__ */ #endif /* __GIMP_EDIT_SELECTION_TOOL_H__ */

View File

@ -86,9 +86,6 @@ static void gimp_paint_tool_motion (GimpTool *tool,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp);
static void gimp_paint_tool_modifier_key (GimpTool *tool, static void gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key, GdkModifierType key,
gboolean press, gboolean press,
@ -169,7 +166,6 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
tool_class->button_press = gimp_paint_tool_button_press; tool_class->button_press = gimp_paint_tool_button_press;
tool_class->button_release = gimp_paint_tool_button_release; tool_class->button_release = gimp_paint_tool_button_release;
tool_class->motion = gimp_paint_tool_motion; tool_class->motion = gimp_paint_tool_motion;
tool_class->key_press = gimp_paint_tool_key_press;
tool_class->modifier_key = gimp_paint_tool_modifier_key; tool_class->modifier_key = gimp_paint_tool_modifier_key;
tool_class->oper_update = gimp_paint_tool_oper_update; tool_class->oper_update = gimp_paint_tool_oper_update;
tool_class->cursor_update = gimp_paint_tool_cursor_update; tool_class->cursor_update = gimp_paint_tool_cursor_update;
@ -548,40 +544,6 @@ gimp_paint_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
} }
static void
gimp_paint_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *gdisp)
{
if (tool->gdisp)
{
GimpContext *context = GIMP_CONTEXT (tool->tool_info->tool_options);
gdouble opacity;
opacity = gimp_context_get_opacity (context);
switch (kevent->keyval)
{
case GDK_Left:
opacity = CLAMP (opacity - 0.01, 0, 1);
break;
case GDK_Right:
opacity = CLAMP (opacity + 0.01, 0, 1);
break;
case GDK_Up:
opacity = CLAMP (opacity + 0.1, 0, 1);
break;
case GDK_Down:
opacity = CLAMP (opacity - 0.1, 0, 1);
break;
default:
break;
}
gimp_context_set_opacity (context, opacity);
}
}
static void static void
gimp_paint_tool_modifier_key (GimpTool *tool, gimp_paint_tool_modifier_key (GimpTool *tool,
GdkModifierType key, GdkModifierType key,

View File

@ -74,7 +74,7 @@ static void gimp_tool_real_motion (GimpTool *tool,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_tool_real_key_press (GimpTool *tool, static gboolean gimp_tool_real_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_tool_real_modifier_key (GimpTool *tool, static void gimp_tool_real_modifier_key (GimpTool *tool,
@ -276,11 +276,12 @@ gimp_tool_real_motion (GimpTool *tool,
{ {
} }
static void static gboolean
gimp_tool_real_key_press (GimpTool *tool, gimp_tool_real_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
return FALSE;
} }
static void static void
@ -442,16 +443,16 @@ gimp_tool_set_focus_display (GimpTool *tool,
} }
} }
void gboolean
gimp_tool_key_press (GimpTool *tool, gimp_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
g_return_if_fail (GIMP_IS_TOOL (tool)); g_return_val_if_fail (GIMP_IS_TOOL (tool), FALSE);
g_return_if_fail (GIMP_IS_DISPLAY (gdisp)); g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), FALSE);
g_return_if_fail (gdisp == tool->focus_display); g_return_val_if_fail (gdisp == tool->focus_display, FALSE);
GIMP_TOOL_GET_CLASS (tool)->key_press (tool, kevent, gdisp); return GIMP_TOOL_GET_CLASS (tool)->key_press (tool, kevent, gdisp);
} }
static void static void

View File

@ -82,7 +82,7 @@ struct _GimpToolClass
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
void (* key_press) (GimpTool *tool, gboolean (* key_press) (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);
void (* modifier_key) (GimpTool *tool, void (* modifier_key) (GimpTool *tool,
@ -126,7 +126,7 @@ void gimp_tool_motion (GimpTool *tool,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
void gimp_tool_key_press (GimpTool *tool, gboolean gimp_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);

View File

@ -100,7 +100,7 @@ static void gimp_transform_tool_motion (GimpTool *tool,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_transform_tool_key_press (GimpTool *tool, static gboolean gimp_transform_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_transform_tool_modifier_key (GimpTool *tool, static void gimp_transform_tool_modifier_key (GimpTool *tool,
@ -184,13 +184,9 @@ gimp_transform_tool_get_type (void)
static void static void
gimp_transform_tool_class_init (GimpTransformToolClass *klass) gimp_transform_tool_class_init (GimpTransformToolClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class; GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_class; GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass);
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
draw_class = GIMP_DRAW_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
@ -519,7 +515,7 @@ gimp_transform_tool_motion (GimpTool *tool,
#define RESPONSE_RESET 1 #define RESPONSE_RESET 1
static void static gboolean
gimp_transform_tool_key_press (GimpTool *tool, gimp_transform_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp) GimpDisplay *gdisp)
@ -534,17 +530,16 @@ gimp_transform_tool_key_press (GimpTool *tool,
case GDK_KP_Enter: case GDK_KP_Enter:
case GDK_Return: case GDK_Return:
gimp_transform_tool_response (NULL, GTK_RESPONSE_OK, trans_tool); gimp_transform_tool_response (NULL, GTK_RESPONSE_OK, trans_tool);
break; return TRUE;
case GDK_Delete: case GDK_Delete:
case GDK_BackSpace: case GDK_BackSpace:
gimp_transform_tool_response (NULL, RESPONSE_RESET, trans_tool); gimp_transform_tool_response (NULL, RESPONSE_RESET, trans_tool);
break; return TRUE;
default:
break;
} }
} }
return FALSE;
} }
static void static void

View File

@ -71,78 +71,78 @@
/* local function prototypes */ /* local function prototypes */
static void gimp_vector_tool_class_init (GimpVectorToolClass *klass); static void gimp_vector_tool_class_init (GimpVectorToolClass *klass);
static void gimp_vector_tool_init (GimpVectorTool *tool); static void gimp_vector_tool_init (GimpVectorTool *tool);
static void gimp_vector_tool_control (GimpTool *tool, static void gimp_vector_tool_control (GimpTool *tool,
GimpToolAction action, GimpToolAction action,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_button_press (GimpTool *tool, static void gimp_vector_tool_button_press (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_button_release (GimpTool *tool, static void gimp_vector_tool_button_release (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_motion (GimpTool *tool, static void gimp_vector_tool_motion (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_key_press (GimpTool *tool, static gboolean gimp_vector_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_modifier_key (GimpTool *tool, static void gimp_vector_tool_modifier_key (GimpTool *tool,
GdkModifierType key, GdkModifierType key,
gboolean press, gboolean press,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_oper_update (GimpTool *tool, static void gimp_vector_tool_oper_update (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_status_update (GimpTool *tool, static void gimp_vector_tool_status_update (GimpTool *tool,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_status_set (GimpTool *tool, static void gimp_vector_tool_status_set (GimpTool *tool,
GimpDisplay *gdisp, GimpDisplay *gdisp,
const gchar *message); const gchar *message);
static void gimp_vector_tool_cursor_update (GimpTool *tool, static void gimp_vector_tool_cursor_update (GimpTool *tool,
GimpCoords *coords, GimpCoords *coords,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
static void gimp_vector_tool_draw (GimpDrawTool *draw_tool); static void gimp_vector_tool_draw (GimpDrawTool *draw_tool);
static void gimp_vector_tool_vectors_changed (GimpImage *gimage, static void gimp_vector_tool_vectors_changed (GimpImage *gimage,
GimpVectorTool *vector_tool); GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_removed (GimpVectors *vectors, static void gimp_vector_tool_vectors_removed (GimpVectors *vectors,
GimpVectorTool *vector_tool); GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_visible (GimpVectors *vectors, static void gimp_vector_tool_vectors_visible (GimpVectors *vectors,
GimpVectorTool *vector_tool); GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_freeze (GimpVectors *vectors, static void gimp_vector_tool_vectors_freeze (GimpVectors *vectors,
GimpVectorTool *vector_tool); GimpVectorTool *vector_tool);
static void gimp_vector_tool_vectors_thaw (GimpVectors *vectors, static void gimp_vector_tool_vectors_thaw (GimpVectors *vectors,
GimpVectorTool *vector_tool); GimpVectorTool *vector_tool);
static void gimp_vector_tool_move_selected_anchors static void gimp_vector_tool_move_selected_anchors
(GimpVectorTool *vector_tool, (GimpVectorTool *vector_tool,
gdouble x, gdouble x,
gdouble y); gdouble y);
static void gimp_vector_tool_delete_selected_anchors static void gimp_vector_tool_delete_selected_anchors
(GimpVectorTool *vector_tool); (GimpVectorTool *vector_tool);
static void gimp_vector_tool_verify_state (GimpVectorTool *vector_tool); static void gimp_vector_tool_verify_state (GimpVectorTool *vector_tool);
static void gimp_vector_tool_undo_push (GimpVectorTool *vector_tool, static void gimp_vector_tool_undo_push (GimpVectorTool *vector_tool,
const gchar *desc); const gchar *desc);
static void gimp_vector_tool_to_selection (GimpVectorTool *vector_tool); static void gimp_vector_tool_to_selection (GimpVectorTool *vector_tool);
static void gimp_vector_tool_to_selection_extended static void gimp_vector_tool_to_selection_extended
(GimpVectorTool *vector_tool, (GimpVectorTool *vector_tool,
gint state); gint state);
static void gimp_vector_tool_stroke_vectors (GimpVectorTool *vector_tool, static void gimp_vector_tool_stroke_vectors (GimpVectorTool *vector_tool,
GtkWidget *button); GtkWidget *button);
static GimpDrawToolClass *parent_class = NULL; static GimpDrawToolClass *parent_class = NULL;
@ -783,19 +783,19 @@ gimp_vector_tool_motion (GimpTool *tool,
gimp_vectors_thaw (vector_tool->vectors); gimp_vectors_thaw (vector_tool->vectors);
} }
static void static gboolean
gimp_vector_tool_key_press (GimpTool *tool, gimp_vector_tool_key_press (GimpTool *tool,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool); GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool); GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpDisplayShell *shell; GimpDisplayShell *shell;
gdouble xdist, ydist; gdouble xdist, ydist;
gdouble pixels = 1.0; gdouble pixels = 1.0;
if (!vector_tool->vectors) if (! vector_tool->vectors)
return; return TRUE;
shell = GIMP_DISPLAY_SHELL (draw_tool->gdisp->shell); shell = GIMP_DISPLAY_SHELL (draw_tool->gdisp->shell);
@ -809,59 +809,61 @@ gimp_vector_tool_key_press (GimpTool *tool,
{ {
switch (kevent->keyval) switch (kevent->keyval)
{ {
case GDK_KP_Enter: case GDK_KP_Enter:
case GDK_Return: case GDK_Return:
gimp_vector_tool_to_selection_extended (vector_tool, gimp_vector_tool_to_selection_extended (vector_tool, kevent->state);
kevent->state); break;
break;
case GDK_BackSpace:
case GDK_Delete:
gimp_vector_tool_delete_selected_anchors (vector_tool);
break;
case GDK_Left: case GDK_BackSpace:
case GDK_Right: case GDK_Delete:
case GDK_Up: gimp_vector_tool_delete_selected_anchors (vector_tool);
case GDK_Down: break;
xdist = FUNSCALEX (shell, pixels);
ydist = FUNSCALEY (shell, pixels);
gimp_vector_tool_undo_push (vector_tool, _("Move Anchors"));
gimp_vectors_freeze (vector_tool->vectors);
switch (kevent->keyval)
{
case GDK_Left:
gimp_vector_tool_move_selected_anchors (vector_tool,
-xdist, 0);
break;
case GDK_Right:
gimp_vector_tool_move_selected_anchors (vector_tool,
xdist, 0);
break;
case GDK_Up:
gimp_vector_tool_move_selected_anchors (vector_tool,
0, -ydist);
break;
case GDK_Down:
gimp_vector_tool_move_selected_anchors (vector_tool,
0, ydist);
break;
default:
break;
}
gimp_vectors_thaw (vector_tool->vectors); case GDK_Left:
vector_tool->have_undo = FALSE; case GDK_Right:
case GDK_Up:
case GDK_Down:
xdist = FUNSCALEX (shell, pixels);
ydist = FUNSCALEY (shell, pixels);
gimp_vector_tool_undo_push (vector_tool, _("Move Anchors"));
gimp_vectors_freeze (vector_tool->vectors);
switch (kevent->keyval)
{
case GDK_Left:
gimp_vector_tool_move_selected_anchors (vector_tool, -xdist, 0);
break; break;
default: case GDK_Right:
break; gimp_vector_tool_move_selected_anchors (vector_tool, xdist, 0);
break;
case GDK_Up:
gimp_vector_tool_move_selected_anchors (vector_tool, 0, -ydist);
break;
case GDK_Down:
gimp_vector_tool_move_selected_anchors (vector_tool, 0, ydist);
break;
default:
break;
}
gimp_vectors_thaw (vector_tool->vectors);
vector_tool->have_undo = FALSE;
break;
default:
break;
} }
gimp_image_flush (gdisp->gimage); gimp_image_flush (gdisp->gimage);
} }
return TRUE;
} }
static void static void
@ -871,11 +873,10 @@ gimp_vector_tool_modifier_key (GimpTool *tool,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpVectorTool *vector_tool; GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
GimpVectorOptions *options; GimpVectorOptions *options;
vector_tool = GIMP_VECTOR_TOOL (tool); options = GIMP_VECTOR_OPTIONS (tool->tool_info->tool_options);
options = GIMP_VECTOR_OPTIONS (tool->tool_info->tool_options);
if (key == TOGGLE_MASK) if (key == TOGGLE_MASK)
return; return;

View File

@ -328,23 +328,25 @@ tool_manager_motion_active (Gimp *gimp,
} }
} }
void gboolean
tool_manager_key_press_active (Gimp *gimp, tool_manager_key_press_active (Gimp *gimp,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpToolManager *tool_manager; GimpToolManager *tool_manager;
g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
tool_manager = tool_manager_get (gimp); tool_manager = tool_manager_get (gimp);
if (tool_manager->active_tool) if (tool_manager->active_tool)
{ {
gimp_tool_key_press (tool_manager->active_tool, return gimp_tool_key_press (tool_manager->active_tool,
kevent, kevent,
gdisp); gdisp);
} }
return FALSE;
} }
void void

View File

@ -53,7 +53,7 @@ void tool_manager_motion_active (Gimp *gimp,
guint32 time, guint32 time,
GdkModifierType state, GdkModifierType state,
GimpDisplay *gdisp); GimpDisplay *gdisp);
void tool_manager_key_press_active (Gimp *gimp, gboolean tool_manager_key_press_active (Gimp *gimp,
GdkEventKey *kevent, GdkEventKey *kevent,
GimpDisplay *gdisp); GimpDisplay *gdisp);

View File

@ -75,6 +75,8 @@ libappwidgets_a_sources = \
gimpcontrollerinfo.h \ gimpcontrollerinfo.h \
gimpcontrollers.c \ gimpcontrollers.c \
gimpcontrollers.h \ gimpcontrollers.h \
gimpcontrollerkeyboard.c \
gimpcontrollerkeyboard.h \
gimpcontrollerwheel.c \ gimpcontrollerwheel.c \
gimpcontrollerwheel.h \ gimpcontrollerwheel.h \
gimpcursor.c \ gimpcursor.c \

View File

@ -0,0 +1,293 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcontrollerkeyboard.c
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "gimpcontrollerkeyboard.h"
#include "gimp-intl.h"
typedef struct _KeyboardEvent KeyboardEvent;
struct _KeyboardEvent
{
guint keyval;
GdkModifierType modifiers;
const gchar *name;
const gchar *blurb;
};
static void gimp_controller_keyboard_class_init (GimpControllerKeyboardClass *klass);
static void gimp_controller_keyboard_init (GimpControllerKeyboard *keyboard);
static GObject * gimp_controller_keyboard_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static gint gimp_controller_keyboard_get_n_events (GimpController *controller);
static const gchar * gimp_controller_keyboard_get_event_name (GimpController *controller,
gint event_id);
static const gchar * gimp_controller_keyboard_get_event_blurb (GimpController *controller,
gint event_id);
static GimpControllerClass *parent_class = NULL;
static const KeyboardEvent keyboard_events[] =
{
{ GDK_Up, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-up-shift-control-alt",
N_("Key Up (Shift + Control + Alt)") },
{ GDK_Up, GDK_MOD1_MASK | GDK_CONTROL_MASK,
"key-up-control-alt",
N_("Key Up (Control + Alt)") },
{ GDK_Up, GDK_MOD1_MASK | GDK_SHIFT_MASK,
"key-up-shift-alt",
N_("Key Up (Shift + Alt)") },
{ GDK_Up, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-up-shift-control",
N_("Key Up (Shift + Control)") },
{ GDK_Up, GDK_MOD1_MASK,
"key-up-alt",
N_("Key Up (Alt)") },
{ GDK_Up, GDK_CONTROL_MASK,
"key-up-control",
N_("Key Up (Control)") },
{ GDK_Up, GDK_SHIFT_MASK,
"key-up-shift",
N_("Key Up (Shift)") },
{ GDK_Up, 0,
"key-up",
N_("Key Up") },
{ GDK_Down, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-down-shift-control-alt",
N_("Key Down (Shift + Control + Alt)") },
{ GDK_Down, GDK_MOD1_MASK | GDK_CONTROL_MASK,
"key-down-control-alt",
N_("Key Down (Control + Alt)") },
{ GDK_Down, GDK_MOD1_MASK | GDK_SHIFT_MASK,
"key-down-shift-alt",
N_("Key Down (Shift + Alt)") },
{ GDK_Down, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-down-shift-control",
N_("Key Down (Shift + Control)") },
{ GDK_Down, GDK_MOD1_MASK,
"key-down-alt",
N_("Key Down (Alt)") },
{ GDK_Down, GDK_CONTROL_MASK,
"key-down-control",
N_("Key Down (Control)") },
{ GDK_Down, GDK_SHIFT_MASK,
"key-down-shift",
N_("Key Down (Shift)") },
{ GDK_Down, 0,
"key-down",
N_("Key Down") },
{ GDK_Left, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-left-shift-control-alt",
N_("Key Left (Shift + Control + Alt)") },
{ GDK_Left, GDK_MOD1_MASK | GDK_CONTROL_MASK,
"key-left-control-alt",
N_("Key Left (Control + Alt)") },
{ GDK_Left, GDK_MOD1_MASK | GDK_SHIFT_MASK,
"key-left-shift-alt",
N_("Key Left (Shift + Alt)") },
{ GDK_Left, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-left-shift-control",
N_("Key Left (Shift + Control)") },
{ GDK_Left, GDK_MOD1_MASK,
"key-left-alt",
N_("Key Left (Alt)") },
{ GDK_Left, GDK_CONTROL_MASK,
"key-left-control",
N_("Key Left (Control)") },
{ GDK_Left, GDK_SHIFT_MASK,
"key-left-shift",
N_("Key Left (Shift)") },
{ GDK_Left, 0,
"key-left",
N_("Key Left") },
{ GDK_Right, GDK_MOD1_MASK | GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-right-shift-control-alt",
N_("Key Right (Shift + Control + Alt)") },
{ GDK_Right, GDK_MOD1_MASK | GDK_CONTROL_MASK,
"key-right-control-alt",
N_("Key Right (Control + Alt)") },
{ GDK_Right, GDK_MOD1_MASK | GDK_SHIFT_MASK,
"key-right-shift-alt",
N_("Key Right (Shift + Alt)") },
{ GDK_Right, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"key-right-shift-control",
N_("Key Right (Shift + Control)") },
{ GDK_Right, GDK_MOD1_MASK,
"key-right-alt",
N_("Key Right (Alt)") },
{ GDK_Right, GDK_CONTROL_MASK,
"key-right-control",
N_("Key Right (Control)") },
{ GDK_Right, GDK_SHIFT_MASK,
"key-right-shift",
N_("Key Right (Shift)") },
{ GDK_Right, 0,
"key-right",
N_("Key Right") }
};
GType
gimp_controller_keyboard_get_type (void)
{
static GType controller_type = 0;
if (! controller_type)
{
static const GTypeInfo controller_info =
{
sizeof (GimpControllerKeyboardClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_controller_keyboard_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpControllerKeyboard),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_controller_keyboard_init,
};
controller_type = g_type_register_static (GIMP_TYPE_CONTROLLER,
"GimpControllerKeyboard",
&controller_info, 0);
}
return controller_type;
}
static void
gimp_controller_keyboard_class_init (GimpControllerKeyboardClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpControllerClass *controller_class = GIMP_CONTROLLER_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_controller_keyboard_constructor;
controller_class->name = _("Keyboard");
controller_class->get_n_events = gimp_controller_keyboard_get_n_events;
controller_class->get_event_name = gimp_controller_keyboard_get_event_name;
controller_class->get_event_blurb = gimp_controller_keyboard_get_event_blurb;
}
static void
gimp_controller_keyboard_init (GimpControllerKeyboard *keyboard)
{
}
static GObject *
gimp_controller_keyboard_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
g_object_set (object, "name", _("Main Keyboard"), NULL);
return object;
}
static gint
gimp_controller_keyboard_get_n_events (GimpController *controller)
{
return G_N_ELEMENTS (keyboard_events);
}
static const gchar *
gimp_controller_keyboard_get_event_name (GimpController *controller,
gint event_id)
{
if (event_id < 0 || event_id >= G_N_ELEMENTS (keyboard_events))
return NULL;
return keyboard_events[event_id].name;
}
static const gchar *
gimp_controller_keyboard_get_event_blurb (GimpController *controller,
gint event_id)
{
if (event_id < 0 || event_id >= G_N_ELEMENTS (keyboard_events))
return NULL;
return gettext (keyboard_events[event_id].blurb);
}
gboolean
gimp_controller_keyboard_key_press (GimpControllerKeyboard *keyboard,
const GdkEventKey *kevent)
{
gint i;
g_return_val_if_fail (GIMP_IS_CONTROLLER_KEYBOARD (keyboard), FALSE);
g_return_val_if_fail (kevent != NULL, FALSE);
for (i = 0; i < G_N_ELEMENTS (keyboard_events); i++)
{
if (keyboard_events[i].keyval == kevent->keyval)
{
if ((keyboard_events[i].modifiers & kevent->state) ==
keyboard_events[i].modifiers)
{
GimpControllerEvent controller_event;
GimpControllerEventTrigger *trigger;
trigger = (GimpControllerEventTrigger *) &controller_event;
trigger->type = GIMP_CONTROLLER_EVENT_TRIGGER;
trigger->source = GIMP_CONTROLLER (keyboard);
trigger->event_id = i;
if (gimp_controller_event (GIMP_CONTROLLER (keyboard),
&controller_event))
{
return TRUE;
}
}
}
}
return FALSE;
}

View File

@ -0,0 +1,57 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcontrollerkeyboard.h
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CONTROLLER_WHELL_H__
#define __GIMP_CONTROLLER_KEYBOARD_H__
#include "libgimpwidgets/gimpcontroller.h"
#define GIMP_TYPE_CONTROLLER_KEYBOARD (gimp_controller_keyboard_get_type ())
#define GIMP_CONTROLLER_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CONTROLLER_KEYBOARD, GimpControllerKeyboard))
#define GIMP_CONTROLLER_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTROLLER_KEYBOARD, GimpControllerKeyboardClass))
#define GIMP_IS_CONTROLLER_KEYBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CONTROLLER_KEYBOARD))
#define GIMP_IS_CONTROLLER_KEYBOARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTROLLER_KEYBOARD))
#define GIMP_CONTROLLER_KEYBOARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CONTROLLER_KEYBOARD, GimpControllerKeyboardClass))
typedef struct _GimpControllerKeyboardClass GimpControllerKeyboardClass;
struct _GimpControllerKeyboard
{
GimpController parent_instance;
};
struct _GimpControllerKeyboardClass
{
GimpControllerClass parent_class;
};
GType gimp_controller_keyboard_get_type (void) G_GNUC_CONST;
gboolean gimp_controller_keyboard_key_press (GimpControllerKeyboard *keyboard,
const GdkEventKey *kevent);
#endif /* __GIMP_CONTROLLER_KEYBOARD_H__ */

View File

@ -38,6 +38,7 @@
#include "gimpcontrollerinfo.h" #include "gimpcontrollerinfo.h"
#include "gimpcontrollers.h" #include "gimpcontrollers.h"
#include "gimpcontrollerkeyboard.h"
#include "gimpcontrollerwheel.h" #include "gimpcontrollerwheel.h"
#include "gimpenumaction.h" #include "gimpenumaction.h"
#include "gimpuimanager.h" #include "gimpuimanager.h"
@ -55,6 +56,7 @@ struct _GimpControllerManager
GimpContainer *controllers; GimpContainer *controllers;
GQuark event_mapped_id; GQuark event_mapped_id;
GimpController *wheel; GimpController *wheel;
GimpController *keyboard;
GimpUIManager *ui_manager; GimpUIManager *ui_manager;
}; };
@ -122,6 +124,7 @@ gimp_controllers_init (Gimp *gimp)
} }
g_type_class_ref (GIMP_TYPE_CONTROLLER_WHEEL); g_type_class_ref (GIMP_TYPE_CONTROLLER_WHEEL);
g_type_class_ref (GIMP_TYPE_CONTROLLER_KEYBOARD);
} }
void void
@ -133,6 +136,7 @@ gimp_controllers_exit (Gimp *gimp)
g_object_set_data (G_OBJECT (gimp), GIMP_CONTROLLER_MANAGER_DATA_KEY, NULL); g_object_set_data (G_OBJECT (gimp), GIMP_CONTROLLER_MANAGER_DATA_KEY, NULL);
g_type_class_unref (g_type_class_peek (GIMP_TYPE_CONTROLLER_WHEEL)); g_type_class_unref (g_type_class_peek (GIMP_TYPE_CONTROLLER_WHEEL));
g_type_class_unref (g_type_class_peek (GIMP_TYPE_CONTROLLER_KEYBOARD));
} }
void void
@ -247,6 +251,21 @@ gimp_controllers_get_wheel (Gimp *gimp)
return manager->wheel; return manager->wheel;
} }
GimpController *
gimp_controllers_get_keyboard (Gimp *gimp)
{
GimpControllerManager *manager;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
manager = gimp_controller_manager_get (gimp);
g_return_val_if_fail (manager != NULL, NULL);
return manager->keyboard;
}
/* private functions */ /* private functions */
static GimpControllerManager * static GimpControllerManager *
@ -274,6 +293,8 @@ gimp_controllers_add (GimpContainer *container,
{ {
if (GIMP_IS_CONTROLLER_WHEEL (info->controller)) if (GIMP_IS_CONTROLLER_WHEEL (info->controller))
manager->wheel = info->controller; manager->wheel = info->controller;
else if (GIMP_IS_CONTROLLER_KEYBOARD (info->controller))
manager->keyboard = info->controller;
} }
static void static void
@ -283,6 +304,8 @@ gimp_controllers_remove (GimpContainer *container,
{ {
if (info->controller == manager->wheel) if (info->controller == manager->wheel)
manager->wheel = NULL; manager->wheel = NULL;
else if (info->controller == manager->keyboard)
manager->keyboard = NULL;
} }
static gboolean static gboolean

View File

@ -23,15 +23,16 @@
#define __GIMP_CONTROLLERS_H__ #define __GIMP_CONTROLLERS_H__
void gimp_controllers_init (Gimp *gimp); void gimp_controllers_init (Gimp *gimp);
void gimp_controllers_exit (Gimp *gimp); void gimp_controllers_exit (Gimp *gimp);
void gimp_controllers_restore (Gimp *gimp, void gimp_controllers_restore (Gimp *gimp,
GimpUIManager *ui_manager); GimpUIManager *ui_manager);
void gimp_controllers_save (Gimp *gimp); void gimp_controllers_save (Gimp *gimp);
GimpContainer * gimp_controllers_get_list (Gimp *gimp); GimpContainer * gimp_controllers_get_list (Gimp *gimp);
GimpController * gimp_controllers_get_wheel (Gimp *gimp); GimpController * gimp_controllers_get_wheel (Gimp *gimp);
GimpController * gimp_controllers_get_keyboard (Gimp *gimp);
#endif /* __GIMP_CONTROLLERS_H__ */ #endif /* __GIMP_CONTROLLERS_H__ */

View File

@ -57,6 +57,7 @@ typedef struct _GimpPreviewRendererImagefile GimpPreviewRendererImagefile;
typedef struct _GimpPreviewRendererVectors GimpPreviewRendererVectors; typedef struct _GimpPreviewRendererVectors GimpPreviewRendererVectors;
typedef struct _GimpControllerInfo GimpControllerInfo; typedef struct _GimpControllerInfo GimpControllerInfo;
typedef struct _GimpControllerKeyboard GimpControllerKeyboard;
typedef struct _GimpControllerWheel GimpControllerWheel; typedef struct _GimpControllerWheel GimpControllerWheel;

View File

@ -15,6 +15,15 @@
(map "scroll-up-shift-control-alt" "context-font-next"))) (map "scroll-up-shift-control-alt" "context-font-next")))
(map "scroll-down-shift-control-alt" "context-font-previous") (map "scroll-down-shift-control-alt" "context-font-previous")
(GimpControllerInfo "Main Keyboard"
(enabled yes)
(controller "GimpControllerKeyboard")
(mapping
(map "key-up" "context-opacity-increase-skip")
(map "key-down" "context-opacity-decrease-skip")
(map "key-left" "context-opacity-decrease")
(map "key-right" "context-opacity-increase")))
# (GimpControllerInfo "LinuxInput" # (GimpControllerInfo "LinuxInput"
# (enabled yes) # (enabled yes)
# (controller "ControllerLinuxInput" # (controller "ControllerLinuxInput"