From: <umg...@us...> - 2007-04-03 12:00:16
|
Revision: 396 http://svn.sourceforge.net/pybridge/?rev=396&view=rev Author: umgangee Date: 2007-04-03 05:00:17 -0700 (Tue, 03 Apr 2007) Log Message: ----------- Change utils references to manager. Modified Paths: -------------- trunk/pybridge/pybridge/ui/dialog_connection.py trunk/pybridge/pybridge/ui/dialog_newtable.py trunk/pybridge/pybridge/ui/dialog_preferences.py Modified: trunk/pybridge/pybridge/ui/dialog_connection.py =================================================================== --- trunk/pybridge/pybridge/ui/dialog_connection.py 2007-04-03 11:59:11 UTC (rev 395) +++ trunk/pybridge/pybridge/ui/dialog_connection.py 2007-04-03 12:00:17 UTC (rev 396) @@ -1,5 +1,5 @@ # PyBridge -- online contract bridge made easy. -# Copyright (C) 2004-2006 PyBridge Project. +# Copyright (C) 2004-2007 PyBridge Project. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -10,7 +10,7 @@ # 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. @@ -20,50 +20,47 @@ from wrapper import GladeWrapper from pybridge.network.client import client -import utils +from manager import wm +from pybridge.ui import settings +TCP_PORT = 5040 + class DialogConnection(GladeWrapper): glade_name = 'dialog_connection' - def new(self): + def setUp(self): # Read connection parameters from client settings. - hostname = utils.settings.connection.get('hostname', '') - portnum = utils.settings.connection.get('portnum', str(utils.PORT)) - username = utils.settings.connection.get('username', '') - password = utils.settings.connection.get('password', '') - - self.entry_hostname.set_text(hostname) - self.entry_portnum.set_text(portnum) - self.entry_username.set_text(username) - self.entry_password.set_text(password) - if password: - self.check_savepassword.set_active(True) + connection = settings.connection + if connection: + self.entry_hostname.set_text(connection['hostname']) + self.entry_portnum.set_text(connection['portnum']) + self.entry_username.set_text(connection['username']) + self.entry_password.set_text(connection['password']) + self.check_savepassword.set_active(connection['password'] != '') + else: + self.entry_portnum.set_text(str(TCP_PORT)) + def connectSuccess(self, avatar): """Actions to perform when connecting succeeds.""" - hostname = self.entry_hostname.get_text() - portnum = self.entry_portnum.get_text() - username = self.entry_username.get_text() + + # Save connection information. + settings.connection = {} + settings.connection['hostname'] = self.entry_hostname.get_text() + settings.connection['portnum'] = self.entry_portnum.get_text() + settings.connection['username'] = self.entry_username.get_text() if self.check_savepassword.get_active(): - password = self.entry_password.get_text() + settings.connection['password'] = self.entry_password.get_text() else: # Flush password. - password = '' - - # Save connection information. - utils.settings.connection['hostname'] = hostname - utils.settings.connection['portnum'] = portnum - utils.settings.connection['username'] = username - utils.settings.connection['password'] = password - - # Launch main window. - utils.windows.close('dialog_connection') - utils.windows.open('window_main') + settings.connection['password'] = '' + wm.close(self) + def connectFailure(self, failure): """Actions to perform when connecting fails.""" error = gtk.MessageDialog(parent=self.window, flags=gtk.DIALOG_MODAL, @@ -79,7 +76,7 @@ def on_dialog_connection_delete_event(self, widget, *args): - utils.quit() + wm.close(self) def on_field_changed(self, widget, *args): @@ -100,15 +97,15 @@ def on_connect_clicked(self, widget, *args): # Prevent repeat clicks. self.button_connect.set_property('sensitive', False) - + hostname = self.entry_hostname.get_text() port = int(self.entry_portnum.get_text()) client.connect(hostname, port) - + username = self.entry_username.get_text() password = self.entry_password.get_text() register = self.check_registeruser.get_active() == True - + if register: # Attempt login only after registration. # TODO: can defer.waitForDeferred() be used here? @@ -119,6 +116,6 @@ d.addCallbacks(self.connectSuccess, self.connectFailure) - def on_quit_clicked(self, widget, *args): - utils.quit() + def on_cancel_clicked(self, widget, *args): + wm.close(self) Modified: trunk/pybridge/pybridge/ui/dialog_newtable.py =================================================================== --- trunk/pybridge/pybridge/ui/dialog_newtable.py 2007-04-03 11:59:11 UTC (rev 395) +++ trunk/pybridge/pybridge/ui/dialog_newtable.py 2007-04-03 12:00:17 UTC (rev 396) @@ -1,5 +1,5 @@ # PyBridge -- online contract bridge made easy. -# Copyright (C) 2004-2006 PyBridge Project. +# Copyright (C) 2004-2007 PyBridge Project. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -10,7 +10,7 @@ # 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. @@ -19,7 +19,7 @@ import gtk from wrapper import GladeWrapper -import utils +from manager import wm class DialogNewtable(GladeWrapper): @@ -31,31 +31,33 @@ pass + def createSuccess(self, table): + wm.close(self) + + + def createFailure(self, reason): + error = reason.getErrorMessage() + dialog = gtk.MessageDialog(parent=self.window, flags=gtk.DIALOG_MODAL, + type=gtk.MESSAGE_ERROR, + buttons=gtk.BUTTONS_OK) + dialog.set_markup(_('Could not create new table.')) + dialog.format_secondary_text(_('Reason: %s') % error) + + dialog.run() + dialog.destroy() + + # Signal handlers. def on_cancelbutton_clicked(self, widget, *args): - utils.windows.close('dialog_newtable') + wm.close(self) def on_okbutton_clicked(self, widget, *args): - - def success(table): - utils.windows.close('dialog_newtable') - - def failure(reason): - error = reason.getErrorMessage() - dialog = gtk.MessageDialog(parent=self.window, - flags=gtk.DIALOG_MODAL, - type=gtk.MESSAGE_ERROR, - buttons=gtk.BUTTONS_OK, - message_format=error) - dialog.run() - dialog.destroy() - tableid = self.entry_tablename.get_text() d = self.parent.joinTable(tableid, host=True) - d.addCallbacks(success, failure) + d.addCallbacks(self.createSuccess, self.createFailure) def on_tablename_changed(self, widget, *args): Modified: trunk/pybridge/pybridge/ui/dialog_preferences.py =================================================================== --- trunk/pybridge/pybridge/ui/dialog_preferences.py 2007-04-03 11:59:11 UTC (rev 395) +++ trunk/pybridge/pybridge/ui/dialog_preferences.py 2007-04-03 12:00:17 UTC (rev 396) @@ -21,7 +21,7 @@ from wrapper import GladeWrapper import pybridge.environment as env -import utils +from manager import wm class DialogPreferences(GladeWrapper): @@ -53,10 +53,10 @@ def on_cancelbutton_clicked(self, widget, *args): print "cancel" - utils.windows.close(self.glade_name) + wm.close(self) def on_okbutton_clicked(self, widget, *args): print "ok" - utils.windows.close(self.glade_name) + wm.close(self) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |