[gnome-boxes/wip/rishi/rhel: 2/14] wizard, wizard-source: Use the headerbar to go back from "Enter URL"



commit 9167acbd90afbde0b6a62fc8878c0987668b9295
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Aug 23 18:35:10 2017 +0200

    wizard, wizard-source: Use the headerbar to go back from "Enter URL"
    
    This makes the "Enter URL" page visually consistent with the others,
    and enables the alt+<left> keyboard shortcut.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786689

 data/ui/wizard-source.ui |   42 ------------------------------------------
 src/wizard-source.vala   |    6 ------
 src/wizard.vala          |   19 +++++++++++++++----
 3 files changed, 15 insertions(+), 52 deletions(-)
---
diff --git a/data/ui/wizard-source.ui b/data/ui/wizard-source.ui
index d85376c..4664fe7 100644
--- a/data/ui/wizard-source.ui
+++ b/data/ui/wizard-source.ui
@@ -202,48 +202,6 @@
           <class name="boxes-menu"/>
         </style>
         <child>
-          <object class="GtkButton" id="url_back_button">
-          <property name="visible">True</property>
-            <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-start">20</property>
-                <property name="margin-end">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="halign">start</property>
-                    <property name="label" translatable="yes">Enter URL</property>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-          </object>
-        </child>
-
-        <child>
           <object class="GtkBox" id="url_entry_vbox">
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index eb99882..70936a4 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -223,12 +223,6 @@ private class Boxes.WizardSource: Gtk.Stack {
         activated ();
     }
 
-    [GtkCallback]
-    private void on_url_back_button_clicked () {
-        selected = null;
-        page = SourcePage.MAIN;
-    }
-
     private async void add_media_entries () {
         var medias = yield media_manager.list_installer_medias ();
 
diff --git a/src/wizard.vala b/src/wizard.vala
index 16879ad..6001e44 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -132,7 +132,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
                 return;
 
             _page = value;
-            back_button.sensitive = (value != WizardPage.SOURCE);
+            update_back_button_sensitivity ();
             wizard_window.topbar.set_title_for_page (value);
             visible_child_name = page_names[value];
 
@@ -153,6 +153,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
     }
 
     private void wizard_source_update_next () {
+        update_back_button_sensitivity ();
         if (page != WizardPage.SOURCE)
             return;
 
@@ -629,9 +630,14 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
         cancel_button.clicked.connect (cancel);
         back_button = wizard_window.topbar.back_btn;
         back_button.clicked.connect (() => {
-            prepare_cancellable.cancel ();
-
-            page = page - 1;
+            if (page == WizardPage.SOURCE) {
+                return_if_fail (wizard_source.page == SourcePage.URL);
+                wizard_source.selected = null;
+                wizard_source.page = SourcePage.MAIN;
+            } else {
+                prepare_cancellable.cancel ();
+                page = page - 1;
+            }
         });
         continue_button = wizard_window.topbar.continue_btn;
         continue_button.clicked.connect (() => {
@@ -646,6 +652,11 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
         wizard_source.setup_ui (window);
     }
 
+    public void update_back_button_sensitivity () {
+        var disable_back_button = page == WizardPage.SOURCE && wizard_source.page == SourcePage.MAIN;
+        back_button.sensitive = !disable_back_button;
+    }
+
     public void open_with_uri (string uri, bool skip_review_for_live = true) {
         window.set_state (UIState.WIZARD);
         this.skip_review_for_live = skip_review_for_live;


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