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);

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;

A GtkTreeModel for TnyFolderStore instances that'll become TnyFolderStoreObserver and TnyFolderObserver (in case the TnyFolderStore instance is a TnyFolder too) of each added TnyFolderStore and each of its children en grandchildren (recursively).

It will detect changes in the instance's tree structure this way and it will adapt itself to a new situation automatically. It also contains columns that contain certain popular numbers (like the unread and the total counts of TnyFolder instances).

Note that a TnyGtkFolderStoreTreeModel is a TnyList too. You can use the TnyList API on instances of this type too.

Note that you must make sure that you unreference TnyFolderStore instances that you get out of the instance column of this type using the GtkTreeModel API gtk_tree_model_get().

free-function: g_object_unref


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 for showing TnyFolderStore instances

query : the TnyFolderStoreQuery that will be used to retrieve the child folders of each TnyFolderStore
Returns : (caller-owns): a new GtkTreeModel for TnyFolderStore instances

Since 1.0 audience: application-developer


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
item : a TnyFolderStore to add
root_name : The node's root name

Since 1.0 audience: application-developer


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
item : a TnyFolderStore to add
root_name : The node's root name

Since 1.0 audience: application-developer

See Also

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