[PATCH v2 4/5] virt-manager: add UI elements for domain title in the details window

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

 



Commit b79ba8382e2205c416d7c4836ac9ee08c72e2c56 in libvirt adds a
<title> attribute to the domain XML, that is used by the user to
identify more easily the VM. This feature is not supported by all
HVs. This patch allows to see and modify the title from the details
window.

Something similar was requested here:
https://bugzilla.redhat.com/show_bug.cgi?id=798949

Signed-off-by: Giuseppe Scrivano <gscrivan@xxxxxxxxxx>
---
 ui/details.ui          | 84 +++++++++++++++++++++++++++++++++-----------------
 virtManager/details.py | 13 +++++++-
 2 files changed, 68 insertions(+), 29 deletions(-)

diff --git a/ui/details.ui b/ui/details.ui
index 0104941..dcf9ef0 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -631,7 +631,7 @@
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="border_width">3</property>
-                                        <property name="n_rows">5</property>
+                                        <property name="n_rows">6</property>
                                         <property name="n_columns">2</property>
                                         <property name="column_spacing">6</property>
                                         <property name="row_spacing">6</property>
@@ -734,49 +734,39 @@
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="label24">
+                                          <object class="GtkEntry" id="overview-name">
                                             <property name="visible">True</property>
-                                            <property name="can_focus">False</property>
-                                            <property name="xalign">0</property>
-                                            <property name="yalign">0</property>
-                                            <property name="label" translatable="yes">Description:</property>
+                                            <property name="can_focus">True</property>
+                                            <signal name="changed" handler="on_overview_name_changed" swapped="no"/>
                                           </object>
                                           <packing>
-                                            <property name="top_attach">3</property>
-                                            <property name="bottom_attach">4</property>
-                                            <property name="x_options">GTK_FILL</property>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
                                             <property name="y_options">GTK_FILL</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkScrolledWindow" id="scrolledwindow2">
+                                          <object class="GtkAlignment" id="alignment14">
                                             <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="shadow_type">in</property>
-                                            <property name="min_content_height">80</property>
+                                            <property name="can_focus">False</property>
                                             <child>
-                                              <object class="GtkTextView" id="overview-description">
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="wrap_mode">word</property>
-                                              </object>
+                                              <placeholder/>
                                             </child>
                                           </object>
                                           <packing>
-                                            <property name="left_attach">1</property>
-                                            <property name="right_attach">2</property>
-                                            <property name="top_attach">3</property>
-                                            <property name="bottom_attach">5</property>
+                                            <property name="top_attach">5</property>
+                                            <property name="bottom_attach">6</property>
+                                            <property name="x_options">GTK_FILL</property>
                                             <property name="y_options">GTK_FILL</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkAlignment" id="alignment14">
+                                          <object class="GtkLabel" id="label24">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
-                                            <child>
-                                              <placeholder/>
-                                            </child>
+                                            <property name="xalign">0</property>
+                                            <property name="yalign">0</property>
+                                            <property name="label" translatable="yes">Description:</property>
                                           </object>
                                           <packing>
                                             <property name="top_attach">4</property>
@@ -786,14 +776,52 @@
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkEntry" id="overview-name">
+                                          <object class="GtkLabel" id="title-label">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">Title:</property>
+                                          </object>
+                                          <packing>
+                                            <property name="top_attach">3</property>
+                                            <property name="bottom_attach">4</property>
+                                            <property name="x_options">GTK_FILL</property>
+                                            <property name="y_options"/>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkEntry" id="overview-title">
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
-                                            <signal name="changed" handler="on_overview_name_changed" swapped="no"/>
+                                            <signal name="changed" handler="on_overview_title_changed" swapped="no"/>
+                                          </object>
+                                          <packing>
+                                            <property name="left_attach">1</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">3</property>
+                                            <property name="bottom_attach">4</property>
+                                            <property name="y_options">GTK_FILL</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkScrolledWindow" id="scrolledwindow2">
+                                            <property name="visible">True</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="shadow_type">in</property>
+                                            <property name="min_content_height">80</property>
+                                            <child>
+                                              <object class="GtkTextView" id="overview-description">
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="wrap_mode">word</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="left_attach">1</property>
                                             <property name="right_attach">2</property>
+                                            <property name="top_attach">4</property>
+                                            <property name="bottom_attach">6</property>
                                             <property name="y_options">GTK_FILL</property>
                                           </packing>
                                         </child>
diff --git a/virtManager/details.py b/virtManager/details.py
index bcca814..5ba4af5 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -43,6 +43,7 @@ from virtinst import util
 
 # Parameters that can be editted in the details window
 (EDIT_NAME,
+EDIT_TITLE,
 EDIT_ACPI,
 EDIT_APIC,
 EDIT_CLOCK,
@@ -93,7 +94,7 @@ EDIT_WATCHDOG_ACTION,
 EDIT_CONTROLLER_MODEL,
 
 EDIT_TPM_TYPE,
-) = range(1, 40)
+) = range(1, 41)
 
 
 # Columns in hw list model
@@ -438,6 +439,7 @@ class vmmDetails(vmmGObjectUI):
             "on_details_pages_switch_page": self.switch_page,
 
             "on_overview_name_changed": lambda *x: self.enable_apply(x, EDIT_NAME),
+            "on_overview_title_changed": lambda *x: self.enable_apply(x, EDIT_TITLE),
             "on_overview_acpi_changed": self.config_acpi_changed,
             "on_overview_apic_changed": self.config_apic_changed,
             "on_overview_clock_changed": lambda *x: self.enable_apply(x, EDIT_CLOCK),
@@ -1979,6 +1981,11 @@ class vmmDetails(vmmGObjectUI):
             name = self.widget("overview-name").get_text()
             add_define(self.vm.define_name, name)
 
+        if self.edited(EDIT_TITLE):
+            title = self.widget("overview-title").get_text()
+            add_define(self.vm.define_title, title)
+            add_hotplug(self.vm.hotplug_title, title)
+
         if self.edited(EDIT_ACPI):
             enable_acpi = self.widget("overview-acpi").get_active()
             if self.widget("overview-acpi").get_inconsistent():
@@ -2543,6 +2550,10 @@ class vmmDetails(vmmGObjectUI):
         desc_widget = self.widget("overview-description")
         desc_widget.get_buffer().set_text(desc)
 
+        title = self.vm.get_title()
+        self.widget("overview-title").set_sensitive(self.vm.title_supported)
+        self.widget("overview-title").set_text(title or "")
+
         # Hypervisor Details
         self.widget("overview-hv").set_text(self.vm.get_pretty_hv_type())
         arch = self.vm.get_arch() or _("Unknown")
-- 
1.8.3.1

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux