PERFORCE change 121173 for review
Ivan Voras
ivoras at FreeBSD.org
Thu Jun 7 20:59:43 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=121173
Change 121173 by ivoras at ivoras_finstall on 2007/06/07 20:59:21
Start working on interface to the SysToolD server. Currently it's
used succesfully to display a list of drives to the user.
Affected files ...
.. //depot/projects/soc2007/ivoras_finstall/installer/basewin.py#3 edit
.. //depot/projects/soc2007/ivoras_finstall/installer/finstall.py#8 edit
.. //depot/projects/soc2007/ivoras_finstall/installer/glade/mainwin.glade#8 edit
.. //depot/projects/soc2007/ivoras_finstall/installer/glade/ndisks.glade#3 edit
.. //depot/projects/soc2007/ivoras_finstall/installer/helpdialog.py#2 edit
Differences ...
==== //depot/projects/soc2007/ivoras_finstall/installer/basewin.py#3 (text+ko) ====
@@ -51,5 +51,22 @@
cont.remove(child)
+ def _show_message(self, text, title, p_buttons=gtk.BUTTONS_OK, p_type=gtk.MESSAGE_INFO):
+ """Displays a message box"""
+ dlg = gtk.MessageDialog(self.window, flags=gtk.DIALOG_MODAL, type=p_type, buttons=p_buttons, message_format=text)
+ dlg.set_title(title)
+ dlg.run()
+ dlg.destroy()
+
+ def _make_column(self, name, listid, sort=False):
+ """Creates a TreeViewColumn named "name" which is connected to "listid" column
+ of the rows added as a model"""
+ col = gtk.TreeViewColumn(name)
+ cell = gtk.CellRendererText()
+ col.pack_start(cell, True)
+ col.add_attribute(cell, "text", listid)
+ if sort:
+ col.set_sort_column_id(listid)
+ return col
==== //depot/projects/soc2007/ivoras_finstall/installer/finstall.py#8 (text+ko) ====
@@ -1,5 +1,8 @@
+import sys
+import time
import logging
from types import MethodType
+from xmlrpclib import ServerProxy
import gtk, gtk.gdk, gtk.glade
from basewin import BaseWin
@@ -17,6 +20,7 @@
def __init__(self):
BaseWin.__init__(self, "mainwin")
self.tile_xml = None # will be used for tiles
+ self.first_focus = True
self["img_logo"].set_from_file("img/logo.jpg")
# img_logo stretches the window vertically, so calling window.set_position() has no affect
self._center_window(self.window)
@@ -65,6 +69,37 @@
# buttons, etc.
def on_mainwin_delete_event(self, obj, data):
gtk.main_quit()
+ return False
+
+
+ def on_mainwin_activate_focus(self, obj, data):
+ print "activate_focus"
+
+
+ def on_mainwin_set_focus(self, obj, data):
+ """A kludge - hook an event to fire after the GUI is running"""
+ if self.first_focus:
+ self.first_focus = False
+ self.initial_tasks()
+
+
+ def initial_tasks(self):
+ """Perform initial tasks after the GUI is running. For now,
+ set up connection to the SysToolD server"""
+ self.server = ServerProxy("http://localhost:1025")
+ try:
+ caps = self.server.GetCaps()
+ except:
+ time.sleep(5) # retry
+ try :
+ caps = self.server.GetCaps()
+ except:
+ self._show_message("Cannot contact local SysToolD server.\nShutting down.", "Error", p_type=gtk.MESSAGE_ERROR)
+ logging.exception("Cannot contact local SysToolD server")
+ sys.exit(1)
+ if not "systoold" in caps:
+ self._show_message("The SysToolD server is bogus.\nShutting down.", "Error", p_type=gtk.MESSAGE_ERROR)
+ sys.exit(1)
def on_button_next_clicked(self, obj):
@@ -125,6 +160,21 @@
# Handlers for "ndisks"
def ndisks_on_load(self):
self._load_label(self["label2"], "ndisks.txt")
+ drives = self.server.GetDrives()
+ if len(drives) < 0:
+ self._show_message("No usable drives detected.\nThis is a fatal error and the Installer cannot continue.", "Error", p_type=gtk.MESSAGE_ERROR)
+ return
+
+ list = gtk.ListStore(str, str, str)
+ drive_list = drives.keys()
+ drive_list.sort()
+ for dev in drive_list:
+ list.append([dev, drives[dev]["name"], "%d MB" % drives[dev]["mediasize"]])
+ self["disktree"].set_model(list)
+ self["disktree"].append_column(self._make_column("Device", 0, True))
+ self["disktree"].append_column(self._make_column("Description", 1))
+ self["disktree"].append_column(self._make_column("Size", 2))
+ self["disktree"].set_cursor(0)
return True
==== //depot/projects/soc2007/ivoras_finstall/installer/glade/mainwin.glade#8 (text+ko) ====
@@ -13,9 +13,12 @@
<property name="default_height">450</property>
<property name="icon">logo.png</property>
<signal name="delete_event" handler="on_mainwin_delete_event"/>
+ <signal name="show" handler="on_mainwin_show"/>
+ <signal name="set_focus" handler="on_mainwin_set_focus"/>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
+ <signal name="show" handler="on_hbox1_show"/>
<child>
<widget class="GtkImage" id="img_logo">
<property name="width_request">160</property>
==== //depot/projects/soc2007/ivoras_finstall/installer/glade/ndisks.glade#3 (text+ko) ====
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.2.0 on Sat May 19 12:02:23 2007 by ivoras at beastie.home.net-->
+<!--Generated with glade3 3.2.0 on Thu Jun 7 20:57:58 2007 by ivoras at finstall.cosmos-->
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -43,7 +43,7 @@
</packing>
</child>
<child>
- <widget class="GtkTreeView" id="treeview1">
+ <widget class="GtkTreeView" id="disktree">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
==== //depot/projects/soc2007/ivoras_finstall/installer/helpdialog.py#2 (text+ko) ====
More information about the p4-projects
mailing list