[gimp] app: forward tool get_popup() to widget get_popup() in GimpDrawTool



commit 18d747611cd602be358746dce71e8b8e8fb9686a
Author: Ell <ell_se yahoo com>
Date:   Tue May 26 11:07:25 2020 +0300

    app: forward tool get_popup() to widget get_popup() in GimpDrawTool
    
    Override GimpTool::get_popup() in GimpDrawTool, forwarding the
    request to the tool widget, if one exists.
    
    Remove the same code in GimpVectorTool -- this now works for all
    tools/widgets.

 app/tools/gimpdrawtool.c   | 156 +++++++++++++++++++++++++++------------------
 app/tools/gimpvectortool.c |  24 -------
 2 files changed, 94 insertions(+), 86 deletions(-)
---
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 129f9293d8..c9acd2ffd6 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -59,68 +59,73 @@
 #define MINIMUM_DRAW_INTERVAL (G_TIME_SPAN_SECOND / DRAW_FPS)
 
 
-static void          gimp_draw_tool_dispose       (GObject          *object);
-
-static gboolean      gimp_draw_tool_has_display   (GimpTool         *tool,
-                                                   GimpDisplay      *display);
-static GimpDisplay * gimp_draw_tool_has_image     (GimpTool         *tool,
-                                                   GimpImage        *image);
-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_modifier_key  (GimpTool         *tool,
-                                                   GdkModifierType   key,
-                                                   gboolean          press,
-                                                   GdkModifierType   state,
-                                                   GimpDisplay      *display);
-static void          gimp_draw_tool_active_modifier_key
-                                                  (GimpTool         *tool,
-                                                   GdkModifierType   key,
-                                                   gboolean          press,
-                                                   GdkModifierType   state,
-                                                   GimpDisplay      *display);
-static void          gimp_draw_tool_oper_update   (GimpTool         *tool,
-                                                   const GimpCoords *coords,
-                                                   GdkModifierType   state,
-                                                   gboolean          proximity,
-                                                   GimpDisplay      *display);
-static void          gimp_draw_tool_cursor_update (GimpTool         *tool,
-                                                   const GimpCoords *coords,
-                                                   GdkModifierType   state,
-                                                   GimpDisplay      *display);
-
-static void          gimp_draw_tool_widget_status (GimpToolWidget   *widget,
-                                                   const gchar      *status,
-                                                   GimpTool         *tool);
-static void          gimp_draw_tool_widget_status_coords
-                                                  (GimpToolWidget   *widget,
-                                                   const gchar      *title,
-                                                   gdouble           x,
-                                                   const gchar      *separator,
-                                                   gdouble           y,
-                                                   const gchar      *help,
-                                                   GimpTool         *tool);
-static void          gimp_draw_tool_widget_message
-                                                  (GimpToolWidget   *widget,
-                                                   const gchar      *message,
-                                                   GimpTool         *tool);
-static void          gimp_draw_tool_widget_snap_offsets
-                                                  (GimpToolWidget   *widget,
-                                                   gint              offset_x,
-                                                   gint              offset_y,
-                                                   gint              width,
-                                                   gint              height,
-                                                   GimpTool         *tool);
-
-static void          gimp_draw_tool_draw          (GimpDrawTool     *draw_tool);
-static void          gimp_draw_tool_undraw        (GimpDrawTool     *draw_tool);
-static void          gimp_draw_tool_real_draw     (GimpDrawTool     *draw_tool);
+static void            gimp_draw_tool_dispose       (GObject           *object);
+
+static gboolean        gimp_draw_tool_has_display   (GimpTool          *tool,
+                                                     GimpDisplay       *display);
+static GimpDisplay   * gimp_draw_tool_has_image     (GimpTool          *tool,
+                                                     GimpImage         *image);
+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_modifier_key  (GimpTool          *tool,
+                                                     GdkModifierType    key,
+                                                     gboolean           press,
+                                                     GdkModifierType    state,
+                                                     GimpDisplay       *display);
+static void            gimp_draw_tool_active_modifier_key
+                                                    (GimpTool          *tool,
+                                                     GdkModifierType    key,
+                                                     gboolean           press,
+                                                     GdkModifierType    state,
+                                                     GimpDisplay       *display);
+static void            gimp_draw_tool_oper_update   (GimpTool          *tool,
+                                                     const GimpCoords  *coords,
+                                                     GdkModifierType    state,
+                                                     gboolean           proximity,
+                                                     GimpDisplay       *display);
+static void            gimp_draw_tool_cursor_update (GimpTool          *tool,
+                                                     const GimpCoords  *coords,
+                                                     GdkModifierType    state,
+                                                     GimpDisplay       *display);
+static GimpUIManager * gimp_draw_tool_get_popup     (GimpTool          *tool,
+                                                     const GimpCoords  *coords,
+                                                     GdkModifierType    state,
+                                                     GimpDisplay       *display,
+                                                     const gchar      **ui_path);
+
+static void            gimp_draw_tool_widget_status (GimpToolWidget    *widget,
+                                                     const gchar       *status,
+                                                     GimpTool          *tool);
+static void            gimp_draw_tool_widget_status_coords
+                                                    (GimpToolWidget    *widget,
+                                                     const gchar       *title,
+                                                     gdouble            x,
+                                                     const gchar       *separator,
+                                                     gdouble            y,
+                                                     const gchar       *help,
+                                                     GimpTool          *tool);
+static void            gimp_draw_tool_widget_message
+                                                    (GimpToolWidget    *widget,
+                                                     const gchar       *message,
+                                                     GimpTool          *tool);
+static void            gimp_draw_tool_widget_snap_offsets
+                                                    (GimpToolWidget    *widget,
+                                                     gint               offset_x,
+                                                     gint               offset_y,
+                                                     gint               width,
+                                                     gint               height,
+                                                     GimpTool          *tool);
+
+static void            gimp_draw_tool_draw          (GimpDrawTool      *draw_tool);
+static void            gimp_draw_tool_undraw        (GimpDrawTool      *draw_tool);
+static void            gimp_draw_tool_real_draw     (GimpDrawTool      *draw_tool);
 
 
 G_DEFINE_TYPE (GimpDrawTool, gimp_draw_tool, GIMP_TYPE_TOOL)
