From: <umg...@us...> - 2007-07-19 15:30:38
|
Revision: 484 http://svn.sourceforge.net/pybridge/?rev=484&view=rev Author: umgangee Date: 2007-07-19 08:30:30 -0700 (Thu, 19 Jul 2007) Log Message: ----------- Allow user to specify which game is played at new table. Modified Paths: -------------- trunk/pybridge/glade/pybridge.glade trunk/pybridge/pybridge/ui/dialog_newtable.py Modified: trunk/pybridge/glade/pybridge.glade =================================================================== --- trunk/pybridge/glade/pybridge.glade 2007-07-16 15:28:30 UTC (rev 483) +++ trunk/pybridge/glade/pybridge.glade 2007-07-19 15:30:30 UTC (rev 484) @@ -13,9 +13,9 @@ <widget class="GtkMenuBar" id="menubar_main"> <property name="visible">True</property> <child> - <widget class="GtkMenuItem" id="menu_server"> + <widget class="GtkMenuItem" id="menu_connection"> <property name="visible">True</property> - <property name="label" translatable="yes">_Server</property> + <property name="label" translatable="yes">_Connection</property> <property name="use_underline">True</property> <child> <widget class="GtkMenu" id="menu_server_menu"> @@ -815,7 +815,7 @@ </widget> <widget class="GtkDialog" id="dialog_newtable"> <property name="visible">True</property> - <property name="title" translatable="yes">New Table</property> + <property name="title" translatable="yes">Create a New Table</property> <property name="resizable">False</property> <property name="modal">True</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> @@ -835,12 +835,39 @@ <child> <widget class="GtkTable" id="table2"> <property name="visible">True</property> - <property name="n_rows">1</property> + <property name="n_rows">2</property> <property name="n_columns">2</property> - <property name="column_spacing">4</property> - <property name="row_spacing">2</property> + <property name="column_spacing">8</property> + <property name="row_spacing">4</property> <child> - <widget class="GtkEntry" id="entry_tablename"> + <widget class="GtkLabel" id="label_gamelist"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Game at Table:</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkComboBox" id="gamelist"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <signal name="changed" handler="on_gamelist_changed"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="tablename"> <property name="width_request">140</property> <property name="visible">True</property> <property name="can_focus">True</property> @@ -850,16 +877,16 @@ <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="y_options"></property> + <property name="y_options">GTK_FILL</property> </packing> </child> <child> <widget class="GtkLabel" id="label_tablename"> <property name="visible">True</property> + <property name="xalign">0</property> <property name="label" translatable="yes">Table Name:</property> </widget> <packing> - <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> </child> Modified: trunk/pybridge/pybridge/ui/dialog_newtable.py =================================================================== --- trunk/pybridge/pybridge/ui/dialog_newtable.py 2007-07-16 15:28:30 UTC (rev 483) +++ trunk/pybridge/pybridge/ui/dialog_newtable.py 2007-07-19 15:30:30 UTC (rev 484) @@ -30,8 +30,17 @@ def setUp(self): + # Build and populate list of supported games. + model = gtk.ListStore(str) + self.gamelist.set_model(model) + cell = gtk.CellRendererText() + self.gamelist.pack_start(cell, True) + self.gamelist.add_attribute(cell, 'text', 0) + + for gamename in sorted(SUPPORTED_GAMES): + iter = model.append((gamename, )) + self.gamelist.set_active_iter(iter) # TODO: display intersection of games supported by client and server. - pass def createSuccess(self, table): @@ -43,13 +52,16 @@ dialog = gtk.MessageDialog(parent=self.window, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK) dialog.set_title(_('Could not create table')) - dialog.set_markup(_('The table could not be created.')) + dialog.set_markup(_('The table was not created by the server.')) dialog.format_secondary_text(_('Reason: %s') % error) - dialog.run() - dialog.destroy() + def dialog_response_cb(dialog, response_id): + dialog.destroy() + dialog.connect('response', dialog_response_cb) + dialog.show() + # Signal handlers. @@ -58,15 +70,19 @@ def on_okbutton_clicked(self, widget, *args): - tableid = self.entry_tablename.get_text() - d = client.joinTable(tableid, gameclass=SUPPORTED_GAMES['Bridge'], - host=True) + model = self.gamelist.get_model() + iter = self.gamelist.get_active_iter() + gamename = model.get_value(iter, 0) + + tableid = self.tablename.get_text() + gameclass = SUPPORTED_GAMES[gamename] + d = client.joinTable(tableid, gameclass, host=True) d.addCallbacks(self.createSuccess, self.createFailure) def on_tablename_changed(self, widget, *args): # Disable the OK button if the table name field is empty. - sensitive = self.entry_tablename.get_text() != "" + sensitive = self.tablename.get_text() != "" self.okbutton.set_property('sensitive', sensitive) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |