[gimp] app: move gimp_tools_blink_widget() as gimp_blink_dockable() in…



commit 5dcc833398c5adc5606f04bf2586b02a175a7373
Author: Jehan <jehan girinstud io>
Date:   Sat Mar 5 14:32:34 2022 +0100

    app: move gimp_tools_blink_widget() as gimp_blink_dockable() in…
    
    … gimpwidgets-utils.h.
    
    It just makes more sense, even in terms of #include-s which we'd need to
    make.

 app/tools/gimpbucketfilltool.c  |  3 +-
 app/tools/gimptools-utils.c     | 81 ---------------------------------------
 app/tools/gimptools-utils.h     |  4 --
 app/widgets/gimpwidgets-utils.c | 85 +++++++++++++++++++++++++++++++++++++++++
 app/widgets/gimpwidgets-utils.h |  4 ++
 5 files changed, 90 insertions(+), 87 deletions(-)
---
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index a507c51668..a8a279def3 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -632,8 +632,7 @@ gimp_bucket_fill_tool_button_press (GimpTool            *tool,
     {
       gimp_tool_message_literal (tool, display,
                                  _("No valid line art source selected."));
-      gimp_tools_blink_widget (display->gimp,
-                               "gimp-tool-options", "line-art-source");
+      gimp_blink_dockable (display->gimp, "gimp-tool-options", "line-art-source");
       return;
     }
 
diff --git a/app/tools/gimptools-utils.c b/app/tools/gimptools-utils.c
index f46858112a..8958e988c6 100644
--- a/app/tools/gimptools-utils.c
+++ b/app/tools/gimptools-utils.c
@@ -39,9 +39,6 @@
 #include "gimptools-utils.h"
 
 
-static void gimp_tools_search_widget_rec (GtkWidget   *widget,
-                                          const gchar *searched_id);
-
 
 /*  public functions  */
 
@@ -81,81 +78,3 @@ gimp_tools_blink_lock_box (Gimp     *gimp,
   view = GIMP_ITEM_TREE_VIEW (gtk_bin_get_child (GTK_BIN (dockable)));
   gimp_item_tree_view_blink_lock (view, item);
 }
-
-
-/**
- * gimp_tools_blink_widget:
- * @gimp:
- * @dockable_identifier:
- * @widget_identifier:
- *
- * This function will raise the dockable identified by
- * @dockable_identifier. The list of dockable identifiers can be found
- * in `app/dialogs/dialogs.c`.
- *
- * Then it will find the widget identified by @widget_identifier. Note
- * that for propwidgets, this is usually the associated property name.
- * Finally it will blink this widget to raise attention.
- */
-void
-gimp_tools_blink_widget (Gimp        *gimp,
-                         const gchar *dockable_identifier,
-                         const gchar *widget_identifier)
-{
-  GtkWidget  *dockable;
-  GdkMonitor *monitor;
-
-  g_return_if_fail (GIMP_IS_GIMP (gimp));
-
-  monitor = gimp_get_monitor_at_pointer ();
-
-  dockable = gimp_window_strategy_show_dockable_dialog (
-    GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
-    gimp,
-    gimp_dialog_factory_get_singleton (),
-    monitor,
-    dockable_identifier);
-
-  if (! dockable)
-    return;
-
-  gtk_container_foreach (GTK_CONTAINER (dockable),
-                         (GtkCallback) gimp_tools_search_widget_rec,
-                         (gpointer) widget_identifier);
-}
-
-
-/*  private functions  */
-
-static void
-gimp_tools_search_widget_rec (GtkWidget   *widget,
-                              const gchar *searched_id)
-{
-  if (gtk_widget_is_visible (widget))
-    {
-      const gchar *id;
-
-      id = g_object_get_data (G_OBJECT (widget),
-                              "gimp-widget-identifier");
-
-      if (id && g_strcmp0 (id, searched_id) == 0)
-        {
-          /* Giving focus to help scrolling the dockable so that the
-           * widget is visible. Note that it seems to work fine if the
-           * dockable was already present, not if it was just created.
-           *
-           * TODO: this should be fixed so that we always make the
-           * widget visible before blinking, otherwise it's a bit
-           * useless when this happens.
-           */
-          gtk_widget_grab_focus (widget);
-          gimp_widget_blink (widget);
-        }
-      else if (GTK_IS_CONTAINER (widget))
-        {
-          gtk_container_foreach (GTK_CONTAINER (widget),
-                                 (GtkCallback) gimp_tools_search_widget_rec,
-                                 (gpointer) searched_id);
-        }
-    }
-}
diff --git a/app/tools/gimptools-utils.h b/app/tools/gimptools-utils.h
index c2821fa888..5810f19ca6 100644
--- a/app/tools/gimptools-utils.h
+++ b/app/tools/gimptools-utils.h
@@ -22,9 +22,5 @@
 void   gimp_tools_blink_lock_box (Gimp     *gimp,
                                   GimpItem *item);
 
-void   gimp_tools_blink_widget   (Gimp        *gimp,
-                                  const gchar *dockable_identifier,
-                                  const gchar *widget_identifier);
-
 
 #endif  /* __GIMP_TOOLS_UTILS_H__ */
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 7ac5fd3189..51d301f545 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -51,6 +51,9 @@
 
 #include "gegl/gimp-babl.h"
 
+#include "core/gimp.h"
+
+#include "gimpaction.h"
 #include "gimpaction.h"
 #include "gimpdialogfactory.h"
 #include "gimpdock.h"
@@ -59,6 +62,7 @@
 #include "gimperrordialog.h"
 #include "gimpsessioninfo.h"
 #include "gimpwidgets-utils.h"
+#include "gimpwindowstrategy.h"
 
 #include "gimp-intl.h"
 
@@ -67,6 +71,10 @@
 #define GIMP_TOOL_OPTIONS_GUI_FUNC_KEY "gimp-tool-options-gui-func"
 
 
+static void         gimp_search_widget_rec         (GtkWidget            *widget,
+                                                    const gchar          *searched_id);
+
+
 GtkWidget *
 gimp_menu_item_get_image (GtkMenuItem *item)
 {
@@ -1474,6 +1482,47 @@ gimp_widget_blink_cancel (GtkWidget *widget)
     }
 }
 
