## FmDirTreeModel FmDirTreeModel — A model for directory tree view |

## Functions

void | fm_dir_tree_model_add_root ()
guint | fm_dir_tree_model_get_icon_size ()
gboolean | fm_dir_tree_model_get_show_hidden ()
void | fm_dir_tree_model_load_row ()
FmDirTreeModel * | fm_dir_tree_model_new ()
void | fm_dir_tree_model_set_icon_size ()
void | fm_dir_tree_model_set_show_hidden ()
void | fm_dir_tree_model_unload_row ()
const char * | fm_dir_tree_row_get_disp_name ()
FmFileInfo * | fm_dir_tree_row_get_file_info ()
FmPath * | fm_dir_tree_row_get_file_path ()
GdkPixbuf * | fm_dir_tree_row_get_icon ()
gboolean | fm_dir_tree_row_is_loaded ()

## Signals

void | row-loaded | Run First

## Types and Values

struct | FmDirTreeModel
struct | FmDirTreeModelClass
enum | FmDirTreeModelCol

## Object Hierarchy

        GObject
        ╰── FmDirTreeModel

## Implemented Interfaces

FmDirTreeModel implements GtkTreeModel.

## Description

`include` : libfm/fm-gtk.h

The FmDirTreeModel represents tree of folders which can be used by FmDirTreeView to create tree-like expandable list of directories.

## Functions

### fm_dir_tree_model_add_root ()

    void
    fm_dir_tree_model_add_root (FmDirTreeModel *model,
                                FmFileInfo *root,
                                GtkTreeIter *iter);

Adds a root node for file `root` into `model` . If `iter` is not `NULL` then on return it will be set to new row data.

#### Parameters

model | the model instance |
root | a root path to add |
iter | pointer to iterator to set. | [allow-none]

Since: 0.1.16

### fm_dir_tree_model_get_icon_size ()

    guint
    fm_dir_tree_model_get_icon_size (FmDirTreeModel *model);

Retrieves size of icons which are associated with rows.

Before 1.0.0 this API had name fm_dir_tree_get_icon_size.

#### Parameters

model | the model instance |

#### Returns

preferrable icom size for the `model` .

Since: 0.1.16

### fm_dir_tree_model_get_show_hidden ()

    gboolean
    fm_dir_tree_model_get_show_hidden (FmDirTreeModel *model);

### fm_dir_tree_model_load_row ()

    void
    fm_dir_tree_model_load_row (FmDirTreeModel *model,
                                GtkTreeIter *it,
                                GtkTreePath *tp);

If row with iterator `it` has its children already retrieved then does nothing. Else starts retrieving of list of children for row with iterator `it` and path `tp` . When children are loaded then a “row-loaded” signal will be emitted. The folder associated with the row will be monitored for changes in children after that. This API is used when the row is expanded in the view.

Before 1.0.0 this API had name fm_dir_tree_model_expand_row.

See also: `fm_dir_tree_row_is_loaded()`, `fm_dir_tree_model_unload_row()`.

#### Parameters

model | the model instance |
it | iterator of row to load |
tp | path of row to load |

Since: 0.1.16

### fm_dir_tree_model_new ()

    FmDirTreeModel *
    fm_dir_tree_model_new (void);

Creates new FmDirTreeModel instance.

#### Returns

a new FmDirTreeModel object.

Since: 0.1.16

### fm_dir_tree_model_set_icon_size ()

    void
    fm_dir_tree_model_set_icon_size (FmDirTreeModel *model,
                                     guint icon_size);

Sets size of icons which are associated with rows.

#### Parameters

model | the model instance |
icon_size | new preferrable icon size |

Since: 0.1.16

### fm_dir_tree_model_set_show_hidden ()

    void
    fm_dir_tree_model_set_show_hidden (FmDirTreeModel *model,
                                       gboolean show_hidden);

### fm_dir_tree_model_unload_row ()

    void
    fm_dir_tree_model_unload_row (FmDirTreeModel *model,
                                  GtkTreeIter *it,
                                  GtkTreePath *tp);

If children of row with iterator `it` are retrieved or monitored then stops monitoring the folder and forgets children of the row. This API is used when the row is collapsed in the view.

