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

@ -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);
}

View File

@ -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