Working on new treeview.
[gmpc.git] / src / Widgets / gmpc-data-view.vala
blobb2bff12df35087ef83488fa5e41b7ef6de02167d
1 using Gmpc;
2 using Gtk;
3 const int NUM_COLS = 20;
4 const int[] col_ids = {
5 Gmpc.MpdData.ColumnTypes.MARKUP,
6 Gmpc.MpdData.ColumnTypes.SONG_ARTIST, /* album name */
7 Gmpc.MpdData.ColumnTypes.SONG_ALBUM, /* album name */
8 Gmpc.MpdData.ColumnTypes.SONG_TITLE, /* song title */
9 Gmpc.MpdData.ColumnTypes.SONG_TITLEFILE, /* song title */
10 Gmpc.MpdData.ColumnTypes.SONG_GENRE, /* song genre */
11 Gmpc.MpdData.ColumnTypes.SONG_TRACK, /* song track */
12 Gmpc.MpdData.ColumnTypes.SONG_NAME, /* stream name */
13 Gmpc.MpdData.ColumnTypes.SONG_COMPOSER, /* composer name */
14 Gmpc.MpdData.ColumnTypes.SONG_PERFORMER, /* performer */
15 Gmpc.MpdData.ColumnTypes.SONG_DATE, /* date */
16 Gmpc.MpdData.ColumnTypes.SONG_LENGTH_FORMAT, /* length formatted */
17 Gmpc.MpdData.ColumnTypes.SONG_DISC, /* disc */
18 Gmpc.MpdData.ColumnTypes.SONG_COMMENT, /* comment */
19 Gmpc.MpdData.ColumnTypes.ICON_ID, /* icon id */
20 Gmpc.MpdData.ColumnTypes.SONG_POS,
21 Gmpc.MpdData.ColumnTypes.SONG_ALBUMARTIST,
22 Gmpc.MpdData.ColumnTypes.PATH_EXTENSION, /* Extension */
23 Gmpc.MpdData.ColumnTypes.PATH_DIRECTORY, /* Directory */
24 Gmpc.MpdData.ColumnTypes.SONG_PRIORITY,
26 const string[] col_names = {
27 N_("Markup"),
28 N_("Artist"),
29 N_("Album"),
30 N_("Title"),
31 N_("File"),
32 N_("Genre"),
33 N_("Track"),
34 N_("Name"),
35 N_("Composer"),
36 N_("Performer"),
37 N_("Date"),
38 N_("Duration"),
39 N_("Disc"),
40 N_("Comment"),
41 N_("Icon Id"),
42 N_("Position"),
43 N_("AlbumArtist"),
44 N_("Extension"),
45 N_("Directory"),
46 N_("Priority")
49 const bool[] col_enabled = {
50 false,//"Markup",
51 true, //"Artist",
52 true,//"Album",
53 true,//"Title",
54 false,//"File",
55 false,//"Genre",
56 false,//"Track",
57 false,//"Name",
58 false,//"Composer",
59 false,//"Performer",
60 false,//"Date",
61 false,//"Duration",
62 false,//"Disc",
63 false,//"Comment",
64 true,//"Icon Id"
65 false,//"Position"
66 false,//"AlbumArtist"
67 false,//Extension
68 false,//Directory
69 false//Priority
73 const int[] col_position = {
74 14,//"Markup",
75 3, //"Artist",
76 2,//"Album",
77 1,//"Title",
78 4,//"File",
79 5,//"Genre",
80 6,//"Track",
81 7,//"Name",
82 8,//"Composer",
83 9,//"Performer",
84 10,//"Date",
85 11,//"Duration",
86 12,//"Disc",
87 13,//"Comment",
88 0,//"Icon Id"
89 15, // "Position"
90 18, // "AlbumArtist"
91 16,// Extension
92 17, // Directory
96 public class Gmpc.DataView : Gtk.TreeView
98 /**
99 * If we are a play-queue we should treat the content.
100 * slightly different.
101 * e.g. add-replace will be play-crop
103 public bool is_play_queue {get; set; default=false;}
106 * The name of the treeview.
107 * This is used to store the column layout.
109 public string uid {get; set; default="default";}
113 * Construction function.
115 public DataView()
117 // Connect row activated signal.
118 this.row_activated.connect(__row_activated);
123 * Populate the treeview with the right columns.
124 * The treeview should have a name now.
126 public void populate()
128 for(int i = 0; i < NUM_COLS; i++) {
129 Gtk.TreeViewColumn col = new Gtk.TreeViewColumn();
130 col.set_title(col_names[i]);
132 this.insert_column(col, col_position[i]);
139 * Internal functions.
141 private void __row_activated(Gtk.TreePath path, Gtk.TreeViewColumn col)