[gnome-games/applygsoc2009: 25/76] XXX: Port main.py to use GtkBuilder



commit 43c05ce94a0b3d0f35b42ebfdae3043d39d71c15
Author: Pablo Castellano <pablog src gnome org>
Date:   Thu Aug 26 12:27:15 2010 +0200

    XXX: Port main.py to use GtkBuilder
    
    * Accelerators are not working.
    * Move the definition of sudoku_maker _before_ setup_gui, or else
    toggle_generator_cb will cause crash.

 gnome-sudoku/data/main.ui    |  489 ++++++++++++++++++++++++++++++++++++++++++
 gnome-sudoku/src/lib/main.py |  186 ++++------------
 2 files changed, 537 insertions(+), 138 deletions(-)
---
diff --git a/gnome-sudoku/data/main.ui b/gnome-sudoku/data/main.ui
new file mode 100644
index 0000000..69fb35c
--- /dev/null
+++ b/gnome-sudoku/data/main.ui
@@ -0,0 +1,489 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkWindow" id="window">
+    <child>
+      <object class="GtkVBox" id="vbox">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkMenuBar" id="menubar">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkMenuItem" id="menuitem_game">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Game</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu_game">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_new">
+                        <property name="visible">True</property>
+                        <property name="related_action">New</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_reset">
+                        <property name="visible">True</property>
+                        <property name="related_action">Reset</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem11">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_undo">
+                        <property name="visible">True</property>
+                        <property name="related_action">Undo</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_redo">
+                        <property name="visible">True</property>
+                        <property name="related_action">Redo</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem12">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_puzzleinfo">
+                        <property name="visible">True</property>
+                        <property name="related_action">PuzzleInfo</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem13">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_print">
+                        <property name="visible">True</property>
+                        <property name="related_action">Print</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_printmany">
+                        <property name="visible">True</property>
+                        <property name="related_action">PrintMany</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem14">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_close">
+                        <property name="visible">True</property>
+                        <property name="related_action">Close</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="menuitem_settings">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Settings</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu_settings">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_fullscreen">
+                        <property name="visible">True</property>
+                        <property name="related_action">FullScreen</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="mi_show_toolbar">
+                        <property name="visible">True</property>
+                        <property name="related_action">ToggleToolbar</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem21">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="mi_toggle_highlighter">
+                        <property name="visible">True</property>
+                        <property name="related_action">ToggleHighlight</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="mi_always_show_possible">
+                        <property name="visible">True</property>
+                        <property name="related_action">AlwaysShowPossible</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="mi_show_impossible_implications">
+                        <property name="visible">True</property>
+                        <property name="related_action">ShowImpossibleImplications</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                    </child>
+                    
+                    
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_clear">
+                        <property name="visible">True</property>
+                        <property name="related_action">Clear</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_clear_notes">
+                        <property name="visible">True</property>
+                        <property name="related_action">ClearNotes</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    
+                    
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="menuitem_tools">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Tools</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu_tools">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_show_possible">
+                        <property name="visible">True</property>
+                        <property name="related_action">ShowPossible</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem41">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_clear_top_notes">
+                        <property name="visible">True</property>
+                        <property name="related_action">ClearTopNotes</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_clear_bottom_notes">
+                        <property name="visible">True</property>
+                        <property name="related_action">ClearBottomNotes</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkSeparatorMenuItem" id="separatormenuitem42">
+                        <property name="visible">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkCheckMenuItem" id="mi_tracker">
+                        <property name="visible">True</property>
+                        <property name="related_action">ToggleTracker</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkMenuItem" id="menuitem_help">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Help</property>
+                <property name="use_underline">True</property>
+                <child type="submenu">
+                  <object class="GtkMenu" id="menu_help">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_show_help">
+                        <property name="visible">True</property>
+                        <property name="related_action">ShowHelp</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkImageMenuItem" id="mi_about">
+                        <property name="visible">True</property>
+                        <property name="related_action">About</property>
+                        <property name="use_underline">True</property>
+                        <property name="use_stock">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkToolbar" id="toolbar">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkToolButton" id="tb_new">
+                <property name="visible">True</property>
+                <property name="related_action">New</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparatorToolItem" id="separatortoolitem1">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+               <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="tb_undo">
+                <property name="visible">True</property>
+                <property name="related_action">Undo</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="tb_redo">
+                <property name="visible">True</property>
+                <property name="related_action">Redo</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparatorToolItem" id="separatortoolitem2">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToolButton" id="tb_show_possible">
+                <property name="visible">True</property>
+                <property name="related_action">ShowPossible</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparatorToolItem" id="separatortoolitem3">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="tb_toggle_tracker">
+                <property name="visible">True</property>
+                <property name="related_action">ToggleTracker</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkHBox" id="main_area">
+            <property name="visible">True</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkStatusbar" id="statusbar">
+            <property name="visible">True</property>
+            <property name="spacing">2</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkAction" id="New">
+    <property name="label">_New</property>
+    <property name="tooltip">New game</property>
+    <property name="stock_id">gtk-new</property>
+  </object>
+  <object class="GtkAction" id="Reset">
+    <property name="label">_Reset</property>
+    <property name="tooltip">Reset current grid(do-over)</property>
+    <property name="stock_id">gtk-clear</property>
+  </object>
+  <object class="GtkAction" id="Print">
+    <property name="label">_Print</property>
+    <property name="tooltip">Print current game</property>
+    <property name="stock_id">gtk-print</property>
+  </object>
+  <object class="GtkAction" id="PrintMany">
+    <property name="label">Print _Multiple Sudokus</property>
+    <property name="tooltip">Print more than one sudoku at a time</property>
+    <property name="stock_id">gtk-print</property>
+  </object>
+  <object class="GtkAction" id="Close">
+    <property name="label">Close</property>
+    <property name="tooltip">Close Sudoku</property>
+    <property name="stock_id">gtk-close</property>
+  </object>
+  <object class="GtkAction" id="ShowPossible">
+    <property name="label">Hint</property>
+    <property name="tooltip">Show which numbers could go in the current square</property>
+    <property name="stock_id">gtk-dialog-info</property>
+  </object>
+  <object class="GtkAction" id="ClearTopNotes">
+    <property name="label">Clear _Top Notes</property>
+    <property name="tooltip">Clear all of the top notes</property>
+  </object>
+  <object class="GtkAction" id="ClearBottomNotes">
+    <property name="label">Clear _Bottom Notes</property>
+    <property name="tooltip">Clear all of the bottom notes</property>
+  </object>
+  <object class="GtkAction" id="FullScreen">
+    <property name="label">FullScreen</property>
+    <property name="stock_id">gtk-fullscreen</property>
+  </object>
+  <object class="GtkAction" id="PuzzleInfo">
+    <property name="label">Puzzle _Statistics</property>
+    <property name="tooltip">Show statistics about current puzzle</property>
+    <property name="stock_id">gtk-about</property>
+  </object>
+  <object class="GtkAction" id="About">
+    <property name="label">About</property>
+    <property name="stock_id">gtk-about</property>
+  </object>
+  <object class="GtkAction" id="ShowHelp">
+    <property name="label">_Contents</property>
+    <property name="stock_id">gtk-help</property>
+  </object>
+  <object class="GtkAction" id="Undo">
+    <property name="label">_Undo</property>
+    <property name="tooltip">Undo last action</property>
+    <property name="stock_id">gtk-undo</property>
+  </object>
+  <object class="GtkAction" id="Redo">
+    <property name="label">_Redo</property>
+    <property name="tooltip">Redo last action</property>
+    <property name="stock_id">gtk-redo</property>
+  </object>
+  
+<!-- 
+  <object class="GtkAction" id="Clear">
+    <property name="label">_Clear</property>
+    <property name="tooltip">Clear entries you've filled in</property>
+    <property name="stock_id">gtk-clear</property>
+  </object>
+  <object class="GtkAction" id="ClearNotes">
+    <property name="label">Clear _Notes</property>
+    <property name="tooltip">Clear notes and hints</property>
+    <property name="stock_id">gtk-clear</property>
+  </object>
+-->
+
+  <object class="GtkToggleAction" id="AlwaysShowPossible">
+    <property name="label">_Always show hint</property>
+    <property name="tooltip">Always show possible numbers in a square</property>
+  </object>
+  <object class="GtkToggleAction" id="ShowImpossibleImplications">
+    <property name="label">Warn about _unfillable squares</property>
+    <property name="tooltip">Warn about squares made unfillable by a move</property>
+    <property name="active">True</property>
+  </object>
+  <object class="GtkToggleAction" id="ToggleTracker">
+    <property name="label">_Track additions</property>
+    <property name="tooltip">Mark new additions in a separate color so you can keep track of them</property>
+    <property name="icon_name">trackers</property>
+  </object>
+  <object class="GtkToggleAction" id="ToggleToolbar">
+    <property name="label">Show _Toolbar</property>
+    <property name="active">True</property>
+  </object>
+  <object class="GtkToggleAction" id="ToggleHighlight">
+    <property name="label">_Highlighter</property>
+    <property name="tooltip">Highlight the current row, column and box</property>
+    <property name="stock_id">gtk-select-color</property>
+  </object>
+</interface>
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index f253a29..04f2955 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -47,54 +47,6 @@ gtk.stock_add([('tracks',
                 0, 0, ""), ])
 
 class UI (gconf_wrapper.GConfWrapper):
