From: <umg...@us...> - 2007-06-16 13:21:42
|
Revision: 421 http://svn.sourceforge.net/pybridge/?rev=421&view=rev Author: umgangee Date: 2007-06-16 06:21:39 -0700 (Sat, 16 Jun 2007) Log Message: ----------- Preliminary work on the Preferences dialog. Modified Paths: -------------- trunk/pybridge/glade/pybridge.glade trunk/pybridge/pybridge/ui/dialog_preferences.py Modified: trunk/pybridge/glade/pybridge.glade =================================================================== --- trunk/pybridge/glade/pybridge.glade 2007-06-14 16:22:05 UTC (rev 420) +++ trunk/pybridge/glade/pybridge.glade 2007-06-16 13:21:39 UTC (rev 421) @@ -1411,7 +1411,7 @@ </widget> </child> <child> - <widget class="GtkLabel" id="label62"> + <widget class="GtkLabel" id="label_useraccount"> <property name="visible">True</property> <property name="label" translatable="yes"><b>User Account</b></property> <property name="use_markup">True</property> @@ -1948,200 +1948,6 @@ </packing> </child> <child> - <widget class="GtkExpander" id="expander_players"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <widget class="GtkTable" id="table5"> - <property name="visible">True</property> - <property name="n_rows">4</property> - <property name="n_columns">3</property> - <property name="column_spacing">4</property> - <property name="row_spacing">2</property> - <child> - <widget class="GtkLabel" id="label_west"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">4</property> - <property name="label" translatable="yes"><i>Vacant</i></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_south"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">4</property> - <property name="label" translatable="yes"><i>Vacant</i></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_north"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">4</property> - <property name="label" translatable="yes"><i>Vacant</i></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label_east"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">4</property> - <property name="label" translatable="yes"><i>Vacant</i></property> - <property name="use_markup">True</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkImage" id="image321"> - <property name="visible">True</property> - <property name="stock">gtk-go-back</property> - </widget> - <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkImage" id="image320"> - <property name="visible">True</property> - <property name="stock">gtk-go-down</property> - </widget> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkImage" id="image319"> - <property name="visible">True</property> - <property name="stock">gtk-go-forward</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkImage" id="image318"> - <property name="visible">True</property> - <property name="stock">gtk-go-up</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> - <property name="y_options">GTK_FILL</property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label49"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">West:</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label48"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">South:</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label47"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">East:</property> - </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="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label46"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">North:</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - <child> - <widget class="GtkLabel" id="label45"> - <property name="visible">True</property> - <property name="label" translatable="yes">Players</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="expand">False</property> - <property name="position">4</property> - </packing> - </child> - <child> <widget class="GtkExpander" id="expander_observers"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -2174,7 +1980,7 @@ </widget> <packing> <property name="expand">False</property> - <property name="position">5</property> + <property name="position">4</property> </packing> </child> </widget> @@ -2278,7 +2084,7 @@ <widget class="GtkDialog" id="dialog_preferences"> <property name="visible">True</property> <property name="border_width">5</property> - <property name="title" translatable="yes">Preferences</property> + <property name="title" translatable="yes">PyBridge Preferences</property> <property name="resizable">False</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> <property name="has_separator">False</property> @@ -2296,92 +2102,166 @@ <property name="border_width">4</property> <property name="spacing">8</property> <child> - <widget class="GtkFrame" id="frame3"> + <widget class="GtkTable" id="table3"> <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <property name="column_spacing">8</property> + <property name="row_spacing">4</property> <child> - <widget class="GtkAlignment" id="alignment1"> + <widget class="GtkLabel" id="label_cardstyle"> <property name="visible">True</property> - <property name="left_padding">12</property> - <child> - <widget class="GtkComboBox" id="carddeck"> - <property name="visible">True</property> - <signal name="changed" handler="on_carddeck_changed"/> - </widget> - </child> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Card Style:</property> </widget> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + </packing> </child> <child> - <widget class="GtkLabel" id="label1"> + <widget class="GtkLabel" id="label_background"> <property name="visible">True</property> - <property name="label" translatable="yes"><b>Card Deck</b></property> - <property name="use_markup">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="label" translatable="yes">Background:</property> </widget> <packing> - <property name="type">label_item</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> </packing> </child> + <child> + <widget class="GtkComboBox" id="cardstyle"> + <property name="width_request">160</property> + <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_cardstyle_changed"/> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> + <child> + <widget class="GtkFileChooserButton" id="background"> + <property name="width_request">160</property> + <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="selection_changed" handler="on_background_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> + </packing> + </child> </widget> + <packing> + <property name="expand">False</property> + </packing> </child> <child> - <widget class="GtkFrame" id="frame4"> + <widget class="GtkFrame" id="frame5"> <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="label_xalign">0</property> <property name="shadow_type">GTK_SHADOW_NONE</property> <child> - <widget class="GtkAlignment" id="alignment2"> + <widget class="GtkAlignment" id="alignment3"> <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="left_padding">12</property> <child> - <widget class="GtkTable" id="table3"> + <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="column_spacing">9</property> - <property name="row_spacing">4</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="spacing">4</property> + <property name="homogeneous">True</property> <child> - <widget class="GtkFileChooserButton" id="filechooserbutton1"> + <widget class="GtkButton" id="button_clubcolour"> <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">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="clicked" handler="on_suitcolour_clicked"/> + <child> + <widget class="GtkLabel" id="label_clubcolour"> + <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="label" translatable="yes"><span color='#000000' size='xx-large'>♣</span></property> + <property name="use_markup">True</property> + </widget> + </child> </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="expand">False</property> </packing> </child> <child> - <widget class="GtkColorButton" id="colorbutton1"> + <widget class="GtkButton" id="button_diamondcolour"> <property name="visible">True</property> - <property name="color">#000000000000</property> + <property name="can_focus">True</property> + <property name="receives_default">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="clicked" handler="on_suitcolour_clicked"/> + <child> + <widget class="GtkLabel" id="label_diamondcolour"> + <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="label" translatable="yes"><span color='#ff0000' size='xx-large'>♦</span></property> + <property name="use_markup">True</property> + </widget> + </child> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> + <property name="expand">False</property> + <property name="position">1</property> </packing> </child> <child> - <widget class="GtkRadioButton" id="radio_image"> + <widget class="GtkButton" id="button_heartcolour"> <property name="visible">True</property> - <property name="label" translatable="yes">Image</property> - <property name="draw_indicator">True</property> + <property name="can_focus">True</property> + <property name="receives_default">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="clicked" handler="on_suitcolour_clicked"/> + <child> + <widget class="GtkLabel" id="label_heartcolour"> + <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="label" translatable="yes"><span color='#ff0000' size='xx-large'>♥</span></property> + <property name="use_markup">True</property> + </widget> + </child> </widget> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> + <property name="expand">False</property> + <property name="position">2</property> </packing> </child> <child> - <widget class="GtkRadioButton" id="radio_colour"> + <widget class="GtkButton" id="button_spadecolour"> <property name="visible">True</property> - <property name="label" translatable="yes">Colour</property> - <property name="draw_indicator">True</property> - <property name="group">radio_image</property> + <property name="can_focus">True</property> + <property name="receives_default">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="clicked" handler="on_suitcolour_clicked"/> + <child> + <widget class="GtkLabel" id="label_spadecolour"> + <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="label" translatable="yes"><span color='#000000' size='xx-large'>♠</span></property> + <property name="use_markup">True</property> + </widget> + </child> </widget> <packing> - <property name="x_options">GTK_FILL</property> + <property name="expand">False</property> + <property name="position">3</property> </packing> </child> </widget> @@ -2389,9 +2269,10 @@ </widget> </child> <child> - <widget class="GtkLabel" id="label2"> + <widget class="GtkLabel" id="label_suitcolours"> <property name="visible">True</property> - <property name="label" translatable="yes"><b>Background</b></property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Colours for Suits</property> <property name="use_markup">True</property> </widget> <packing> @@ -2400,6 +2281,7 @@ </child> </widget> <packing> + <property name="expand">False</property> <property name="position">1</property> </packing> </child> @@ -2409,9 +2291,9 @@ </packing> </child> <child> - <widget class="GtkLabel" id="label_style"> + <widget class="GtkLabel" id="label_gamedisplay"> <property name="visible">True</property> - <property name="label" translatable="yes">Style</property> + <property name="label" translatable="yes">Game Display</property> </widget> <packing> <property name="type">tab</property> Modified: trunk/pybridge/pybridge/ui/dialog_preferences.py =================================================================== --- trunk/pybridge/pybridge/ui/dialog_preferences.py 2007-06-14 16:22:05 UTC (rev 420) +++ trunk/pybridge/pybridge/ui/dialog_preferences.py 2007-06-16 13:21:39 UTC (rev 421) @@ -22,41 +22,95 @@ import pybridge.environment as env from manager import wm +from pybridge.ui import settings +from pybridge.bridge.symbols import Suit +SUIT_NAMES = {Suit.Club: _("Club"), Suit.Diamond: _("Diamond"), + Suit.Heart: _("Heart"), Suit.Spade: _("Spade") } + +SUIT_SYMBOLS = {Suit.Club: u'\N{BLACK CLUB SUIT}', + Suit.Diamond: u'\N{BLACK DIAMOND SUIT}', + Suit.Heart: u'\N{BLACK HEART SUIT}', + Suit.Spade: u'\N{BLACK SPADE SUIT}' } + +SUIT_LABEL_TEMPLATE = "<span color=\'%s\' size=\'xx-large\'>%s</span>" + + class DialogPreferences(GladeWrapper): glade_name = 'dialog_preferences' - def new(self): + def setUp(self): + # Allow user to select only image files for background. + filter_pixbufs = gtk.FileFilter() + filter_pixbufs.add_pixbuf_formats() + filter_pixbufs.set_name(_("Image files")) + self.background.add_filter(filter_pixbufs) + + # Build a list of card decks from which the user may choose. + # (The user is prevented from selecting an arbitary image.) model = gtk.ListStore(str) - self.carddeck.set_model(model) + self.cardstyle.set_model(model) cell = gtk.CellRendererText() - self.carddeck.pack_start(cell, True) - self.carddeck.add_attribute(cell, 'text', 0) + self.cardstyle.pack_start(cell, True) + self.cardstyle.add_attribute(cell, 'text', 0) + + activedeck = settings.appearance.get('deck', 'bonded.png') # Populate list of card decks. path = env.find_pixmap('') for filename in os.listdir(path): if filename.endswith('.png'): iter = model.append((filename,)) - if filename == 'bonded.png': - self.carddeck.set_active_iter(iter) + if filename == activedeck: + self.cardstyle.set_active_iter(iter) # Signal handlers. - def on_carddeck_changed(self, widget, *args): - print "changed" + def on_cardstyle_changed(self, widget, *args): + print "cardstyle changed" + def on_background_changed(self, widget, *args): + print "background changed" + + + def on_suitcolour_clicked(self, widget, *args): + # Get symbol in Suit corresponding to button clicked. + suit_buttons = {self.button_clubcolour: Suit.Club, + self.button_diamondcolour: Suit.Diamond, + self.button_heartcolour: Suit.Heart, + self.button_spadecolour: Suit.Spade } + suit = suit_buttons[widget] + + title = _("Select colour for %s symbol" % SUIT_NAMES[suit]) + dialog = gtk.ColorSelectionDialog(title) + dialog.colorsel.set_current_color(gtk.gdk.color_parse('#888888')) + + def dialog_response_cb(dialog, response_id): + if response_id == gtk.RESPONSE_OK: + colour = dialog.colorsel.get_current_color() + + # Set button label to colour selected by user. + label = widget.get_children()[0] + hexrep = gtk.color_selection_palette_to_string([colour]) + label.set_markup(SUIT_LABEL_TEMPLATE % (hexrep, SUIT_SYMBOLS[suit])) + + dialog.destroy() + + dialog.connect('response', dialog_response_cb) + #dialog.show() + dialog.run() + + def on_cancelbutton_clicked(self, widget, *args): - print "cancel" wm.close(self) def on_okbutton_clicked(self, widget, *args): - print "ok" + print "SAVE SETTINGS" wm.close(self) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |