[gnome-boxes] Move WizardSource widget setup to .ui files



commit ee26f7ad146e4b781c3468d0b081b5247d336ab1
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Dec 24 20:24:51 2013 +0000

    Move WizardSource widget setup to .ui files

 data/gnome-boxes.gresource.xml |    2 +
 data/ui/wizard-media-entry.ui  |   72 +++++++++
 data/ui/wizard-source.ui       |  269 ++++++++++++++++++++++++++++++++++
 po/POTFILES.in                 |    1 +
 src/wizard-source.vala         |  312 +++++++++++++++-------------------------
 src/wizard.vala                |    8 +-
 6 files changed, 463 insertions(+), 201 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index ce518e6..3f7c824 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -6,6 +6,8 @@
     <file>icons/boxes-dark.png</file>
     <file>icons/boxes-gray.png</file>
     <file preprocess="xml-stripblanks">ui/unattended-setup-box.ui</file>
+    <file preprocess="xml-stripblanks">ui/wizard-media-entry.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard-scrolled.ui</file>
+    <file preprocess="xml-stripblanks">ui/wizard-source.ui</file>
   </gresource>
 </gresources>
diff --git a/data/ui/wizard-media-entry.ui b/data/ui/wizard-media-entry.ui
new file mode 100644
index 0000000..a8585f6
--- /dev/null
+++ b/data/ui/wizard-media-entry.ui
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.9 -->
+  <template class="BoxesWizardMediaEntry" parent="GtkButton">
+    <style>
+      <class name="boxes-menu-row"/>
+    </style>
+    <child>
+      <object class="GtkBox" id="hbox">
+        <property name="visible">True</property>
+        <property name="margin-top">5</property>
+        <property name="margin-bottom">5</property>
+        <property name="margin-left">15</property>
+        <property name="margin-right">15</property>
+        <property name="spacing">20</property>
+        <property name="orientation">horizontal</property>
+        <child>
+          <object class="GtkImage" id="media_image">
+            <property name="visible">True</property>
+            <property name="icon-name">media-optical</property>
+            <property name="icon-size">0</property>
+            <property name="pixel-size">64</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="vbox">
+            <property name="visible">True</property>
+            <property name="homogeneous">True</property>
+            <property name="spacing">5</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkLabel" id="title_label">
+                <property name="visible">True</property>
+                <property name="ellipsize">end</property>
+                <property name="xalign">0.0</property>
+                <style>
+                  <class name="boxes-source-label"/>
+                </style>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="details_label">
+                <property name="visible">True</property>
+                <property name="ellipsize">end</property>
+                <property name="xalign">0.0</property>
+                <style>
+                  <class name="boxes-step-label"/>
+                </style>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/data/ui/wizard-source.ui b/data/ui/wizard-source.ui
new file mode 100644
index 0000000..3f6d7d9
--- /dev/null
+++ b/data/ui/wizard-source.ui
@@ -0,0 +1,269 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.9 -->
+  <template class="BoxesWizardSource" parent="GtkNotebook">
+    <property name="visible">True</property>
+    <property name="show-tabs">False</property>
+    <signal name="switch-page" handler="on_switch_page"/>
+    <style>
+      <class name="boxes-source-nb"/>
+    </style>
+
+    <!-- main page -->
+    <child>
+      <object class="GtkBox" id="main_vbox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">0</property>
+        <property name="margin-top">15</property>
+        <property name="margin-bottom">15</property>
+        <style>
+          <class name="boxes-menu"/>
+        </style>
+        <child>
+          <object class="BoxesWizardScrolled" id="media_scrolled"/>
+        </child>
+
+        <child>
+          <object class="GtkButton" id="enter_url_button">
+            <signal name="clicked" handler="on_enter_url_button_clicked"/>
+            <style>
+              <class name="boxes-menu-row"/>
+            </style>
+            <child>
+              <object class="GtkBox" id="enter_url_box">
+                <property name="visible">True</property>
+                <property name="margin-top">10</property>
+                <property name="margin-bottom">10</property>
+                <property name="margin-left">20</property>
+                <property name="margin-right">20</property>
+                <property name="spacing">20</property>
+                <property name="orientation">horizontal</property>
+                <child>
+                  <object class="GtkLabel" id="enter_url_label">
+                    <property name="visible">True</property>
+                    <property name="xalign">0.0</property>
+                    <property name="label" translatable="yes">Enter URL</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="enter_url_next_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">▶</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+
+        <child>
+          <object class="GtkButton" id="select_file_button">
+            <signal name="clicked" handler="on_select_file_button_clicked"/>
+            <style>
+              <class name="boxes-menu-row"/>
+            </style>
+            <child>
+              <object class="GtkBox" id="select_file_box">
+                <property name="visible">True</property>
+                <property name="margin-top">10</property>
+                <property name="margin-bottom">10</property>
+                <property name="margin-left">20</property>
+                <property name="margin-right">20</property>
+                <property name="spacing">20</property>
+                <property name="orientation">horizontal</property>
+                <child>
+                  <object class="GtkLabel" id="select_file_label">
+                    <property name="visible">True</property>
+                    <property name="xalign">0.0</property>
+                    <property name="label" translatable="yes">Select a file</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="select_file_next_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">▶</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+
+        <child>
+          <object class="GtkButton" id="libvirt_sys_import_button">
+            <property name="visible">False</property>
+            <signal name="clicked" handler="on_libvirt_sys_import_button_clicked"/>
+            <style>
+              <class name="boxes-menu-row"/>
+            </style>
+            <child>
+              <object class="GtkBox" id="libvirt_sys_import_box">
+                <property name="visible">True</property>
+                <property name="margin-top">10</property>
+                <property name="margin-bottom">10</property>
+                <property name="margin-left">20</property>
+                <property name="margin-right">20</property>
+                <property name="spacing">20</property>
+                <property name="orientation">horizontal</property>
+                <child>
+                  <object class="GtkLabel" id="libvirt_sys_import_label">
+                    <property name="visible">True</property>
+                    <property name="xalign">0.0</property>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="libvirt_sys_import_next_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">▶</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+
+    <!-- URL page -->
+    <child>
+      <object class="GtkBox" id="url_menubox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">0</property>
+        <property name="margin-top">15</property>
+        <property name="margin-bottom">15</property>
+        <style>
+          <class name="boxes-menu"/>
+        </style>
+        <child>
+          <object class="GtkButton" id="url_back_button">
+            <signal name="clicked" handler="on_url_back_button_clicked"/>
+            <style>
+              <class name="boxes-menu-row"/>
+            </style>
+            <child>
+              <object class="GtkBox" id="url_back_box">
+                <property name="visible">True</property>
+                <property name="margin-top">10</property>
+                <property name="margin-bottom">10</property>
+                <property name="margin-left">20</property>
+                <property name="margin-right">20</property>
+                <property name="spacing">20</property>
+                <property name="orientation">horizontal</property>
+                <child>
+                  <object class="GtkLabel" id="enter_url_back_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">◀</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="enter_url_label2">
+                    <property name="visible">True</property>
+                    <property name="xalign">0.0</property>
+                    <property name="label" translatable="yes">Enter URL</property>
+                    <style>
+                      <class name="boxes-source-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+
+        <child>
+          <object class="GtkAlignment" id="url_entry_bin">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="xscale">1</property>
+            <property name="yscale">1</property>
+            <style>
+              <class name="boxes-menu-row"/>
+            </style>
+            <child>
+              <object class="GtkBox" id="url_entry_vbox">
+                <property name="visible">True</property>
+                <property name="margin-top">10</property>
+                <property name="margin-bottom">10</property>
+                <property name="margin-left">20</property>
+                <property name="margin-right">20</property>
+                <property name="spacing">20</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkEntry" id="url_entry"/>
+                </child>
+
+                <child>
+                  <object class="GtkBox" id="url_entry_hbox">
+                    <property name="visible">True</property>
+                    <property name="spacing">0</property>
+                    <property name="orientation">horizontal</property>
+                    <child>
+                      <object class="GtkImage" id="url_image">
+                        <property name="visible">True</property>
+                        <property name="icon-name">network-workgroup</property>
+                        <property name="icon-size">0</property>
+                        <property name="pixel-size">96</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                      </packing>
+                    </child>
+
+                    <child>
+                      <object class="GtkLabel" id="url_description_label">
+                        <property name="visible">True</property>
+                        <property name="use-markup">True</property>
+                        <property name="wrap">True</property>
+                        <property name="xalign">0</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 00b5a82..1bce449 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ data/gnome-boxes.desktop.in.in
 data/org.gnome.boxes.gschema.xml.in
 [type: gettext/glade]data/ui/unattended-setup-box.ui
 [type: gettext/glade]data/ui/wizard-scrolled.ui
+[type: gettext/glade]data/ui/wizard-source.ui
 src/app.vala
 src/collection-view.vala
 src/display-page.vala
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 866c2bb..1506486 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -17,7 +17,10 @@ private class Boxes.WizardScrolled : Gtk.ScrolledWindow {
     public Gtk.Box vbox;
 
     private int num_visible;
-    public WizardScrolled (int num_visible) {
+
+    // Ideally, we shouldn't need this fuction but is there a way to connect
+    // vscrollbar signals from the UI template?
+    public void setup (int num_visible) {
         this.num_visible = num_visible;
 
         notify["num-visible"].connect (() => {
@@ -55,30 +58,46 @@ 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 ();
-                // FIXME: grab first element in the menu list
-                main_vbox.grab_focus ();
-                break;
-            case SourcePage.URL:
-                url_entry.changed ();
-                url_entry.grab_focus ();
-                break;
-            }
-        }
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-media-entry.ui")]
+private class Boxes.WizardMediaEntry : Gtk.Button {
+    public InstallerMedia media;
+
+    [GtkChild]
+    private Gtk.Image media_image;
+    [GtkChild]
+    private Gtk.Label title_label;
+    [GtkChild]
+    private Gtk.Label details_label;
+
+    public WizardMediaEntry (InstallerMedia media) {
+        this.media = media;
+
+        if (media.os != null)
+            Downloader.fetch_os_logo.begin (media_image, media.os, 64);
+
+        title_label.label = media.label;
+        if (media.os_media != null && media.os_media.live)
+            // Translators: We show 'Live' tag next or below the name of live OS media or box based on such 
media.
+            //              http://en.wikipedia.org/wiki/Live_CD
+            title_label.label += " (" +  _("Live") + ")";
+
+        if (media.os_media != null) {
+            var architecture = (media.os_media.architecture == "i386" || media.os_media.architecture == 
"i686") ?
+                               _("32-bit x86 system") :
+                               _("64-bit x86 system");
+            details_label.label = architecture;
+
+            if (media.os.vendor != null)
+                // Translator comment: %s is name of vendor here (e.g Canonical Ltd or Red Hat Inc)
+                details_label.label += _(" from %s").printf (media.os.vendor);
+        } else
+            details_label.label += _("Unknown media");
     }
+}
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-source.ui")]
+private class Boxes.WizardSource: Gtk.Notebook {
+    public Gtk.Widget? selected { get; set; }
     public string uri {
         get { return url_entry.get_text (); }
         set { url_entry.set_text (value); }
@@ -87,101 +106,74 @@ private class Boxes.WizardSource: GLib.Object {
     public LibvirtSystemImporter libvirt_sys_importer { get; private set; }
     public bool libvirt_sys_import;
 
+    public signal void activated (); // Emitted on user activating a source
+
+    [GtkChild]
     private Gtk.Box main_vbox;
-    private Gtk.Box media_vbox;
+    [GtkChild]
     private Boxes.WizardScrolled media_scrolled;
-    private Gtk.Notebook notebook;
-    private Gtk.Label url_label;
+    [GtkChild]
+    private Gtk.Label url_description_label;
+    [GtkChild]
     private Gtk.Image url_image;
+    [GtkChild]
+    private Gtk.Alignment url_entry_bin;
+    [GtkChild]
     public Gtk.Entry url_entry;
+    [GtkChild]
+    private Gtk.Button select_file_button;
+    [GtkChild]
+    private Gtk.Button libvirt_sys_import_button;
+    [GtkChild]
+    private Gtk.Label libvirt_sys_import_label;
 
-    public signal void activate (); // Emitted on user activating a source
+    private Gtk.Box media_vbox;
 
     private MediaManager media_manager;
 
     public WizardSource (MediaManager media_manager) {
         this.media_manager = media_manager;
 
-        notebook = new Gtk.Notebook ();
-        notebook.width_request = 500;
-        notebook.get_style_context ().add_class ("boxes-source-nb");
-        notebook.show_tabs = false;
-
-        /* main page */
-        main_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-        main_vbox.get_style_context ().add_class ("boxes-menu");
-        main_vbox.margin_top = main_vbox.margin_bottom = 15;
         main_vbox.grab_focus ();
-        notebook.append_page (main_vbox, null);
 
-        media_scrolled = new WizardScrolled (5);
+        media_scrolled.setup (5);
         media_vbox = media_scrolled.vbox;
-        main_vbox.add (media_scrolled);
+        draw_as_css_box (url_entry_bin);
 
-        var hbox = add_entry (main_vbox, () => {
-            page = SourcePage.URL;
-
-            return false;
-        });
-        var label = new Gtk.Label (_("Enter URL"));
-        label.xalign = 0.0f;
-        hbox.pack_start (label, true, true);
-        var next = new Gtk.Label ("▶");
-        hbox.pack_start (next, false, false);
-
-        hbox = add_entry (main_vbox, launch_file_selection_dialog);
-        label = new Gtk.Label (_("Select a file"));
-        label.xalign = 0.0f;
-        hbox.pack_start (label, true, true);
-        next = new Gtk.Label ("▶");
-        hbox.pack_start (next, false, false);
-
-        /* URL page */
-        var url_menubox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
-        url_menubox.get_style_context ().add_class ("boxes-menu");
-        url_menubox.margin_top = url_menubox.margin_bottom = 15;
-        notebook.append_page (url_menubox, null);
-
-        hbox = add_entry (url_menubox, () => {
-            selected = null;
-            page = SourcePage.MAIN;
-
-            return false;
-        });
-        var prev = new Gtk.Label ("◀");
-        hbox.pack_start (prev, false, false);
-        label = new Gtk.Label (_("Enter URL"));
-        label.get_style_context ().add_class ("boxes-source-label");
-        hbox.pack_start (label, true, true);
-
-        var vbox = add_entry (url_menubox);
-        vbox.set_orientation (Gtk.Orientation.VERTICAL);
-        url_entry = new Gtk.Entry ();
-        vbox.add (url_entry);
-
-        hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
-        url_image = new Gtk.Image.from_icon_name ("network-workgroup", 0);
-        // var image = new Gtk.Image.from_icon_name ("krfb", 0);
-        url_image.pixel_size = 96;
-        hbox.pack_start (url_image, false, false);
-
-        url_label = new Gtk.Label (null);
-        url_label.xalign = 0.0f;
-        url_label.set_markup (_("<b>Desktop Access</b>\n\nWill add boxes for all systems available from this 
account."));
-        url_label.set_use_markup (true);
-        url_label.wrap = true;
-
-        hbox.pack_start (url_label, true, true);
-        vbox.add (hbox);
-
-        notebook.show_all ();
-
-        add_libvirt_sytem_entry.begin ();
+        update_libvirt_sytem_entry_visibility.begin ();
         add_media_entries.begin ();
     }
 
+    [GtkCallback]
+    private void on_enter_url_button_clicked () {
+        page = SourcePage.URL;
+    }
+
+    [GtkCallback]
+    private void on_url_back_button_clicked () {
+        selected = null;
+        page = SourcePage.MAIN;
+    }
+
+    [GtkCallback]
+    private void on_switch_page (Gtk.Notebook self, Gtk.Widget page, uint page_num) {
+        if (selected != null)
+            selected.grab_focus ();
+        switch (page_num) {
+        case SourcePage.MAIN:
+            add_media_entries.begin ();
+            // FIXME: grab first element in the menu list
+            main_vbox.grab_focus ();
+            break;
+        case SourcePage.URL:
+            url_entry.changed ();
+            url_entry.grab_focus ();
+            break;
+        }
+    }
+
     public void update_url_page(string title, string text, string icon_name) {
-        url_label.set_markup ("<b>"  + title + "</b>\n\n" + text);
+        url_description_label.set_markup ("<b>"  + title + "</b>\n\n" + text);
         url_image.icon_name = icon_name;
     }
 
@@ -189,13 +181,11 @@ private class Boxes.WizardSource: GLib.Object {
         var medias = yield media_manager.list_installer_medias ();
 
         foreach (var child in media_vbox.get_children ()) {
-            var child_media = child.get_data<string> ("boxes-media");
-            if (child_media == null)
-                continue;
+            var child_media = (child as WizardMediaEntry).media;
 
             var obsolete = true;
             foreach (var media in medias)
-                if (child_media == media.device_file) {
+                if (child_media.device_file == media.device_file) {
                     obsolete = false;
 
                     break;
@@ -208,8 +198,8 @@ private class Boxes.WizardSource: GLib.Object {
         foreach (var media in medias) {
             var nouveau = true; // Everyone speaks some French, right? :)
             foreach (var child in media_vbox.get_children ()) {
-                var child_media = child.get_data<string> ("boxes-media");
-                if (child_media  != null && child_media == media.device_file) {
+                var child_media = (child as WizardMediaEntry).media;
+                if (child_media.device_file == media.device_file) {
                     nouveau = false;
 
                     break;
@@ -226,54 +216,19 @@ private class Boxes.WizardSource: GLib.Object {
     }
 
     private void add_media_entry (InstallerMedia media) {
-        var hbox = add_entry (media_vbox, () => {
+        var entry = new WizardMediaEntry (media);
+        media_vbox.add (entry);
+        entry.clicked.connect (() => {
             on_media_selected (media);
 
-            return true;
-        }, 15, 5, media.device_file);
-
-        var image = new Gtk.Image.from_icon_name ("media-optical", 0);
-        image.pixel_size = 64;
-        hbox.pack_start (image, false, false);
-
-        if (media.os != null)
-            Downloader.fetch_os_logo.begin (image, media.os, 64);
-
-        var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 5);
-        vbox.homogeneous = true;
-        hbox.pack_start (vbox, true, true);
-
-        var media_label = media.label;
-        if (media.os_media != null && media.os_media.live)
-            // Translators: We show 'Live' tag next or below the name of live OS media or box based on such 
media.
-            //              http://en.wikipedia.org/wiki/Live_CD
-            media_label += " (" +  _("Live") + ")";
-        var label = new Gtk.Label (media_label);
-        label.set_ellipsize (Pango.EllipsizeMode.END);
-        label.get_style_context ().add_class ("boxes-source-label");
-        label.xalign = 0.0f;
-        vbox.pack_start (label, true, true);
-
-        if (media.os_media != null) {
-            var architecture = (media.os_media.architecture == "i386" || media.os_media.architecture == 
"i686") ?
-                               _("32-bit x86 system") :
-                               _("64-bit x86 system");
-            label = new Gtk.Label (architecture);
-            label.set_ellipsize (Pango.EllipsizeMode.END);
-            label.get_style_context ().add_class ("boxes-step-label");
-            label.xalign = 0.0f;
-            vbox.pack_start (label, true, true);
-
-            if (media.os.vendor != null)
-                // Translator comment: %s is name of vendor here (e.g Canonical Ltd or Red Hat Inc)
-                label.label += _(" from %s").printf (media.os.vendor);
-        }
+            selected = entry;
+        });
 
         media_vbox.show_all ();
         media_scrolled.show ();
     }
 
-    private async void add_libvirt_sytem_entry () {
+    private async void update_libvirt_sytem_entry_visibility () {
         try {
             libvirt_sys_importer = yield new LibvirtSystemImporter ();
         } catch (LibvirtSystemImporterError.NO_IMPORTS error) {
@@ -281,54 +236,12 @@ private class Boxes.WizardSource: GLib.Object {
 
             return;
         }
-
-        var hbox = add_entry (main_vbox, () => {
-            libvirt_sys_import = true;
-            activate ();
-
-            return true;
-        });
-        var label = new Gtk.Label (libvirt_sys_importer.wizard_menu_label);
-        label.xalign = 0.0f;
-        hbox.pack_start (label, true, true);
-        var next = new Gtk.Label ("▶");
-        hbox.pack_start (next, false, false);
+        libvirt_sys_import_label.label = libvirt_sys_importer.wizard_menu_label;
         main_vbox.show_all ();
     }
 
-    private Gtk.Box add_entry (Gtk.Box            box,
-                               owned ClickedFunc? clicked = null,
-                               int                h_margin = 20,
-                               int                v_margin = 10,
-                               string?            media = null) {
-        Gtk.Container row;
-        if (clicked != null) {
-            var button = new Gtk.Button ();
-            button.clicked.connect (() => {
-                if (clicked ())
-                    selected = button;
-            });
-            row = button;
-        } else {
-            var bin = new Gtk.Alignment (0,0,1,1);
-            draw_as_css_box (bin);
-            row = bin;
-        }
-        var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
-        row.add (hbox);
-        row.get_style_context ().add_class ("boxes-menu-row");
-
-        box.add (row);
-        if (media != null)
-            row.set_data ("boxes-media", media);
-
-        hbox.margin_left = hbox.margin_right = h_margin;
-        hbox.margin_top = hbox.margin_bottom = v_margin;
-
-        return hbox;
-    }
-
-    private bool launch_file_selection_dialog () {
+    [GtkCallback]
+    private void on_select_file_button_clicked () {
         var dialog = new Gtk.FileChooserDialog (_("Select a device or ISO file"),
                                                 App.app.window,
                                                 Gtk.FileChooserAction.OPEN,
@@ -339,26 +252,31 @@ private class Boxes.WizardSource: GLib.Object {
         dialog.filter.add_mime_type ("application/x-cd-image");
         foreach (var extension in InstalledMedia.supported_extensions)
             dialog.filter.add_pattern ("*" + extension);
-        var ret = false;
         if (dialog.run () == Gtk.ResponseType.ACCEPT) {
             uri = dialog.get_uri ();
             // clean install_media as this may be set already when going back in the wizard
             install_media = null;
-            activate ();
+            activated ();
 
-            ret = true;
+            selected = select_file_button;
         }
 
         dialog.destroy ();
+    }
+
+    [GtkCallback]
+    private void on_libvirt_sys_import_button_clicked () {
+        libvirt_sys_import = true;
+        activated ();
 
-        return ret;
+        selected = libvirt_sys_import_button;
     }
 
     private void on_media_selected (InstallerMedia media) {
         try {
             install_media = media_manager.create_installer_media_from_media (media);
             uri = media.device_file;
-            activate ();
+            activated ();
         } catch (GLib.Error error) {
             // This is unlikely to happen since media we use as template should have already done most async 
work
             warning ("Failed to setup installation media '%s': %s", media.device_file, error.message);
diff --git a/src/wizard.vala b/src/wizard.vala
index 30d7fec..4f357e1 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -175,7 +175,7 @@ private class Boxes.Wizard: Boxes.UI {
         wizard_source.notify["selected"].connect(wizard_source_update_next);
         wizard_source.url_entry.changed.connect (wizard_source_update_next);
 
-        wizard_source.activate.connect(() => {
+        wizard_source.activated.connect(() => {
             page = WizardPage.PREPARATION;
         });
 
@@ -577,9 +577,9 @@ private class Boxes.Wizard: Boxes.UI {
         label.wrap = true;
         label.xalign = 0.0f;
         vbox.pack_start (label, false, false);
-        vbox.pack_start (wizard_source.widget, false, false);
-        wizard_source.widget.hexpand = true;
-        wizard_source.widget.halign = Gtk.Align.CENTER;
+        vbox.pack_start (wizard_source, false, false);
+        wizard_source.hexpand = true;
+        wizard_source.halign = Gtk.Align.CENTER;
         label = new Gtk.Label (_("Any trademarks shown above are used merely for identification of software 
products you have already obtained and are the property of their respective owners."));
         label.get_style_context ().add_class ("boxes-logo-notice-label");
         label.wrap = true;


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