/pidgin/main: f1831b0421b2: Box GntFile and GntTreeRow
Ankit Vani
a at nevitus.org
Thu Feb 20 07:24:46 EST 2014
Changeset: f1831b0421b20a6a80190960f50d063528b5b80d
Author: Ankit Vani <a at nevitus.org>
Date: 2014-02-20 17:54 +0530
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/f1831b0421b2
Description:
Box GntFile and GntTreeRow
diffstat:
finch/libgnt/gntfilesel.c | 33 +++++++++++++++++++++++++++++++++
finch/libgnt/gntfilesel.h | 9 +++++++++
finch/libgnt/gnttree.c | 29 +++++++++++++++++++++++++++++
finch/libgnt/gnttree.h | 9 +++++++++
4 files changed, 80 insertions(+), 0 deletions(-)
diffs (136 lines):
diff --git a/finch/libgnt/gntfilesel.c b/finch/libgnt/gntfilesel.c
--- a/finch/libgnt/gntfilesel.c
+++ b/finch/libgnt/gntfilesel.c
@@ -184,6 +184,8 @@ local_read_fn(const char *path, GList **
static void
gnt_file_free(GntFile *file)
{
+ g_return_if_fail(file != NULL);
+
g_free(file->fullpath);
g_free(file->basename);
g_free(file);
@@ -685,4 +687,35 @@ void gnt_file_sel_set_read_fn(GntFileSel
sel->read_fn = read_fn;
}
+/**************************************************************************
+ * GntFile GBoxed API
+ **************************************************************************/
+static GntFile *
+gnt_file_copy(GntFile *file)
+{
+ GntFile *file_new;
+ g_return_val_if_fail(file != NULL, NULL);
+
+ file_new = g_new(GntFile, 1);
+ *file_new = *file;
+
+ file_new->fullpath = g_strdup(file->fullpath);
+ file_new->basename = g_strdup(file->basename);
+
+ return file_new;
+}
+
+GType
+gnt_file_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("GntFile",
+ (GBoxedCopyFunc)gnt_file_copy,
+ (GBoxedFreeFunc)gnt_file_free);
+ }
+
+ return type;
+}
diff --git a/finch/libgnt/gntfilesel.h b/finch/libgnt/gntfilesel.h
--- a/finch/libgnt/gntfilesel.h
+++ b/finch/libgnt/gntfilesel.h
@@ -45,6 +45,8 @@
#define GNT_FILE_SEL_SET_FLAGS(obj, flags) (GNT_FILE_SEL_FLAGS(obj) |= flags)
#define GNT_FILE_SEL_UNSET_FLAGS(obj, flags) (GNT_FILE_SEL_FLAGS(obj) &= ~(flags))
+#define GNT_TYPE_FILE (gnt_file_get_type())
+
typedef struct _GntFileSel GntFileSel;
typedef struct _GntFileSelPriv GntFileSelPriv;
typedef struct _GntFileSelClass GntFileSelClass;
@@ -109,6 +111,13 @@ G_BEGIN_DECLS
GType gnt_file_sel_get_type(void);
/**
+ * gnt_file_get_type:
+ *
+ * Returns: The #GType for the #GntFile boxed structure.
+ */
+GType gnt_file_get_type(void);
+
+/**
* gnt_file_sel_new:
*
* Create a new file selector.
diff --git a/finch/libgnt/gnttree.c b/finch/libgnt/gnttree.c
--- a/finch/libgnt/gnttree.c
+++ b/finch/libgnt/gnttree.c
@@ -1955,3 +1955,32 @@ GntTreeRow * gnt_tree_row_get_parent(Gnt
return row->parent;
}
+/**************************************************************************
+ * GntTreeRow GBoxed API
+ **************************************************************************/
+static GntTreeRow *
+copy_tree_row(GntTreeRow *row)
+{
+ GntTreeRow *row_new;
+
+ g_return_val_if_fail(row != NULL, NULL);
+
+ row_new = g_new(GntTreeRow, 1);
+ *row_new = *row;
+
+ return row_new;
+}
+
+GType
+gnt_tree_row_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("GntTreeRow",
+ (GBoxedCopyFunc)copy_tree_row,
+ (GBoxedFreeFunc)free_tree_row);
+ }
+
+ return type;
+}
diff --git a/finch/libgnt/gnttree.h b/finch/libgnt/gnttree.h
--- a/finch/libgnt/gnttree.h
+++ b/finch/libgnt/gnttree.h
@@ -42,6 +42,8 @@
#define GNT_IS_TREE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_TREE))
#define GNT_TREE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_TREE, GntTreeClass))
+#define GNT_TYPE_TREE_ROW (gnt_tree_row_get_type())
+
typedef guint (*GntTreeHashFunc)(gconstpointer);
typedef gboolean (*GntTreeHashEqualityFunc)(gconstpointer, gconstpointer);
@@ -118,6 +120,13 @@ G_BEGIN_DECLS
GType gnt_tree_get_type(void);
/**
+ * gnt_tree_row_get_type:
+ *
+ * Returns: The #GType for the #GntTreeRow boxed structure.
+ */
+GType gnt_tree_row_get_type(void);
+
+/**
* gnt_tree_new:
*
* Create a tree with one column.
More information about the Commits
mailing list