Before 1.0.0 this API had name fm_dir_tree_model_collapse_row.

#### Parameters

model | the model instance |
it | iterator of row to unload |
tp | path of row to unload |

Since: 0.1.16

### fm_dir_tree_row_get_disp_name ()

    const char *
    fm_dir_tree_row_get_disp_name (FmDirTreeModel *model,
                                   GtkTreeIter *iter);

Retrieves display name of file associated with row of `iter` in `model` . Returned data are owned by `model` and should be not freed by caller.

#### Parameters

model | the model instance |
iter | the iterator of row to retrieve data |

#### Returns

the file display name for the row.

[transfer none]

Since: 1.0.0

### fm_dir_tree_row_get_file_info ()

    FmFileInfo *
    fm_dir_tree_row_get_file_info (FmDirTreeModel *model,
                                   GtkTreeIter *iter);

Retrieves info for file associated with row of `iter` in `model` . Returned data are owned by `model` and should be not freed by caller.

#### Parameters

model | the model instance |
iter | the iterator of row to retrieve data |

#### Returns

the file info for the row.

[transfer none]

Since: 1.0.0

### fm_dir_tree_row_get_file_path ()

    FmPath *
    fm_dir_tree_row_get_file_path (FmDirTreeModel *model,
                                   GtkTreeIter *iter);

Retrieves FmPath for file associated with row of `iter` in `model` . Returned data are owned by `model` and should be not freed by caller.

#### Parameters

model | the model instance |
iter | the iterator of row to retrieve data |

#### Returns

the file path for the row.

[transfer none]

Since: 1.0.0

### fm_dir_tree_row_get_icon ()

    GdkPixbuf *
    fm_dir_tree_row_get_icon (FmDirTreeModel *model,
                              GtkTreeIter *iter);

Retrieves an icon associated with row of `iter` in `model` . Returned data are owned by `model` and should be not freed by caller.

#### Parameters

model | the model instance |
iter | the iterator of row to retrieve data |

#### Returns

the icon for the row.

[transfer none]

Since: 1.0.0

### fm_dir_tree_row_is_loaded ()

    gboolean
    fm_dir_tree_row_is_loaded (FmDirTreeModel *model,
                               GtkTreeIter *iter);

Checks if the row has its children already retrieved. This check may need be done since any duplicate calls to `fm_dir_tree_model_load_row()` will not emit any duplicate “row-loaded” signal.

#### Parameters

model | the model instance |
iter | the iterator of row to inspect |

#### Returns

`TRUE` if the row has children already loaded.

Since: 1.0.0

## Types and Values

### struct FmDirTreeModel

    struct FmDirTreeModel;

### struct FmDirTreeModelClass

    struct FmDirTreeModelClass {
        GObjectClass parent_class;
        void (*row_loaded)(FmDirTreeModel* model, GtkTreePath* row);
    };

#### Members

`row_loaded` () | the class closure for the “row-loaded” signal |

### enum FmDirTreeModelCol

Columns of dir tree model

#### Members

FM_DIR_TREE_MODEL_COL_ICON | (GdkPixbuf *) icon |
FM_DIR_TREE_MODEL_COL_DISP_NAME | (char *) displayed name |
FM_DIR_TREE_MODEL_COL_INFO | (FmFileInfo *) file info |
FM_DIR_TREE_MODEL_COL_PATH | (FmPath *) file path |
FM_DIR_TREE_MODEL_COL_FOLDER | (FmFolder *) folder object |

## Signal Details

### The `“row-loaded”` signal

    void
    user_function (FmDirTreeModel *model,
                   GtkTreePath    *row,
                   gpointer        user_data)

The “row-loaded” signal is emitted when content of folder `row` is completely retrieved. It may happen either after call to `fm_dir_tree_model_load_row()` or in time of that call (in case if the folder was already cached in memory).

See also: `fm_dir_tree_model_unload_row()`.

#### Parameters

model | dir tree model instance that received the signal |
row | path to folder row that is ready |
user_data | user data set when the signal handler was connected. |

Flags: Run First

Since: 1.0.0