qulogic/libgnt

Box GntFile and GntTreeRow

2014-02-20, Ankit Vani
aa332bbcc67a
Box GntFile and GntTreeRow
  • +33 -0
    gntfilesel.c
  • +9 -0
    gntfilesel.h
  • +29 -0
    gnttree.c
  • +9 -0
    gnttree.h
  • --- a/gntfilesel.c Mon Feb 17 16:43:14 2014 +0100
    +++ b/gntfilesel.c Thu Feb 20 17:54:28 2014 +0530
    @@ -184,6 +184,8 @@
    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 @@
    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;
    +}
    --- a/gntfilesel.h Mon Feb 17 16:43:14 2014 +0100
    +++ b/gntfilesel.h Thu Feb 20 17:54:28 2014 +0530
    @@ -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 @@
    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.
    --- a/gnttree.c Mon Feb 17 16:43:14 2014 +0100
    +++ b/gnttree.c Thu Feb 20 17:54:28 2014 +0530
    @@ -1955,3 +1955,32 @@
    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;
    +}
    --- a/gnttree.h Mon Feb 17 16:43:14 2014 +0100
    +++ b/gnttree.h Thu Feb 20 17:54:28 2014 +0530
    @@ -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 @@
    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.