Commit 18578b33 authored by Colin Walters's avatar Colin Walters Committed by Matthias Clasen
Browse files

Add boxed type and constructor

This allows bindings to sanely construct these.

https://bugzilla.gnome.org/show_bug.cgi?id=632095
parent f87023d8
......@@ -5319,6 +5319,9 @@ GtkRcContext
GtkTargetEntry
GtkTargetList
GtkTargetPair
gtk_target_entry_new
gtk_target_entry_copy
gtk_target_entry_free
gtk_target_list_new
gtk_target_list_ref
gtk_target_list_unref
......
......@@ -2972,7 +2972,10 @@ gtk_target_list_ref
gtk_target_list_remove
gtk_target_list_unref
gtk_target_table_new_from_list
gtk_target_entry_get_type G_GNUC_CONST
gtk_target_table_free
gtk_target_entry_new
gtk_target_entry_copy
#endif
#endif
......
......@@ -3116,6 +3116,68 @@ gtk_selection_data_free (GtkSelectionData *data)
g_slice_free (GtkSelectionData, data);
}
/**
* gtk_target_entry_new:
* @target: String identifier for target
* @flags: Set of flags, see #GtkTargetFlags
* @info: an ID that will be passed back to the application
*
* Makes a new #GtkTargetEntry structure.
*
* Return value: a pointer to a new GtkTargetEntry structure.
* Free with gtk_target_entry_free()
**/
GtkTargetEntry *
gtk_target_entry_new (const char *target,
guint flags,
guint info)
{
GtkTargetEntry entry = { target, flags, info };
return gtk_target_entry_copy (&entry);
}
/**
* gtk_target_entry_copy:
* @data: a pointer to a #GtkTargetEntry structure.
*
* Makes a copy of a #GtkTargetEntry structure and its data.
*
* Return value: a pointer to a copy of @data.
* Free with gtk_target_entry_free()
**/
GtkTargetEntry *
gtk_target_entry_copy (GtkTargetEntry *data)
{
GtkTargetEntry *new_data;
g_return_val_if_fail (data != NULL, NULL);
new_data = g_slice_new (GtkTargetEntry);
new_data->target = g_strdup (data->target);
new_data->flags = data->flags;
new_data->info = data->info;
return new_data;
}
/**
* gtk_target_entry_free:
* @data: a pointer to a #GtkTargetEntry structure.
*
* Frees a #GtkTargetEntry structure returned from
* gtk_target_entry_new() or gtk_target_entry_copy().
**/
void
gtk_target_entry_free (GtkTargetEntry *data)
{
g_return_if_fail (data != NULL);
g_free (data->target);
g_slice_free (GtkTargetEntry, data);
}
G_DEFINE_BOXED_TYPE (GtkSelectionData, gtk_selection_data,
gtk_selection_data_copy,
gtk_selection_data_free)
......@@ -3124,7 +3186,11 @@ G_DEFINE_BOXED_TYPE (GtkTargetList, gtk_target_list,
gtk_target_list_ref,
gtk_target_list_unref)
static int
G_DEFINE_BOXED_TYPE (GtkTargetEntry, gtk_target_entry,
gtk_target_entry_copy,
gtk_target_entry_free)
static int
gtk_selection_bytes_per_item (gint format)
{
switch (format)
......
......@@ -212,6 +212,12 @@ GType gtk_selection_data_get_type (void) G_GNUC_CONST;
GtkSelectionData *gtk_selection_data_copy (GtkSelectionData *data);
void gtk_selection_data_free (GtkSelectionData *data);
GType gtk_target_entry_get_type (void) G_GNUC_CONST;
GtkTargetEntry *gtk_target_entry_new (const char *target, guint flags, guint info);
GtkTargetEntry *gtk_target_entry_copy (GtkTargetEntry *data);
void gtk_target_entry_free (GtkTargetEntry *data);
GType gtk_target_list_get_type (void) G_GNUC_CONST;
G_END_DECLS
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment