[gimp] libgimpwidgets: add a GDestroyNotify for gimp_help_connect()'s user_data



commit 55940b733b43910a540c53ec13d01fa49165d0ae
Author: Michael Natterer <mitch gimp org>
Date:   Fri Aug 9 13:11:30 2019 +0200

    libgimpwidgets: add a GDestroyNotify for gimp_help_connect()'s user_data

 app/actions/dashboard-commands.c     |  2 +-
 app/actions/error-console-commands.c |  2 +-
 app/actions/gradients-commands.c     |  2 +-
 app/display/gimpdisplayshell.c       |  2 +-
 app/widgets/gimpdockbook.c           |  2 +-
 app/widgets/gimpdockwindow.c         |  2 +-
 app/widgets/gimpfiledialog.c         |  3 ++-
 app/widgets/gimpsettingsbox.c        |  2 +-
 app/widgets/gimptoolbox.c            |  2 +-
 libgimpwidgets/gimpdialog.c          |  2 +-
 libgimpwidgets/gimphelpui.c          | 23 +++++++++++++----------
 libgimpwidgets/gimphelpui.h          | 27 ++++++++++++++-------------
 plug-ins/common/animation-play.c     |  2 +-
 plug-ins/imagemap/imap_main.c        |  2 +-
 plug-ins/print/print-page-layout.c   |  2 +-
 15 files changed, 41 insertions(+), 36 deletions(-)
---
diff --git a/app/actions/dashboard-commands.c b/app/actions/dashboard-commands.c
index 156720730d..e54c242f49 100644
--- a/app/actions/dashboard-commands.c
+++ b/app/actions/dashboard-commands.c
@@ -154,7 +154,7 @@ dashboard_log_record_cmd_callback (GimpAction *action,
                             NULL);
 
           gimp_help_connect (dialog, gimp_standard_help_func,
-                             GIMP_HELP_DASHBOARD_LOG_RECORD, NULL);
+                             GIMP_HELP_DASHBOARD_LOG_RECORD, NULL, NULL);
 
           dialogs_attach_dialog (G_OBJECT (dashboard), LOG_RECORD_KEY, dialog);
 
diff --git a/app/actions/error-console-commands.c b/app/actions/error-console-commands.c
index 6e3b2ec8da..c37c143bc9 100644
--- a/app/actions/error-console-commands.c
+++ b/app/actions/error-console-commands.c
@@ -129,7 +129,7 @@ error_console_save_cmd_callback (GimpAction *action,
                         NULL);
 
       gimp_help_connect (dialog, gimp_standard_help_func,
-                         GIMP_HELP_ERRORS_DIALOG, NULL);
+                         GIMP_HELP_ERRORS_DIALOG, NULL, NULL);
     }
 
   gtk_window_present (GTK_WINDOW (console->file_dialog));
