[gnome-games] Undo accidental glchess changes



commit 230349bb7afe6f9f21c07260f735a06c773cd026
Author: Robert Ancell <robert ancell gmail com>
Date:   Fri Apr 2 18:44:20 2010 +1100

    Undo accidental glchess changes

 glchess/src/lib/gtkui/chessview.py |    2 ++
 glchess/src/lib/gtkui/dialogs.py   |    9 +++++++++
 glchess/src/lib/gtkui/gtkui.py     |   23 +++++++++++++++++++++++
 glchess/src/lib/gtkui/network.py   |    1 +
 4 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/glchess/src/lib/gtkui/chessview.py b/glchess/src/lib/gtkui/chessview.py
index 4065893..7768728 100644
--- a/glchess/src/lib/gtkui/chessview.py
+++ b/glchess/src/lib/gtkui/chessview.py
@@ -261,6 +261,8 @@ class GtkView(glchess.ui.ViewController):
         self.viewWidget = GtkViewArea(self)
         self.gui.get_object('view_container').add(self.viewWidget)
 
+        self.ui.setTooltipStyle(self.gui.get_object('info_panel'))
+
         # Make a model for navigation (move object, number, description) 
         model = gtk.ListStore(gobject.TYPE_PYOBJECT, int, str)
         iter = model.append()
diff --git a/glchess/src/lib/gtkui/dialogs.py b/glchess/src/lib/gtkui/dialogs.py
index 3cdc5b9..d8ca8f1 100644
--- a/glchess/src/lib/gtkui/dialogs.py
+++ b/glchess/src/lib/gtkui/dialogs.py
@@ -96,6 +96,9 @@ class GtkNewGameDialog:
         self.window = self.__gui.get_object('new_game_dialog')
         self.window.set_transient_for(mainUI.mainWindow)
 
+        # Set style of error panel
+        mainUI.setTooltipStyle(self.__gui.get_object('info_box'))
+        
         # Make all the labels the same width
         group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
         i = 1
@@ -422,6 +425,9 @@ class GtkLoadGameDialog:
         self.window = self.__gui.get_object('game_load_dialog')
         self.window.set_transient_for(mainUI.mainWindow)
         
+        # Set style of error panel
+        mainUI.setTooltipStyle(self.__gui.get_object('error_box'))
+        
         fileChooser = self.__gui.get_object('filechooserwidget')
         
         try:
@@ -492,6 +498,9 @@ class GtkSaveGameDialog:
         self.__gui = gtkui.loadUIFile('save_game.ui')
         self.__gui.connect_signals(self)
         
+        # Set style of error panel
+        mainUI.setTooltipStyle(self.__gui.get_object('error_box'))
+
         self.window = self.__gui.get_object('save_dialog')
         self.window.set_transient_for(mainUI.mainWindow)
         chooser = self.__gui.get_object('filechooser')
diff --git a/glchess/src/lib/gtkui/gtkui.py b/glchess/src/lib/gtkui/gtkui.py
index 689abdc..c57697f 100644
--- a/glchess/src/lib/gtkui/gtkui.py
+++ b/glchess/src/lib/gtkui/gtkui.py
@@ -231,7 +231,30 @@ class GtkUI(glchess.ui.UI):
             glchess.config.watch(key, self.__applyConfig)
 
     # Public methods
+    
+    def setTooltipStyle(self, widget):
+        """Set a widget to be in the tooltip style.
+        
+        'widget' is the widget to modify.
+        """
+        if self._tooltipStyle is None:
+            return
+        widget.set_style(self._tooltipStyle)
+        widget.connect("expose_event", self._on_tooltip_expose_event)
+        widget.queue_draw()
 
+    def _on_tooltip_expose_event(self, widget, event):
+        """Gtk+ callback"""
+        allocation = widget.allocation
+        widget.style.paint_flat_box(widget.window, gtk.STATE_NORMAL, gtk.SHADOW_OUT, None, widget, "tooltip",
+                                    allocation.x, allocation.y, allocation.width, allocation.height)
+                                    
+        # The first draw is corrupt for me so draw it twice.
+        # Bonus points to anyone who tracks down the problem and fixes it
+        if not self._tooltipWidgetsDrawn.has_key(widget):
+            self._tooltipWidgetsDrawn[widget] = True
+            widget.queue_draw()
+    
     def watchFileDescriptor(self, fd):
         """Extends ui.UI"""
         self._watches[fd] = gobject.io_add_watch(fd, gobject.IO_IN | gobject.IO_PRI | gobject.IO_HUP | gobject.IO_ERR, self.__readData)
diff --git a/glchess/src/lib/gtkui/network.py b/glchess/src/lib/gtkui/network.py
index dc265d2..cbf3381 100644
--- a/glchess/src/lib/gtkui/network.py
+++ b/glchess/src/lib/gtkui/network.py
@@ -217,6 +217,7 @@ class GtkNetworkGameDialog(glchess.ui.NetworkController):
         #buffer.create_tag('error', family='Monospace', foreground = 'red')
         buffer.create_mark('end', buffer.get_end_iter())
         
+        mainUI.setTooltipStyle(self.__gui.get_object('info_panel'))
         self.__addProfileDialog = GtkNetworkAddDialog(self, self.__gui.get_object('network_game_dialog'))
 
     # Extended methods



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