app: allow giving an uri instead of a directory as a startup arg

This way we can play streams.
This commit is contained in:
Stefan Sauer 2013-09-04 09:17:28 +02:00
parent a432c367e7
commit 540923db9c
2 changed files with 27 additions and 13 deletions

View file

@ -25,12 +25,19 @@ public class MediaInfo.App : Window
private FileChooserWidget chooser; private FileChooserWidget chooser;
private Info info; private Info info;
public string directory { get; set; } public App (string? directory_or_uri)
public App (string? directory)
{ {
GLib.Object (type : WindowType.TOPLEVEL); GLib.Object (type : WindowType.TOPLEVEL);
this.directory = directory;
string directory = null;
string uri = null;
if (directory_or_uri != null) {
if (FileUtils.test (directory_or_uri, FileTest.IS_DIR)) {
directory = directory_or_uri;
} else if (Uri.parse_scheme (directory_or_uri) != null) {
uri = directory_or_uri;
}
}
// configure the window // configure the window
set_title (_("GStreamer Media Info")); set_title (_("GStreamer Media Info"));
@ -61,7 +68,16 @@ public class MediaInfo.App : Window
chooser.set_current_folder (directory); chooser.set_current_folder (directory);
} }
chooser.set_show_hidden (false); chooser.set_show_hidden (false);
chooser.selection_changed.connect (on_update_preview);
if (uri != null) {
chooser.set_sensitive (false);
Idle.add ( () => {
info.discover (uri);
return false;
});
} else {
chooser.selection_changed.connect (on_update_preview);
}
info = new Info (); info = new Info ();
paned.pack2 (info, true, true); paned.pack2 (info, true, true);

View file

@ -26,15 +26,13 @@ const OptionEntry[] options = {
{ null } { null }
}; };
int int main(string[] args)
main(string[] args) {
{
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR); Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE); Intl.textdomain (Config.GETTEXT_PACKAGE);
OptionContext opt_context = new OptionContext (_("<directory>")); OptionContext opt_context = new OptionContext (_("<directory|uri>"));
opt_context.set_help_enabled (true); opt_context.set_help_enabled (true);
opt_context.add_main_entries (options, null); opt_context.add_main_entries (options, null);
opt_context.add_group (Gst.init_get_option_group ()); opt_context.add_group (Gst.init_get_option_group ());
@ -52,12 +50,12 @@ main(string[] args)
} }
// take remaining arg and use as default dir // take remaining arg and use as default dir
string directory = null; string directory_or_uri = null;
if (args.length > 1) { if (args.length > 1) {
directory=args[1]; directory_or_uri = args[1];
} }
App app = new App (directory); App app = new App (directory_or_uri);
app.show_all (); app.show_all ();
Gtk.main (); Gtk.main ();