diff --git a/app/actions/gradients-commands.c b/app/actions/gradients-commands.c
index a79dc1baa9..60609df42e 100644
--- a/app/actions/gradients-commands.c
+++ b/app/actions/gradients-commands.c
@@ -112,7 +112,7 @@ gradients_save_as_pov_ray_cmd_callback (GimpAction *action,
                                G_CONNECT_SWAPPED);
 
       gimp_help_connect (dialog, gimp_standard_help_func,
-                         GIMP_HELP_GRADIENT_SAVE_AS_POV, NULL);
+                         GIMP_HELP_GRADIENT_SAVE_AS_POV, NULL, NULL);
 
       dialogs_attach_dialog (G_OBJECT (gradient),
                              SAVE_AS_POV_DIALOG_KEY, dialog);
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 9beed2df36..edf197c4b3 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -388,7 +388,7 @@ gimp_display_shell_init (GimpDisplayShell *shell)
                     shell);
 
   gimp_help_connect (GTK_WIDGET (shell), gimp_standard_help_func,
-                     GIMP_HELP_IMAGE_WINDOW, NULL);
+                     GIMP_HELP_IMAGE_WINDOW, NULL, NULL);
 }
 
 static void
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index 476f754c03..428f0c9f78 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -624,7 +624,7 @@ gimp_dockbook_new (GimpMenuFactory *menu_factory)
                                                            dockbook);
 
   gimp_help_connect (GTK_WIDGET (dockbook), gimp_dockbook_help_func,
-                     GIMP_HELP_DOCK, dockbook);
+                     GIMP_HELP_DOCK, dockbook, NULL);
 
   return GTK_WIDGET (dockbook);
 }
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index b602549630..ac63c96c29 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -453,7 +453,7 @@ gimp_dock_window_constructed (GObject *object)
                 NULL);
 
   gimp_help_connect (GTK_WIDGET (dock_window), gimp_standard_help_func,
-                     GIMP_HELP_DOCK, NULL);
+                     GIMP_HELP_DOCK, NULL, NULL);
 
   if (dock_window->p->auto_follow_active)
     {
diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c
index d679424f5b..08481b2be0 100644
--- a/app/widgets/gimpfiledialog.c
+++ b/app/widgets/gimpfiledialog.c
@@ -341,7 +341,8 @@ gimp_file_dialog_constructed (GObject *object)
   if (dialog->help_id)
     {
       gimp_help_connect (GTK_WIDGET (dialog),
-                         gimp_file_dialog_help_func, dialog->help_id, dialog);
+                         gimp_file_dialog_help_func, dialog->help_id,
+                         dialog, NULL);
 
       if (GIMP_GUI_CONFIG (dialog->gimp->config)->show_help_button)
         {
diff --git a/app/widgets/gimpsettingsbox.c b/app/widgets/gimpsettingsbox.c
index 7c59b5ac7c..fe80d7932c 100644
--- a/app/widgets/gimpsettingsbox.c
+++ b/app/widgets/gimpsettingsbox.c
@@ -766,7 +766,7 @@ gimp_settings_box_file_dialog (GimpSettingsBox *box,
                                private->last_file, NULL);
 
   gimp_help_connect (private->file_dialog, gimp_standard_help_func,
-                     private->help_id, NULL);
+                     private->help_id, NULL, NULL);
 
   /*  allow callbacks to add widgets to the dialog  */
   g_signal_emit (box, settings_box_signals[FILE_DIALOG_SETUP], 0,
diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c
index 660da92ffa..a5d4d50f10 100644
--- a/app/widgets/gimptoolbox.c
+++ b/app/widgets/gimptoolbox.c
@@ -173,7 +173,7 @@ gimp_toolbox_init (GimpToolbox *toolbox)
   toolbox->p = gimp_toolbox_get_instance_private (toolbox);
 
   gimp_help_connect (GTK_WIDGET (toolbox), gimp_standard_help_func,
-                     GIMP_HELP_TOOLBOX, NULL);
+                     GIMP_HELP_TOOLBOX, NULL, NULL);
 }
 
 static void
