[gtk+] Add boxed type and constructor
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add boxed type and constructor
- Date: Fri, 15 Oct 2010 17:57:29 +0000 (UTC)
commit 18578b33c59c2c4c5852cab9cda03f087a28dbc3
Author: Colin Walters <walters verbum org>
Date: Fri Oct 15 13:54:37 2010 -0400
Add boxed type and constructor
This allows bindings to sanely construct these.
https://bugzilla.gnome.org/show_bug.cgi?id=632095
docs/reference/gtk/gtk3-sections.txt | 3 +
gtk/gtk.symbols | 3 +
gtk/gtkselection.c | 68 +++++++++++++++++++++++++++++++++-
gtk/gtkselection.h | 6 +++
4 files changed, 79 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index c9ebabb..3456543 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -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
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 9c29d73..48ca796 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -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
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index 0a18fba..fc0f031 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -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)
diff --git a/gtk/gtkselection.h b/gtk/gtkselection.h
index ae689d5..ac9b082 100644
--- a/gtk/gtkselection.h
+++ b/gtk/gtkselection.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]