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.
This commit is contained in:
Michael Natterer 2019-08-07 22:48:06 +02:00
parent b2582e80f6
commit cbefd8e5bb
10 changed files with 142 additions and 103 deletions

View File

@ -202,7 +202,7 @@ dashboard_log_add_marker_cmd_callback (GimpAction *action,
NULL, NULL,
G_OBJECT (dashboard), "destroy", G_OBJECT (dashboard), "destroy",
(GimpQueryStringCallback) dashboard_log_add_marker_response, (GimpQueryStringCallback) dashboard_log_add_marker_response,
dashboard); dashboard, NULL);
dialogs_attach_dialog (G_OBJECT (dashboard), LOG_ADD_MARKER_KEY, dialog); dialogs_attach_dialog (G_OBJECT (dashboard), LOG_ADD_MARKER_KEY, dialog);

View File

@ -404,7 +404,8 @@ edit_named_cut_cmd_callback (GimpAction *action,
_("Enter a name for this buffer"), _("Enter a name for this buffer"),
NULL, NULL,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
cut_named_buffer_callback, image); cut_named_buffer_callback,
image, NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }
@ -425,7 +426,8 @@ edit_named_copy_cmd_callback (GimpAction *action,
_("Enter a name for this buffer"), _("Enter a name for this buffer"),
NULL, NULL,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
copy_named_buffer_callback, image); copy_named_buffer_callback,
image, NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }
@ -446,7 +448,8 @@ edit_named_copy_visible_cmd_callback (GimpAction *action,
_("Enter a name for this buffer"), _("Enter a name for this buffer"),
NULL, NULL,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
copy_named_visible_buffer_callback, image); copy_named_visible_buffer_callback,
image, NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }

View File

@ -377,7 +377,8 @@ file_create_template_cmd_callback (GimpAction *action,
_("Enter a name for this template"), _("Enter a name for this template"),
NULL, NULL,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
file_new_template_callback, image); file_new_template_callback,
image, NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }

View File

@ -89,7 +89,8 @@ palettes_merge_cmd_callback (GimpAction *action,
_("Enter a name for the merged palette"), _("Enter a name for the merged palette"),
NULL, NULL,
G_OBJECT (editor), "destroy", G_OBJECT (editor), "destroy",
palettes_merge_callback, editor); palettes_merge_callback,
editor, NULL);
dialogs_attach_dialog (G_OBJECT (editor), MERGE_DIALOG_KEY, dialog); dialogs_attach_dialog (G_OBJECT (editor), MERGE_DIALOG_KEY, dialog);
} }

View File

@ -169,7 +169,8 @@ select_feather_cmd_callback (GimpAction *action,
MIN (xres, yres), MIN (xres, yres),
FALSE, FALSE,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
select_feather_callback, image); select_feather_callback,
image, NULL);
/* Edge lock button */ /* Edge lock button */
button = gtk_check_button_new_with_mnemonic (_("_Selected areas continue outside the image")); 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), MIN (xres, yres),
FALSE, FALSE,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
select_shrink_callback, image); select_shrink_callback,
image, NULL);
/* Edge lock button */ /* Edge lock button */
button = gtk_check_button_new_with_mnemonic (_("_Selected areas continue outside the image")); 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), MIN (xres, yres),
FALSE, FALSE,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
select_grow_callback, image); select_grow_callback,
image, NULL);
dialogs_attach_dialog (G_OBJECT (image), GROW_DIALOG_KEY, dialog); dialogs_attach_dialog (G_OBJECT (image), GROW_DIALOG_KEY, dialog);
} }
@ -360,7 +363,8 @@ select_border_cmd_callback (GimpAction *action,
MIN (xres, yres), MIN (xres, yres),
FALSE, FALSE,
G_OBJECT (image), "disconnect", G_OBJECT (image), "disconnect",
select_border_callback, image); select_border_callback,
image, NULL);
/* Border style combo */ /* Border style combo */
combo = gimp_enum_combo_box_new (GIMP_TYPE_CHANNEL_BORDER_STYLE); combo = gimp_enum_combo_box_new (GIMP_TYPE_CHANNEL_BORDER_STYLE);

View File

@ -589,7 +589,8 @@ gimp_settings_box_favorite_activate (GtkWidget *widget,
_("Enter a name for the preset"), _("Enter a name for the preset"),
_("Saved Settings"), _("Saved Settings"),
G_OBJECT (toplevel), "hide", G_OBJECT (toplevel), "hide",
gimp_settings_box_favorite_callback, box); gimp_settings_box_favorite_callback,
box, NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }

View File

@ -60,13 +60,14 @@ typedef struct _QueryBox QueryBox;
struct _QueryBox struct _QueryBox
{ {
GtkWidget *qbox; GtkWidget *qbox;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *entry; GtkWidget *entry;
GObject *object; GObject *object;
gulong response_handler; gulong response_handler;
GCallback callback; GCallback callback;
gpointer callback_data; gpointer callback_data;
GDestroyNotify callback_data_destroy;
}; };
@ -82,7 +83,8 @@ static QueryBox * create_query_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GCallback callback, GCallback callback,
gpointer callback_data); gpointer callback_data,
GDestroyNotify callback_data_destroy);
static void query_box_disconnect (QueryBox *query_box); static void query_box_disconnect (QueryBox *query_box);
static void query_box_destroy (QueryBox *query_box); static void query_box_destroy (QueryBox *query_box);
@ -122,7 +124,8 @@ create_query_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GCallback callback, GCallback callback,
gpointer callback_data) gpointer callback_data,
GDestroyNotify callback_data_destroy)
{ {
QueryBox *query_box; QueryBox *query_box;
GtkWidget *hbox = NULL; GtkWidget *hbox = NULL;
@ -221,30 +224,32 @@ create_query_box (const gchar *title,
gtk_widget_show (label); gtk_widget_show (label);
} }
query_box->entry = NULL; query_box->entry = NULL;
query_box->object = object; query_box->object = object;
query_box->callback = callback; query_box->callback = callback;
query_box->callback_data = callback_data; query_box->callback_data = callback_data;
query_box->callback_data_destroy = callback_data_destroy;
return query_box; return query_box;
} }
/** /**
* gimp_query_string_box: * gimp_query_string_box:
* @title: The query box dialog's title. * @title: The query box dialog's title.
* @parent: The dialog's parent widget. * @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. * @help_id: A string identifying this dialog's help page.
* @message: A string which will be shown above the dialog's entry widget. * @message: A string which will be shown above the dialog's entry widget.
* @initial: The initial value. * @initial: The initial value.
* @object: The object this query box is associated with. * @object: The object this query box is associated with.
* @signal: The object's signal which will cause the query box to be closed. * @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". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @data: The callback's user data.
* @data_destroy: Destroy function for @data.
* *
* Creates a new #GtkDialog that queries the user for a string value. * 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 * GtkWidget *
gimp_query_string_box (const gchar *title, gimp_query_string_box (const gchar *title,
@ -256,7 +261,8 @@ gimp_query_string_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryStringCallback callback, GimpQueryStringCallback callback,
gpointer data) gpointer data,
GDestroyNotify data_destroy)
{ {
QueryBox *query_box; QueryBox *query_box;
GtkWidget *entry; GtkWidget *entry;
@ -267,7 +273,8 @@ gimp_query_string_box (const gchar *title,
message, message,
_("_OK"), _("_Cancel"), _("_OK"), _("_Cancel"),
object, signal, object, signal,
G_CALLBACK (callback), data); G_CALLBACK (callback),
data, data_destroy);
if (! query_box) if (! query_box)
return NULL; return NULL;
@ -286,22 +293,23 @@ gimp_query_string_box (const gchar *title,
/** /**
* gimp_query_int_box: * gimp_query_int_box:
* @title: The query box dialog's title. * @title: The query box dialog's title.
* @parent: The dialog's parent widget. * @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. * @help_id: A string identifying this dialog's help page.
* @message: A string which will be shown above the dialog's entry widget. * @message: A string which will be shown above the dialog's entry widget.
* @initial: The initial value. * @initial: The initial value.
* @lower: The lower boundary of the range of possible values. * @lower: The lower boundary of the range of possible values.
* @upper: The upper boundray 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. * @object: The object this query box is associated with.
* @signal: The object's signal which will cause the query box to be closed. * @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". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @data: The callback's user data.
* @data_destroy: Destroy function for @data.
* *
* Creates a new #GtkDialog that queries the user for an integer value. * 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 * GtkWidget *
gimp_query_int_box (const gchar *title, gimp_query_int_box (const gchar *title,
@ -315,7 +323,8 @@ gimp_query_int_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryIntCallback callback, GimpQueryIntCallback callback,
gpointer data) gpointer data,
GDestroyNotify data_destroy)
{ {
QueryBox *query_box; QueryBox *query_box;
GtkWidget *spinbutton; GtkWidget *spinbutton;
@ -327,7 +336,8 @@ gimp_query_int_box (const gchar *title,
message, message,
_("_OK"), _("_Cancel"), _("_OK"), _("_Cancel"),
object, signal, object, signal,
G_CALLBACK (callback), data); G_CALLBACK (callback),
data, data_destroy);
if (! query_box) if (! query_box)
return NULL; return NULL;
@ -347,23 +357,24 @@ gimp_query_int_box (const gchar *title,
/** /**
* gimp_query_double_box: * gimp_query_double_box:
* @title: The query box dialog's title. * @title: The query box dialog's title.
* @parent: The dialog's parent widget. * @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. * @help_id: A string identifying this dialog's help page.
* @message: A string which will be shown above the dialog's entry widget. * @message: A string which will be shown above the dialog's entry widget.
* @initial: The initial value. * @initial: The initial value.
* @lower: The lower boundary of the range of possible values. * @lower: The lower boundary of the range of possible values.
* @upper: The upper boundray 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. * @digits: The number of decimal digits the #GtkSpinButton will provide.
* @object: The object this query box is associated with. * @object: The object this query box is associated with.
* @signal: The object's signal which will cause the query box to be closed. * @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". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @data: The callback's user data.
* @data_destroy: Destroy function for @data.
* *
* Creates a new #GtkDialog that queries the user for a double value. * 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 * GtkWidget *
gimp_query_double_box (const gchar *title, gimp_query_double_box (const gchar *title,
@ -378,7 +389,8 @@ gimp_query_double_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryDoubleCallback callback, GimpQueryDoubleCallback callback,
gpointer data) gpointer data,
GDestroyNotify data_destroy)
{ {
QueryBox *query_box; QueryBox *query_box;
GtkWidget *spinbutton; GtkWidget *spinbutton;
@ -390,7 +402,8 @@ gimp_query_double_box (const gchar *title,
message, message,
_("_OK"), _("_Cancel"), _("_OK"), _("_Cancel"),
object, signal, object, signal,
G_CALLBACK (callback), data); G_CALLBACK (callback),
data, data_destroy);
if (! query_box) if (! query_box)
return NULL; return NULL;
@ -410,30 +423,31 @@ gimp_query_double_box (const gchar *title,
/** /**
* gimp_query_size_box: * gimp_query_size_box:
* @title: The query box dialog's title. * @title: The query box dialog's title.
* @parent: The dialog's parent widget. * @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. * @help_id: A string identifying this dialog's help page.
* @message: A string which will be shown above the dialog's entry widget. * @message: A string which will be shown above the dialog's entry widget.
* @initial: The initial value. * @initial: The initial value.
* @lower: The lower boundary of the range of possible values. * @lower: The lower boundary of the range of possible values.
* @upper: The upper boundray 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 * @digits: The number of decimal digits the #GimpSizeEntry provide in
* "pixel" mode. * "pixel" mode.
* @unit: The unit initially shown by the #GimpUnitMenu. * @unit: The unit initially shown by the #GimpUnitMenu.
* @resolution: The resolution (in dpi) which will be used for pixel/unit * @resolution: The resolution (in dpi) which will be used for pixel/unit
* calculations. * calculations.
* @dot_for_dot: %TRUE if the #GimpUnitMenu's initial unit should be "pixels". * @dot_for_dot: %TRUE if the #GimpUnitMenu's initial unit should be "pixels".
* @object: The object this query box is associated with. * @object: The object this query box is associated with.
* @signal: The object's signal which will cause the query box * @signal: The object's signal which will cause the query box
* to be closed. * to be closed.
* @callback: The function which will be called when the user selects "OK". * @callback: The function which will be called when the user selects "OK".
* @data: The callback's user data. * @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 * Creates a new #GtkDialog that queries the user for a size using a
* #GimpSizeEntry. * #GimpSizeEntry.
* *
* Returns: A pointer to the new #GtkDialog. * Returns: (transfer full): A pointer to the new #GtkDialog.
**/ **/
GtkWidget * GtkWidget *
gimp_query_size_box (const gchar *title, gimp_query_size_box (const gchar *title,
@ -451,7 +465,8 @@ gimp_query_size_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQuerySizeCallback callback, GimpQuerySizeCallback callback,
gpointer data) gpointer data,
GDestroyNotify data_destroy)
{ {
QueryBox *query_box; QueryBox *query_box;
GtkWidget *sizeentry; GtkWidget *sizeentry;
@ -463,7 +478,8 @@ gimp_query_size_box (const gchar *title,
message, message,
_("_OK"), _("_Cancel"), _("_OK"), _("_Cancel"),
object, signal, object, signal,
G_CALLBACK (callback), data); G_CALLBACK (callback),
data, data_destroy);
if (! query_box) if (! query_box)
return NULL; return NULL;
@ -495,7 +511,7 @@ gimp_query_size_box (const gchar *title,
* gimp_query_boolean_box: * gimp_query_boolean_box:
* @title: The query box dialog's title. * @title: The query box dialog's title.
* @parent: The dialog's parent widget. * @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. * @help_id: A string identifying this dialog's help page.
* @icon_name: An icon name to specify an icon to appear on the left * @icon_name: An icon name to specify an icon to appear on the left
* on the dialog's message. * 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 * @callback: The function which will be called when the user clicks one
* of the buttons. * of the buttons.
* @data: The callback's user data. * @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. * 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 * GtkWidget *
gimp_query_boolean_box (const gchar *title, gimp_query_boolean_box (const gchar *title,
@ -525,7 +542,8 @@ gimp_query_boolean_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryBooleanCallback callback, GimpQueryBooleanCallback callback,
gpointer data) gpointer data,
GDestroyNotify data_destroy)
{ {
QueryBox *query_box; QueryBox *query_box;
@ -535,7 +553,8 @@ gimp_query_boolean_box (const gchar *title,
message, message,
true_button, false_button, true_button, false_button,
object, signal, object, signal,
G_CALLBACK (callback), data); G_CALLBACK (callback),
data, data_destroy);
if (! query_box) if (! query_box)
return NULL; return NULL;
@ -576,6 +595,9 @@ query_box_destroy (QueryBox *query_box)
if (query_box->qbox) if (query_box->qbox)
gtk_widget_destroy (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); g_slice_free (QueryBox, query_box);
} }

View File

@ -115,7 +115,8 @@ GtkWidget * gimp_query_string_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryStringCallback callback, GimpQueryStringCallback callback,
gpointer data); gpointer data,
GDestroyNotify data_destroy);
GtkWidget * gimp_query_int_box (const gchar *title, GtkWidget * gimp_query_int_box (const gchar *title,
GtkWidget *parent, GtkWidget *parent,
@ -128,7 +129,8 @@ GtkWidget * gimp_query_int_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryIntCallback callback, GimpQueryIntCallback callback,
gpointer data); gpointer data,
GDestroyNotify data_destroy);
GtkWidget * gimp_query_double_box (const gchar *title, GtkWidget * gimp_query_double_box (const gchar *title,
GtkWidget *parent, GtkWidget *parent,
@ -142,7 +144,8 @@ GtkWidget * gimp_query_double_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryDoubleCallback callback, GimpQueryDoubleCallback callback,
gpointer data); gpointer data,
GDestroyNotify data_destroy);
GtkWidget * gimp_query_size_box (const gchar *title, GtkWidget * gimp_query_size_box (const gchar *title,
GtkWidget *parent, GtkWidget *parent,
@ -159,7 +162,8 @@ GtkWidget * gimp_query_size_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQuerySizeCallback callback, GimpQuerySizeCallback callback,
gpointer data); gpointer data,
GDestroyNotify data_destroy);
GtkWidget * gimp_query_boolean_box (const gchar *title, GtkWidget * gimp_query_boolean_box (const gchar *title,
GtkWidget *parent, GtkWidget *parent,
@ -172,7 +176,8 @@ GtkWidget * gimp_query_boolean_box (const gchar *title,
GObject *object, GObject *object,
const gchar *signal, const gchar *signal,
GimpQueryBooleanCallback callback, GimpQueryBooleanCallback callback,
gpointer data); gpointer data,
GDestroyNotify data_destroy);
G_END_DECLS G_END_DECLS

View File

@ -750,7 +750,7 @@ delete_fractal_callback (GtkWidget *widget,
_("_Delete"), _("_Cancel"), _("_Delete"), _("_Cancel"),
G_OBJECT (widget), "destroy", G_OBJECT (widget), "destroy",
delete_dialog_callback, delete_dialog_callback,
data); data, NULL);
g_free (str); g_free (str);
gtk_widget_show (delete_dialog); gtk_widget_show (delete_dialog);

