[gimp] app: implement GimpTool::key_press() and ::key_release() in GimpDrawTool



commit 4e50eb503d19cb73cdd13a53c81caf6fd55779a3
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 26 20:13:51 2017 +0200

    app: implement GimpTool::key_press() and ::key_release() in GimpDrawTool
    
    and feed the events to the widget. Remove the implementations from
    most subclasses.

 app/tools/gimpblendtool.c     |   19 -------------------
 app/tools/gimpcroptool.c      |   19 -------------------
 app/tools/gimpdrawtool.c      |   38 ++++++++++++++++++++++++++++++++++++++
 app/tools/gimptransformtool.c |   19 -------------------
 app/tools/gimpvectortool.c    |   19 -------------------
 5 files changed, 38 insertions(+), 76 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 3d63100..c678c1e 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -95,9 +95,6 @@ static void   gimp_blend_tool_motion              (GimpTool              *tool,
                                                    guint32                time,
                                                    GdkModifierType        state,
                                                    GimpDisplay           *display);
-static gboolean gimp_blend_tool_key_press         (GimpTool              *tool,
-                                                   GdkEventKey           *kevent,
-                                                   GimpDisplay           *display);
 static void   gimp_blend_tool_active_modifier_key (GimpTool              *tool,
                                                    GdkModifierType        key,
                                                    gboolean               press,
@@ -198,7 +195,6 @@ gimp_blend_tool_class_init (GimpBlendToolClass *klass)
   tool_class->button_press        = gimp_blend_tool_button_press;
   tool_class->button_release      = gimp_blend_tool_button_release;
   tool_class->motion              = gimp_blend_tool_motion;
-  tool_class->key_press           = gimp_blend_tool_key_press;
   tool_class->active_modifier_key = gimp_blend_tool_active_modifier_key;
   tool_class->cursor_update       = gimp_blend_tool_cursor_update;
   tool_class->get_undo_desc       = gimp_blend_tool_get_undo_desc;
@@ -469,21 +465,6 @@ gimp_blend_tool_motion (GimpTool         *tool,
   gimp_blend_tool_update_status (blend_tool, state, TRUE, display);
 }
 
-static gboolean
-gimp_blend_tool_key_press (GimpTool    *tool,
-                           GdkEventKey *kevent,
-                           GimpDisplay *display)
-{
-  GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
-
-  if (blend_tool->line && display == tool->display)
-    {
-      return gimp_tool_widget_key_press (blend_tool->line, kevent);
-    }
-
-  return FALSE;
-}
-
 static void
 gimp_blend_tool_active_modifier_key (GimpTool        *tool,
                                      GdkModifierType  key,
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index 9bb9d04..2a9fba8 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -66,9 +66,6 @@ static void     gimp_crop_tool_motion                     (GimpTool
                                                            guint32               time,
                                                            GdkModifierType       state,
                                                            GimpDisplay          *display);
-static gboolean  gimp_crop_tool_key_press                 (GimpTool             *tool,
-                                                           GdkEventKey          *kevent,
-                                                           GimpDisplay          *display);
 static void      gimp_crop_tool_active_modifier_key       (GimpTool             *tool,
                                                            GdkModifierType       key,
                                                            gboolean              press,
@@ -163,7 +160,6 @@ gimp_crop_tool_class_init (GimpCropToolClass *klass)
   tool_class->button_press        = gimp_crop_tool_button_press;
   tool_class->button_release      = gimp_crop_tool_button_release;
   tool_class->motion              = gimp_crop_tool_motion;
-  tool_class->key_press           = gimp_crop_tool_key_press;
   tool_class->active_modifier_key = gimp_crop_tool_active_modifier_key;
   tool_class->oper_update         = gimp_crop_tool_oper_update;
   tool_class->cursor_update       = gimp_crop_tool_cursor_update;
@@ -370,21 +366,6 @@ gimp_crop_tool_motion (GimpTool         *tool,
     }
 }
 
-static gboolean
-gimp_crop_tool_key_press (GimpTool    *tool,
-                          GdkEventKey *kevent,
-                          GimpDisplay *display)
-{
-  GimpCropTool *crop_tool = GIMP_CROP_TOOL (tool);
-
-  if (crop_tool->rectangle && display == tool->display)
-    {
-      return gimp_tool_widget_key_press (crop_tool->rectangle, kevent);
-    }
-
-  return FALSE;
-}
-
 static void
 gimp_crop_tool_active_modifier_key (GimpTool        *tool,
                                     GdkModifierType  key,
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index fc55082..f4225a5 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -68,6 +68,12 @@ static GimpDisplay * gimp_draw_tool_has_image    (GimpTool         *tool,
 static void          gimp_draw_tool_control      (GimpTool         *tool,
                                                   GimpToolAction    action,
                                                   GimpDisplay      *display);
+static gboolean      gimp_draw_tool_key_press    (GimpTool         *tool,
+                                                  GdkEventKey      *kevent,
+                                                  GimpDisplay      *display);
+static gboolean      gimp_draw_tool_key_release  (GimpTool         *tool,
+                                                  GdkEventKey      *kevent,
+                                                  GimpDisplay      *display);
 
 static void          gimp_draw_tool_draw         (GimpDrawTool     *draw_tool);
 static void          gimp_draw_tool_undraw       (GimpDrawTool     *draw_tool);
@@ -90,6 +96,8 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
   tool_class->has_display = gimp_draw_tool_has_display;
   tool_class->has_image   = gimp_draw_tool_has_image;
   tool_class->control     = gimp_draw_tool_control;
+  tool_class->key_press   = gimp_draw_tool_key_press;
+  tool_class->key_release = gimp_draw_tool_key_release;
 
   klass->draw             = gimp_draw_tool_real_draw;
 }
@@ -175,6 +183,36 @@ gimp_draw_tool_control (GimpTool       *tool,
   GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
 }
 
+static gboolean
+gimp_draw_tool_key_press (GimpTool    *tool,
+                          GdkEventKey *kevent,
+                          GimpDisplay *display)
+{
+  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
+  if (draw_tool->widget && display == draw_tool->display)
+    {
+      return gimp_tool_widget_key_press (draw_tool->widget, kevent);
+    }
+
+  return GIMP_TOOL_CLASS (parent_class)->key_press (tool, kevent, display);
+}
+
+static gboolean
+gimp_draw_tool_key_release (GimpTool    *tool,
+                            GdkEventKey *kevent,
+                            GimpDisplay *display)
+{
+  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
+  if (draw_tool->widget && display == draw_tool->display)
+    {
+      return gimp_tool_widget_key_release (draw_tool->widget, kevent);
+    }
+
+  return GIMP_TOOL_CLASS (parent_class)->key_release (tool, kevent, display);
+}
+
 #ifdef USE_TIMEOUT
 static gboolean
 gimp_draw_tool_draw_timeout (GimpDrawTool *draw_tool)
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index e6a0bcd..ab6f1f3 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -86,9 +86,6 @@ static void      gimp_transform_tool_motion              (GimpTool
                                                           guint32                time,
                                                           GdkModifierType        state,
                                                           GimpDisplay           *display);
-static gboolean  gimp_transform_tool_key_press           (GimpTool              *tool,
-                                                          GdkEventKey           *kevent,
-                                                          GimpDisplay           *display);
 static void      gimp_transform_tool_modifier_key        (GimpTool              *tool,
                                                           GdkModifierType        key,
                                                           gboolean               press,
@@ -192,7 +189,6 @@ gimp_transform_tool_class_init (GimpTransformToolClass *klass)
   tool_class->button_press        = gimp_transform_tool_button_press;
   tool_class->button_release      = gimp_transform_tool_button_release;
   tool_class->motion              = gimp_transform_tool_motion;
-  tool_class->key_press           = gimp_transform_tool_key_press;
   tool_class->modifier_key        = gimp_transform_tool_modifier_key;
   tool_class->active_modifier_key = gimp_transform_tool_modifier_key;
   tool_class->oper_update         = gimp_transform_tool_oper_update;
@@ -478,21 +474,6 @@ gimp_transform_tool_motion (GimpTool         *tool,
     }
 }
 
-static gboolean
-gimp_transform_tool_key_press (GimpTool    *tool,
-                               GdkEventKey *kevent,
-                               GimpDisplay *display)
-{
-  GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
-
-  if (tr_tool->widget && display == tool->display)
-    {
-      return gimp_tool_widget_key_press (tr_tool->widget, kevent);
-    }
-
-  return FALSE;
-}
-
 static void
 gimp_transform_tool_modifier_key (GimpTool        *tool,
                                   GdkModifierType  key,
diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c
index 322d40e..97322c6 100644
--- a/app/tools/gimpvectortool.c
+++ b/app/tools/gimpvectortool.c
@@ -88,9 +88,6 @@ static void     gimp_vector_tool_motion          (GimpTool              *tool,
                                                   guint32                time,
                                                   GdkModifierType        state,
                                                   GimpDisplay           *display);
-static gboolean gimp_vector_tool_key_press       (GimpTool              *tool,
-                                                  GdkEventKey           *kevent,
-                                                  GimpDisplay           *display);
 static void     gimp_vector_tool_modifier_key    (GimpTool              *tool,
                                                   GdkModifierType        key,
                                                   gboolean               press,
@@ -191,7 +188,6 @@ gimp_vector_tool_class_init (GimpVectorToolClass *klass)
   tool_class->button_press   = gimp_vector_tool_button_press;
   tool_class->button_release = gimp_vector_tool_button_release;
   tool_class->motion         = gimp_vector_tool_motion;
-  tool_class->key_press      = gimp_vector_tool_key_press;
   tool_class->modifier_key   = gimp_vector_tool_modifier_key;
   tool_class->oper_update    = gimp_vector_tool_oper_update;
   tool_class->cursor_update  = gimp_vector_tool_cursor_update;
@@ -310,21 +306,6 @@ gimp_vector_tool_motion (GimpTool         *tool,
     }
 }
 
-static gboolean
-gimp_vector_tool_key_press (GimpTool     *tool,
-                            GdkEventKey  *kevent,
-                            GimpDisplay  *display)
-{
-  GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (tool);
-
-  if (display == tool->display && vector_tool->path)
-    {
-      return gimp_tool_widget_key_press (vector_tool->path, kevent);
-    }
-
-  return FALSE;
-}
-
 static void
 gimp_vector_tool_modifier_key (GimpTool        *tool,
                                GdkModifierType  key,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]