app: add directory property and use it as default location for browsing

Allow passing a directory as a commandline arg. If given use that as the default
location, otherwise use current working dir.
This commit is contained in:
Stefan Sauer 2010-11-04 09:48:55 +02:00
parent 03f32a222c
commit d3a0351bd2
2 changed files with 17 additions and 3 deletions

View file

@ -25,8 +25,13 @@ public class MediaInfo.App : Window
private FileChooserWidget chooser;
private Info info;
public App()
public string directory { get; set; }
public App(string? directory)
{
GLib.Object (type : WindowType.TOPLEVEL);
this.directory = directory;
// configure the window
set_title (_("GStreamer Media Info"));
set_default_size (500, 350);
@ -45,7 +50,10 @@ public class MediaInfo.App : Window
chooser = new FileChooserWidget (FileChooserAction.OPEN);
paned.pack1 (chooser, true, true);
chooser.set_current_folder (GLib.Environment.get_home_dir ());
if (directory != null) {
//chooser.set_current_folder (GLib.Environment.get_home_dir ());
chooser.set_current_folder (directory);
}
chooser.set_show_hidden (false);
chooser.selection_changed.connect (on_update_preview);

View file

@ -51,7 +51,13 @@ main(string[] args)
return (0);
}
App app = new App ();
// take remaining arg and use as default dir
string directory = null;
if (args.length > 1) {
directory=args[1];
}
App app = new App (directory);
app.show_all ();
Gtk.main ();