- Revision
- 15955
- Author
- grant
- Date
- 2007-11-29 08:13:58 -0800 (Thu, 29 Nov 2007)
Log Message
[APP] Port over the triage button image provider code
- Some slight API changes (e.g. get_image instead of wx.GetApp().GetImage)
- Hard-code some constants that previously came from osaf.pim.
- Some slight API changes (e.g. get_image instead of wx.GetApp().GetImage)
- Hard-code some constants that previously came from osaf.pim.
Modified Paths
Diff
Modified: branches/rearchitecture/Chandler-App/ocap/chandler/triage_buttons.py (15954 => 15955)
--- branches/rearchitecture/Chandler-App/ocap/chandler/triage_buttons.py 2007-11-29 16:11:52 UTC (rev 15954) +++ branches/rearchitecture/Chandler-App/ocap/chandler/triage_buttons.py 2007-11-29 16:13:58 UTC (rev 15955) @@ -13,11 +13,16 @@ # limitations under the License. import os, wx -from application import styles +from ocap.wxui.image import get_image +import ocap.wxui.styles as styles import logging -from osaf.framework.blocks import Styles -from osaf import pim +_ = lambda x:x + +class styles_cfg(object): + @classmethod + def get(cls, *args): return None + logger = logging.getLogger(__name__) class TriageButtonImageNotFoundException(Exception): @@ -99,18 +104,18 @@ def getTextFont(self): font = getattr(self, 'font', None) if font is None: - fontsize = styles.cfg.get('triagebuttons', 'FontSize.%s' % wx.Platform) or \ - styles.cfg.get('triagebuttons', 'FontSize') or "10" - fontweight = styles.cfg.get('triagebuttons', 'FontWeight.%s' % wx.Platform) or \ - styles.cfg.get('triagebuttons', 'FontWeight') or wx.BOLD - font = self.font = Styles.getFont(size=int(fontsize), weight=int(fontweight)) + fontsize = styles_cfg.get('triagebuttons', 'FontSize.%s' % wx.Platform) or \ + styles_cfg.get('triagebuttons', 'FontSize') or "10" + fontweight = styles_cfg.get('triagebuttons', 'FontWeight.%s' % wx.Platform) or \ + styles_cfg.get('triagebuttons', 'FontWeight') or wx.BOLD + font = self.font = styles.getFont(size=int(fontsize), weight=int(fontweight)) return font def getImageSize(self, leftImage=None, rightImage=None): imageSize = getattr(self, 'imageSize', None) if imageSize is None: # Measure the triage values - aWidget = wx.GetApp().mainFrame + aWidget = wx.GetApp().TopWindow dc = wx.ClientDC(aWidget) oldWidgetFont = aWidget.GetFont() textWidth = 0 @@ -132,8 +137,8 @@ leftImage, rightImage = self._getSideImages(self.sampleImageName) imageSize = leftImage.GetSize() imageSize[0] += rightImage.GetWidth() - padding = int(styles.cfg.get('triagebuttons', 'Padding.%s' % wx.Platform) or \ - styles.cfg.get('triagebuttons', 'Padding') or 6) + padding = int(styles_cfg.get('triagebuttons', 'Padding.%s' % wx.Platform) or \ + styles_cfg.get('triagebuttons', 'Padding') or 6) maxTextWidth = imageSize[0] - padding if textWidth < maxTextWidth: # we're not past the limit imageSize[0] = textWidth + padding @@ -146,11 +151,14 @@ def loadSideImage(side): basename, extension = os.path.splitext(name) sideImageName = "%s.%s%s" % (basename, side, extension) - image = wx.GetApp().GetImage(sideImageName) + image = get_image(sideImageName) if image is None: raise TriageButtonImageNotFoundException, sideImageName return image return [ loadSideImage(side) for side in "Left", "Right" ] + + TRIAGE_BUTTONS = ( ('now', _(u'NOW')), ('later', _(u'LATER')), + ('done', _(u'DONE')) ) def _getTriageButtonLabel(self, name): """ @@ -161,12 +169,15 @@ """ if name is None: # it's looking for the widest label - return them all - return [ pim.getTriageStatusButtonLabel(getattr(pim.TriageEnum, status)) - for status in pim.TriageEnum.values ] + return [label for name, label in self.TRIAGE_BUTTONS] else: # We were given an image name, like "Triage.Now.png" # extract the "Now", convert to lowercase, and get the # localized label to use for it. - status = getattr(pim.TriageEnum, name.split('.',2)[1].lower()) - return pim.getTriageStatusButtonLabel(status) + status = name.split('.',2)[1].lower() + for name, label in self.TRIAGE_BUTTONS: + if name == status: + return label + + raise ValueError, "Unrecognized triage status %s" % (status,)
_______________________________________________ Commits mailing list [email protected] http://lists.osafoundation.org/mailman/listinfo/commits
