[gnome-boxes] Do not show URL entry when going back after selecting source



commit 5baba3e23357d75ff66c088254cabe17526e8be2
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Sat Jun 9 00:00:06 2012 +0200

    Do not show URL entry when going back after selecting source
    
    Show the same source list when going back, the item previously
    selected will have the focus again.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677034

 src/wizard-source.vala |    6 ++++--
 src/wizard.vala        |   32 +++++++++++++++++++++++---------
 2 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 9047295..01a95fb 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -51,12 +51,15 @@ private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
 
 private class Boxes.WizardSource: GLib.Object {
     public Gtk.Widget widget { get { return notebook; } }
+    public Gtk.Widget? selected { get; set; }
     private SourcePage _page;
     public SourcePage page {
         get { return _page; }
         set {
             _page = value;
             notebook.set_current_page (page);
+            if (selected != null)
+                selected.grab_focus ();
             switch (page) {
             case SourcePage.MAIN:
                 add_media_entries.begin ();
@@ -212,7 +215,6 @@ private class Boxes.WizardSource: GLib.Object {
             install_media = media;
             uri = media.device_file;
             url_entry.activate ();
-            page = SourcePage.URL;
         }, 15, 5, media.device_file);
 
         var image = get_os_logo (media.os, 64);
@@ -255,6 +257,7 @@ private class Boxes.WizardSource: GLib.Object {
         if (clicked != null) {
             var button = new Gtk.Button ();
             button.clicked.connect (() => {
+                selected = button;
                 clicked ();
             });
             row = button;
@@ -301,7 +304,6 @@ private class Boxes.WizardSource: GLib.Object {
         if (dialog.run () == Gtk.ResponseType.ACCEPT) {
             uri = dialog.get_uri ();
             url_entry.activate ();
-            page = SourcePage.URL;
         }
 
         dialog.hide ();
diff --git a/src/wizard.vala b/src/wizard.vala
index 0f88ba7..7334520 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -103,14 +103,15 @@ private class Boxes.Wizard: Boxes.UI {
         media_manager = new MediaManager ();
     }
 
-    public Wizard () {
-        vm_creator = new VMCreator ();
-        wizard_source = new Boxes.WizardSource (media_manager);
-        wizard_source.notify["page"].connect(() => {
-            if (wizard_source.page == Boxes.SourcePage.MAIN)
-                next_button.sensitive = false;
-        });
-        wizard_source.url_entry.changed.connect (() => {
+    private void wizard_source_update_next () {
+        next_button.sensitive = false;
+
+        switch (wizard_source.page) {
+        case Boxes.SourcePage.MAIN:
+            next_button.sensitive = wizard_source.selected != null;
+            break;
+
+        case Boxes.SourcePage.URL:
             next_button.sensitive = wizard_source.uri.length != 0;
 
             var text = _("Please enter desktop or collection URI");
@@ -129,7 +130,20 @@ private class Boxes.Wizard: Boxes.UI {
             }
 
             wizard_source.update_url_page (_("Desktop Access"), text, icon);
-        });
+            break;
+
+        default:
+            warn_if_reached ();
+            break;
+        }
+    }
+
+    public Wizard () {
+        vm_creator = new VMCreator ();
+        wizard_source = new Boxes.WizardSource (media_manager);
+        wizard_source.notify["page"].connect(wizard_source_update_next);
+        wizard_source.notify["selected"].connect(wizard_source_update_next);
+        wizard_source.url_entry.changed.connect (wizard_source_update_next);
 
         wizard_source.url_entry.activate.connect(() => {
             page = WizardPage.PREPARATION;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]