From 78ee00b3f407dc549b315cd8dd5dc6eb0eae7b15 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Wed, 28 Dec 2016 20:29:50 +0100 Subject: [PATCH] mediinfo: replace some deprecated UI by the new one --- mediainfo/src/mi-app.vala | 9 ++--- mediainfo/src/mi-info.vala | 83 +++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/mediainfo/src/mi-app.vala b/mediainfo/src/mi-app.vala index da4d156c0a..a8a9a816ae 100644 --- a/mediainfo/src/mi-app.vala +++ b/mediainfo/src/mi-app.vala @@ -29,7 +29,7 @@ public class MediaInfo.App : Window public App (string? directory_or_uri) { GLib.Object (type : WindowType.TOPLEVEL); - + if (directory_or_uri != null) { if (FileUtils.test (directory_or_uri, FileTest.IS_DIR)) { directory = directory_or_uri; @@ -66,7 +66,7 @@ public class MediaInfo.App : Window info = new Info (); paned.pack2 (info, true, true); - + realize.connect ( () => { debug ("realized"); if (uri != null) { @@ -103,12 +103,11 @@ public class MediaInfo.App : Window // -> dialog with text entry (pre-file with clipboard content) // -> discover that uri and clear selection in browser - item = new ImageMenuItem.from_stock (Stock.QUIT, accel_group); + item = new Gtk.MenuItem.with_label (_("Quit")); sub_menu.append (item); item.activate.connect (Gtk.main_quit); item = new Gtk.MenuItem.with_label (_("View")); - //item.set_accel_path ("/MainMenu/View"); menu_bar.append (item); sub_menu = new Gtk.Menu (); @@ -131,7 +130,7 @@ public class MediaInfo.App : Window sub_menu = new Gtk.Menu (); item.set_submenu (sub_menu); - item = new ImageMenuItem.from_stock (Stock.ABOUT, accel_group); + item = new Gtk.MenuItem.with_label (_("About")); sub_menu.append (item); item.activate.connect (on_about_clicked); diff --git a/mediainfo/src/mi-info.vala b/mediainfo/src/mi-info.vala index e8a17e0001..d17cd94a01 100644 --- a/mediainfo/src/mi-info.vala +++ b/mediainfo/src/mi-info.vala @@ -176,7 +176,7 @@ public class MediaInfo.Info : Box table = new Table (8, 3, false); info_area.add_with_viewport (table); - + /* TODO(ensonic): add a 'Source' box ? maybe only for streams? Transport: {file, http, rtsp, ....} as wikilink Size: (in bytes) @@ -280,7 +280,7 @@ public class MediaInfo.Info : Box table.attach (toc_entries, 0, 3, row, row+1, fill_exp, 0, 0, 1); row++; - + // TODO: add message list widget // set up the gstreamer components @@ -327,25 +327,25 @@ public class MediaInfo.Info : Box } debug ("Discovering '%s'", uri); - if (true) { - /* sync API */ + /*if (true) {*/ + // sync API try { process_new_uri (dc.discover_uri (uri)); } catch (Error e) { // we're failing here when there are missing container plugins debug ("Failed to extract metadata from %s: %s: %s", uri, e.domain.to_string (), e.message); } - } else { + /*} else { // TODO(ensonic): this breaks when discovering 'too quickly' - /* async API */ + // async API dc.stop(); dc.start(); dc.discover_uri_async (uri); - } + }*/ } return (res); } - + private void on_uri_discovered (DiscovererInfo info, Error e) { if (e != null) { debug ("Failed to extract metadata from %s: %s: %s", info.get_uri(), e.domain.to_string (), e.message); @@ -354,7 +354,7 @@ public class MediaInfo.Info : Box process_new_uri (info); } } - + private void process_new_uri (DiscovererInfo? info) { GLib.List l; DiscovererStreamInfo sinfo; @@ -380,7 +380,7 @@ public class MediaInfo.Info : Box duration.set_text (""); return; } - + // prepare file from preview ((GLib.Object)pb).set_property ("uri", info.get_uri()); pb.set_state (State.PAUSED); @@ -412,11 +412,11 @@ public class MediaInfo.Info : Box if ((nick != "container") && (nick != "unknown")) { continue; } - + if (toc == null) { toc = sinfo.get_toc(); } - + nb.append_page (describe_container_stream (sinfo), new Label (@"container $six")); six++; } @@ -432,7 +432,7 @@ public class MediaInfo.Info : Box for (int i = 0; i < num_video_streams; i++) { sinfo = l.nth_data (i); debug("video[%d]=%s", i, sinfo.get_stream_id()); - + if (toc == null) { toc = sinfo.get_toc(); } @@ -509,19 +509,19 @@ public class MediaInfo.Info : Box } // signal handlers - + private bool on_preview_configured (Gdk.EventConfigure event) { if (overlay != null) overlay.expose(); return false; - } + } private void on_element_sync_message (Gst.Bus bus, Message message) { if (Video.is_video_overlay_prepare_window_handle_message (message)) { Gdk.Window window = preview.get_window (); debug ("prepare overlay: %p", window); overlay = message.src as Gst.Video.Overlay; - overlay.set_window_handle ((uint *)Gdk.X11Window.get_xid (window)); + overlay.set_window_handle ((uint*) ((Gdk.X11.Window) window).get_xid ()); debug ("prepared overlay"); } } @@ -578,12 +578,12 @@ public class MediaInfo.Info : Box } } } - + private void on_toc_entry_changed (TreeView view) { TreeSelection sel = view.get_selection (); if (sel == null) return; - + TreeModel model; TreeIter iter; if (sel.get_selected (out model, out iter)) { @@ -595,30 +595,31 @@ public class MediaInfo.Info : Box } } } - + // helpers - + private Widget describe_container_stream (DiscovererStreamInfo sinfo) { Table table = new Table (2, 4, false); uint row = 0; add_table_rows_for_caps (table, row, "Format:", sinfo.get_caps ()); row+=2; - + + // gchar ** get_missing_elements_installer_details() if (add_table_row_for_structure (table, row, sinfo.get_misc ())) { row++; } if (add_table_row_for_taglist (table, row, sinfo.get_tags ())) { row++; } - + return (Widget)table; } private Widget describe_video_stream (DiscovererStreamInfo sinfo) { DiscovererVideoInfo vinfo = (DiscovererVideoInfo)sinfo; Table table = new Table (2, 8, false); - + Gdk.Point res = { (int)((DiscovererVideoInfo)sinfo).get_width(), (int)((DiscovererVideoInfo)sinfo).get_height() @@ -629,7 +630,7 @@ public class MediaInfo.Info : Box uint row = 0; add_table_rows_for_caps (table, row, "Codec:", sinfo.get_caps ()); row+=2; - + add_table_row_for_bitrates (table, row, vinfo.get_bitrate(), vinfo.get_max_bitrate()); row++; @@ -725,7 +726,7 @@ public class MediaInfo.Info : Box private Widget describe_subtitle_stream (DiscovererStreamInfo sinfo) { DiscovererSubtitleInfo tinfo = (DiscovererSubtitleInfo) sinfo; Table table = new Table (2, 5, false); - + uint row = 0; add_table_rows_for_caps (table, row, "Codec:", sinfo.get_caps ()); row+=2; @@ -748,7 +749,7 @@ public class MediaInfo.Info : Box nb.remove_page (-1); } } - + private void set_wikilink (Label label, Caps caps) { string str = get_codec_description (caps); string wikilink = wikilinks[str]; @@ -794,17 +795,17 @@ public class MediaInfo.Info : Box label.set_alignment (0.0f, 0.5f); label.set_selectable (true); label.set_use_markup (true); - set_wikilink (label, caps); + set_wikilink (label, caps); table.attach (label, 1, 2, row, row+1, fill_exp, 0, 3, 1); } - + private void add_table_row_for_bitrates (Table table, uint row, uint br, uint mbr) { string str; - + if (br == mbr) { mbr = 0; // no point in printing this as a range } - + if (mbr != 0) { str = "%.2f ... %.2f kbit/second".printf (br/1024.0, mbr/1024.0); } else { @@ -816,7 +817,7 @@ public class MediaInfo.Info : Box } add_table_row_for_string (table, row, "Bitrate:", str); } - + private void add_table_row_for_string (Table table, uint row, string title, string? str) { AttachOptions fill = AttachOptions.FILL; AttachOptions fill_exp = AttachOptions.EXPAND|AttachOptions.FILL; @@ -866,12 +867,12 @@ public class MediaInfo.Info : Box table.attach (label, 1, 2, row, row+1, fill_exp, 0, 0, 1); return true; } - + // get stream index where streams are orderd by stream_id private int get_stream_index (DiscovererStreamInfo sinfo, ArrayList sids) { string sid = sinfo.get_stream_id (); int six = 0; - + for (six = 0; six < sids.size; six++) { if (strcmp (sid, sids[six]) <= 0) break; @@ -929,7 +930,7 @@ public class MediaInfo.Info : Box return str; } - + private string format_time(ClockTime t) { if (t == Gst.CLOCK_TIME_NONE) return "unknown"; @@ -940,7 +941,7 @@ public class MediaInfo.Info : Box (uint) ((t / SECOND) % 60), (uint) ((t) % SECOND)); } - + private void build_toc_info_for_entry (TreeStore s, TocEntry e, TreeIter? p) { TreeIter iter; int64 start, stop; @@ -952,12 +953,12 @@ public class MediaInfo.Info : Box } if (stop != Gst.CLOCK_TIME_NONE) { str += "- %s ".printf(format_time((ClockTime)stop)); - } + } str += TocEntryType.get_nick(e.get_entry_type()); - + s.append(out iter, p); s.set(iter, 0, str, 1, start, 2, stop, -1); - + unowned GLib.List entries = e.get_sub_entries (); if (entries != null) { foreach (TocEntry se in entries) { @@ -965,17 +966,17 @@ public class MediaInfo.Info : Box } } } - + private TreeStore? build_toc_info (Toc? t) { if (t == null) return null; - + TreeStore s = new TreeStore(3, typeof (string), typeof (int64), typeof (int64)); unowned GLib.List entries = t.get_entries (); foreach (TocEntry e in entries) { build_toc_info_for_entry (s, e, null); } - + return s; } }