From cbefd8e5bb1b8e581fb9bc3ecc00cbe2b9ee30a7 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 7 Aug 2019 22:48:06 +0200 Subject: [PATCH] libgimpwidgets: add GDestroyNotify for gimp_query_foo_box() user_data This is ugly shit that should go down the canal but let's just fix these GI warnings. --- app/actions/dashboard-commands.c | 2 +- app/actions/edit-commands.c | 9 +- app/actions/file-commands.c | 3 +- app/actions/palettes-commands.c | 3 +- app/actions/select-commands.c | 12 +- app/widgets/gimpsettingsbox.c | 3 +- libgimpwidgets/gimpquerybox.c | 188 +++++++++++-------- libgimpwidgets/gimpquerybox.h | 15 +- plug-ins/fractal-explorer/fractal-explorer.c | 2 +- plug-ins/gradient-flare/gradient-flare.c | 8 +- 10 files changed, 142 insertions(+), 103 deletions(-) diff --git a/app/actions/dashboard-commands.c b/app/actions/dashboard-commands.c index 18fc35b0a9..156720730d 100644 --- a/app/actions/dashboard-commands.c +++ b/app/actions/dashboard-commands.c @@ -202,7 +202,7 @@ dashboard_log_add_marker_cmd_callback (GimpAction *action, NULL, G_OBJECT (dashboard), "destroy", (GimpQueryStringCallback) dashboard_log_add_marker_response, - dashboard); + dashboard, NULL); dialogs_attach_dialog (G_OBJECT (dashboard), LOG_ADD_MARKER_KEY, dialog); diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c index 51d7dc5fe4..8e43e3f473 100644 --- a/app/actions/edit-commands.c +++ b/app/actions/edit-commands.c @@ -404,7 +404,8 @@ edit_named_cut_cmd_callback (GimpAction *action, _("Enter a name for this buffer"), NULL, G_OBJECT (image), "disconnect", - cut_named_buffer_callback, image); + cut_named_buffer_callback, + image, NULL); gtk_widget_show (dialog); } @@ -425,7 +426,8 @@ edit_named_copy_cmd_callback (GimpAction *action, _("Enter a name for this buffer"), NULL, G_OBJECT (image), "disconnect", - copy_named_buffer_callback, image); + copy_named_buffer_callback, + image, NULL); gtk_widget_show (dialog); } @@ -446,7 +448,8 @@ edit_named_copy_visible_cmd_callback (GimpAction *action, _("Enter a name for this buffer"), NULL, G_OBJECT (image), "disconnect", - copy_named_visible_buffer_callback, image); + copy_named_visible_buffer_callback, + image, NULL); gtk_widget_show (dialog); } diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c index 66a81feab6..00a8f37fc5 100644 --- a/app/actions/file-commands.c +++ b/app/actions/file-commands.c @@ -377,7 +377,8 @@ file_create_template_cmd_callback (GimpAction *action, _("Enter a name for this template"), NULL, G_OBJECT (image), "disconnect", - file_new_template_callback, image); + file_new_template_callback, + image, NULL); gtk_widget_show (dialog); } diff --git a/app/actions/palettes-commands.c b/app/actions/palettes-commands.c index 2287acc5f2..238e07753f 100644 --- a/app/actions/palettes-commands.c +++ b/app/actions/palettes-commands.c @@ -89,7 +89,8 @@ palettes_merge_cmd_callback (GimpAction *action, _("Enter a name for the merged palette"), NULL, G_OBJECT (editor), "destroy", - palettes_merge_callback, editor); + palettes_merge_callback, + editor, NULL); dialogs_attach_dialog (G_OBJECT (editor), MERGE_DIALOG_KEY, dialog); } diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c index 13ba60ea9c..c32595029d 100644 --- a/app/actions/select-commands.c +++ b/app/actions/select-commands.c @@ -169,7 +169,8 @@ select_feather_cmd_callback (GimpAction *action, MIN (xres, yres), FALSE, G_OBJECT (image), "disconnect", - select_feather_callback, image); + select_feather_callback, + image, NULL); /* Edge lock button */ button = gtk_check_button_new_with_mnemonic (_("_Selected areas continue outside the image")); @@ -245,7 +246,8 @@ select_shrink_cmd_callback (GimpAction *action, MIN (xres, yres), FALSE, G_OBJECT (image), "disconnect", - select_shrink_callback, image); + select_shrink_callback, + image, NULL); /* Edge lock button */ button = gtk_check_button_new_with_mnemonic (_("_Selected areas continue outside the image")); @@ -308,7 +310,8 @@ select_grow_cmd_callback (GimpAction *action, MIN (xres, yres), FALSE, G_OBJECT (image), "disconnect", - select_grow_callback, image); + select_grow_callback, + image, NULL); dialogs_attach_dialog (G_OBJECT (image), GROW_DIALOG_KEY, dialog); } @@ -360,7 +363,8 @@ select_border_cmd_callback (GimpAction *action, MIN (xres, yres), FALSE, G_OBJECT (image), "disconnect", - select_border_callback, image); + select_border_callback, + image, NULL); /* Border style combo */ combo = gimp_enum_combo_box_new (GIMP_TYPE_CHANNEL_BORDER_STYLE); diff --git a/app/widgets/gimpsettingsbox.c b/app/widgets/gimpsettingsbox.c index 08a8d6418f..7c59b5ac7c 100644 --- a/app/widgets/gimpsettingsbox.c +++ b/app/widgets/gimpsettingsbox.c @@ -589,7 +589,8 @@ gimp_settings_box_favorite_activate (GtkWidget *widget, _("Enter a name for the preset"), _("Saved Settings"), G_OBJECT (toplevel), "hide", - gimp_settings_box_favorite_callback, box); + gimp_settings_box_favorite_callback, + box, NULL); gtk_widget_show (dialog); } diff --git a/libgimpwidgets/gimpquerybox.c b/libgimpwidgets/gimpquerybox.c index 31f9a0de04..3adf4b85d6 100644 --- a/libgimpwidgets/gimpquerybox.c +++ b/libgimpwidgets/gimpquerybox.c @@ -60,13 +60,14 @@ typedef struct _QueryBox QueryBox; struct _QueryBox { - GtkWidget *qbox; - GtkWidget *vbox; - GtkWidget *entry; - GObject *object; - gulong response_handler; - GCallback callback; - gpointer callback_data; + GtkWidget *qbox; + GtkWidget *vbox; + GtkWidget *entry; + GObject *object; + gulong response_handler; + GCallback callback; + gpointer callback_data; + GDestroyNotify callback_data_destroy; }; @@ -82,7 +83,8 @@ static QueryBox * create_query_box (const gchar *title, GObject *object, const gchar *signal, GCallback callback, - gpointer callback_data); + gpointer callback_data, + GDestroyNotify callback_data_destroy); static void query_box_disconnect (QueryBox *query_box); static void query_box_destroy (QueryBox *query_box); @@ -122,7 +124,8 @@ create_query_box (const gchar *title, GObject *object, const gchar *signal, GCallback callback, - gpointer callback_data) + gpointer callback_data, + GDestroyNotify callback_data_destroy) { QueryBox *query_box; GtkWidget *hbox = NULL; @@ -221,30 +224,32 @@ create_query_box (const gchar *title, gtk_widget_show (label); } - query_box->entry = NULL; - query_box->object = object; - query_box->callback = callback; - query_box->callback_data = callback_data; + query_box->entry = NULL; + query_box->object = object; + query_box->callback = callback; + query_box->callback_data = callback_data; + query_box->callback_data_destroy = callback_data_destroy; return query_box; } /** * gimp_query_string_box: - * @title: The query box dialog's title. - * @parent: The dialog's parent widget. - * @help_func: The help function to show this dialog's help page. - * @help_id: A string identifying this dialog's help page. - * @message: A string which will be shown above the dialog's entry widget. - * @initial: The initial value. - * @object: The object this query box is associated with. - * @signal: The object's signal which will cause the query box to be closed. - * @callback: The function which will be called when the user selects "OK". - * @data: The callback's user data. + * @title: The query box dialog's title. + * @parent: The dialog's parent widget. + * @help_func: (scope async): The help function to show this dialog's help page. + * @help_id: A string identifying this dialog's help page. + * @message: A string which will be shown above the dialog's entry widget. + * @initial: The initial value. + * @object: The object this query box is associated with. + * @signal: The object's signal which will cause the query box to be closed. + * @callback: The function which will be called when the user selects "OK". + * @data: The callback's user data. + * @data_destroy: Destroy function for @data. * * Creates a new #GtkDialog that queries the user for a string value. * - * Returns: A pointer to the new #GtkDialog. + * Returns: (transfer full): A pointer to the new #GtkDialog. **/ GtkWidget * gimp_query_string_box (const gchar *title, @@ -256,7 +261,8 @@ gimp_query_string_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryStringCallback callback, - gpointer data) + gpointer data, + GDestroyNotify data_destroy) { QueryBox *query_box; GtkWidget *entry; @@ -267,7 +273,8 @@ gimp_query_string_box (const gchar *title, message, _("_OK"), _("_Cancel"), object, signal, - G_CALLBACK (callback), data); + G_CALLBACK (callback), + data, data_destroy); if (! query_box) return NULL; @@ -286,22 +293,23 @@ gimp_query_string_box (const gchar *title, /** * gimp_query_int_box: - * @title: The query box dialog's title. - * @parent: The dialog's parent widget. - * @help_func: The help function to show this dialog's help page. - * @help_id: A string identifying this dialog's help page. - * @message: A string which will be shown above the dialog's entry widget. - * @initial: The initial value. - * @lower: The lower boundary of the range of possible values. - * @upper: The upper boundray of the range of possible values. - * @object: The object this query box is associated with. - * @signal: The object's signal which will cause the query box to be closed. - * @callback: The function which will be called when the user selects "OK". - * @data: The callback's user data. + * @title: The query box dialog's title. + * @parent: The dialog's parent widget. + * @help_func: (scope async): The help function to show this dialog's help page. + * @help_id: A string identifying this dialog's help page. + * @message: A string which will be shown above the dialog's entry widget. + * @initial: The initial value. + * @lower: The lower boundary of the range of possible values. + * @upper: The upper boundray of the range of possible values. + * @object: The object this query box is associated with. + * @signal: The object's signal which will cause the query box to be closed. + * @callback: The function which will be called when the user selects "OK". + * @data: The callback's user data. + * @data_destroy: Destroy function for @data. * * Creates a new #GtkDialog that queries the user for an integer value. * - * Returns: A pointer to the new #GtkDialog. + * Returns: (transfer full): A pointer to the new #GtkDialog. **/ GtkWidget * gimp_query_int_box (const gchar *title, @@ -315,7 +323,8 @@ gimp_query_int_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryIntCallback callback, - gpointer data) + gpointer data, + GDestroyNotify data_destroy) { QueryBox *query_box; GtkWidget *spinbutton; @@ -327,7 +336,8 @@ gimp_query_int_box (const gchar *title, message, _("_OK"), _("_Cancel"), object, signal, - G_CALLBACK (callback), data); + G_CALLBACK (callback), + data, data_destroy); if (! query_box) return NULL; @@ -347,23 +357,24 @@ gimp_query_int_box (const gchar *title, /** * gimp_query_double_box: - * @title: The query box dialog's title. - * @parent: The dialog's parent widget. - * @help_func: The help function to show this dialog's help page. - * @help_id: A string identifying this dialog's help page. - * @message: A string which will be shown above the dialog's entry widget. - * @initial: The initial value. - * @lower: The lower boundary of the range of possible values. - * @upper: The upper boundray of the range of possible values. - * @digits: The number of decimal digits the #GtkSpinButton will provide. - * @object: The object this query box is associated with. - * @signal: The object's signal which will cause the query box to be closed. - * @callback: The function which will be called when the user selects "OK". - * @data: The callback's user data. + * @title: The query box dialog's title. + * @parent: The dialog's parent widget. + * @help_func: (scope async): The help function to show this dialog's help page. + * @help_id: A string identifying this dialog's help page. + * @message: A string which will be shown above the dialog's entry widget. + * @initial: The initial value. + * @lower: The lower boundary of the range of possible values. + * @upper: The upper boundray of the range of possible values. + * @digits: The number of decimal digits the #GtkSpinButton will provide. + * @object: The object this query box is associated with. + * @signal: The object's signal which will cause the query box to be closed. + * @callback: The function which will be called when the user selects "OK". + * @data: The callback's user data. + * @data_destroy: Destroy function for @data. * * Creates a new #GtkDialog that queries the user for a double value. * - * Returns: A pointer to the new #GtkDialog. + * Returns: (transfer full): A pointer to the new #GtkDialog. **/ GtkWidget * gimp_query_double_box (const gchar *title, @@ -378,7 +389,8 @@ gimp_query_double_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryDoubleCallback callback, - gpointer data) + gpointer data, + GDestroyNotify data_destroy) { QueryBox *query_box; GtkWidget *spinbutton; @@ -390,7 +402,8 @@ gimp_query_double_box (const gchar *title, message, _("_OK"), _("_Cancel"), object, signal, - G_CALLBACK (callback), data); + G_CALLBACK (callback), + data, data_destroy); if (! query_box) return NULL; @@ -410,30 +423,31 @@ gimp_query_double_box (const gchar *title, /** * gimp_query_size_box: - * @title: The query box dialog's title. - * @parent: The dialog's parent widget. - * @help_func: The help function to show this dialog's help page. - * @help_id: A string identifying this dialog's help page. - * @message: A string which will be shown above the dialog's entry widget. - * @initial: The initial value. - * @lower: The lower boundary of the range of possible values. - * @upper: The upper boundray of the range of possible values. - * @digits: The number of decimal digits the #GimpSizeEntry provide in - * "pixel" mode. - * @unit: The unit initially shown by the #GimpUnitMenu. - * @resolution: The resolution (in dpi) which will be used for pixel/unit - * calculations. - * @dot_for_dot: %TRUE if the #GimpUnitMenu's initial unit should be "pixels". - * @object: The object this query box is associated with. - * @signal: The object's signal which will cause the query box - * to be closed. - * @callback: The function which will be called when the user selects "OK". - * @data: The callback's user data. + * @title: The query box dialog's title. + * @parent: The dialog's parent widget. + * @help_func: (scope async): The help function to show this dialog's help page. + * @help_id: A string identifying this dialog's help page. + * @message: A string which will be shown above the dialog's entry widget. + * @initial: The initial value. + * @lower: The lower boundary of the range of possible values. + * @upper: The upper boundray of the range of possible values. + * @digits: The number of decimal digits the #GimpSizeEntry provide in + * "pixel" mode. + * @unit: The unit initially shown by the #GimpUnitMenu. + * @resolution: The resolution (in dpi) which will be used for pixel/unit + * calculations. + * @dot_for_dot: %TRUE if the #GimpUnitMenu's initial unit should be "pixels". + * @object: The object this query box is associated with. + * @signal: The object's signal which will cause the query box + * to be closed. + * @callback: The function which will be called when the user selects "OK". + * @data: The callback's user data. + * @data_destroy: Destroy function for @data. * * Creates a new #GtkDialog that queries the user for a size using a * #GimpSizeEntry. * - * Returns: A pointer to the new #GtkDialog. + * Returns: (transfer full): A pointer to the new #GtkDialog. **/ GtkWidget * gimp_query_size_box (const gchar *title, @@ -451,7 +465,8 @@ gimp_query_size_box (const gchar *title, GObject *object, const gchar *signal, GimpQuerySizeCallback callback, - gpointer data) + gpointer data, + GDestroyNotify data_destroy) { QueryBox *query_box; GtkWidget *sizeentry; @@ -463,7 +478,8 @@ gimp_query_size_box (const gchar *title, message, _("_OK"), _("_Cancel"), object, signal, - G_CALLBACK (callback), data); + G_CALLBACK (callback), + data, data_destroy); if (! query_box) return NULL; @@ -495,7 +511,7 @@ gimp_query_size_box (const gchar *title, * gimp_query_boolean_box: * @title: The query box dialog's title. * @parent: The dialog's parent widget. - * @help_func: The help function to show this dialog's help page. + * @help_func: (scope async): The help function to show this dialog's help page. * @help_id: A string identifying this dialog's help page. * @icon_name: An icon name to specify an icon to appear on the left * on the dialog's message. @@ -508,10 +524,11 @@ gimp_query_size_box (const gchar *title, * @callback: The function which will be called when the user clicks one * of the buttons. * @data: The callback's user data. + * @data_destroy: Destroy function for @data. * * Creates a new #GtkDialog that asks the user to do a boolean decision. * - * Returns: A pointer to the new #GtkDialog. + * Returns: (transfer full): A pointer to the new #GtkDialog. **/ GtkWidget * gimp_query_boolean_box (const gchar *title, @@ -525,7 +542,8 @@ gimp_query_boolean_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryBooleanCallback callback, - gpointer data) + gpointer data, + GDestroyNotify data_destroy) { QueryBox *query_box; @@ -535,7 +553,8 @@ gimp_query_boolean_box (const gchar *title, message, true_button, false_button, object, signal, - G_CALLBACK (callback), data); + G_CALLBACK (callback), + data, data_destroy); if (! query_box) return NULL; @@ -576,6 +595,9 @@ query_box_destroy (QueryBox *query_box) if (query_box->qbox) gtk_widget_destroy (query_box->qbox); + if (query_box->callback_data_destroy) + query_box->callback_data_destroy (query_box->callback_data); + g_slice_free (QueryBox, query_box); } diff --git a/libgimpwidgets/gimpquerybox.h b/libgimpwidgets/gimpquerybox.h index 3535629041..4b69439c63 100644 --- a/libgimpwidgets/gimpquerybox.h +++ b/libgimpwidgets/gimpquerybox.h @@ -115,7 +115,8 @@ GtkWidget * gimp_query_string_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryStringCallback callback, - gpointer data); + gpointer data, + GDestroyNotify data_destroy); GtkWidget * gimp_query_int_box (const gchar *title, GtkWidget *parent, @@ -128,7 +129,8 @@ GtkWidget * gimp_query_int_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryIntCallback callback, - gpointer data); + gpointer data, + GDestroyNotify data_destroy); GtkWidget * gimp_query_double_box (const gchar *title, GtkWidget *parent, @@ -142,7 +144,8 @@ GtkWidget * gimp_query_double_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryDoubleCallback callback, - gpointer data); + gpointer data, + GDestroyNotify data_destroy); GtkWidget * gimp_query_size_box (const gchar *title, GtkWidget *parent, @@ -159,7 +162,8 @@ GtkWidget * gimp_query_size_box (const gchar *title, GObject *object, const gchar *signal, GimpQuerySizeCallback callback, - gpointer data); + gpointer data, + GDestroyNotify data_destroy); GtkWidget * gimp_query_boolean_box (const gchar *title, GtkWidget *parent, @@ -172,7 +176,8 @@ GtkWidget * gimp_query_boolean_box (const gchar *title, GObject *object, const gchar *signal, GimpQueryBooleanCallback callback, - gpointer data); + gpointer data, + GDestroyNotify data_destroy); G_END_DECLS diff --git a/plug-ins/fractal-explorer/fractal-explorer.c b/plug-ins/fractal-explorer/fractal-explorer.c index 00c7d2fb53..b9c2017da7 100644 --- a/plug-ins/fractal-explorer/fractal-explorer.c +++ b/plug-ins/fractal-explorer/fractal-explorer.c @@ -750,7 +750,7 @@ delete_fractal_callback (GtkWidget *widget, _("_Delete"), _("_Cancel"), G_OBJECT (widget), "destroy", delete_dialog_callback, - data); + data, NULL); g_free (str); gtk_widget_show (delete_dialog); diff --git a/plug-ins/gradient-flare/gradient-flare.c b/plug-ins/gradient-flare/gradient-flare.c index ca4ae734a1..3c89db03f2 100644 --- a/plug-ins/gradient-flare/gradient-flare.c +++ b/plug-ins/gradient-flare/gradient-flare.c @@ -3137,7 +3137,8 @@ dlg_selector_new_callback (GtkWidget *widget, _("Enter a name for the new GFlare"), _("Unnamed"), NULL, NULL, - dlg_selector_new_ok_callback, dlg); + dlg_selector_new_ok_callback, + dlg, NULL); gtk_widget_show (query_box); } @@ -3216,7 +3217,8 @@ dlg_selector_copy_callback (GtkWidget *widget, _("Enter a name for the copied GFlare"), name, NULL, NULL, - dlg_selector_copy_ok_callback, dlg); + dlg_selector_copy_ok_callback, + dlg, NULL); g_free (name); gtk_widget_show (query_box); @@ -3284,7 +3286,7 @@ dlg_selector_delete_callback (GtkWidget *widget, _("_Delete"), _("_Cancel"), NULL, NULL, dlg_selector_do_delete_callback, - NULL); + NULL, NULL); g_free (str);