View File

@ -3137,7 +3137,8 @@ dlg_selector_new_callback (GtkWidget *widget,
_("Enter a name for the new GFlare"), _("Enter a name for the new GFlare"),
_("Unnamed"), _("Unnamed"),
NULL, NULL, NULL, NULL,
dlg_selector_new_ok_callback, dlg); dlg_selector_new_ok_callback,
dlg, NULL);
gtk_widget_show (query_box); gtk_widget_show (query_box);
} }
@ -3216,7 +3217,8 @@ dlg_selector_copy_callback (GtkWidget *widget,
_("Enter a name for the copied GFlare"), _("Enter a name for the copied GFlare"),
name, name,
NULL, NULL, NULL, NULL,
dlg_selector_copy_ok_callback, dlg); dlg_selector_copy_ok_callback,
dlg, NULL);
g_free (name); g_free (name);
gtk_widget_show (query_box); gtk_widget_show (query_box);
@ -3284,7 +3286,7 @@ dlg_selector_delete_callback (GtkWidget *widget,
_("_Delete"), _("_Cancel"), _("_Delete"), _("_Cancel"),
NULL, NULL, NULL, NULL,
dlg_selector_do_delete_callback, dlg_selector_do_delete_callback,
NULL); NULL, NULL);
g_free (str); g_free (str);