bigboard r7316 - in trunk: . bigboard



Author: walters
Date: Thu Apr 24 19:56:16 2008
New Revision: 7316
URL: http://svn.gnome.org/viewvc/bigboard?rev=7316&view=rev

Log:
Bug #527613: Visual indication of collapsed stock state (Marco)



Modified:
   trunk/bigboard/big_widgets.py
   trunk/main.py

Modified: trunk/bigboard/big_widgets.py
==============================================================================
--- trunk/bigboard/big_widgets.py	(original)
+++ trunk/bigboard/big_widgets.py	Thu Apr 24 19:56:16 2008
@@ -1,4 +1,4 @@
-import os, code, sys, traceback, logging, StringIO, re, threading, urlparse, weakref
+import os, code, sys, traceback, logging, StringIO, re, threading, urlparse, weakref, math
 
 import cairo
 import pango
@@ -180,6 +180,59 @@
         
 gobject.type_register(Header)
 
+class Arrow(hippo.CanvasBox):
+    __gtype_name__ = 'BigboardArrow'
+
+    UP    = 0
+    DOWN  = 1
+    LEFT  = 2
+    RIGHT = 3
+
+    MIN_SIZE = 12
+
+    def __init__(self, arrow_type, **kwargs):
+        gobject.GObject.__init__(self, **kwargs)
+        self.__arrow_type = arrow_type
+
+        self.set_clickable(True)
+
+    def do_get_content_width_request(self):
+        return (self.MIN_SIZE, self.MIN_SIZE)
+
+    def do_get_content_height_request(self, for_width):
+        return (self.MIN_SIZE, self.MIN_SIZE)
+
+    def do_paint_below_children(self, cr, dmgbox):
+        [w, h] = self.get_allocation()
+
+        color = self.get_style().get_color('color', True)
+        hippo.cairo_set_source_rgba32(cr, color)
+
+        x1 = self.props.padding_left
+        y1 = self.props.padding_top
+        x2 = w - 1 - self.props.padding_right
+        y2 = h - 1 - self.props.padding_bottom
+
+        if self.__arrow_type == self.RIGHT:
+            cr.move_to(x1, y1)
+            cr.line_to(x1, y2)
+            cr.line_to(x2, (y1 + y2) / 2)
+        elif self.__arrow_type == self.LEFT:
+            cr.move_to(x2, y1)
+            cr.line_to(x2, y2)
+            cr.line_to(x1, (y1 + y2) / 2)
+        elif self.__arrow_type == self.UP:
+            cr.move_to(x1, y2)
+            cr.line_to(x2, y2)
+            cr.line_to((x1 + x2) / 2, y1)
+        elif self.__arrow_type == self.DOWN:
+            cr.move_to(x1, y1)
+            cr.line_to(x2, y1)
+            cr.line_to((x1 + x2) / 2, y2)
+
+        cr.close_path()
+        cr.fill()
+
 class GradientHeader(hippo.CanvasGradient):
     def __init__(self, **kwargs):
         hippo.CanvasGradient.__init__(self, 

Modified: trunk/main.py
==============================================================================
--- trunk/main.py	(original)
+++ trunk/main.py	Thu Apr 24 19:56:16 2008
@@ -20,7 +20,7 @@
 
 import bigboard
 import bigboard.big_widgets
-from bigboard.big_widgets import Sidebar, CanvasHBox, CanvasVBox, ActionLink
+from bigboard.big_widgets import Sidebar, CanvasHBox, CanvasVBox, ActionLink, Arrow
 from bigboard.big_widgets import Button, GradientHeader, ThemedWidgetMixin, ThemeManager, Header
 from bigboard.stock import Stock
 import bigboard.libbig
@@ -310,8 +310,13 @@
         if not is_notitle:
             self.__ticker_container = Header()
             self.__ticker_text = hippo.CanvasText(classes='header', text=metainfo.title, xalign=hippo.ALIGNMENT_START)
-            self.__ticker_text.connect("button-press-event", lambda text, event: self.__toggle_expanded())  
+            self.__ticker_text.set_clickable(True)
+            self.__ticker_text.connect("activated", lambda text: self.__toggle_expanded())  
             self.__ticker_container.append(self.__ticker_text, hippo.PACK_EXPAND)
+
+            self.__ticker_arrow = Arrow(Arrow.LEFT, padding=4)
+            self.__ticker_arrow.connect("activated", lambda text: self.__toggle_expanded())
+            self.__ticker_container.append(self.__ticker_arrow)
             
             if pymodule and pymodule.has_more_button():
                 more_button = HeaderButton()
@@ -319,6 +324,7 @@
                 self.__ticker_container.append(more_button)
             
             self.append(self.__ticker_container)
+
         self.__stockbox = hippo.CanvasBox()
         self.append(self.__stockbox)
         if pymodule:
@@ -327,16 +333,23 @@
         else:
             self.__render_google_gadget()    
 
+        self.__sync_visibility()
+
     def on_delisted(self):
         _logger.debug("on_delisted exchange %s" % (str(self)))
         self.__unrender_pymodule()
 
     def on_popped_out_changed(self, popped_out):
         self.__pymodule.on_popped_out_changed(popped_out)
-    
+
+    def __sync_visibility(self):
+        self.set_child_visible(self.__stockbox, self.__expanded)
+        if self.__ticker_container:
+            self.__ticker_container.set_child_visible(self.__ticker_arrow, not self.__expanded)
+
     def __toggle_expanded(self):
         self.__expanded = not self.__expanded
-        self.set_child_visible(self.__stockbox, self.__expanded)
+        self.__sync_visibility()
     
     def get_metainfo(self):
         return self.__metainfo



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