2012-07-07 49 views
0

我刚开始研究gtk,因为我必须用它编写一个GUI应用程序。这是一个即时通讯应用程序,我需要向用户显示他/她的朋友列表时,他或她登录该列表应显示在左侧和名称的小图片上右边,像图所示:gtk + 2.0哪个小部件用于朋友列表?

Friends 
----------- 
Pic1 John 
Pic2 Sara 
... ... 

据我所知,到目前为止,我认为最好的西装是树视图,但它有恼人的分离器和头部因此名单是这样的:

Friends 
------------ 
PIC | Name 
------------ 
Pic1 | John 
------------ 
Pic2 | Sara 

反正是有解决这个问题?或者有更好的方法来实现这一目标?

此外,我要包含名称部分的详细信息,如:

Friends 
---------- 
Pic1 John 
Pic1 This is more about John 
Pic1 Still more about John 
Pic1 Sara 
Pic1 This is more about Sara 
Pic1 Still more about Sara 

注意三个Pic1s和Pic2s仍占上方一张图片。

另外我正在用C编写应用程序。

建议?

+0

可能您会想为此创建自己的复合控件,然后将它们的列表打包到滚动容器中。 – mlibby 2012-07-07 16:04:35

回答

0

对于TreeView,列标题可以用gtk_tree_view_set_headers_visible(view,false)隐藏。这似乎也删除列分隔符,虽然我找不到任何有关此行为的文档。

2

在文本单元格渲染器中可以有一个多行字符串。例如,下面是我从事的一个应用程序的示例:https://github.com/wmvanvliet/Chimara/blob/browser/player/browser.c

设置在单元格渲染器自定义数据功能:

gtk_tree_view_column_set_cell_data_func(column, renderer, (GtkTreeCellDataFunc)text_function, NULL, NULL); 

这是一个很好的格式化的标题,作者自定义数据函数的例子,每年出版一部作品进入细胞渲染器的标记属性:

static void 
text_function(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) 
{ 
    char *title, *author, *rendered_string; 
    unsigned year; 
    gtk_tree_model_get(model, iter, 
     1, &title, 
     2, &author, 
     3, &year, 
     -1); 
    rendered_string = g_strdup_printf("<big><big><b><i>%s</i></b></big>\nby %s</big> (%d)", title, author, year); 
    g_object_set(cell, "markup", rendered_string, NULL); 
}