diff --git a/wx/lib/softwareupdate.py b/wx/lib/softwareupdate.py index 02cdf15b..6f2f4b50 100644 --- a/wx/lib/softwareupdate.py +++ b/wx/lib/softwareupdate.py @@ -7,7 +7,7 @@ # Author: Robin Dunn # # Created: 1-Aug-2011 -# RCS-ID: $Id$ +# RCS-ID: $Id: softwareupdate.py 72188 2012-07-24 03:24:51Z RD $ # Copyright: (c) 2011 by Total Control Software # Licence: wxWindows license #---------------------------------------------------------------------- @@ -46,6 +46,10 @@ except AttributeError: wx.App.SetAppDisplayName = wx.App.SetAppName +SOT = 0 +#if 'wxMac' in wx.PlatformInfo: +# SOT = wx.STAY_ON_TOP + #---------------------------------------------------------------------- @@ -158,7 +162,8 @@ class SoftwareUpdate(object): if not silentUnlessUpdate: MultiMessageBox( self._networkFailureMsg % self._updatesURL, - self._caption, parent=parentWindow, icon=self._icon) + self._caption, parent=parentWindow, icon=self._icon, + style=wx.OK|SOT) return active = self._esky.active_version @@ -173,7 +178,8 @@ class SoftwareUpdate(object): if not silentUnlessUpdate: MultiMessageBox("You are already running the newest verison of %s." % self.GetAppDisplayName(), - self._caption, parent=parentWindow, icon=self._icon) + self._caption, parent=parentWindow, icon=self._icon, + style=wx.OK|SOT) return self._parentWindow = parentWindow @@ -181,7 +187,7 @@ class SoftwareUpdate(object): "You are currently running verison %s; version %s is now " "available for download. Do you wish to install it now?" % (self.GetAppDisplayName(), active, newest), - self._caption, msg2=chLogTxt, style=wx.YES_NO, + self._caption, msg2=chLogTxt, style=wx.YES_NO|SOT, parent=parentWindow, icon=self._icon, btnLabels={wx.ID_YES:"Yes, install now", wx.ID_NO:"No, maybe later"}) @@ -215,12 +221,13 @@ class SoftwareUpdate(object): self._esky.auto_update(self._updateProgress) except UpdateAbortedError: - self._esky.cleanup() - self._esky.reinitialize() MultiMessageBox("Update canceled.", self._caption, - parent=parentWindow, icon=self._icon) + parent=parentWindow, icon=self._icon, + style=wx.OK|SOT) if self._pd: self._pd.Destroy() + + self.InitUpdates(self._updatesURL, self._changelogURL, self._icon) return # Ask the user if they want the application to be restarted. @@ -228,7 +235,7 @@ class SoftwareUpdate(object): "need to be restarted to begin using the new release.\n\n" "Restart %s now?" % (self.GetAppDisplayName(), newest, self.GetAppDisplayName()), - self._caption, style=wx.YES_NO, + self._caption, style=wx.YES_NO|SOT, parent=parentWindow, icon=self._icon, btnLabels={wx.ID_YES:"Yes, restart now", wx.ID_NO:"No, I'll restart later"}) @@ -297,7 +304,10 @@ class SoftwareUpdate(object): received = status.get('received') size = status.get('size') currentPercentage = 1.0 * received / size * 100 - self._doUpdateProgress(False, "Downloading...", int(currentPercentage)) + if currentPercentage > 99.5: + self._doUpdateProgress(False, "Unzipping...", int(currentPercentage)) + else: + self._doUpdateProgress(False, "Downloading...", int(currentPercentage)) elif status.get('status') == 'done': if self._pd: diff --git a/wx/lib/wxcairo.py b/wx/lib/wxcairo.py index acfb69c8..c3985225 100644 --- a/wx/lib/wxcairo.py +++ b/wx/lib/wxcairo.py @@ -68,7 +68,7 @@ pycairoAPI = None # a convenience funtion, just to save a bit of typing below def voidp(ptr): """Convert a SWIGged void* type to a ctypes c_void_p""" - return ctypes.c_void_p(int(ptr)) + return ctypes.c_void_p(long(ptr)) #---------------------------------------------------------------------------- @@ -85,15 +85,19 @@ def ContextFromDC(dc): width, height = dc.GetSize() # use the CGContextRef of the DC to make the cairo surface - cgc = dc.GetCGContext() + cgc = dc.GetHandle() assert cgc is not None, "Unable to get CGContext from DC." cgref = voidp( cgc ) - surfaceptr = voidp( - cairoLib.cairo_quartz_surface_create_for_cg_context( - cgref, width, height) ) + surface_create = cairoLib.cairo_quartz_surface_create_for_cg_context + surface_create.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int] + surface_create.restype = ctypes.c_void_p + surfaceptr = voidp(surface_create(cgref, width, height)) # create a cairo context for that surface - ctxptr = cairoLib.cairo_create(surfaceptr) + cairo_create = cairoLib.cairo_create + cairo_create.argtypes = [ctypes.c_void_p] + cairo_create.restype = ctypes.c_void_p + ctxptr = voidp(cairo_create(surfaceptr)) # Turn it into a pycairo context object ctx = pycairoAPI.Context_FromContext(ctxptr, pycairoAPI.Context_Type, None) @@ -105,8 +109,10 @@ def ContextFromDC(dc): elif 'wxMSW' in wx.PlatformInfo: # This one is easy, just fetch the HDC and use PyCairo to make # the surface and context. - hdc = dc.GetHDC() - surface = cairo.Win32Surface(hdc) + hdc = dc.GetHandle() + # Ensure the pointer value is clampped into the range of a C signed long + hdc = ctypes.c_long(hdc) + surface = cairo.Win32Surface(hdc.value) ctx = cairo.Context(surface) @@ -114,7 +120,7 @@ def ContextFromDC(dc): gdkLib = _findGDKLib() # Get the GdkDrawable from the dc - drawable = voidp( dc.GetGdkDrawable() ) + drawable = voidp( dc.GetHandle() ) # Call a GDK API to create a cairo context gdkLib.gdk_cairo_create.restype = ctypes.c_void_p @@ -138,13 +144,16 @@ def FontFaceFromFont(font): """ if 'wxMac' in wx.PlatformInfo: - fontfaceptr = voidp( - cairoLib.cairo_quartz_font_face_create_for_cgfont( - voidp(font.OSXGetCGFont())) ) + font_face_create = cairoLib.cairo_quartz_font_face_create_for_cgfont + font_face_create.argtypes = [ctypes.c_void_p] + font_face_create.restype = ctypes.c_void_p + + fontfaceptr = font_face_create(voidp(font.OSXGetCGFont())) fontface = pycairoAPI.FontFace_FromFontFace(fontfaceptr) elif 'wxMSW' in wx.PlatformInfo: + cairoLib.cairo_win32_font_face_create_for_hfont.restype = ctypes.c_void_p fontfaceptr = voidp( cairoLib.cairo_win32_font_face_create_for_hfont( ctypes.c_ulong(font.GetHFONT())) ) fontface = pycairoAPI.FontFace_FromFontFace(fontfaceptr) @@ -257,11 +266,12 @@ def _findCairoLib(): # appropriate for the system for name in names: location = ctypes.util.find_library(name) - try: - cairoLib = ctypes.CDLL(location) - return - except: - pass + if location: + try: + cairoLib = ctypes.CDLL(location) + return + except: + pass # If the above didn't find it on OS X then we still have a # trick up our sleeve...