diff --git a/libgimpwidgets/gimpdialog.c b/libgimpwidgets/gimpdialog.c
index 7315ce9118..53f973cfe3 100644
--- a/libgimpwidgets/gimpdialog.c
+++ b/libgimpwidgets/gimpdialog.c
@@ -169,7 +169,7 @@ gimp_dialog_constructed (GObject *object)
   if (private->help_func)
     gimp_help_connect (GTK_WIDGET (object),
                        private->help_func, private->help_id,
-                       object);
+                       object, NULL);
 
   if (show_help_button && private->help_func && private->help_id)
     {
diff --git a/libgimpwidgets/gimphelpui.c b/libgimpwidgets/gimphelpui.c
index 236ee2a40e..e42195b547 100644
--- a/libgimpwidgets/gimphelpui.c
+++ b/libgimpwidgets/gimphelpui.c
@@ -103,21 +103,23 @@ gimp_standard_help_func (const gchar *help_id,
 
 /**
  * gimp_help_connect:
- * @widget: The widget you want to connect the help accelerator for. Will
- *          be a #GtkWindow in most cases.
- * @help_func: The function which will be called if the user presses "F1".
- * @help_id:   The @help_id which will be passed to @help_func.
- * @help_data: The @help_data pointer which will be passed to @help_func.
+ * @widget:            The widget you want to connect the help accelerator for.
+ *                     Will be a #GtkWindow in most cases.
+ * @help_func:         The function which will be called if the user presses "F1".
+ * @help_id:           The @help_id which will be passed to @help_func.
+ * @help_data:         The @help_data pointer which will be passed to @help_func.
+ * @help_data_destroy: Destroy function for @help_data.
  *
  * Note that this function is automatically called by all libgimp dialog
  * constructors. You only have to call it for windows/dialogs you created
  * "manually".
  **/
 void
-gimp_help_connect (GtkWidget    *widget,
-                   GimpHelpFunc  help_func,
-                   const gchar  *help_id,
-                   gpointer      help_data)
+gimp_help_connect (GtkWidget      *widget,
+                   GimpHelpFunc    help_func,
+                   const gchar    *help_id,
+                   gpointer        help_data,
+                   GDestroyNotify  help_data_destroy)
 {
   static gboolean initialized = FALSE;
 
@@ -147,7 +149,8 @@ gimp_help_connect (GtkWidget    *widget,
 
   gimp_help_set_help_data (widget, NULL, help_id);
 
-  g_object_set_data (G_OBJECT (widget), "gimp-help-data", help_data);
+  g_object_set_data_full (G_OBJECT (widget), "gimp-help-data",
+                          help_data, help_data_destroy);
 
   g_signal_connect (widget, "show-help",
                     G_CALLBACK (gimp_help_callback),
diff --git a/libgimpwidgets/gimphelpui.h b/libgimpwidgets/gimphelpui.h
index 75c7eed024..a1313a10f2 100644
--- a/libgimpwidgets/gimphelpui.h
+++ b/libgimpwidgets/gimphelpui.h
@@ -33,27 +33,28 @@ G_BEGIN_DECLS
 
 /*  the standard gimp help function
  */
-void   gimp_standard_help_func             (const gchar  *help_id,
-                                            gpointer      help_data);
+void   gimp_standard_help_func             (const gchar    *help_id,
+                                            gpointer        help_data);
 
 /*  connect the help callback of a window  */
-void   gimp_help_connect                   (GtkWidget    *widget,
-                                            GimpHelpFunc  help_func,
-                                            const gchar  *help_id,
-                                            gpointer      help_data);
+void   gimp_help_connect                   (GtkWidget      *widget,
+                                            GimpHelpFunc    help_func,
+                                            const gchar    *help_id,
+                                            gpointer        help_data,
+                                            GDestroyNotify  help_data_destroy);
 
 /*  set help data for non-window widgets  */
-void   gimp_help_set_help_data             (GtkWidget    *widget,
-                                            const gchar  *tooltip,
-                                            const gchar  *help_id);
+void   gimp_help_set_help_data             (GtkWidget      *widget,
+                                            const gchar    *tooltip,
+                                            const gchar    *help_id);
 
 /*  set help data with markup for non-window widgets  */
-void   gimp_help_set_help_data_with_markup (GtkWidget   *widget,
-                                            const gchar *tooltip,
-                                            const gchar *help_id);
+void   gimp_help_set_help_data_with_markup (GtkWidget      *widget,
+                                            const gchar    *tooltip,
+                                            const gchar    *help_id);
 
 /*  activate the context help inspector  */
-void   gimp_context_help                   (GtkWidget    *widget);
+void   gimp_context_help                   (GtkWidget      *widget);
 
 
 /**
diff --git a/plug-ins/common/animation-play.c b/plug-ins/common/animation-play.c
index 22126ae28f..fd9d33e436 100644
--- a/plug-ins/common/animation-play.c
+++ b/plug-ins/common/animation-play.c
@@ -769,7 +769,7 @@ build_dialog (gchar *imagename)
                     G_CALLBACK (popup_menu),
                     NULL);
 
-  gimp_help_connect (window, gimp_standard_help_func, PLUG_IN_PROC, NULL);
+  gimp_help_connect (window, gimp_standard_help_func, PLUG_IN_PROC, NULL, NULL);
 
   ui_manager = ui_manager_new (window);
 
diff --git a/plug-ins/imagemap/imap_main.c b/plug-ins/imagemap/imap_main.c
index 9286e4980b..6c21f87641 100644
--- a/plug-ins/imagemap/imap_main.c
+++ b/plug-ins/imagemap/imap_main.c
@@ -1224,7 +1224,7 @@ dialog(gint32 drawable_id)
    gtk_window_set_resizable(GTK_WINDOW(dlg), TRUE);
 
    main_set_title(NULL);
-   gimp_help_connect (dlg, gimp_standard_help_func, PLUG_IN_PROC, NULL);
+   gimp_help_connect (dlg, gimp_standard_help_func, PLUG_IN_PROC, NULL, NULL);
 
    gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
 
diff --git a/plug-ins/print/print-page-layout.c b/plug-ins/print/print-page-layout.c
index e5d070a4db..159d46aaca 100644
--- a/plug-ins/print/print-page-layout.c
+++ b/plug-ins/print/print-page-layout.c
@@ -200,7 +200,7 @@ print_page_layout_gui (PrintData   *data,
                            G_CALLBACK (update_custom_widget),
                            main_hbox, 0);
 
-  gimp_help_connect (main_hbox, gimp_standard_help_func, help_id, NULL);
+  gimp_help_connect (main_hbox, gimp_standard_help_func, help_id, NULL, NULL);
 
   return main_hbox;
 }


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