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

[virt-tools-list] [PATCH] x2 [virt-manager] trivial GUI improvements



I'm hoping to do a bit more significant work tomorrow: improving on fullscreen behaviour.
I'm envisioning a mini menubar that minimizes to a small line, like the one Virtualbox has. Thoughts concerning behaviour and/or implementation welcomed.

Also, on browsing the bugtracker I saw that:
https://bugzilla.redhat.com/show_bug.cgi?id=498641 has a sensible patch seemingly ignored
https://bugzilla.redhat.com/show_bug.cgi?id=459074 can probably be marked invalid/resolved now

Patches following inline.

# HG changeset patch
# User Jon Nordby <jononor gmail com>
# Date 1257885231 -3600
# Node ID 3f28e5933acde147d357923907d28754e8817444
# Parent  f8fbdfc7439c5e5b7ae0d2c1c5cb68853692e260
host: Show hostname in window title

Activating a connected host entry in manager opens host window.

diff -r f8fbdfc7439c -r 3f28e5933acd src/virtManager/host.py
--- a/src/virtManager/host.py    Tue Nov 10 12:04:38 2009 -0500
+++ b/src/virtManager/host.py    Tue Nov 10 21:33:51 2009 +0100
@@ -49,6 +49,9 @@
         topwin = self.window.get_widget("vmm-host")
         topwin.hide()
 
