Open the file passed as an argument

This commit is contained in:
Alexander Kojevnikov 2010-05-17 17:39:22 +10:00
parent c32bcadde1
commit 24d4da8796
2 changed files with 17 additions and 4 deletions

View File

@ -28,7 +28,7 @@ namespace Spek {
private FileFilter filter_audio;
private FileFilter filter_png;
public Window () {
public Window (string file_name) {
title = _("Spek - Acoustic Spectrum Analyser");
set_default_icon_name ("spek");
set_default_size (640, 480);
@ -95,6 +95,11 @@ namespace Spek {
vbox.pack_start (spectrogram, true, true, 0);
add (vbox);
show_all ();
if (file_name != null) {
cur_dir = Path.get_dirname (file_name);
spectrogram.open (file_name);
}
}
private void on_open_clicked () {

View File

@ -19,9 +19,12 @@
using Spek;
bool version = false;
// TODO: move into main() when bgo#530623 is fixed.
[CCode (array_length = false, array_null_terminated = true)]
string[] files = null;
const OptionEntry[] options = {
{ "version", 'V', 0, OptionArg.NONE, &version, N_("Display the version and exit"), null },
{ "version", 'V', 0, OptionArg.NONE, ref version, N_("Display the version and exit"), null },
{ "", 0, 0, OptionArg.FILENAME_ARRAY, ref files, null, null },
{ null }
};
@ -44,8 +47,13 @@ int main (string[] args) {
return 0;
}
if (files != null && files.length != 1) {
print (_("Specify a single file\n"));
return 1;
}
Gst.init (ref args);
var window = new Window ();
var window = new Window (files == null ? null : files[0]);
Gtk.main ();
window.destroy ();
return 0;