[virt-tools-list] [virt-manager] [PATCH v2 7/8] asyncjob: Add enable/update details methods

Radostin Stoyanov rstoyanov1 at gmail.com
Wed Jul 5 16:51:24 UTC 2017


Add virtual terminal emulator (Vte) in which could be shown details
of background running process.

Usage example:

- To enable details:
> asyncjob.details_enable()

- To show text inside the Vte:
> asyncjob.details_update("Some text here")
---
 ui/asyncjob.ui          | 33 ++++++++++++++++++++++++++++++++-
 virtManager/asyncjob.py | 15 +++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/ui/asyncjob.ui b/ui/asyncjob.ui
index 91caef0..d854246 100644
--- a/ui/asyncjob.ui
+++ b/ui/asyncjob.ui
@@ -89,7 +89,6 @@
                 <property name="width_request">400</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="halign">start</property>
                 <property name="label">some warning</property>
                 <property name="wrap">True</property>
                 <property name="max_width_chars">40</property>
@@ -166,6 +165,38 @@
             <property name="position">4</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkExpander" id="details">
+            <property name="can_focus">True</property>
+            <property name="resize_toplevel">True</property>
+            <child>
+              <object class="GtkScrolledWindow" id="details-box">
+                <property name="width_request">380</property>
+                <property name="height_request">200</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <placeholder/>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">_Details</property>
+                <property name="use_underline">True</property>
+                <property name="track_visited_links">False</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">5</property>
+          </packing>
+        </child>
       </object>
     </child>
   </object>
diff --git a/virtManager/asyncjob.py b/virtManager/asyncjob.py
index 5386296..3c96fdf 100644
--- a/virtManager/asyncjob.py
+++ b/virtManager/asyncjob.py
@@ -23,6 +23,7 @@ import traceback
 
 from gi.repository import Gdk
 from gi.repository import GLib
+from gi.repository import Vte
 
 import libvirt
 
@@ -182,6 +183,9 @@ class vmmAsyncJob(vmmGObjectUI):
         self._error_info = None
         self._data = None
 
+        self._details_widget = None
+        self._details_update_cb = None
+
         self._is_pulsing = True
         self._meter = None
 
@@ -345,3 +349,14 @@ class vmmAsyncJob(vmmGObjectUI):
         self._set_stage_text(stage or _("Completed"))
         self.widget("pbar").set_text(progress)
         self.widget("pbar").set_fraction(1)
+
+    @idle_wrapper
+    def details_enable(self):
+        self._details_widget = Vte.Terminal()
+        self.widget("details-box").add(self._details_widget)
+        self._details_widget.set_visible(True)
+        self.widget("details").set_visible(True)
+
+    @idle_wrapper
+    def details_update(self, data):
+        self._details_widget.feed(data.replace("\n", "\r\n").encode())
-- 
2.9.4




More information about the virt-tools-list mailing list