[Xword-commits] r35 - branches/letterbars

btb at garage.maemo.org btb at garage.maemo.org
Wed Apr 23 01:22:09 EEST 2008


Author: btb
Date: 2008-04-23 01:22:06 +0300 (Wed, 23 Apr 2008)
New Revision: 35

Modified:
   branches/letterbars/xword
Log:
merge r33 from trunk


Modified: branches/letterbars/xword
===================================================================
--- branches/letterbars/xword	2008-04-22 22:10:50 UTC (rev 34)
+++ branches/letterbars/xword	2008-04-22 22:22:06 UTC (rev 35)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-__version__ = "1.0.4"
+__version__ = "1.0.5"
 
 __license__ = """
 Copyright (c) 2005-2006,
@@ -68,7 +68,8 @@
 TIMER_ICON = HOME_PATH + '/crossword-clock.png'
 ABOUT_ICON = HOME_PATH + '/xword-logo2.png'
 
-MIN_BOX_SIZE = 20
+MIN_BOX_SIZE = 12 
+MAX_BOX_SIZE = 40
 
 ACROSS = 0
 DOWN = 1
@@ -740,9 +741,10 @@
         dialog.show()
 
 class PuzzleWidget:
-    def __init__(self, puzzle, control):
+    def __init__(self, puzzle, control, min_box_size=20):
         self.puzzle = puzzle
         self.control = control
+        self.min_box_size = min_box_size
         
         self.area = gtk.DrawingArea()
         self.pango = self.area.create_pango_layout('')
@@ -762,11 +764,11 @@
         self.control = control
 
         if puzzle:
-            width = puzzle.width * MIN_BOX_SIZE
-            height = puzzle.height * MIN_BOX_SIZE
+            width = puzzle.width * self.min_box_size
+            height = puzzle.height * self.min_box_size
             self.area.set_size_request(width, height)
         else:
-            self.box_size = MIN_BOX_SIZE
+            self.box_size = self.min_box_size
 
         self.area.queue_draw_area(0, 0, 32768, 32768)
 
@@ -903,7 +905,7 @@
         self.control = control
 
         width = 0
-        height = MIN_BOX_SIZE
+        height = 20
 
         self.area = gtk.DrawingArea()
         self.pango = self.area.create_pango_layout('')
@@ -1190,13 +1192,14 @@
 
         self.skip_filled = False
         self.layout = 0
-        self.toolbox_layout = 0
+        self.toolbox_layout = 2
         self.window_size = (800, 480)
         self.maximized = False
         self.fullscreen = False
         self.positions = layouts[self.layout][1]
         self.default_loc = None
         self.last_file = None
+        self.min_box_size = 20
 
         title = 'Crossword Puzzle'
         if self.puzzle: title = 'Crossword Puzzle - %s' % self.puzzle.title
@@ -1454,6 +1457,29 @@
         self.about_dialog.hide()
         return True
 
+    def prompt_min_box_size(self):
+        dialog = gtk.Dialog(None, self.win,
+                     gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                     (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+                      gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+        box = gtk.HBox();
+        dialog.vbox.pack_start(box)
+        label = gtk.Label("Minimum Box Size:");
+        box.pack_start(label)
+        adjust = gtk.Adjustment(self.min_box_size,
+            MIN_BOX_SIZE,MAX_BOX_SIZE,2,0,0)
+        spin = gtk.SpinButton(adjust)
+        box.pack_start(spin)
+        dialog.show_all();
+        r = dialog.run()
+        if r == gtk.RESPONSE_ACCEPT:
+            spinval = spin.get_value_as_int()
+            if spinval != self.min_box_size:
+                self.min_box_size = spinval
+                self.puzzle_widget.min_box_size = spinval
+                self.puzzle_widget.set_puzzle(self.puzzle, self.control)
+        dialog.destroy()
+
     def create_widgets(self):
         self.widgets = {}
 
@@ -1463,7 +1489,7 @@
         vbox.pack_start(clue.widget, False, False, 0)
         self.clue_widget = clue
 
-        puzzle = PuzzleWidget(self.puzzle, self.control)
+        puzzle = PuzzleWidget(self.puzzle, self.control, self.min_box_size)
         puzzle.area.connect('key-press-event', self.puzzle_key_event)
         vbox.pack_start(puzzle.widget, True, True, 0)
         self.puzzle_widget = puzzle
@@ -1617,6 +1643,9 @@
                create_menu_item('Skip Filled', MENU_SKIP, None,
                                 gtk.CheckMenuItem, self.skip_filled))
 
+        append(menu, 'min_box_size', 
+            create_menu_item('Set Min Box Size', 'min_box_size'))
+
         item = create_menu_item('Toolbox Layout', 0)
         append(menu, 'toolbox', item)
 
@@ -1683,6 +1712,8 @@
             self.show_properties()
         elif action == 'about':
             self.show_about()
+        elif action == 'min_box_size':
+            self.prompt_min_box_size()
         elif action < -10:
             toolbox_layout = -(action+11)
             if toolbox_layout <> self.toolbox_layout:
@@ -2001,6 +2032,8 @@
                 self.default_loc = eval(c.get('options', 'default_loc'))
             if c.has_option('options', 'last_file'):
                 self.last_file = eval(c.get('options', 'last_file'))
+            if c.has_option('options', 'min_box_size'):
+                self.min_box_size = c.getint('options', 'min_box_size')
 
     def write_config(self):
         c = ConfigParser.ConfigParser()
@@ -2013,6 +2046,7 @@
         c.set('options', 'maximized', repr(self.maximized))
         c.set('options', 'default_loc', repr(self.default_loc))
         c.set('options', 'last_file', repr(self.last_file))
+        c.set('options', 'min_box_size', self.min_box_size)
         c.write(file(os.path.expanduser('~/.crossword.cfg'), 'w'))
 
 



More information about the Xword-commits mailing list