mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 18:51:11 +00:00
mi-info: use a TreeView for the toc
Use a TreeView with a TreeStore to show toc-entries.
This commit is contained in:
parent
3a6f42bf67
commit
ddeadf0f7c
1 changed files with 30 additions and 15 deletions
|
@ -35,7 +35,7 @@ public class MediaInfo.Info : Box
|
||||||
private Notebook video_streams; // depending on screen resolution
|
private Notebook video_streams; // depending on screen resolution
|
||||||
private Notebook audio_streams;
|
private Notebook audio_streams;
|
||||||
private Notebook subtitle_streams;
|
private Notebook subtitle_streams;
|
||||||
private Label toc_entries; // TODO(ensonic): use treeview
|
private TreeView toc_entries;
|
||||||
private Preview preview;
|
private Preview preview;
|
||||||
private ScrolledWindow info_area;
|
private ScrolledWindow info_area;
|
||||||
// gstreamer objects
|
// gstreamer objects
|
||||||
|
@ -239,8 +239,19 @@ public class MediaInfo.Info : Box
|
||||||
table.attach (label, 0, 3, row, row+1, fill_exp, 0, 0, 1);
|
table.attach (label, 0, 3, row, row+1, fill_exp, 0, 0, 1);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
toc_entries = new Label (null); // TODO(ensonic): use TreeView
|
// TODO(ensonic): use tabs for editions?
|
||||||
//toc.row_activated.connect (on_toc_entry_activated);
|
toc_entries = new TreeView ();
|
||||||
|
toc_entries.set_enable_search (false);
|
||||||
|
toc_entries.set_headers_visible (false);
|
||||||
|
toc_entries.get_selection ().set_mode (SelectionMode.BROWSE);
|
||||||
|
//toc_entries.row_activated.connect (on_toc_entry_activated);
|
||||||
|
|
||||||
|
TreeViewColumn column = new TreeViewColumn ();
|
||||||
|
toc_entries.append_column (column);
|
||||||
|
CellRendererText renderer = new CellRendererText ();
|
||||||
|
column.pack_start (renderer, false);
|
||||||
|
column.add_attribute (renderer, "text", 0);
|
||||||
|
|
||||||
table.attach (toc_entries, 0, 3, row, row+1, fill_exp, 0, 0, 1);
|
table.attach (toc_entries, 0, 3, row, row+1, fill_exp, 0, 0, 1);
|
||||||
row++;
|
row++;
|
||||||
|
|
||||||
|
@ -441,7 +452,8 @@ public class MediaInfo.Info : Box
|
||||||
}
|
}
|
||||||
nb.show_all();
|
nb.show_all();
|
||||||
|
|
||||||
toc_entries.set_text (build_toc_info (toc));
|
toc_entries.set_model (build_toc_info (toc));
|
||||||
|
toc_entries.expand_all ();
|
||||||
|
|
||||||
if (have_video) {
|
if (have_video) {
|
||||||
Gdk.Point res = video_resolutions[0];
|
Gdk.Point res = video_resolutions[0];
|
||||||
|
@ -843,36 +855,39 @@ public class MediaInfo.Info : Box
|
||||||
// TODO(ensonic): use a Gtk.TreeStore here, pass parent, instead of indent
|
// TODO(ensonic): use a Gtk.TreeStore here, pass parent, instead of indent
|
||||||
// TODO(ensonic): one column with the formatted string or 3 strings: label, start, stop
|
// TODO(ensonic): one column with the formatted string or 3 strings: label, start, stop
|
||||||
|
|
||||||
private string build_toc_info_for_entry (TocEntry e, string indent) {
|
private void build_toc_info_for_entry (TreeStore s, TocEntry e, TreeIter? p) {
|
||||||
|
TreeIter iter;
|
||||||
int64 start, stop;
|
int64 start, stop;
|
||||||
|
|
||||||
e.get_start_stop_times(out start, out stop);
|
e.get_start_stop_times(out start, out stop);
|
||||||
string s = indent;
|
string str = "";
|
||||||
if (start != Gst.CLOCK_TIME_NONE) {
|
if (start != Gst.CLOCK_TIME_NONE) {
|
||||||
s += "%s ".printf(format_time((ClockTime)start));
|
str += "%s ".printf(format_time((ClockTime)start));
|
||||||
}
|
}
|
||||||
if (stop != Gst.CLOCK_TIME_NONE) {
|
if (stop != Gst.CLOCK_TIME_NONE) {
|
||||||
s += "- %s ".printf(format_time((ClockTime)stop));
|
str += "- %s ".printf(format_time((ClockTime)stop));
|
||||||
}
|
}
|
||||||
s += "%s\n".printf(TocEntryType.get_nick(e.get_entry_type()));
|
str += TocEntryType.get_nick(e.get_entry_type());
|
||||||
|
|
||||||
|
s.append(out iter, p);
|
||||||
|
s.set(iter, 0, str, -1);
|
||||||
|
|
||||||
unowned GLib.List<TocEntry> entries = e.get_sub_entries ();
|
unowned GLib.List<TocEntry> entries = e.get_sub_entries ();
|
||||||
if (entries != null) {
|
if (entries != null) {
|
||||||
string new_indent = indent + " ";
|
|
||||||
foreach (TocEntry se in entries) {
|
foreach (TocEntry se in entries) {
|
||||||
s += build_toc_info_for_entry (se, new_indent);
|
build_toc_info_for_entry (s, se, iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string? build_toc_info (Toc? t) {
|
private TreeStore? build_toc_info (Toc? t) {
|
||||||
if (t == null)
|
if (t == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string s = "";
|
TreeStore s = new TreeStore(1, typeof (string));
|
||||||
unowned GLib.List<TocEntry> entries = t.get_entries ();
|
unowned GLib.List<TocEntry> entries = t.get_entries ();
|
||||||
foreach (TocEntry e in entries) {
|
foreach (TocEntry e in entries) {
|
||||||
s += build_toc_info_for_entry (e, "");
|
build_toc_info_for_entry (s, e, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in a new issue