ocarina: Display treeview columns
Columns are displayed with the names of attributes that will be listed.
This commit is contained in:
parent
1c944d3156
commit
7bf6f48488
|
@ -25,6 +25,7 @@ static void fill_library()
|
|||
libsaria_library_list(track_list);
|
||||
print("track list size: ");
|
||||
println(track_list.size());
|
||||
library_list.insert(track_list);
|
||||
}
|
||||
|
||||
void ocarina_library_refresh()
|
||||
|
|
|
@ -11,6 +11,22 @@ SongList::~SongList()
|
|||
{
|
||||
}
|
||||
|
||||
string columns[7] = { "Id", "#", "Title", "Length", "Artist", "Album", "Year" };
|
||||
int col_width[7] = { 2, 20, 300, 60, 125, 125, 50 };
|
||||
|
||||
void SongList::add_column(unsigned int index)
|
||||
{
|
||||
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(
|
||||
columns[index].c_str(), text_cell,
|
||||
"text", index, NULL);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_min_width(column, 2);
|
||||
gtk_tree_view_column_set_max_width(column, 700);
|
||||
gtk_tree_view_column_set_fixed_width(column, col_width[index]);
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
|
||||
}
|
||||
|
||||
/*
|
||||
* I need an init() function to set up the scrolled window AFTER
|
||||
* the gtk_init() function has been called.
|
||||
|
@ -21,7 +37,21 @@ void SongList::init(string text)
|
|||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(window),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_show(window);
|
||||
|
||||
treeview = gtk_tree_view_new();
|
||||
text_cell = gtk_cell_renderer_text_new();
|
||||
gtk_cell_renderer_text_set_fixed_height_from_font(
|
||||
GTK_CELL_RENDERER_TEXT(text_cell), 1);
|
||||
|
||||
liststore = gtk_list_store_new(7, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING,
|
||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
for (unsigned int i = 1; i < 7; i++)
|
||||
add_column(i);
|
||||
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(treeview), GTK_TREE_MODEL(liststore));
|
||||
container_add(window, treeview);
|
||||
gtk_widget_show_all(window);
|
||||
|
||||
label = gtk_label_new(text.c_str());
|
||||
gtk_label_set_angle(GTK_LABEL(label), 90);
|
||||
|
@ -37,3 +67,8 @@ GtkWidget *SongList::get_label()
|
|||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
void SongList::insert(list<Track> &track_list)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#define OCARINA_SONGLIST_H
|
||||
|
||||
#include <ocarina/gtk.h>
|
||||
#include <libsaria/track.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
|
@ -12,6 +14,12 @@ class SongList
|
|||
GtkWidget *window;
|
||||
GtkWidget *label;
|
||||
|
||||
GtkWidget *treeview;
|
||||
GtkListStore *liststore;
|
||||
GtkCellRenderer *text_cell;
|
||||
|
||||
void add_column(unsigned int);
|
||||
|
||||
public:
|
||||
SongList();
|
||||
~SongList();
|
||||
|
@ -19,6 +27,8 @@ class SongList
|
|||
void init(string);
|
||||
GtkWidget *get_window();
|
||||
GtkWidget *get_label();
|
||||
|
||||
void insert(list<Track> &track_list);
|
||||
};
|
||||
|
||||
#endif /* OCARINA_SONGLIST_H */
|
||||
|
|
Loading…
Reference in New Issue