From 63c77a10b6c5a7f07bdfb12b814f756b3ab91d4d Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 10 Sep 2008 11:08:19 -0400 Subject: [PATCH] Add right click option to copy a volume target path to the clipboard. --- src/virtManager/host.py | 27 +++++++++++++++++++++++++++ src/vmm-host.glade | 1 + 2 files changed, 28 insertions(+) diff --git a/src/virtManager/host.py b/src/virtManager/host.py index d43468c9..d11499a2 100644 --- a/src/virtManager/host.py +++ b/src/virtManager/host.py @@ -75,6 +75,12 @@ class vmmHost(gobject.GObject): volListModel = gtk.ListStore(str, str, str, str, str) self.window.get_widget("vol-list").set_model(volListModel) + self.volmenu = gtk.Menu() + volCopyPath = gtk.MenuItem("Copy Volume Path") + volCopyPath.show() + volCopyPath.connect("activate", self.copy_vol_path) + self.volmenu.add(volCopyPath) + self.window.get_widget("net-list").get_selection().connect("changed", self.net_selected) self.window.get_widget("pool-list").get_selection().connect("changed", self.pool_selected) self.window.get_widget("vol-list").get_selection().connect("changed", self.vol_selected) @@ -169,6 +175,7 @@ class vmmHost(gobject.GObject): "on_pool_delete_clicked": self.delete_pool, "on_pool_autostart_toggled": self.pool_autostart_changed, "on_vol_delete_clicked": self.delete_vol, + "on_vol_list_button_press_event": self.popup_vol_menu, "on_pool_apply_clicked": self.pool_apply, "on_config_autoconnect_toggled": self.toggle_autoconnect, }) @@ -591,6 +598,26 @@ class vmmHost(gobject.GObject): self.window.get_widget("vol-delete").set_sensitive(True) + def popup_vol_menu(self, widget, event): + 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) + vol = model.get_value(iter, 0) + self.volmenu.popup(None, None, None, 0, event.time) + + def copy_vol_path(self, ignore=None): + vol = self.current_vol() + if not vol: + return + clipboard = gtk.Clipboard() + target_path = vol.get_target_path() + if target_path: + clipboard.set_text(target_path) + + def repopulate_storage_pools(self, src, uri, uuid): self.populate_storage_pools(self.window.get_widget("pool-list").get_model()) diff --git a/src/vmm-host.glade b/src/vmm-host.glade index b73a9ba2..6e77b544 100644 --- a/src/vmm-host.glade +++ b/src/vmm-host.glade @@ -2090,6 +2090,7 @@ False False False +