[gnome-games/gnome-3-0] sodoku: gi port, tidy dialog_extras
- From: Thomas Hindoe Paaboel Andersen <thomashpa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/gnome-3-0] sodoku: gi port, tidy dialog_extras
- Date: Fri, 20 May 2011 21:16:22 +0000 (UTC)
commit d19d750a19b5b422a14ac819bd19d0f5afdcb20f
Author: John Stowers <john stowers gmail com>
Date: Sat Apr 30 09:12:02 2011 +1200
sodoku: gi port, tidy dialog_extras
There is a lot of unused code here, it should be
deleted
gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py | 67 ++++++++++-----------
gnome-sudoku/src/lib/main.py | 10 ++--
gnome-sudoku/src/lib/saver.py | 12 ++--
3 files changed, 42 insertions(+), 47 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py b/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py
index a148a30..4e75af1 100644
--- a/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py
+++ b/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py
@@ -63,16 +63,16 @@ class ModalDialog (Gtk.Dialog):
self.get_content_area().pack_start(label,expand=False)
def setup_sublabel (self,sublabel):
- self.sublabel = Gtk.Label()
- self.sublabel.set_selectable(True)
- self.sublabel.set_padding(H_PADDING,Y_PADDING)
- self.sublabel.set_alignment(0,0)
- self.sublabel.set_justify(Gtk.Justification.LEFT)
- self.sublabel.set_markup(sublabel)
- self.sublabel.set_line_wrap(True)
- self.sublabel.show()
+ sublabel = Gtk.Label()
+ sublabel.set_selectable(True)
+ sublabel.set_padding(H_PADDING,Y_PADDING)
+ sublabel.set_alignment(0,0)
+ sublabel.set_justify(Gtk.Justification.LEFT)
+ sublabel.set_markup(sublabel)
+ sublabel.set_line_wrap(True)
+ sublabel.show()
- self.get_content_area().pack_start(self.sublabel, False, True, 0)
+ self.get_content_area().pack_start(sublabel, False, True, 0)
def setup_buttons (self, cancel, okay):
if cancel:
@@ -82,42 +82,37 @@ class ModalDialog (Gtk.Dialog):
self.connect('response',self.response_cb)
def response_cb (self, dialog, response, *params):
- #print 'response CB ',dialog,response,params
if self.responses.has_key(response):
- #print 'we have a response!'
self.responses[response]()
else:
print 'WARNING, no response for ',response
def setup_expander (self, expander):
- label=expander[0]
- body = expander[1]
- self.expander = Gtk.Expander(label)
- self.expander.set_use_underline(True)
- self.expander_vbox = Gtk.VBox()
- self.expander.add(self.expander_vbox)
- self._add_expander_item(body)
- self.expander.show()
- self.expander_vbox.show_all()
-
- self.get_content_area().add(self.expander)
+ label,body = expander
+ expander = Gtk.Expander(label)
+ expander.set_use_underline(True)
+ expander_vbox = Gtk.VBox()
+ expander.add(self.expander_vbox)
+ self._add_expander_item(expander_vbox, body)
+ expander.show_all()
+
+ self.get_content_area().add(expander)
- def _add_expander_item (self, item):
- if type(item)==type(""):
- l=Gtk.Label(label=item)
+ def _add_expander_item (self, expander_vbox, item):
+ if type(item) == type(""):
+ l = Gtk.Label(label=item)
l.set_selectable(True)
l.set_line_wrap(True)
- self.expander_vbox.pack_start(l,
- expand=False,
- fill=False)
- elif type(item)==[] or type(item)==():
- map(self._add_expander_item,item)
+ expander_vbox.pack_start(l, expand=False, fill=False)
+ elif type(item) == [] or type(item) == ():
+ map(self._add_expander_item, expander_vbox, item)
else:
- self.expander_vbox.pack_start(item, True, True, 0)
+ expander_vbox.pack_start(item, True, True, 0)
def run (self):
self.show()
- if self.widget_that_grabs_focus: self.widget_that_grabs_focus.grab_focus()
+ if self.widget_that_grabs_focus:
+ self.widget_that_grabs_focus.grab_focus()
if self.props.modal:
Gtk.main()
return self.ret
@@ -226,16 +221,16 @@ class BooleanDialog (MessageDialog):
self.ret=False
self.okcb()
-def show_message (*args, **kwargs):
+def show_message_dialog (*args, **kwargs):
d = MessageDialog(*args, **kwargs)
return d.run()
-def getBoolean (*args,**kwargs):
+def show_boolean_dialog (*args,**kwargs):
"""Run BooleanDialog, passing along all args, waiting on input and
passing along the results."""
d = BooleanDialog(*args,**kwargs)
retval = d.run()
- if retval==None:
- raise UserCancelledError("getBoolean dialog cancelled!")
+ if retval == None:
+ raise UserCancelledError("show_boolean_dialog dialog cancelled!")
else:
return retval
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 4b1dacf..d8d499a 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -414,7 +414,7 @@ class UI (gconf_wrapper.GConfWrapper):
self.gsd.impossible_hints) % {'n':self.gsd.impossible_hints}
sublabel += "\n"
self.start_dancer()
- dialog_extras.show_message(_("You win!"), label = _("You win!"),
+ dialog_extras.show_message_dialog(_("You win!"), label = _("You win!"),
sublabel = sublabel
)
@@ -431,7 +431,7 @@ class UI (gconf_wrapper.GConfWrapper):
def new_cb (self, *args):
if (self.gsd.grid and self.gsd.grid.is_changed() and not self.won):
try:
- if dialog_extras.getBoolean(
+ if dialog_extras.show_boolean_dialog(
label = _("Save this game before starting new one?"),
custom_yes = _("_Save game for later"),
custom_no = _("_Abandon game"),
@@ -452,7 +452,7 @@ class UI (gconf_wrapper.GConfWrapper):
and self.gsd.grid.is_changed()
and (not self.won)):
try:
- if dialog_extras.getBoolean(label = _("Save game before closing?")):
+ if dialog_extras.show_boolean_dialog(label = _("Save game before closing?")):
self.save_game(self)
except dialog_extras.UserCancelledError:
return
@@ -649,7 +649,7 @@ class UI (gconf_wrapper.GConfWrapper):
@simple_debug
def show_info_cb (self, *args):
if not self.gsd.grid:
- dialog_extras.show_message(parent = self.w,
+ dialog_extras.show_message_dialog(parent = self.w,
title = _("Puzzle Information"),
label = _("There is no current puzzle.")
)
@@ -674,7 +674,7 @@ class UI (gconf_wrapper.GConfWrapper):
information += "\n"
information += _("Amount of trial-and-error required to solve: ")
information += str(len(diff.guesses))
- dialog_extras.show_message(parent = self.w,
+ dialog_extras.show_message_dialog(parent = self.w,
title = _("Puzzle Statistics"),
label = _("Puzzle Statistics"),
sublabel = information)
diff --git a/gnome-sudoku/src/lib/saver.py b/gnome-sudoku/src/lib/saver.py
index c159e6e..b156afd 100644
--- a/gnome-sudoku/src/lib/saver.py
+++ b/gnome-sudoku/src/lib/saver.py
@@ -2,7 +2,7 @@
from gi.repository import Gtk
import pickle, types, os, errno
import defaults
-from gtk_goodies.dialog_extras import show_message
+from gtk_goodies.dialog_extras import show_message_dialog
from gettext import gettext as _
import tracker_info
@@ -134,7 +134,7 @@ class SudokuTracker:
os.makedirs(path)
except OSError, e:
if e.errno == errno.ENOSPC:
- show_message(
+ show_message_dialog(
title = _('No Space'),
label = _('No space left on disk'),
message_type = Gtk.MessageType.ERROR,
@@ -142,7 +142,7 @@ class SudokuTracker:
_('There is no disk space left!')
)
else:
- show_message(
+ show_message_dialog(
title = 'Error creating directory',
label = 'Error creating directory',
sublabel = (_('Unable to create data folder %(path)s.') % locals() + '\n' +
@@ -165,7 +165,7 @@ class SudokuTracker:
pickle.dump(jar, outfi)
outfi.close()
except (OSError, IOError), e:
- show_message(
+ show_message_dialog(
title = _('Unable to save game.'),
label = _('Unable to save game.'),
message_type = Gtk.MessageType.ERROR,
@@ -190,7 +190,7 @@ class SudokuTracker:
pickle.dump(jar, outfi)
outfi.close()
except (OSError, IOError), e:
- show_message(
+ show_message_dialog(
title = _('Unable to mark game as finished.'),
label = _('Unable to mark game as finished.'),
message_type = Gtk.MessageType.ERROR,
@@ -208,7 +208,7 @@ class SudokuTracker:
ofi.write(jar['game'].split('\n')[0]+'\n')
ofi.close()
except (OSError, IOError), e:
- show_message(
+ show_message_dialog(
title = _('Sudoku unable to mark game as finished.'),
label = _('Sudoku unable to mark game as finished.'),
message_type = Gtk.MessageType.ERROR,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]