Index: gtkfrontend/Makefile.am
===================================================================
--- gtkfrontend/Makefile.am	(revision 544eee75393a38b5e7c73f7d88f75bf3cb69515e)
+++ gtkfrontend/Makefile.am	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -20,4 +20,5 @@
 	builderslist.vala \
 	closeconfirmationdialog.vala \
+	commandview.vala \
 	dialogresponses.vala \
 	documentpageview.vala \
@@ -32,4 +33,5 @@
 	messagebar.vala \
 	newprojectdialog.vala \
+	optionview.vala \
 	page.vala \
 	pagepositions.vala \
Index: gtkfrontend/commandview.vala
===================================================================
--- gtkfrontend/commandview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
+++ gtkfrontend/commandview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -0,0 +1,86 @@
+/* commandview.vala
+ *
+ * Copyright (C) 2011  Matias De la Puente
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author:
+ * 	Matias De la Puente <mfpuente.ar@gmail.com>
+ */
+using Gtk;
+
+public class I4uc.GtkFrontend.CommandView : Gtk.VBox, I4uc.Core.CommandView
+{
+	private VBox _options_vbox = new VBox (false, 5);
+	private Expander _extra_options_expander = new Expander ("<b>" + _("More options") + "</b>");
+	private VBox _extra_options_vbox = new VBox (false, 5);
+	
+	public CommandView ()
+	{
+		this.border_width = 3;
+		
+		_extra_options_expander.use_markup = true;
+		_extra_options_expander.add (_extra_options_vbox);
+		
+		pack_start (_options_vbox, false, false, 5);
+		pack_end (_extra_options_expander, false, false, 5);
+	}
+	
+	public I4uc.Core.OptionView add_option (string name, string label, string value_type, bool optional, bool most_used)
+	{
+		OptionView option = null;
+		switch (value_type)
+		{
+			case "None":
+				option = new NoneOptionView (name, label);
+				break;
+			case "Entry":
+				option = new EntryOptionView (name, label, optional);
+				break;
+			case "List":
+			case "SerialPort":
+			case "BaudRate":
+				option = new ListOptionView (name, label, optional);
+				break;
+			case "FilePath":
+				option = new FilePathOptionView (name, label, optional);
+				break;
+			case "FolderPath":
+				option = new FolderPathOptionView (name, label, optional);
+				break;
+			case "Range":
+				option = new RangeOptionView (name, label, optional);
+				break;
+		}
+		if (most_used)
+			_options_vbox.pack_start (option, false, false, 4);
+		else
+			_extra_options_vbox.pack_start (option, false, false, 4);
+		show_all ();
+		return option;
+	}
+	
+	public void clear_options ()
+	{
+		// Remove and create options vbox
+		remove (_options_vbox);
+		_options_vbox = new VBox (false, 5);
+		pack_start (_options_vbox, false, false, 5);
+		
+		// Remove and create extra options vbox
+		_extra_options_expander.remove (_extra_options_vbox);
+		_extra_options_vbox = new VBox (false, 5);
+		_extra_options_expander.add (_extra_options_vbox);
+	}
+}
Index: gtkfrontend/main.vala
===================================================================
--- gtkfrontend/main.vala	(revision 41ce6fea3638e7ddb42e62ed95cb72fcc0af67df)
+++ gtkfrontend/main.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -58,5 +58,5 @@
 		context.parse (ref args);
 	}