@@ -145,6 +150,7 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
   tool_class->active_modifier_key = gimp_draw_tool_active_modifier_key;
   tool_class->oper_update         = gimp_draw_tool_oper_update;
   tool_class->cursor_update       = gimp_draw_tool_cursor_update;
+  tool_class->get_popup           = gimp_draw_tool_get_popup;
 
   klass->draw                     = gimp_draw_tool_real_draw;
 }
@@ -358,6 +364,32 @@ gimp_draw_tool_cursor_update (GimpTool         *tool,
                                                  display);
 }
 
+static GimpUIManager *
+gimp_draw_tool_get_popup (GimpTool          *tool,
+                          const GimpCoords  *coords,
+                          GdkModifierType    state,
+                          GimpDisplay       *display,
+                          const gchar      **ui_path)
+{
+  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
+  if (draw_tool->widget && display == draw_tool->display)
+    {
+      GimpUIManager *ui_manager;
+
+      ui_manager = gimp_tool_widget_get_popup (draw_tool->widget,
+                                               coords, state,
+                                               ui_path);
+
+      if (ui_manager)
+        return ui_manager;
+    }
+
+  return GIMP_TOOL_CLASS (parent_class)->get_popup (tool,
+                                                    coords, state, display,
+                                                    ui_path);
+}
+
 static void
 gimp_draw_tool_widget_status (GimpToolWidget *widget,
                               const gchar    *status,
diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c
index 4662f4c07c..7e40e22291 100644
--- a/app/tools/gimpvectortool.c
+++ b/app/tools/gimpvectortool.c
@@ -101,11 +101,6 @@ static void     gimp_vector_tool_cursor_update   (GimpTool              *tool,
                                                   const GimpCoords      *coords,
                                                   GdkModifierType        state,
                                                   GimpDisplay           *display);
-static GimpUIManager * gimp_vector_tool_get_popup (GimpTool             *tool,
-                                                  const GimpCoords      *coords,
-                                                  GdkModifierType        state,
-                                                  GimpDisplay           *display,
-                                                  const gchar          **ui_path);
 
 static void     gimp_vector_tool_start           (GimpVectorTool        *vector_tool,
                                                   GimpDisplay           *display);
@@ -191,7 +186,6 @@ gimp_vector_tool_class_init (GimpVectorToolClass *klass)
   tool_class->motion         = gimp_vector_tool_motion;
   tool_class->modifier_key   = gimp_vector_tool_modifier_key;
   tool_class->cursor_update  = gimp_vector_tool_cursor_update;
-  tool_class->get_popup      = gimp_vector_tool_get_popup;
 }
 
 static void
@@ -388,24 +382,6 @@ gimp_vector_tool_cursor_update (GimpTool         *tool,
   GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
 }
 
-static GimpUIManager *
-gimp_vector_tool_get_popup (GimpTool         *tool,
-                            const GimpCoords *coords,
-                            GdkModifierType   state,
-                            GimpDisplay      *display,
-                            const gchar     **ui_path)
-{
-  GimpVectorTool   *vector_tool = GIMP_VECTOR_TOOL (tool);
-
-  if (display != tool->display || ! vector_tool->widget)
-    {
-      return NULL;
-    }
-
-  return gimp_tool_widget_get_popup (GIMP_TOOL_WIDGET (vector_tool->widget),
-                                     coords, state, ui_path);
-}
-
 static void
 gimp_vector_tool_start (GimpVectorTool *vector_tool,
                         GimpDisplay    *display)


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