gnome-games r7272 - in trunk/glchess: . glade src/lib/gtkui
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r7272 - in trunk/glchess: . glade src/lib/gtkui
- Date: Sat, 26 Jan 2008 00:40:15 +0000 (GMT)
Author: rancell
Date: Sat Jan 26 00:40:15 2008
New Revision: 7272
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7272&view=rev
Log:
Tidy up preferences dialog
Make all dialogs transient of the main window
Modified:
trunk/glchess/ChangeLog
trunk/glchess/glade/preferences.glade
trunk/glchess/src/lib/gtkui/dialogs.py
trunk/glchess/src/lib/gtkui/gtkui.py
Modified: trunk/glchess/glade/preferences.glade
==============================================================================
--- trunk/glchess/glade/preferences.glade (original)
+++ trunk/glchess/glade/preferences.glade Sat Jan 26 00:40:15 2008
@@ -5,11 +5,10 @@
<requires lib="gnome"/>
<widget class="GtkDialog" id="preferences">
- <property name="visible">True</property>
<property name="title" translatable="yes">Preferences</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
- <property name="modal">True</property>
+ <property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">True</property>
<property name="decorated">True</property>
@@ -20,6 +19,8 @@
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
+ <signal name="delete_event" handler="_on_delete" last_modification_time="Thu, 24 Jan 2008 22:53:01 GMT"/>
+ <signal name="response" handler="_on_response" last_modification_time="Thu, 24 Jan 2008 22:53:53 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
@@ -42,7 +43,6 @@
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
- <signal name="clicked" handler="_on_response" last_modification_time="Sun, 20 Jan 2008 17:40:42 GMT"/>
</widget>
</child>
</widget>
@@ -162,10 +162,9 @@
<widget class="GtkComboBox" id="board_combo">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
- <property name="tooltip" translatable="yes">Choose the orientation of the chess board.</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
- <signal name="changed" handler="on_board_combo_changed" last_modification_time="Sun, 20 Jan 2008 12:51:36 GMT"/>
+ <signal name="changed" handler="_on_board_combo_changed" last_modification_time="Sun, 20 Jan 2008 12:51:36 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -180,10 +179,9 @@
<widget class="GtkComboBox" id="move_format_combo">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
- <property name="tooltip" translatable="yes">Choose the move format for the game history panel.</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
- <signal name="changed" handler="on_move_format_combo_changed" last_modification_time="Sun, 20 Jan 2008 18:45:14 GMT"/>
+ <signal name="changed" handler="_on_move_format_combo_changed" last_modification_time="Sun, 20 Jan 2008 18:45:14 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -199,10 +197,9 @@
<widget class="GtkComboBox" id="promotion_type_combo">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
- <property name="tooltip" translatable="yes">Choose the transformation of a pawn that reaches the eighth rank.</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
- <signal name="changed" handler="on_promotion_type_combo_changed" last_modification_time="Sun, 20 Jan 2008 12:52:19 GMT"/>
+ <signal name="changed" handler="_on_promotion_type_combo_changed" last_modification_time="Sun, 20 Jan 2008 12:52:19 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -245,24 +242,24 @@
<child>
<widget class="GtkVBox" id="view_box">
+ <property name="border_width">10</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
- <property name="border_width">10</property>
<child>
<widget class="GtkCheckButton" id="show_3d">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">View the chess board by default in 2D mode, or optionally in 3D mode using OpenGL.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">3_D Chess View</property>
- <property name="tooltip" translatable="yes">View the chess board by default in 2D mode, or optionally in 3D mode using OpenGL.</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_3d_view_activate" last_modification_time="Sun, 20 Jan 2008 19:36:35 GMT"/>
+ <signal name="toggled" handler="_on_3d_view_activate" last_modification_time="Sun, 20 Jan 2008 19:36:35 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
@@ -274,16 +271,16 @@
<child>
<widget class="GtkCheckButton" id="show_toolbar">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Show or hide the toolbar</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Show _Toolbar</property>
- <property name="tooltip" translatable="yes">Show or hide the toolbar</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_show_toolbar_activate" last_modification_time="Sun, 20 Jan 2008 19:35:47 GMT"/>
+ <signal name="toggled" handler="_on_show_toolbar_activate" last_modification_time="Sun, 20 Jan 2008 19:35:47 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
@@ -295,16 +292,16 @@
<child>
<widget class="GtkCheckButton" id="show_history">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Show or hide the game history panel</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Show _History</property>
- <property name="tooltip" translatable="yes">Show or hide the game history panel</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_show_history_activate" last_modification_time="Sun, 20 Jan 2008 19:36:41 GMT"/>
+ <signal name="toggled" handler="_on_show_history_activate" last_modification_time="Sun, 20 Jan 2008 19:36:41 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
@@ -316,16 +313,16 @@
<child>
<widget class="GtkCheckButton" id="show_move_hints">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Shows hints during chess games</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Move Hints</property>
- <property name="tooltip" translatable="yes">Shows hints during chess games</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_move_hints_activate" last_modification_time="Sun, 20 Jan 2008 19:36:46 GMT"/>
+ <signal name="toggled" handler="_on_move_hints_activate" last_modification_time="Sun, 20 Jan 2008 19:36:46 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
@@ -337,16 +334,16 @@
<child>
<widget class="GtkCheckButton" id="show_numbering">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Show or hide numbering on the chess board</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Board Numbering</property>
- <property name="tooltip" translatable="yes">Show or hide numbering on the chess board</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_board_numbering_activate" last_modification_time="Sun, 20 Jan 2008 19:36:51 GMT"/>
+ <signal name="toggled" handler="_on_board_numbering_activate" last_modification_time="Sun, 20 Jan 2008 19:36:51 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
Modified: trunk/glchess/src/lib/gtkui/dialogs.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/dialogs.py (original)
+++ trunk/glchess/src/lib/gtkui/dialogs.py Sat Jan 26 00:40:15 2008
@@ -75,13 +75,6 @@
class GtkNewGameDialog:
"""
"""
- # The main UI and the ???
- __mainUI = None
- __gui = None
-
- __customName = False
- __checking = False
-
def __init__(self, mainUI, aiModel, game = None):
"""Constructor for a new game dialog.
@@ -93,11 +86,15 @@
self.game = game
self.__checking = True
-
+ self.__customName = False
+
# Load the UI
self.__gui = gtkui.loadGladeFile('new_game.glade', 'new_game_dialog')
self.__gui.signal_autoconnect(self)
-
+
+ self.window = self.__gui.get_widget('new_game_dialog')
+ self.window.set_transient_for(mainUI.mainWindow)
+
# Set style of error panel
mainUI.setTooltipStyle(self.__gui.get_widget('info_box'))
@@ -242,7 +239,7 @@
# Change title for loaded games
if g.path is not None:
- self.__gui.get_widget('new_game_dialog').set_title(_('Configure loaded game (%i moves)') % len(g.moves))
+ self.window.set_title(_('Configure loaded game (%i moves)') % len(g.moves))
# Display warning if missing the AIs
if len(errorText) > 0:
@@ -251,7 +248,7 @@
self.__gui.get_widget('info_box').show()
# Show the dialog
- self.__gui.get_widget('new_game_dialog').show()
+ self.window.present()
self.__checking = False
self.__testReady()
@@ -383,18 +380,15 @@
"""Gtk+ callback"""
self.__testReady()
- def _on_response(self, dialog, response_id):
+ def _on_response(self, dialog, responseId):
"""Gtk+ callback"""
- if response_id == gtk.RESPONSE_OK:
+ if responseId == gtk.RESPONSE_OK:
self.__startGame()
dialog.destroy()
class GtkLoadGameDialog:
"""
"""
- __mainUI = None
- __gui = None
-
def __init__(self, mainUI):
"""
"""
@@ -404,6 +398,9 @@
self.__gui = gtkui.loadGladeFile('load_game.glade')
self.__gui.signal_autoconnect(self)
+ self.window = self.__gui.get_widget('game_load_dialog')
+ self.window.set_transient_for(mainUI.mainWindow)
+
# Set style of error panel
mainUI.setTooltipStyle(self.__gui.get_widget('error_box'))
@@ -427,8 +424,7 @@
allFilter.add_pattern('*')
fileChooser.add_filter(allFilter)
- dialog = self.__gui.get_widget('game_load_dialog')
- dialog.show()
+ self.window.present()
def __getFilename(self):
"""Get the currently selected filename.
@@ -449,7 +445,7 @@
def _on_file_activated(self, widget):
"""Gtk+ callback"""
- self._on_response(self.__gui.get_widget('game_load_dialog'), gtk.RESPONSE_OK)
+ self._on_response(self.window, gtk.RESPONSE_OK)
def _on_response(self, dialog, responseId):
"""Gtk+ callback"""
@@ -471,16 +467,7 @@
class GtkSaveGameDialog:
"""
- """
- # The main UI
- __mainUI = None
-
- # The view that is being saved
- __view = None
-
- # The GUI
- __gui = None
-
+ """
def __init__(self, mainUI, view, path = None):
"""
"""
@@ -494,7 +481,8 @@
# Set style of error panel
mainUI.setTooltipStyle(self.__gui.get_widget('error_box'))
- dialog = self.__gui.get_widget('save_dialog')
+ self.window = self.__gui.get_widget('save_dialog')
+ self.window.set_transient_for(mainUI.mainWindow)
chooser = self.__gui.get_widget('filechooser')
try:
@@ -520,7 +508,7 @@
def _on_file_activated(self, widget):
"""Gtk+ callback"""
- self._on_response(self.__gui.get_widget('save_dialog'), gtk.RESPONSE_OK)
+ self._on_response(self.window, gtk.RESPONSE_OK)
def __setError(self, title, content):
"""
@@ -557,34 +545,24 @@
dialog.destroy()
-
class GtkPreferencesDialog:
"""
- """
- # The main UI and the ???
- __mainUI = None
- __gui = None
-
- __customName = False
- __checking = False
-
- def __init__(self, mainUI, aiModel, game = None):
+ """
+ def __init__(self, mainUI, aiModel):
"""Constructor for the preferences dialog.
'mainUI' is the main UI.
'aiModel' is the AI models to use.
- 'game' is the game properties to use (ui.Game).
"""
- self.__mainUI = mainUI
- self.game = game
-
- # Load the UI
+ # Load the UI
self.__gui = gtkui.loadGladeFile('preferences.glade', 'preferences')
self.__gui.signal_autoconnect(self)
+
+ self.__gui.get_widget('preferences').set_transient_for(mainUI.mainWindow)
# Load preferences for move_format
moveFormat = glchess.config.get('move_format')
- moveModel = gtk.ListStore(str, str)
+ moveModel = gtk.ListStore(str, str)
widget = self.__gui.get_widget('move_format_combo')
widget.set_model(moveModel)
move_formats = [('human', _('Human')),
@@ -593,110 +571,116 @@
for (key, label) in move_formats:
iter = moveModel.append()
if key == moveFormat:
- widget.set_active_iter(iter)
+ widget.set_active_iter(iter)
moveModel.set(iter, 0, label, 1, key)
- # Load preferences for board orientation
+ # Load preferences for board orientation
boardView = glchess.config.get('board_view')
- boardModel = gtk.ListStore(str, str)
+ boardModel = gtk.ListStore(str, str)
widget = self.__gui.get_widget('board_combo')
widget.set_model(boardModel)
view_list = [('white', _('White Side')),
('black', _('Black Side')),
('human', _('Human Side')),
- ('current', _('Current Player'))]
+ ('current', _('Current Player'))]
for (key, label) in view_list:
iter = boardModel.append()
if key == boardView:
- widget.set_active_iter(iter)
+ widget.set_active_iter(iter)
boardModel.set(iter, 0, label, 1, key)
# Load preferences for promotion type
promotionType = glchess.config.get('promotion_type')
- promotionModel = gtk.ListStore(str, str)
+ promotionModel = gtk.ListStore(str, str)
widget = self.__gui.get_widget('promotion_type_combo')
widget.set_model(promotionModel)
promotion_list = [('queen', _('Queen')),
- ('knight', _('Knight')),
- ('rook', _('Rook')),
- ('bishop', _('Bishop'))]
+ ('knight', _('Knight')),
+ ('rook', _('Rook')),
+ ('bishop', _('Bishop'))]
for (key, label) in promotion_list:
iter = promotionModel.append()
if key == promotionType:
- widget.set_active_iter(iter)
+ widget.set_active_iter(iter)
promotionModel.set(iter, 0, label, 1, key)
- # Load preferences for View settings.
+ # Load preferences for View settings.
pref = glchess.config.get('show_3d')
widget = self.__gui.get_widget('show_3d')
- widget.set_active(pref)
+ widget.set_active(pref)
pref = glchess.config.get('show_toolbar')
widget = self.__gui.get_widget('show_toolbar')
- widget.set_active(pref)
+ widget.set_active(pref)
pref = glchess.config.get('show_history')
widget = self.__gui.get_widget('show_history')
- widget.set_active(pref)
+ widget.set_active(pref)
pref = glchess.config.get('show_move_hints')
widget = self.__gui.get_widget('show_move_hints')
- widget.set_active(pref)
+ widget.set_active(pref)
pref = glchess.config.get('show_numbering')
widget = self.__gui.get_widget('show_numbering')
- widget.set_active(pref)
-
- self.__gui.get_widget('preferences').show()
+ widget.set_active(pref)
+ def setVisible(self, isVisible):
+ window = self.__gui.get_widget('preferences')
+ if isVisible:
+ window.present()
+ else:
+ window.hide()
- def _on_response(self, dialog):
+ def _on_response(self, dialog, responseId):
"""Gtk+ callback"""
- self.__gui.get_widget('preferences').destroy()
+ self.setVisible(False)
+
+ def _on_delete(self, dialog, event):
+ """Gtk+ callback"""
+ self.setVisible(False)
+ return True
- def on_move_format_combo_changed(self, widget):
+ def _on_move_format_combo_changed(self, widget):
"""Gtk+ callback"""
model = widget.get_model()
iter = widget.get_active_iter()
data = model.get(iter, 1)
- if data[0] is not None:
- glchess.config.set('move_format', data[0])
+ if data[0] is not None:
+ glchess.config.set('move_format', data[0])
- def on_board_combo_changed(self, widget):
+ def _on_board_combo_changed(self, widget):
"""Gtk+ callback"""
model = widget.get_model()
iter = widget.get_active_iter()
data = model.get(iter, 1)
- if data[0] is not None:
- glchess.config.set('board_view', data[0])
+ if data[0] is not None:
+ glchess.config.set('board_view', data[0])
- def on_promotion_type_combo_changed(self, widget):
+ def _on_promotion_type_combo_changed(self, widget):
"""Gtk+ callback"""
model = widget.get_model()
iter = widget.get_active_iter()
data = model.get(iter, 1)
- if data[0] is not None:
- glchess.config.set('promotion_type', data[0])
+ if data[0] is not None:
+ glchess.config.set('promotion_type', data[0])
- def on_3d_view_activate(self, widget):
+ def _on_3d_view_activate(self, widget):
"""Gtk+ callback"""
- glchess.config.set('show_3d', widget.get_active())
+ glchess.config.set('show_3d', widget.get_active())
- def on_show_toolbar_activate(self, widget):
+ def _on_show_toolbar_activate(self, widget):
"""Gtk+ callback"""
- glchess.config.set('show_toolbar', widget.get_active())
+ glchess.config.set('show_toolbar', widget.get_active())
- def on_show_history_activate(self, widget):
+ def _on_show_history_activate(self, widget):
"""Gtk+ callback"""
- glchess.config.set('show_history', widget.get_active())
-
+ glchess.config.set('show_history', widget.get_active())
- def on_move_hints_activate(self, widget):
+ def _on_move_hints_activate(self, widget):
"""Gtk+ callback"""
- glchess.config.set('show_move_hints', widget.get_active())
+ glchess.config.set('show_move_hints', widget.get_active())
-
- def on_board_numbering_activate(self, widget):
+ def _on_board_numbering_activate(self, widget):
"""Gtk+ callback"""
- glchess.config.set('show_numbering', widget.get_active())
-
+ glchess.config.set('show_numbering', widget.get_active())
Modified: trunk/glchess/src/lib/gtkui/gtkui.py
==============================================================================
--- trunk/glchess/src/lib/gtkui/gtkui.py (original)
+++ trunk/glchess/src/lib/gtkui/gtkui.py Sat Jan 26 00:40:15 2008
@@ -220,6 +220,8 @@
self._gui = loadGladeFile('glchess.glade')
self._gui.signal_autoconnect(self)
+ self.mainWindow = self._gui.get_widget('glchess_app')
+
# Workaround as Glade 2 always overrides the system style for toolbars
self.__getWidget('toolbar').unset_style()
@@ -230,6 +232,9 @@
self.__playerModel.set(iter, 0, '', 1, 'stock_person', 2, _('Human'))
self.__logWindow = log.LogWindow(self._gui.get_widget('log_notebook'))
+
+ # Make preferences dialog
+ self.preferences = dialogs.GtkPreferencesDialog(self, self.__playerModel)
# Balance space on each side of the history combo
group = gtk.SizeGroup(gtk.SIZE_GROUP_BOTH)
@@ -357,7 +362,7 @@
else:
# Translators: This is the window title when not playing a game
title = _('Chess')
- self._gui.get_widget('glchess_app').set_title(title)
+ self.mainWindow.set_title(title)
def addLogWindow(self, title, executable, description):
"""
@@ -403,7 +408,7 @@
self.__applyConfig(name, value)
self.__resize()
- self._gui.get_widget('glchess_app').show()
+ self.mainWindow.show()
# Apply the fullscreen flag after the window has been shown otherwise
# gtk.Window.unfullscreen() stops working if the window is set to fullscreen
@@ -485,7 +490,7 @@
def __updateAttention(self):
"""
"""
- widget = self._gui.get_widget('glchess_app')
+ widget = self.mainWindow
widget.set_urgency_hint(self.__attentionCounter != 0 and not widget.is_active())
def _on_focus_changed(self, widget, event):
@@ -513,7 +518,7 @@
except glchess.config.Error:
return
- self._gui.get_widget('glchess_app').resize(width, height)
+ self.mainWindow.resize(width, height)
def __applyConfig(self, name, value):
"""
@@ -550,7 +555,7 @@
# Maximised mode
elif name == 'maximised':
- window = self._gui.get_widget('glchess_app')
+ window = self.mainWindow
if value is True:
window.maximize()
else:
@@ -558,7 +563,7 @@
# Fullscreen mode
elif name == 'fullscreen':
- window = self._gui.get_widget('glchess_app')
+ window = self.mainWindow
if value is True:
window.fullscreen()
else:
@@ -719,7 +724,7 @@
"""Gtk+ callback"""
window = self._gui.get_widget('log_window')
if widget.get_active():
- window.show()
+ window.present()
else:
window.hide()
@@ -871,7 +876,7 @@
def _on_preferences_clicked(self, widget):
"""Gtk+ callback"""
- dialogs.GtkPreferencesDialog(self, self.__playerModel)
+ self.preferences.setVisible(True)
def _on_help_clicked(self, widget):
"""Gtk+ callback"""
@@ -907,6 +912,7 @@
return
dialog = self.__aboutDialog = gtk.AboutDialog()
+ dialog.set_transient_for(self.mainWindow)
dialog.set_name(APPNAME)
dialog.set_version(VERSION)
dialog.set_copyright(COPYRIGHT)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]