[gnome-boxes/troubleshoot-view: 7/7] app, window: Introduce troubleshoot view



commit 7a62b2db108e454de2c5f6ee79a6fecc2e84854f
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jul 11 16:42:01 2017 +0200

    app, window: Introduce troubleshoot view
    
    Sometimes we are not able to launch the application due to issues
    down the stack that we cannot ignore in Boxes.
    
    This patch introduces an error message when Boxes is not able to
    start which allows launching GNOME Logs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784896

 data/gnome-boxes.gresource.xml |  1 +
 data/ui/app-window.ui          |  9 ++++++
 data/ui/troubleshoot-view.ui   | 73 ++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am                |  1 +
 src/app-window.vala            |  8 +++++
 src/app.vala                   |  5 ++-
 src/meson.build                |  1 +
 src/troubleshoot-view.vala     | 13 ++++++++
 src/ui.vala                    |  3 +-
 9 files changed, 112 insertions(+), 2 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 77c1d098..2abaa94c 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -31,6 +31,7 @@
     <file preprocess="xml-stripblanks">ui/snapshot-list-row.ui</file>
     <file preprocess="xml-stripblanks">ui/topbar.ui</file>
     <file preprocess="xml-stripblanks">ui/troubleshoot-log.ui</file>
+    <file preprocess="xml-stripblanks">ui/troubleshoot-view.ui</file>
     <file preprocess="xml-stripblanks">ui/unattended-setup-box.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard-downloadable-entry.ui</file>
diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui
index ee497843..897df7a1 100644
--- a/data/ui/app-window.ui
+++ b/data/ui/app-window.ui
@@ -83,6 +83,15 @@
                   </packing>
                 </child>
 
+                <child>
+                  <object class="BoxesTroubleshootView" id="troubleshoot_view">
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="name">troubleshoot-view</property>
+                  </packing>
+                </child>
+
                 <child>
                   <object class="BoxesIconView" id="icon_view">
                     <property name="visible">True</property>
diff --git a/data/ui/troubleshoot-view.ui b/data/ui/troubleshoot-view.ui
new file mode 100644
index 00000000..7dc964da
--- /dev/null
+++ b/data/ui/troubleshoot-view.ui
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.9 -->
+  <template class="BoxesTroubleshootView" parent="GtkStack">
+    <property name="visible">True</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <property name="halign">fill</property>
+    <property name="valign">fill</property>
+    <property name="transition-type">crossfade</property>
+    <property name="transition-duration">400</property>
+
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+
+        <child>
+          <object class="GtkGrid">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-name">computer-fail-symbolic</property>
+                <property name="pixel-size">128</property>
+                <property name="halign">center</property>
+                <property name="valign">center</property>
+                <property name="margin-bottom">24</property>
+              </object>
+            </child>
+
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="use-markup">True</property>
+                <property name="halign">center</property>
+                <property name="vexpand">True</property>
+                <property name="margin-bottom">6</property>
+                <property name="label" translatable="yes">Oops, something went wrong</property>
+                <attributes>
+                  <attribute name="scale" value="1.2"/> <!-- PANGO_SCALE_LARGE -->
+                  <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
+                </attributes>
+              </object>
+            </child>
+
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="use-markup">True</property>
+                <property name="halign">center</property>
+                <property name="vexpand">True</property>
+                <property name="label" translatable="yes">Boxes cannot access the virtualization 
backend.</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index ffbddffa..598a7cd7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -161,6 +161,7 @@ gnome_boxes_SOURCES =                               \
        empty-boxes.vala                        \
        tracker-iso-query.vala                  \
        troubleshoot-log.vala                   \
+       troubleshoot-view.vala                  \
        shared-folder-popover.vala              \
        snapshot-list-row.vala                  \
        snapshots-property.vala                 \
diff --git a/src/app-window.vala b/src/app-window.vala
index 5d19343c..20fd119d 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -93,6 +93,8 @@
     [GtkChild]
     public EmptyBoxes empty_boxes;
     [GtkChild]
+    public TroubleshootView troubleshoot_view;
+    [GtkChild]
     public Gtk.Stack below_bin;
     [GtkChild]
     private IconView icon_view;
@@ -188,6 +190,7 @@ public void setup_ui () {
         selectionbar.setup_ui (this);
         searchbar.setup_ui (this);
         empty_boxes.setup_ui (this);
+        troubleshoot_view.setup_ui (this);
         notificationbar.searchbar = searchbar;
 
         group = new Gtk.WindowGroup ();
@@ -267,6 +270,11 @@ private void ui_state_changed () {
 
             break;
 
+        case UIState.TROUBLESHOOT:
+            below_bin.visible_child = troubleshoot_view;
+
+            break;
+
         default:
             warning ("Unhandled UI state %s".printf (ui_state.to_string ()));
             break;
diff --git a/src/app.vala b/src/app.vala
index 4dba2aaf..8b50c57a 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -428,7 +428,10 @@ private async void setup_default_source () ensures (default_connection != null)
             yield add_collection_source (source);
         } catch (GLib.Error error) {
             printerr ("Error setting up default broker: %s\n", error.message);
-            release (); // will end application
+
+            main_window.set_state (UIState.TROUBLESHOOT);
+
+            return;
         }
     }
 
diff --git a/src/meson.build b/src/meson.build
index 2555f667..708f74fc 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -86,6 +86,7 @@ vala_sources = [
   'selection-toolbar.vala',
   'shared-folder-popover.vala',
   'spice-display.vala',
+  'troubleshoot-view.vala',
   'topbar.vala',
   'ui.vala',
   'unattended-installer.vala',
diff --git a/src/troubleshoot-view.vala b/src/troubleshoot-view.vala
new file mode 100644
index 00000000..39d35920
--- /dev/null
+++ b/src/troubleshoot-view.vala
@@ -0,0 +1,13 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/troubleshoot-view.ui")]
+private class Boxes.TroubleshootView : Gtk.Stack, Boxes.UI {
+    public UIState previous_ui_state { get; protected set; } 
+    public UIState ui_state { get; protected set; }
+
+    private AppWindow window;
+
+    public void setup_ui (AppWindow window) {
+        this.window = window;
+    }
+}
diff --git a/src/ui.vala b/src/ui.vala
index ed7da367..21b36103 100644
--- a/src/ui.vala
+++ b/src/ui.vala
@@ -6,7 +6,8 @@
     CREDS,
     DISPLAY,
     WIZARD,
-    PROPERTIES
+    PROPERTIES,
+    TROUBLESHOOT
 }
 
 private interface Boxes.UI: GLib.Object {


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