-	catch (OptionError e)
+	catch (GLib.OptionError e)
 	{
 		stderr.printf (e.message + "\n");
Index: gtkfrontend/optionview.vala
===================================================================
--- gtkfrontend/optionview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
+++ gtkfrontend/optionview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -0,0 +1,206 @@
+/* optionview.vala
+ *
+ * Copyright (C) 2011  Matias De la Puente
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author:
+ * 	Matias De la Puente <mfpuente.ar@gmail.com>
+ */
+using Gtk;
+using Gee;
+
+public abstract class I4uc.GtkFrontend.OptionView : Gtk.VBox, I4uc.Core.OptionView
+{
+	protected string _name;
+	protected bool _optional;
+	protected Label _label;
+	protected CheckButton _active_check;
+	
+	public new string name { get { return _name; } }
+	public string tooltip { set; get; }
+	
+	public abstract string value { set; owned get; }
+	
+	public bool active { set; get; }
+	public bool value_sensitive { set; get; }
+	
+	public OptionView (string name, string label, bool optional)
+	{
+		_name = name;
+		_optional = optional;
+		_label = new Label (label + ":");
+		_label.xalign = 0.0f;
+		
+		// Bind properties
+		bind_property ("tooltip", _label, "tooltip-markup", BindingFlags.BIDIRECTIONAL);
+		if (_optional)
+		{
+			_active_check = new CheckButton ();
+			bind_property ("active", _active_check, "active", BindingFlags.BIDIRECTIONAL);
+		}
+	}
+	
+	protected void pack_value (Widget widget)
+	{
+		// Bind value_sensitive
+		if (_optional)
+			bind_property ("value-sensitive", widget, "sensitive", BindingFlags.BIDIRECTIONAL);
+		
+		// Pack label and value widgets
+		pack_start (_label, false, false, 0);
+		var hbox = new HBox (false, 0);
+		if (_optional)
+			hbox.pack_start (_active_check, false, false, 0);
+		hbox.pack_start (widget, false, false, 0);
+		pack_start (hbox);
+	}
+}
+
+public class I4uc.GtkFrontend.NoneOptionView : OptionView
+{
+	public override string value
+	{
+		set { }
+		owned get { return _active_check.active.to_string (); }
+	}
+	
+	public NoneOptionView (string name, string label)
+	{
+		base (name, label, true);
+		
+		var hbox = new HBox (false, 0);
+		hbox.pack_start (_label, false, false, 0);
+		hbox.pack_start (_active_check, false, false, 0);
+		pack_start (hbox);
+	}
+}
+
+public class I4uc.GtkFrontend.EntryOptionView : OptionView
+{
+	private Entry _value_entry = new Entry ();
+	
+	public override string value { set; owned get; }
+	
+	public EntryOptionView (string name, string label, bool optional)
+	{
+		base (name, label, optional);
+		
+		// Bind properties
+		bind_property ("value", _value_entry, "text", BindingFlags.BIDIRECTIONAL);
+		
+		pack_value (_value_entry);
+	}
+}
+
+public class I4uc.GtkFrontend.ListOptionView : OptionView, I4uc.Core.ListOptionView
+{
+	private ComboBox _value_combo = new ComboBox.text ();
+	private ArrayList<string> _items = new ArrayList<string> ();
+	
+	public override string value
+	{
+		set { _value_combo.active = value in _items ? _items.index_of (value) : -1; }
+		owned get
+		{
+			if (_value_combo.active == -1)
+				return "";
+			return _value_combo.get_active_text ();
+		}
+	}
+	
+	public ListOptionView (string name, string label, bool optional)
+	{
+		base (name, label, optional);
+		
+		pack_value (_value_combo);
+	}
+	
+	public void add_items (Gee.List<string> items)
+	{
+		foreach (var item in items)
+		{
+			_value_combo.append_text (item);
+			_items.add (item);
+		}
+	}
+	
+	public void clear_items ()
+	{
+		(_value_combo.model as ListStore).clear ();
+		_items.clear ();
+	}
+}
+
+public class I4uc.GtkFrontend.FilePathOptionView : OptionView
+{
+	private FileChooserButton _value_chooser;
+	
+	public override string value
+	{
+		set { _value_chooser.set_filename (value); }
+		owned get { return _value_chooser.get_filename (); }
+	}
+	
+	public FilePathOptionView (string name, string label, bool optional)
+	{
+		base (name, label, optional);
+		_value_chooser = new FileChooserButton (label, FileChooserAction.OPEN);
+		
+		pack_value (_value_chooser);
+	}
+}
+
+public class I4uc.GtkFrontend.FolderPathOptionView : OptionView
+{
+	private FileChooserButton _value_chooser;
+	
+	public override string value
+	{
+		set { _value_chooser.set_current_folder (value); }
+		owned get { return _value_chooser.get_current_folder (); }
+	}
+	
+	public FolderPathOptionView (string name, string label, bool optional)
+	{
+		base (name, label, optional);
+		_value_chooser = new FileChooserButton (label, FileChooserAction.SELECT_FOLDER);
+		
+		pack_value (_value_chooser);
+	}
+}
+
+public class I4uc.GtkFrontend.RangeOptionView : OptionView, I4uc.Core.RangeOptionView
+{
+	private SpinButton _value_spin = new SpinButton.with_range (0.0, 10.0, 1.0);
+	
+	public override string value
+	{
+		set { _value_spin.value = value.to_double (); }
+		owned get { return _value_spin.value.to_string (); }
+	}
+	
+	public RangeOptionView (string name, string label, bool optional)
+	{
+		base (name, label, optional);
+		
+		pack_value (_value_spin);
+	}
+	
+	public void set_range (int min, int max, int step)
+	{
+		_value_spin.set_range ((double)min, (double)max);
+		_value_spin.set_increments ((double)step, (double)step*5.0);
+	}
+}
Index: libi4uccore/Makefile.am
===================================================================
--- libi4uccore/Makefile.am	(revision 544eee75393a38b5e7c73f7d88f75bf3cb69515e)
+++ libi4uccore/Makefile.am	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -44,6 +44,8 @@
 	command.vala \
 	commandloader.vala \
+	commandlogic.vala \
 	commandrunner.vala \
 	commandrunnerfactory.c \
+	commandview.vala \
 	dialogresponse.vala \
 	document.vala \
@@ -60,4 +62,5 @@
 	mainwindowview.vala \
 	messagebar.vala \
+	optionview.vala \
 	page.vala \
 	pagespanel.vala \
Index: libi4uccore/commandlogic.vala
===================================================================
--- libi4uccore/commandlogic.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
+++ libi4uccore/commandlogic.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -0,0 +1,118 @@
+/* commandlogic.vala
+ *
+ * Copyright (C) 2011  Matias De la Puente
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author:
+ * 	Matias De la Puente <mfpuente.ar@gmail.com>
+ */
+using Gee;
+
+public errordomain I4uc.Core.OptionError
+{
+	OPTION_VALUE_MISSING
+}
+
+public class I4uc.Core.CommandLogic : GLib.Object
+{
+	private CommandView _view;
+	private Command _command;
+	private ArrayList<OptionView> _options = new ArrayList<OptionView> ();
+	
+	public CommandLogic (CommandView view)
+	{
+		_view = view;
+	}
+	
+	public void add_command (Command command)
+	{
+		if (_options.size > 0)
+		{
+			_options.clear ();
+			_view.clear_options ();
+		}
+		_command = command;
+		foreach (var option in command.options)
+		{
+			var option_view = _view.add_option (option.name, option.locale_label, option.value_type, option.optional, option.most_used);
+			option_view.tooltip = option.locale_description;
+			
+			// Load lists and ranges
+			switch (option.value_type)
+			{
+				case "List":
+					(option_view as ListOptionView).add_items ((option as ListOption).items);
+					(option_view as ListOptionView).value = (option as ListOption).default;
+					break;
+				case "Range":
+					var range_option = (option as RangeOption);
+					(option_view as RangeOptionView).set_range (range_option.min, range_option.max, range_option.step);
+					(option_view as RangeOptionView).value = range_option.default.to_string ();
+					break;
+			}
+			
+			if (option.optional)
+				option_view.notify["active"].connect (on_option_activated);
+			
+			_options.add (option_view);
+		}
+		on_option_activated ();
+	}
+	
+	public string get_option_line () throws OptionError
+	{
+		if (_command == null)
+			return "";
+		var option_line = "";
+		foreach (var option_view in _options)
+		{
+			if (option_view.sensitive && option_view.active)
+			{
+				if (option_view.value == null || option_view.value == "")
+					throw new OptionError.OPTION_VALUE_MISSING (_("Option value missing: ") + option_view.name);
+				var option = _command.get_option (option_view.name);
+				option_line += " " + option.format.replace ("%value", option_view.value);
+			}
+		}
+		return option_line;
+	}
+	
+	private OptionView? get_option_view (string option_name)
+	{
+		foreach (var option_view in _options)
+			if (option_view.name == option_name)
+				return option_view;
+		return null;
+	}
+	
+	private void on_option_activated ()
+	{
+		foreach (var option in _command.options)
+		{
+			// Enable/Disable option sensitive
+			var sensitive = true;
+			foreach (var depend in option.depends)
+				sensitive &= get_option_view (depend).active;
+			get_option_view (option.name).sensitive = sensitive;
+			
+			// Enable/Disable value sensitive
+			foreach (var option_view in _options)
+				if (_command.get_option (option_view.name).optional)
+					option_view.value_sensitive = option_view.active;
+				else
+					option_view.active = true;
+		}
+	}
+}
Index: libi4uccore/commandview.vala
===================================================================
--- libi4uccore/commandview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
+++ libi4uccore/commandview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -0,0 +1,26 @@
+/* commandview.vala
+ *
+ * Copyright (C) 2011  Matias De la Puente
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author:
+ * 	Matias De la Puente <mfpuente.ar@gmail.com>
+ */
+
+public interface I4uc.Core.CommandView : GLib.Object
+{
+	public abstract OptionView add_option (string name, string label, string value_type, bool optional, bool most_used);
+	public abstract void clear_options ();
+}
Index: libi4uccore/optionview.vala
===================================================================
--- libi4uccore/optionview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
+++ libi4uccore/optionview.vala	(revision c8a12325832a68ad842b2d51a7380aebdb4ca52a)
@@ -0,0 +1,41 @@
+/* optionview.vala
+ *
+ * Copyright (C) 2011  Matias De la Puente
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author:
+ * 	Matias De la Puente <mfpuente.ar@gmail.com>
+ */
+
+public interface I4uc.Core.OptionView : GLib.Object
+{
+	public abstract string name { get; }
+	public abstract string tooltip { set; get; }
+	public abstract string value { set; owned get; }
+	public abstract bool active { set; get; }
+	public abstract bool sensitive { set; get; }
+	public abstract bool value_sensitive { set; get; }
+}
+
+public interface I4uc.Core.ListOptionView : OptionView
+{
+	public abstract void add_items (Gee.List<string> items);
+	public abstract void clear_items ();
+}
+
+public interface I4uc.Core.RangeOptionView : OptionView
+{
+	public abstract void set_range (int min, int max, int step);
+}
