/* * Build: * gcc $(pkg-config --cflags gtk+-3.0 exo-2) sample.c -o sample $(pkg-config --libs gtk+-3.0 exo-2) */ #include #include enum { COLUMN_NAME = 0, COLUMN_ICON, N_COLUMNS }; int main (int argc, char *argv[]) { GtkWidget *window; GtkListStore *store; GtkTreeIter iter; GtkWidget *iconview; GtkCellRenderer *render; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); gtk_container_set_border_width (GTK_CONTAINER (window), 5); gtk_window_set_default_size (GTK_WINDOW (window), 200, 420); store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_NAME, "alpha", COLUMN_ICON, "text-x-generic", -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_NAME, "long one line", COLUMN_ICON, "text-x-generic", -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_NAME, "alpha beta gamma delta", COLUMN_ICON, "text-x-generic", -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_NAME, "dolor sit amen loremipsum", COLUMN_ICON, "text-x-generic", -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_NAME, "foo bar foo bar foo bar foo bar", COLUMN_ICON, "text-x-generic", -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_NAME, "lorem ipsum dolor sit amen", COLUMN_ICON, "text-x-generic", -1); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, COLUMN_NAME, "loremipsum loremipsum", COLUMN_ICON, "text-x-generic", -1); iconview = exo_icon_view_new_with_model (GTK_TREE_MODEL(store)); gtk_container_add (GTK_CONTAINER (window), iconview); g_object_unref (store); exo_icon_view_set_orientation (EXO_ICON_VIEW (iconview), GTK_ORIENTATION_HORIZONTAL); exo_icon_view_set_margin (EXO_ICON_VIEW (iconview), 0); exo_icon_view_set_enable_search (EXO_ICON_VIEW (iconview), FALSE); // exo_icon_view_set_item_width (EXO_ICON_VIEW (iconview), 200); render = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (iconview), render, FALSE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (iconview), render, "icon-name", COLUMN_ICON); g_object_set (G_OBJECT (render), "stock-size", GTK_ICON_SIZE_DIALOG, NULL); render = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (iconview), render, FALSE); gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (iconview), render, "text", COLUMN_NAME); g_object_set (G_OBJECT (render), "wrap-mode", PANGO_WRAP_WORD, NULL); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_show_all (window); gtk_main (); return 0; }