TnyGtkFolderStoreTreeModel

TnyGtkFolderStoreTreeModel — A tree model for folder store instances that lets a tree view show folders recursively

Synopsis




#define             TNY_TYPE_GTK_FOLDER_STORE_TREE_MODEL_COLUMN
                    TnyGtkFolderStoreTreeModel;
GType               tny_gtk_folder_store_tree_model_column_get_type
                                                        (void);
GtkTreeModel*       tny_gtk_folder_store_tree_model_new (TnyFolderStoreQuery *query);
void                tny_gtk_folder_store_tree_model_prepend
                                                        (TnyGtkFolderStoreTreeModel *self,
                                                         TnyFolderStore *item,
                                                         const gchar *root_name);
void                tny_gtk_folder_store_tree_model_append
                                                        (TnyGtkFolderStoreTreeModel *self,
                                                         TnyFolderStore *item,
                                                         const gchar *root_name);
void                tny_gtk_folder_store_tree_model_stop_observing
                                                        (TnyGtkFolderStoreTreeModel *self);

Object Hierarchy


  GObject
   +----GtkTreeStore
         +----TnyGtkFolderStoreTreeModel

Implemented Interfaces

TnyGtkFolderStoreTreeModel implements TnyFolderObserver, GtkBuildable, GtkTreeModel, TnyList, GtkTreeDragSource, GtkTreeDragDest, GtkTreeSortable and TnyFolderStoreObserver.

Description

A GtkTreeModel implementation for storing TnyFolderStore instances.

The implementation inherits the GtkTreeStore, implements GtkTreeModel and TnyList. It recursively walks the folders of folder store instances that get added. Using it as a model for a GtkTreeView it will display both the account name as parent row, in case the folder store being added is of type TnyAccount, with the account's folders as the child rows and the folder's child folders as sub-child rows.

It's very important to unreference the instance you will get when doing something like this:

TnyFolder *folder;
gtk_tree_model_get (model, &iter,
  TNY_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN,
  &folder, -1);
/* use folder */
g_object_unref (G_OBJECT(folder));

The column is indeed a G_TYPE_OBJECT column and getting it from the GtkTreeModel will indeed add a reference.

Using the TNY_GTK_FOLDER_STORE_TREE_MODEL_TYPE_COLUMN you can know what type of instance you will get when using the TNY_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN. If its value isn't TNY_FOLDER_TYPE_ROOT, the instance type will be a TnyFolder , if it is the instance type will be a TnyAccount. Read more about the available columns and folders-types at the TnyGtkFolderStoreTreeModelColumn, the TnyFolderType and the TnyFolder types.

Example:

TnyFolderType type;
gtk_tree_model_get (model, &iter,
  TNY_GTK_FOLDER_STORE_TREE_MODEL_TYPE_COLUMN,
  &type, -1);
if (type != TNY_FOLDER_TYPE_ROOT)
{
    TnyFolder *folder;
    gtk_tree_model_get (model, &iter,
      TNY_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN,
      &folder, -1);
    /* use folder */
    g_object_unref (G_OBJECT(folder));
} else {
    TnyAccount *account;
    gtk_tree_model_get (model, &iter,
      TNY_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN,
      &account, -1);
    /* use account */
    g_object_unref (G_OBJECT(account));
}

Details

TNY_TYPE_GTK_FOLDER_STORE_TREE_MODEL_COLUMN

#define TNY_TYPE_GTK_FOLDER_STORE_TREE_MODEL_COLUMN (tny_gtk_folder_store_tree_model_column_get_type())


TnyGtkFolderStoreTreeModel

typedef struct _TnyGtkFolderStoreTreeModel TnyGtkFolderStoreTreeModel;


tny_gtk_folder_store_tree_model_column_get_type ()

GType               tny_gtk_folder_store_tree_model_column_get_type
                                                        (void);

GType system helper function

Returns : a GType

tny_gtk_folder_store_tree_model_new ()

GtkTreeModel*       tny_gtk_folder_store_tree_model_new (TnyFolderStoreQuery *query);

Create a new GtkTreeModel instance suitable for showing TnyFolderStore instances

query : the TnyFolderStoreQuery that will be used to retrieve the folders of each folder_store
Returns : a new GtkTreeModel instance suitable for showing TnyFolderStore instances

tny_gtk_folder_store_tree_model_prepend ()

void                tny_gtk_folder_store_tree_model_prepend
                                                        (TnyGtkFolderStoreTreeModel *self,
                                                         TnyFolderStore *item,
                                                         const gchar *root_name);

Prepends an item to the model

self : A TnyGtkFolderStoreTreeModel instance
item : A TnyFolderStore instance to add
root_name : The node's root name

tny_gtk_folder_store_tree_model_append ()

void                tny_gtk_folder_store_tree_model_append
                                                        (TnyGtkFolderStoreTreeModel *self,
                                                         TnyFolderStore *item,
                                                         const gchar *root_name);

Appends an item to the model

self : A TnyGtkFolderStoreTreeModel instance
item : A TnyFolderStore instance to add
root_name : The node's root name

tny_gtk_folder_store_tree_model_stop_observing ()

void                tny_gtk_folder_store_tree_model_stop_observing
                                                        (TnyGtkFolderStoreTreeModel *self);

self :

See Also

TnyList, TnyStoreAccount, TnyFolderStore, GtkTreeView, GtkTreeStore, GtkTreeModel, TnyGtkAccountTreeModelColumn