[gnome-boxes] Alternative approach to passing URI around from commandline
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Alternative approach to passing URI around from commandline
- Date: Wed, 2 Nov 2011 03:03:44 +0000 (UTC)
commit 6f1a0aacb65d968f8d784d6b7b0c6545218006d0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Nov 2 05:01:42 2011 +0200
Alternative approach to passing URI around from commandline
Main goal of this approach is to avoid adding arguments to main App()
construction method and having a separate named one that takes a URI.
src/app.vala | 15 +++++++++------
src/main.vala | 7 +++++--
src/wizard-source.vala | 6 ++----
src/wizard.vala | 3 ++-
4 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 1efcad7..25fea53 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -32,8 +32,7 @@ private class Boxes.App: Boxes.UI {
private HashTable<string,GVir.Connection> connections;
- public App (string? uri) {
- this.uri = uri;
+ public App () {
settings = new GLib.Settings ("org.gnome.boxes");
setup_ui ();
collection = new Collection (this);
@@ -50,6 +49,13 @@ private class Boxes.App: Boxes.UI {
setup_sources.begin ();
}
+ public App.with_uri (string uri) {
+ this ();
+ this.uri = uri;
+
+ ui_state = UIState.WIZARD;
+ }
+
public void set_category (Category category) {
topbar.label.set_text (category.name);
}
@@ -166,10 +172,7 @@ private class Boxes.App: Boxes.UI {
wizard = new Wizard (this);
properties = new Properties (this);
- if (uri != null)
- ui_state = UIState.WIZARD;
- else
- ui_state = UIState.COLLECTION;
+ ui_state = UIState.COLLECTION;
}
private void set_main_ui_state (string clutter_state) {
diff --git a/src/main.vala b/src/main.vala
index 6364665..c1d4bad 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -66,8 +66,11 @@ public void main (string[] args) {
warning (error.message);
}
- // FIXME: We only handle a single URI from commandline
- new Boxes.App ((uris != null)? uris[0] : null);
+ if (uris != null)
+ // FIXME: We only handle a single URI from commandline
+ new Boxes.App.with_uri (uris[0]);
+ else
+ new Boxes.App ();
Gtk.main ();
}
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index bb801e9..d6adf59 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -22,12 +22,13 @@ private class Boxes.WizardSource: GLib.Object {
}
public string uri {
get { return url_entry.get_text (); }
+ set { url_entry.set_text (value); }
}
private Gtk.Notebook notebook;
private Gtk.Entry url_entry;
- public WizardSource (string? uri) {
+ public WizardSource () {
notebook = new Gtk.Notebook ();
notebook.get_style_context ().add_class ("boxes-source-nb");
notebook.show_tabs = false;
@@ -84,9 +85,6 @@ private class Boxes.WizardSource: GLib.Object {
label.wrap = true;
hbox.pack_start (label, true, true);
- if (uri != null)
- url_entry.text = uri;
-
notebook.show_all ();
}
diff --git a/src/wizard.vala b/src/wizard.vala
index d48b728..90ab116 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -71,11 +71,11 @@ private class Boxes.Wizard: Boxes.UI {
construct {
steps = new GenericArray<Gtk.Label> ();
steps.length = WizardPage.LAST;
+ wizard_source = new Boxes.WizardSource ();
}
public Wizard (App app) {
this.app = app;
- wizard_source = new Boxes.WizardSource (app.uri);
setup_ui ();
}
@@ -306,6 +306,7 @@ private class Boxes.Wizard: Boxes.UI {
if (app.uri != null) {
page = WizardPage.SOURCE;
wizard_source.page = SourcePage.URL;
+ wizard_source.uri = app.uri;
} else
page = WizardPage.INTRODUCTION;
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]