+/**
+ * gimp_blink_dockable:
+ * @gimp:
+ * @dockable_identifier:
+ * @widget_identifier:
+ *
+ * This function will raise the dockable identified by
+ * @dockable_identifier. The list of dockable identifiers can be found
+ * in `app/dialogs/dialogs.c`.
+ *
+ * Then it will find the widget identified by @widget_identifier. Note
+ * that for propwidgets, this is usually the associated property name.
+ * Finally it will blink this widget to raise attention.
+ */
+void
+gimp_blink_dockable (Gimp        *gimp,
+                     const gchar *dockable_identifier,
+                     const gchar *widget_identifier)
+{
+  GtkWidget  *dockable;
+  GdkMonitor *monitor;
+
+  g_return_if_fail (GIMP_IS_GIMP (gimp));
+
+  monitor = gimp_get_monitor_at_pointer ();
+
+  dockable = gimp_window_strategy_show_dockable_dialog (
+    GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
+    gimp,
+    gimp_dialog_factory_get_singleton (),
+    monitor,
+    dockable_identifier);
+
+  if (! dockable)
+    return;
+
+  gtk_container_foreach (GTK_CONTAINER (dockable),
+                         (GtkCallback) gimp_search_widget_rec,
+                         (gpointer) widget_identifier);
+}
+
 /**
  * gimp_dock_with_window_new:
  * @factory: a #GimpDialogFacotry
@@ -1981,3 +2030,39 @@ gimp_widget_flush_expose (void)
   while (g_main_context_pending (NULL))
     g_main_context_iteration (NULL, FALSE);
 }
+
+
+/*  private functions  */
+
+static void
+gimp_search_widget_rec (GtkWidget   *widget,
+                        const gchar *searched_id)
+{
+  if (gtk_widget_is_visible (widget))
+    {
+      const gchar *id;
+
+      id = g_object_get_data (G_OBJECT (widget),
+                              "gimp-widget-identifier");
+
+      if (id && g_strcmp0 (id, searched_id) == 0)
+        {
+          /* Giving focus to help scrolling the dockable so that the
+           * widget is visible. Note that it seems to work fine if the
+           * dockable was already present, not if it was just created.
+           *
+           * TODO: this should be fixed so that we always make the
+           * widget visible before blinking, otherwise it's a bit
+           * useless when this happens.
+           */
+          gtk_widget_grab_focus (widget);
+          gimp_widget_blink (widget);
+        }
+      else if (GTK_IS_CONTAINER (widget))
+        {
+          gtk_container_foreach (GTK_CONTAINER (widget),
+                                 (GtkCallback) gimp_search_widget_rec,
+                                 (gpointer) searched_id);
+        }
+    }
+}
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index 6d1392fbc2..85a186a7bb 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -93,6 +93,10 @@ void              gimp_widget_blink_rect           (GtkWidget            *widget
                                                     GdkRectangle         *rect);
 void              gimp_widget_blink                (GtkWidget             *widget);
 void              gimp_widget_blink_cancel         (GtkWidget             *widget);
+void              gimp_blink_dockable              (Gimp                  *gimp,
+                                                    const gchar           *dockable_identifier,
+                                                    const gchar           *widget_identifier);
+
 
 GtkWidget       * gimp_dock_with_window_new        (GimpDialogFactory    *factory,
                                                     GdkMonitor           *monitor,


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