Esempio n. 1
0
static void
fm_compact_view_init (FMCompactView *compact_view)
{
    FMAbstractIconView *view = FM_ABSTRACT_ICON_VIEW (compact_view);

    /* initialize the icon view properties */
    exo_icon_view_set_layout_mode (view->icons, EXO_ICON_VIEW_LAYOUT_COLS);
    exo_icon_view_set_row_spacing (view->icons, 0);
    exo_icon_view_set_margin (view->icons, 3);
   
    g_object_set (G_OBJECT (compact_view), "text-beside-icons", TRUE, NULL);
    
    /* setup the icon renderer */
    g_object_set (FM_DIRECTORY_VIEW (view)->icon_renderer, "ypad", 0u, NULL);

    /* setup the name renderer (wrap only very long names) */
    g_object_set (FM_DIRECTORY_VIEW (view)->name_renderer,
                  "wrap-mode", PANGO_WRAP_WORD_CHAR,
                  "wrap-width", 1280,
                  "xalign", 0.0f,
                  "yalign", 0.5f,
                  NULL);

    g_settings_bind (marlin_compact_view_settings, "zoom-level", 
                     compact_view, "zoom-level", 0);

}
Esempio n. 2
0
static inline void create_icon_view(FmFolderView* fv, GList* sels)
{
    GtkTreeViewColumn* col;
    GtkTreeSelection* ts;
    GList *l;
    GtkCellRenderer* render;
    FmFolderModel* model = (FmFolderModel*)fv->model;
    int icon_size = 0;

    fv->view = exo_icon_view_new();

    render = fm_cell_renderer_pixbuf_new();
    fv->renderer_pixbuf = render;

    g_object_set((GObject*)render, "follow-state", TRUE, NULL );
    gtk_cell_layout_pack_start((GtkCellLayout*)fv->view, render, TRUE);
    gtk_cell_layout_add_attribute((GtkCellLayout*)fv->view, render, "pixbuf", COL_FILE_ICON );
    gtk_cell_layout_add_attribute((GtkCellLayout*)fv->view, render, "info", COL_FILE_INFO );

    if(fv->mode == FM_FV_COMPACT_VIEW) /* compact view */
    {
//        fv->icon_size_changed_handler = g_signal_connect(fm_config, "changed::small_icon_size", G_CALLBACK(on_small_icon_size_changed), fv);
        icon_size = fm_config->small_icon_size;
        fm_cell_renderer_pixbuf_set_fixed_size(FM_CELL_RENDERER_PIXBUF(fv->renderer_pixbuf), icon_size, icon_size);
        if(model)
            fm_folder_model_set_icon_size(model, icon_size);

        render = fm_cell_renderer_text_new();
        g_object_set((GObject*)render,
                     "xalign", 1.0, /* FIXME: why this needs to be 1.0? */
                     "yalign", 0.5,
                     NULL );
        exo_icon_view_set_layout_mode( (ExoIconView*)fv->view, EXO_ICON_VIEW_LAYOUT_COLS );
        exo_icon_view_set_orientation( (ExoIconView*)fv->view, GTK_ORIENTATION_HORIZONTAL );
    }
    else /* big icon view or thumbnail view */
    {
        if(fv->mode == FM_FV_ICON_VIEW)
        {
            fv->icon_size_changed_handler = g_signal_connect(fm_config, "changed::big_icon_size", G_CALLBACK(on_big_icon_size_changed), fv);
            icon_size = fm_config->big_icon_size;
            fm_cell_renderer_pixbuf_set_fixed_size(FM_CELL_RENDERER_PIXBUF(fv->renderer_pixbuf), icon_size, icon_size);
            if(model)
                fm_folder_model_set_icon_size(model, icon_size);

            render = fm_cell_renderer_text_new();
            /* FIXME: set the sizes of cells according to iconsize */
            g_object_set((GObject*)render,
                         "wrap-mode", PANGO_WRAP_WORD_CHAR,
                         "wrap-width", 90,
                         "alignment", PANGO_ALIGN_CENTER,
                         "xalign", 0.5,
                         "yalign", 0.0,
                         NULL );
            exo_icon_view_set_column_spacing( (ExoIconView*)fv->view, 4 );
            exo_icon_view_set_item_width ( (ExoIconView*)fv->view, 110 );
        }
        else
        {
            fv->icon_size_changed_handler = g_signal_connect(fm_config, "changed::thumbnail_size", G_CALLBACK(on_thumbnail_size_changed), fv);
            icon_size = fm_config->thumbnail_size;
            fm_cell_renderer_pixbuf_set_fixed_size(FM_CELL_RENDERER_PIXBUF(fv->renderer_pixbuf), icon_size, icon_size);
            if(model)
                fm_folder_model_set_icon_size(model, icon_size);

            render = fm_cell_renderer_text_new();
            /* FIXME: set the sizes of cells according to iconsize */
            g_object_set((GObject*)render,
                         "wrap-mode", PANGO_WRAP_WORD_CHAR,
                         "wrap-width", 180,
                         "alignment", PANGO_ALIGN_CENTER,
                         "xalign", 0.5,
                         "yalign", 0.0,
                         NULL );
            exo_icon_view_set_column_spacing( (ExoIconView*)fv->view, 8 );
            exo_icon_view_set_item_width ( (ExoIconView*)fv->view, 200 );
        }
    }
    gtk_cell_layout_pack_start((GtkCellLayout*)fv->view, render, TRUE);
    gtk_cell_layout_add_attribute((GtkCellLayout*)fv->view, render,
                                "text", COL_FILE_NAME );
    exo_icon_view_set_item_width((ExoIconView*)fv->view, 96);
    exo_icon_view_set_search_column((ExoIconView*)fv->view, COL_FILE_NAME);
    g_signal_connect(fv->view, "item-activated", G_CALLBACK(on_icon_view_item_activated), fv);
    g_signal_connect(fv->view, "selection-changed", G_CALLBACK(on_sel_changed), fv);
    exo_icon_view_set_model((ExoIconView*)fv->view, fv->model);
    exo_icon_view_set_selection_mode((ExoIconView*)fv->view, fv->sel_mode);
    exo_icon_view_set_single_click((ExoIconView*)fv->view, fm_config->single_click);
    exo_icon_view_set_single_click_timeout((ExoIconView*)fv->view, SINGLE_CLICK_TIMEOUT);

    for(l = sels;l;l=l->next)
        exo_icon_view_select_path((ExoIconView*)fv->view, (GtkTreePath*)l->data);
}