-    ui = '''<ui>
-    <menubar name="MenuBar">
-      <menu name="Game" action="Game">
-        <menuitem action="New"/>
-        <menuitem action="Reset"/>
-        <separator/>
-        <menuitem action="Undo"/>
-        <menuitem action="Redo"/>
-        <separator/>
-        <menuitem action="PuzzleInfo"/>
-        <separator/>
-        <menuitem action="Print"/>
-        <menuitem action="PrintMany"/>
-        <separator/>
-        <menuitem action="Close"/>
-      </menu>
-      <menu action="Settings">
-        <menuitem action="FullScreen"/>
-        <menuitem action="ToggleToolbar"/>
-        <separator/>
-        <menuitem action="ToggleHighlight"/>
-        <menuitem action="AlwaysShowPossible"/>
-        <menuitem action="ShowImpossibleImplications"/>
-      </menu>
-      <menu action="Tools">
-        <menuitem action="ShowPossible"/>
-        <separator/>
-        <menuitem action="ClearTopNotes"/>
-        <menuitem action="ClearBottomNotes"/>
-        <separator/>
-        <menuitem action="Tracker"/>
-      </menu>
-      <menu action="Help">
-        <menuitem action="ShowHelp"/>
-        <menuitem action="About"/>
-      </menu>
-    </menubar>
-    <toolbar name="Toolbar">
-      <toolitem action="New"/>
-      <separator/>
-      <toolitem action="Undo"/>
-      <toolitem action="Redo"/>
-      <separator/>
-      <toolitem action="ShowPossible"/>
-      <separator/>
-      <toolitem action="Tracker"/>
-    </toolbar>
-    </ui>'''
 
     initial_prefs = {'group_size':9,
                      'always_show_hints':False,
@@ -119,6 +71,8 @@ class UI (gconf_wrapper.GConfWrapper):
         gconf_wrapper.GConfWrapper.__init__(self,
                                             gconf_wrapper.GConf('gnome-sudoku')
                                             )
+        self.sudoku_maker = sudoku_maker.SudokuMaker()
+        self.sudoku_tracker = saver.SudokuTracker()
         self.setup_gui()
         self.timer = timer.ActiveTimer(self.w)
         self.gsd.set_timer(self.timer)
@@ -126,10 +80,6 @@ class UI (gconf_wrapper.GConfWrapper):
         self.worker_connections = []
         self.is_fullscreen = False
 
-        # setup sudoku maker...
-        self.sudoku_maker = sudoku_maker.SudokuMaker()
-        self.sudoku_tracker = saver.SudokuTracker()
-
 		self._game = None
 		self._auto_load_saved()
 		if not self._game: # no game loaded
@@ -216,86 +166,61 @@ class UI (gconf_wrapper.GConfWrapper):
         self._setup_actions()
         self.setup_undo()
         self.setup_autosave()
-        self.w.add_accel_group(self.uimanager.get_accel_group())
+        #TODO
+#        self.w.add_accel_group(self.uimanager.get_accel_group())
         self.setup_main_boxes()
         self.setup_tracker_interface()
         self.setup_toggles()
 
     def setup_main_window (self):
         gtk.window_set_default_icon_name('gnome-sudoku')
-        self.w = gtk.Window()
+        self.builder = gtk.Builder()
+        self.builder.add_from_file(os.path.join(UI_DIR, 'main.ui'))
+        self.w = self.builder.get_object("window")
         self.w.set_default_size(self.gconf['width'], self.gconf['height'])
         self.w.set_title(APPNAME_SHORT)
         self.w.connect('configure-event', self.resize_cb)
         self.w.connect('delete-event', self.quit_cb)
-        self.uimanager = gtk.UIManager()
+        self.statusbar = self.builder.get_object("statusbar")
 
     def _setup_actions (self):
-        self.main_actions = gtk.ActionGroup('MainActions')
-        self.main_actions.add_actions([
-            ('Game', None, _('_Game')),
-            ('New', gtk.STOCK_NEW, None, '<Control>n', _('New game'), self.new_cb),
-            ('Reset', gtk.STOCK_CLEAR, _('_Reset'), '<Control>b',
-             _("Reset current grid(do-over)"), self.game_reset_cb),
-            ('Undo', gtk.STOCK_UNDO, _('_Undo'), '<Control>z',
-             _('Undo last action'), self.stop_dancer),
-            ('Redo', gtk.STOCK_REDO, _('_Redo'), '<Shift><Control>z',
-             _('Redo last action')),
-            ('PuzzleInfo', gtk.STOCK_ABOUT, _('Puzzle _Statistics...'), None,
-             _('Show statistics about current puzzle'), self.show_info_cb),
-            ('Print', gtk.STOCK_PRINT, _('_Print...'), '<Control>p', _('Print current game'), self.print_game),
-            ('PrintMany', gtk.STOCK_PRINT, _('Print _Multiple Sudokus...'), None,
-             _('Print more than one sudoku at a time.'), self.print_multiple_games),
-            ('Close', gtk.STOCK_CLOSE, None, '<Control>w', _('Close Sudoku'), self.quit_cb),
-            ('Settings', None, _('_Settings')),
-            ('FullScreen', gtk.STOCK_FULLSCREEN, None, 'F11', None, self.full_screen_cb),
-            ('Tools', None, _('_Tools')),
-            ('ShowPossible', gtk.STOCK_DIALOG_INFO, _('_Hint'), '<Control>h',
-             _('Show a square that is easy to fill.'), self.show_hint_cb),
-            ('ClearTopNotes', None, _('Clear _Top Notes'), '<Control>j',
-             _("Clear all of the top notes"), self.clear_top_notes_cb),
-            ('ClearBottomNotes', None, _('Clear _Bottom Notes'), '<Control>k',
-             _("Clear all of the bottom notes"), self.clear_bottom_notes_cb),
-            ('Help', None, _('_Help'), None, None, None),
-            ('ShowHelp', gtk.STOCK_HELP, _('_Contents'), 'F1', None, self.show_help),
-            ('About', gtk.STOCK_ABOUT, None, None, None, self.show_about),
-            ])
-        self.main_actions.add_toggle_actions([
-            ('AlwaysShowPossible',
-             None,
-             _('Show _Possible Numbers'),
-             None,
-             _('Always show possible numbers in a square'),
-             self.auto_hint_cb),
-            ('ShowImpossibleImplications',
-             None,
-             _('Warn About _Unfillable Squares'),
-             None,
-             _('Warn about squares made unfillable by a move'),
-             self.impossible_implication_cb),
-            ('Tracker', 'tracks', _('_Track Additions'),
-             '<Control>T',
-             _('Mark new additions in a separate color so you can keep track of them.'),
-             self.tracker_toggle_cb, False),
-            ('ToggleToolbar', None, _('Show _Toolbar'), None, None, self.toggle_toolbar_cb, True),
-            ('ToggleHighlight', gtk.STOCK_SELECT_COLOR, _('_Highlighter'),
-             None, _('Highlight the current row, column and box'), self.toggle_highlight_cb, False)
-            ])
-
-        self.main_actions.get_action('Undo').set_is_important(True)
-        self.main_actions.get_action('Redo').set_is_important(True)
-        self.main_actions.get_action('ShowPossible').set_is_important(True)
-        self.main_actions.get_action('Tracker').set_is_important(True)
-
-        self.uimanager.insert_action_group(self.main_actions, 0)
-        self.uimanager.add_ui_from_string(self.ui)
+	    toggle_actions = [
+            ("AlwaysShowPossible", self.auto_hint_cb),
+            ("ShowImpossibleImplications", self.impossible_implication_cb),
+            ("ToggleTracker", self.tracker_toggle_cb),
+            ("ToggleToolbar", self.toggle_toolbar_cb),
+            ("ToggleHighlight", self.toggle_highlight_cb)]
+
+        for action_name, callback in toggle_actions:
+            action = self.builder.get_object(action_name)
+            action.connect("toggled", callback)
+
+        actions = [
+                ("New", self.new_cb),
+                ("Reset", self.game_reset_cb),
+                ("Undo", self.stop_dancer),
+#                ("Redo", None),
+                ("PuzzleInfo", self.show_info_cb),
+                ("Print", self.print_game),
+                ("PrintMany", self.print_multiple_games),
+                ("Close", self.quit_cb),
+                ("FullScreen", self.full_screen_cb),
+                ("ShowPossible", self.show_hint_cb),
+                ("ClearTopNotes", self.clear_top_notes_cb),
+                ("ClearBottomNotes", self.clear_bottom_notes_cb),
+                ("ShowHelp", self.show_help),
+                ("About", self.show_about)]
+
+        for action_name, callback in actions:
+            action = self.builder.get_object(action_name)
+            action.connect("activate", callback)
 
     def setup_undo (self):
         self.cleared = [] # used for Undo memory
         self.cleared_notes = [] # used for Undo memory
         # Set up our UNDO stuff
-        undo_widg = self.main_actions.get_action('Undo')
-        redo_widg = self.main_actions.get_action('Redo')
+        undo_widg = self.builder.get_object('Undo')
+        redo_widg = self.builder.get_object('Redo')
         self.history = Undo.UndoHistoryList(undo_widg, redo_widg)
         for entry in self.gsd.__entries__.values():
             Undo.UndoableGenericWidget(entry, self.history,
@@ -321,37 +246,22 @@ class UI (gconf_wrapper.GConfWrapper):
                             self.autosave)
 
     def setup_main_boxes (self):
-        vb = gtk.VBox()
-        # Add menu bar and toolbar...
-        mb = self.uimanager.get_widget('/MenuBar')
-        mb.show()
-        vb.pack_start(mb, fill = False, expand = False)
-        self.tb = self.uimanager.get_widget('/Toolbar')
-        vb.pack_start(self.tb, fill = False, expand = False)
-        main_area = gtk.HBox()
-        vb.pack_start(main_area, True, padding = 12)
-        main_area.pack_start(self.gsd, padding = 6)
-        self.main_actions.set_visible(True)
-        self.game_box = gtk.VBox()
-        main_area.show()
-        vb.show()
-        self.game_box.show()
-        main_area.pack_start(self.game_box, False, padding = 12)
-        self.w.add(vb)
+        self.main_area = self.builder.get_object("main_area")
+        self.main_area.pack_start(self.gsd, padding = 6)
 
     def setup_toggles (self):
         # sync up toggles with gconf values...
         map(lambda tpl: self.gconf_wrap_toggle(*tpl),
             [('always_show_hints',
-              self.main_actions.get_action('AlwaysShowPossible')),
+              self.builder.get_object('AlwaysShowPossible')),
              ('show_impossible_implications',
-              self.main_actions.get_action('ShowImpossibleImplications')),
+              self.builder.get_object('ShowImpossibleImplications')),
              ('show_toolbar',
-              self.main_actions.get_action('ToggleToolbar')),
+              self.builder.get_object('ToggleToolbar')),
              ('highlight',
-              self.main_actions.get_action('ToggleHighlight')),
+              self.builder.get_object('ToggleHighlight')),
              ('show_tracker',
-              self.main_actions.get_action('Tracker')),
+              self.builder.get_object('ToggleTracker')),
              ])
 
     def start_worker_thread (self, *args):
@@ -582,7 +492,7 @@ class UI (gconf_wrapper.GConfWrapper):
         self.tracker_ui.hide()
         self.tinfo = tracker_info.TrackerInfo()
         self.old_tracker_view = None
-        self.game_box.add(self.tracker_ui)
+        self.main_area.pack(self.tracker_ui, expand=False)
 
     def tracker_toggle_cb (self, widg):
         if widg.get_active():



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]