[virt-tools-list] [PATCH 03/10] Created the new base config screen class for working with hosts.
Darryl L. Pierce
dpierce at redhat.com
Wed Jul 13 19:06:33 UTC 2011
From: "Darryl L. Pierce" <dpierce at redhat.com>
---
src/virtManagerTui/hostlistconfigscreen.py | 58 ++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
create mode 100644 src/virtManagerTui/hostlistconfigscreen.py
diff --git a/src/virtManagerTui/hostlistconfigscreen.py b/src/virtManagerTui/hostlistconfigscreen.py
new file mode 100644
index 0000000..62a4ce5
--- /dev/null
+++ b/src/virtManagerTui/hostlistconfigscreen.py
@@ -0,0 +1,58 @@
+# hostlistconfigscreen.py - Copyright (C) 2011 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+import snack
+
+from vmmconfigscreen import VmmTuiConfigScreen
+
+from halworker import HALWorker
+from libvirtworker import LibvirtWorker, VirtManagerConfig
+import traceback
+
+class HostListConfigScreen(VmmTuiConfigScreen):
+ '''Provides a base class for working with lists of libvirt hosts.'''
+
+ def __init__(self, title):
+ VmmTuiConfigScreen.__init__(self, title)
+ self.__has_connections = None
+ self.__connection_list = None
+
+ def get_connection_list_page(self, screen):
+ ignore = screen
+ connections = self.get_virt_manager_config().get_connection_list()
+ result = None
+
+ if len(connections) > 0:
+ self.__has_connections = True
+ self.__connection_list = snack.Listbox(0)
+ for connection in connections:
+ self.__connection_list.append(connection, connection)
+ result = self.__connection_list
+ else:
+ self.__has_connections = False
+ result = snack.Label("There are no defined connections.")
+ grid = snack.Grid(1, 1)
+ grid.setField(result, 0, 0)
+ return [snack.Label("Host List"),
+ grid]
+
+ def get_selected_connection(self):
+ return self.__connection_list.current()
+
+ def has_selectable_connections(self):
+ return self.__has_connections
--
1.7.6
More information about the virt-tools-list
mailing list