spek

Acoustic spectrum analyser
git clone http://git.hanabi.in/repos/spek.git
Log | Files | Refs | README

commit 24d4da879643d84d5773b24b672f9b37e3f174b6
parent c32bcadde19ed5803a576849d9ff50aa4e918ae0
Author: Alexander Kojevnikov <alexander@kojevnikov.com>
Date:   Mon, 17 May 2010 17:39:22 +1000

Open the file passed as an argument

Diffstat:
Msrc/spek-window.vala | 7++++++-
Msrc/spek.vala | 14+++++++++++---
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/spek-window.vala b/src/spek-window.vala @@ -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 () { diff --git a/src/spek.vala b/src/spek.vala @@ -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;