Libfm

From LXDE.org
Jump to: navigation, search

Introduction

A glib/gio-based library providing some file management utilities and related-widgets missing in gtk+/glib. This is the core of PCManFM. The library is desktop independent (not LXDE specific) and has clean API. It can be used to develop other applications requiring file management functionality. For example, you can create your own file manager with facilities provided by libfm.

Features

How To Use

Here is a simple gtk+ program demonstrating how to show the content of your home directory with libfm.

#include <gtk/gtk.h>
#include <libfm/fm.h> /* header file of libfm */

int main(int argc, char** argv)
{
    FmFolder* folder;
    FmFolderModel* model;
    FmFolderView* view;
    GtkWidget* window, *scroll;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_container_add(GTK_CONTAINER(window), scroll);

    folder = fm_folder_get(fm_path_get_home());
    model = fm_folder_model_new(folder, FALSE);
    view = fm_folder_view_new(FM_FV_LIST_VIEW);
    gtk_container_add(GTK_CONTAINER(scroll), view);
    fm_folder_view_set_model(view, model);
    g_object_unref(model);
    g_object_unref(folder);

    gtk_widget_show_all(window); /* show the main window */
    gtk_main();
    return 0;
}

Build the library from source