³ņ
0Gc           @   s4  d  d k  Z  e Z d Z d Z h  Z h  Z d Z d Z	 e
 a e
 a d a d Z h  Z h  Z h  Z h  Z d   Z d   Z d   Z d   Z d   Z d	   Z e
 d d
  Z d d  Z d d  Z h  Z d d  Z d d  Z d   Z d d  Z  d   Z! d   Z" d   Z# d e$ f d     YZ% e%   Z& d S(   i’’’’Ns   0.6.2t   .c       	   C   s4  d d k  }  t i i t d  } |  i i d |  xł t i |  D]č } t i i |  \ } } | |  i j oŗ t i i	 t i i | |   o y t
 |  i } Wn6 t t t f j
 o! t o t d  | GHq(q,X| t | i <t | d  o | i   n t o t d  | i GHq,qD qD Wd S(   sq       Fills the common.code_writers dictionary: to do so, loads the modules
    found in the 'codegen/' subdir
    i’’’’Nt   codegeni    s)   "%s" is not a valid code generator modulet   setups   loaded code generator for %s(   t   syst   ost   patht   joint   wxglade_patht   insertt   listdirt   splitextt   modulest   isfilet
   __import__t   writert   ImportErrort   AttributeErrort
   ValueErrort   use_guit   _t   code_writerst   languaget   hasattrR   (   R   t   codegen_patht   modulet   namet   extR   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   load_code_writersM   s"     "	c          C   sV   d d k  }  g  } t i i t d  } | i t |   |  i i } | t |  f S(   sŹ       Scans the 'widgets/' directory to find the installed widgets,
    and returns 2 lists of buttons to handle them: the first contains the
    ``core'' components, the second the user-defined ones
    i’’’’Nt   widgets(	   t   configR   R   R   R   t   extendt   __load_widgetst   preferencest   local_widget_path(   R   t   buttonst   built_in_dirt   local_widgets_dir(    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   load_widgetsd   s    c   	   
   C   sś  g  } t  i i |  d  } t  i i |  p | Sn d d  k } | i i |   t |  } t o t d  | GHt d  GHn xf| D]^} | i	   } | p | i
 d  o q n | i d  d i	   } y§ y t |  i   } Wn t j
 o~ t  i i t  i i |  | d   oN | i i t  i i |  | d   z t |  i   } Wd  | i i   Xqz  n XWnI t t f j
 o7 t o) t d  | GHd d  k } | i   qčq Xt o d	 | GHn | i |  q W| i   | S(
   Ns   widgets.txti’’’’s   Found widgets listing -> %ss   loading widget modules:t   #i    s   .zips   ERROR loading "%s"s   	(   R   R   R   R   R   t   appendt   openR   R   t   stript
   startswitht   splitR   t
   initializeR   t   existst   popR   t	   tracebackt	   print_exct   close(	   t
   widget_dirR"   t   widgets_fileR   R   t   lineR   t   bR/   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyR   u   s@     &#
c          C   s   d d  k  }  |  i   S(   Ni’’’’(   t   edit_sizerst   init_all(   R6   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   load_sizers   s    c         C   sF   t  a t a |  i   } t | a t i d  d j o
 t  a n d S(   s5       Adds a widget or a sizer to the current app.
    t   Sizeri’’’’N(   t   Truet   adding_widgett   Falset   adding_sizert   GetIdt   refst   widget_to_addt   find(   t   eventt   tmp(    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt
   add_object¢   s    
c         C   s.   t  t |  i   d d d  t t i _ d S(   sE       Adds a toplevel widget (Frame or Dialog) to the current app.
    i    N(   R   R?   R>   t   NoneR<   t   app_treet   appt   saved(   RB   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   add_toplevel_object°   s    c            sd  d d k    d d k l }   i   } t i i |  p t i i t |  } n   i	 d j o   i
 } n
   i } d d k } | i |  }   i t | | d d d | }	 | p   i |	 | t  n   i |	 | t  |  t | <| p& t d  |  i t d	  d
  } n |	 i   i |   | | i |  <  f d   }
   i |	 |
  |	 S(   sY      creates a button for the widgets toolbar.
    Params:
      - widget: (name of) the widget the button will add to the app
      - icon_path: path to the icon used for the button
      - toplevel: true if the widget is a toplevel object (frame, dialog)
      - tip: tool tip to display
    Returns:
      the newly created wxBitmapButton
    i’’’’N(   t
   WidgetTreet	   __WXGTK__t   sizei   t   styles   Add a %st   Editt    c            s   |  i    p |  i     i j o |  i   d  Sn t a t a d  a d d  k	 } | i
 d  j	 o | i
 i   i  n |  i   d  S(   Ni’’’’(   t   HasModifierst
   GetKeyCodet
   WXK_ESCAPEt   SkipR<   R;   R=   RE   R@   t   misct   _currently_under_mouset	   SetCursort   STANDARD_CURSOR(   RB   RT   (   t   wx(    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   on_charŻ   s    #
(   i   i   (   RX   t   treeRJ   t   NewIdR   R   t   isabsR   R   t   Platformt	   NO_BORDERt   BU_AUTODRAWRT   t   get_xpm_bitmapt   BitmapButtont   palettet
   EVT_BUTTONRD   RI   R?   R   t   replacet
   SetToolTipt   ToolTipt   imagest   EVT_CHAR(   t   widgett	   icon_patht   toplevelt   tipRJ   t   idRM   RT   t   bmpRC   RY   (    (   RX   s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   make_object_buttonŗ   s*    	!
&c         C   s-   | d j o t i i } n |  i | d  S(   sH       Returns a str which is the encoded version of the unicode label
    Rd   N(   RE   RF   RG   t   encodingt   encode(   t   labelRp   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   _encode_from_xmlļ   s    c         C   sc   | d j o t i i } n t |   t d  j o |  i d  Sn t |   i |  i d  S(   s       returns a utf-8 encoded representation of label. This is equivalent to:
    str(label).decode(encoding).encode('utf-8')
    u    s   utf-8N(   RE   RF   RG   Rp   t   typeRq   t   strt   decode(   Rr   Rp   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   _encode_to_xml÷   s
    t   wxgc   
   	   C   sę  d d k  } d d k } d d k } | d j o | i i } n | i i } z7| oz |  t j om | i i |   oZ t	 |   } t	 |  | i i
 d  } | i | i    | i   | i   d t |  <n d } | i i |   o, t	 |   }	 |	 i   | j } |	 i   n | of | i i | i i |    p | i | i i |    n t	 |  d  } | i |  | i   n Wd d t   j o | i   n d t   j o | i   n d t   j o |	 i   n Xd S(	   s+      Saves 'filename' and, if user's preferences say so and 'filename' exists,
    makes a backup copy of it. Exceptions that may occur while performing the
    operations are not handled.
    'content' is the string to store into 'filename'
    'which' is the kind of backup: 'wxg' or 'codegen'
    i’’’’NRx   t   wi   t   infilet   outfilet   oldfile(   R   t   os.pathR   R    t
   wxg_backupt   codegen_backupt
   _backed_upR   R   R(   t   backup_suffixt   writet   readR1   t   isdirt   dirnamet   mkdirt   locals(
   t   filenamet   contentt   whichR   R   t   okRz   R{   t   savecontentR|   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt	   save_file  s2    $'

c         C   s|   |  d  j o t i i }  n |  p# d d  k } | i   d } } n t i i |   \ } } t i i	 | d |  } | S(   Ni’’’’RO   s   #~wxg.autosave~%s#(
   RE   RF   RG   R   R   t	   _get_homeR   R   R+   R   (   R   R   R   R   t   ret(    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   get_name_for_autosave/  s    c          C   sg   t  i i o t Sn y- t t   d  }  t  i |   |  i   Wn t j
 o } | GHt Sn Xt	 S(   NRy   (
   RF   RG   RH   R<   R(   R   R   R1   t	   ExceptionR:   (   R{   t   e(    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   autosave_current:  s    	c         C   sU   t  |   } t i i |  o2 y t i |  WqQ t j
 o } | GHqQ Xn d  S(   N(   R   R   R   R-   t   unlinkt   OSError(   R   t	   autosavedR   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   remove_autosavedG  s    c         C   sŗ   |  d j	 o |  t i i j o t Sn t |   } yM |  o2 t i |   } t i |  } | i | i j  Sn t i	 i
 |  SWn2 t j
 o& } | i d j o	 | GHn t Sn Xd S(   sE       Returns True iff there are some auto saved data for filename
    i   N(   RE   RF   RG   R   R<   R   R   t   statt   st_mtimeR   R-   R   t   errno(   R   R   t   origt   autoR   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   check_autosavedP  s     c         C   so   t  |   } t i | t i  oI y  t |  t |  i   d  Wn t j
 o } | GHt Sn Xt	 Sn t S(   NRx   (
   R   R   t   accesst   R_OKR   R(   R   R   R<   R:   (   R   R   R   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   restore_from_autosavedd  s     	c          C   s@   d d  k  }  |  i i o# t i i o d t i i d Sn d S(   Ni’’’’s    from "t   "RO   (   R   R    t   write_generated_fromRF   RG   R   (   R   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   generated_fromq  s    t   MessageLoggerc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   t  |  _ g  |  _ d  |  _ d  S(   N(   R<   t   disabledt   linesRE   t   logger(   t   self(    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   __init__y  s    		c         C   s>   d d  k  } | i d  d d  |  _ |  i i i d d  d  S(   Ni’’’’RO   i    (   t	   msgdialogt   MessageDialogRE   R§   t   msg_listt   InsertColumn(   RØ   RŖ   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   _setup_logger~  s    c   	   	   G   sā   |  i  o d  Sn | i   } t o d d  k } d d  k } | oA | i |  t g  } | D] } | | i |  q^ ~  } n | i |  } |  i i | i	    n1 | o | t |  } n | } d | | f GHd  S(   Ni’’’’s   %s: %s(
   R„   t   upperR   RX   RT   t   wxstrt   tupleR¦   R   t
   splitlines(	   RØ   t   kindt   fmtt   argsRX   RT   t   _[1]t   at   msg(    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   __call__  s    
Ac         C   s·   |  i  o© t o¢ |  i p |  i   n |  i i i   |  i i i   x' |  i  D] } |  i i i | g  qS Wg  |  _  |  i i i d d  |  i i i	   |  i i
   n d  S(   Ni    i’’’’(   R¦   R   R§   R®   R¬   t   Freezet   DeleteAllItemst   Appendt   SetColumnWidtht   Thawt	   ShowModal(   RØ   R4   (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyt   flush  s    
 	(   t   __name__t
   __module__R©   R®   R¹   RĄ   (    (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pyR¤   x  s   			('   R   R:   R   t   versionR   R   t   widgets_from_xmlRE   t   property_panelRF   R<   R;   R=   R@   Rb   R?   t   class_namest	   toplevelsR   R   R%   R   R8   RD   RI   Ro   Rs   Rw   R   R   R   R   R   R   R    R£   t   objectR¤   t   message(    (    (    s<   C:\Python25\Lib\site-packages\_spe\plugins\wxGlade\common.pys   <module>   sD   			(			
5*					-