+        self.title = conn.get_short_hostname() + " " + topwin.get_title()
+        topwin.set_title(self.title)
+
         self.err = vmmErrorDialog(topwin,
                                   0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
                                   _("Unexpected Error"),
diff -r f8fbdfc7439c -r 3f28e5933acd src/virtManager/manager.py
--- a/src/virtManager/manager.py    Tue Nov 10 12:04:38 2009 -0500
+++ b/src/virtManager/manager.py    Tue Nov 10 21:33:51 2009 +0100
@@ -680,12 +680,14 @@
         conn = self.current_connection()
         if conn.get_state() == vmmConnection.STATE_DISCONNECTED:
             conn.open()
+            return True
 
     def open_vm_console(self,ignore,ignore2=None,ignore3=None):
         if self.current_vmuuid():
             self.emit("action-show-console", self.current_connection_uri(), self.current_vmuuid())
         elif self.current_connection():
-            self.open_connection()
+            if not self.open_connection():
+                self.emit("action-show-host", self.current_connection_uri())
 
     def open_clone_window(self, ignore1=None, ignore2=None, ignore3=None):
         if self.current_vmuuid():



# HG changeset patch
# User Jon Nordby <jononor gmail com>
# Date 1257896253 -3600
# Node ID 9c7e912548261b01cb31d91b3c447a7e866423d7
# Parent  3f28e5933acde147d357923907d28754e8817444
manager: enable menu key to open context menu

diff -r 3f28e5933acd -r 9c7e91254826 src/virtManager/manager.py
--- a/src/virtManager/manager.py    Tue Nov 10 21:33:51 2009 +0100
+++ b/src/virtManager/manager.py    Wed Nov 11 00:37:33 2009 +0100
@@ -350,7 +350,8 @@
             "on_vm_list_row_activated": self.open_vm_console,
             "on_vm_list_row_expanded": self.row_expanded,
             "on_vm_list_row_collapsed": self.row_collapsed,
-            "on_vm_list_button_press_event": self.popup_vm_menu,
+            "on_vm_list_button_press_event": self.popup_vm_menu_button,
+            "on_vm_list_key_press_event": self.popup_vm_menu_key,
 
             "on_menu_edit_preferences_activate": self.show_preferences,
             "on_menu_help_about_activate": self.show_about,
@@ -724,66 +725,78 @@
         self.window.get_widget("menu_file_restore_saved").set_sensitive(restore)
 
 
-    def popup_vm_menu(self, widget, event):
+    def popup_vm_menu_key(self, widget, event):
+        if gtk.gdk.keyval_name(event.keyval) != "Menu":
+            return False
+        vmlist = self.window.get_widget("vm-list")
+        treeselection = vmlist.get_selection()
+        model, _iter = treeselection.get_selected()
+        self.popup_vm_menu(model, _iter, event)
+        return True
+
+    def popup_vm_menu_button(self, widget, event):
+        if event.button != 3:
+            return False
         tup = widget.get_path_at_pos(int(event.x), int(event.y))
         if tup == None:
             return False
         path = tup[0]
         model = widget.get_model()
         _iter = model.get_iter(path)
+        self.popup_vm_menu(model, _iter, event)
+        return True
+
+    def popup_vm_menu(self, model, _iter, event):
         if model.iter_parent(_iter) != None:
             # a vm is selected, retrieve it from the first column of the model
             vm = model.get_value(_iter, ROW_HANDLE)
-            if event.button == 3:
-                # Update popup menu based upon vm status
-                if vm.is_read_only() == True:
-                    self.vmmenu_items["run"].set_sensitive(False)
+            # Update popup menu based upon vm status
+            if vm.is_read_only() == True:
+                self.vmmenu_items["run"].set_sensitive(False)
+                self.vmmenu_items["pause"].set_sensitive(False)
+                self.vmmenu_items["pause"].show()
+                self.vmmenu_items["resume"].hide()
+                self.vmmenu_items["resume"].set_sensitive(False)
+                self.vmmenu_items["shutdown"].set_sensitive(False)
+                self.vmmenu_items["migrate"].set_sensitive(False)
+            else:
+                if vm.status() == libvirt.VIR_DOMAIN_SHUTOFF:
+                    self.vmmenu_items["run"].set_sensitive(True)
                     self.vmmenu_items["pause"].set_sensitive(False)
                     self.vmmenu_items["pause"].show()
                     self.vmmenu_items["resume"].hide()
                     self.vmmenu_items["resume"].set_sensitive(False)
                     self.vmmenu_items["shutdown"].set_sensitive(False)
-                    self.vmmenu_items["migrate"].set_sensitive(False)
-                else:
-                    if vm.status() == libvirt.VIR_DOMAIN_SHUTOFF:
-                        self.vmmenu_items["run"].set_sensitive(True)
-                        self.vmmenu_items["pause"].set_sensitive(False)
-                        self.vmmenu_items["pause"].show()
-                        self.vmmenu_items["resume"].hide()
-                        self.vmmenu_items["resume"].set_sensitive(False)
-                        self.vmmenu_items["shutdown"].set_sensitive(False)
-                        self.vmmenu_items["migrate"].set_sensitive(True)
-                    elif vm.status() == libvirt.VIR_DOMAIN_RUNNING:
-                        self.vmmenu_items["run"].set_sensitive(False)
-                        self.vmmenu_items["pause"].set_sensitive(True)
-                        self.vmmenu_items["pause"].show()
-                        self.vmmenu_items["resume"].hide()
-                        self.vmmenu_items["resume"].set_sensitive(False)
-                        self.vmmenu_items["shutdown"].set_sensitive(True)
-                        self.vmmenu_items["migrate"].set_sensitive(True)
-                    elif vm.status() == libvirt.VIR_DOMAIN_PAUSED:
-                        self.vmmenu_items["run"].set_sensitive(False)
-                        self.vmmenu_items["pause"].hide()
-                        self.vmmenu_items["pause"].set_sensitive(False)
-                        self.vmmenu_items["resume"].show()
-                        self.vmmenu_items["resume"].set_sensitive(True)
-                        self.vmmenu_items["shutdown"].set_sensitive(True)
-                        self.vmmenu_items["migrate"].set_sensitive(True)
-                self.vmmenu.popup(None, None, None, 0, event.time)
-            return False
+                    self.vmmenu_items["migrate"].set_sensitive(True)
+                elif vm.status() == libvirt.VIR_DOMAIN_RUNNING:
+                    self.vmmenu_items["run"].set_sensitive(False)
+                    self.vmmenu_items["pause"].set_sensitive(True)
+                    self.vmmenu_items["pause"].show()
+                    self.vmmenu_items["resume"].hide()
+                    self.vmmenu_items["resume"].set_sensitive(False)
+                    self.vmmenu_items["shutdown"].set_sensitive(True)
+                    self.vmmenu_items["migrate"].set_sensitive(True)
+                elif vm.status() == libvirt.VIR_DOMAIN_PAUSED:
+                    self.vmmenu_items["run"].set_sensitive(False)
+                    self.vmmenu_items["pause"].hide()
+                    self.vmmenu_items["pause"].set_sensitive(False)
+                    self.vmmenu_items["resume"].show()
+                    self.vmmenu_items["resume"].set_sensitive(True)
+                    self.vmmenu_items["shutdown"].set_sensitive(True)
+                    self.vmmenu_items["migrate"].set_sensitive(True)
+            self.vmmenu.popup(None, None, None, 0, event.time)
         else:
+            # a host is selected
             conn = model.get_value(_iter, ROW_HANDLE)
-            if event.button == 3:
-                if conn.get_state() != vmmConnection.STATE_DISCONNECTED:
-                    self.connmenu_items["create"].set_sensitive(True)
-                    self.connmenu_items["disconnect"].set_sensitive(True)
-                    self.connmenu_items["connect"].set_sensitive(False)
-                else:
-                    self.connmenu_items["create"].set_sensitive(False)
-                    self.connmenu_items["disconnect"].set_sensitive(False)
-                    self.connmenu_items["connect"].set_sensitive(True)
-                self.connmenu.popup(None, None, None, 0, event.time)
-            return False
+            if conn.get_state() != vmmConnection.STATE_DISCONNECTED:
+                self.connmenu_items["create"].set_sensitive(True)
+                self.connmenu_items["disconnect"].set_sensitive(True)
+                self.connmenu_items["connect"].set_sensitive(False)
+            else:
+                self.connmenu_items["create"].set_sensitive(False)
+                self.connmenu_items["disconnect"].set_sensitive(False)
+                self.connmenu_items["connect"].set_sensitive(True)
+            self.connmenu.popup(None, None, None, 0, event.time)
 
     def new_vm(self, ignore=None):
         self.emit("action-show-create", self.current_connection_uri())
diff -r 3f28e5933acd -r 9c7e91254826 src/vmm-manager.glade
--- a/src/vmm-manager.glade    Tue Nov 10 21:33:51 2009 +0100
+++ b/src/vmm-manager.glade    Wed Nov 11 00:37:33 2009 +0100
@@ -352,6 +352,7 @@
                     <property name="can_focus">True</property>
                     <signal name="button_press_event" handler="on_vm_list_button_press_event"/>
                     <signal name="row_expanded" handler="on_vm_list_row_expanded"/>
+                    <signal name="key_press_event" handler="on_vm_list_key_press_event"/>
                     <signal name="row_collapsed" handler="on_vm_list_row_collapsed"/>
                     <signal name="row_activated" handler="on_vm_list_row_activated"/>
                   </widget>




--
Regards Jon Nordby - www.jonnor.com

Attachment: hostname_titlebar.patch
Description: Binary data

Attachment: menu_key_context.patch
Description: Binary data


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