From owner-p4-projects@FreeBSD.ORG Thu Jun 7 20:59:43 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7F8B516A46C; Thu, 7 Jun 2007 20:59:43 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 51ED616A468 for ; Thu, 7 Jun 2007 20:59:43 +0000 (UTC) (envelope-from ivoras@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 424DD13C457 for ; Thu, 7 Jun 2007 20:59:43 +0000 (UTC) (envelope-from ivoras@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l57KxhpI001871 for ; Thu, 7 Jun 2007 20:59:43 GMT (envelope-from ivoras@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l57KxgsE001862 for perforce@freebsd.org; Thu, 7 Jun 2007 20:59:42 GMT (envelope-from ivoras@FreeBSD.org) Date: Thu, 7 Jun 2007 20:59:42 GMT Message-Id: <200706072059.l57KxgsE001862@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ivoras@FreeBSD.org using -f From: Ivan Voras To: Perforce Change Reviews Cc: Subject: PERFORCE change 121173 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2007 20:59:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=121173 Change 121173 by ivoras@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 @@ 450 logo.png + + True + - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK ==== //depot/projects/soc2007/ivoras_finstall/installer/helpdialog.py#2 (text+ko) ====