
.Oc           @   s   d  Z  d d l Z d d l Z y$ d d l m Z d d l m Z Wn! e k
 re d d l m Z n Xd d l Z d d l	 m
 Z
 e d d  Z d   Z e   Z d	 d
  Z d   Z d   Z d d  Z d   Z d   Z d   Z d S(   s  
PyGTK compatibility layer.

This modules goes a little bit longer to maintain PyGTK compatibility than
the normal overrides system.

It is recommended to not depend on this layer, but only use it as an
intermediate step when porting your application to PyGI.

Compatibility might never be 100%, but the aim is to make it possible to run
a well behaved PyGTK application mostly unmodified on top of PyGI.

iN(   t   UserList(   t   reload(   t   GObjectt    c   
      C   s  | d  k r |  } n  | j j d d  d j   } x[t |   D]M} y t |  | d   } Wn
 qA n Xy t | t j  r xw | j	 j
   D]c \ } } | j } | j | d d  } | r | j |  r | t |  } n  t | | |  q Wn  Wn t k
 rqA n Xyf t | t j  rvxM | j j
   D]9 \ } }	 |	 j d j | d d  } t | | |	  q6Wn  WqA t k
 rqA qA XqA Wd  S(   Nt   .i   t   _R   i(   t   Nonet   __name__t   rsplitt   uppert   dirt   getattrt
   issubclassR   t   GEnumt   __enum_values__t   itemst
   value_namet   replacet
   startswitht   lent   setattrt	   TypeErrort   GFlagst   __flags_values__t   value_names(
   t   modulet   destt   stript   modnamet   attrt   objt   valuet   enumt   namet   flag(    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   _install_enums2   s2    		c          C   sx   d d l  m }  |  t j d <d d l  m } | t j d <d d l m } | t j d <d d l  m } | t j d	 <d  S(
   Ni(   t   GLibt   glib(   R   t   gobject(   t   propertyhelpers   gobject.propertyhelper(   t   Giot   gio(   t   gi.repositoryR$   t   syst   modulesR   t   gi._gobjectR'   R(   (   R$   R   R'   R(   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   enableN   s    s   2.0c   $         s  t  t  t j dI k  r) t j d  n  t j d d  d d l m } | t j d <t	 |  t j d	 d  d d
 l m
 } | t j d <t	 |  t j d d  d d l m } | t j d <t j d |   t j d d  d d l m  d d l m }  t j d <t	   t	 | d  d  _ d  _  j j  _ | j  _ | j j  _ | j j  _  j j 
  
 f d   } |  j _  j j   f d   } |  j _ t j d |   d d l m   t j d <  _ dJ  _  j  j  j  f  _! t	   d   } t" |   j# _$  j%  d   f  f d!     Y} |  _%  j& j'  t( t( d  f d"  }	 |	  j& _'  j& j)  t( t( d  f d#  }
 |
  j& _)  j* j'  t(  f d$  } |  j* _'  j* j)   t(   f d%  } |  j* _) d&   } |  j+ _,  j- j'  t(  f d'  } |  j- _'  j- j)  t(  f d(  } |  j- _)  j- j.  t/  f d)  } |  j- _. d*  j0 f d+     Y} |  _1  j2 j3  t/  f d,  } |  j2 _3 d-  j2 f  f d.     Y} |  _4  f d/   } |  _5  f d0   } |  _6 d1   } t" |   j7 _8  f d2   } |  _9 d3   } |  j2 _:  j; j<  _=  j> j  _?  j@ jA  _B  j@ jC  _D  jE j  _F  j jG  _H  jI   jJ 	 d4  f  f d5     Y} |  _I d6 	 f 	 f d7     Y} |  _J d8    _K  jL jM  _N  jL jO   f d9   } |  jL _O  jL jP  jL _Q d: tR f  f d;     Y d< tR f   f d=     Y d> tR f  f d?     Y} |    jL _S d@ tR f dA     Y} |   } | t j dB <dC tR f dD     Y} |   }  |  t j dE <|   _T xl tU   D]^ }! |! jV dF  r|! d }" |" d dG k rdH |" }" n  tW  |!  }# tX |  |" |#  qqWd  S(K   Ni   i    s   utf-8t   Atks   1.0i(   R/   t   atkt   Pango(   R1   t   pangot
   PangoCairo(   R3   t
   pangocairot   Gdkt	   GdkPixbufs   2.0(   R5   (   R6   s   gtk.gdkR   i   i   c            sq   yM y   j  d d d d  } Wn t k
 r>   j    } n X |  |  Wn t k
 rl  |   } n X| S(   Ni    (   t	   RectangleR   (   t   windowt   rect(   R5   t   orig_get_frame_extents(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   get_frame_extents   s    c            s     |   d S(   Ni   (    (   t   self(   t   orig_get_origin(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt
   get_origin   s    t   Gtk(   R?   t   gtki   ic   c         S   s   t  j d t d d d  S(   Ns%   set_tool_item_type() is not supportedt
   stackleveli   (   t   warningst   warnt   DeprecationWarning(   t
   menuactiont   gtype(    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   set_tool_item_type   s    	t	   Alignmentc              s#   e  Z d  d  d  d    f d  Z RS(   g        c            sA     j  |   | |  j _ | |  j _ | |  j _ | |  j _ d  S(   N(   t   __init__t   propst   xalignt   yalignt   xscalet   yscale(   R<   RK   RL   RM   RN   (   t   orig_Alignment(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRI      s
    (   R   t
   __module__RI   (    (   RO   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRH      s   c            s     |  | | | |  d  S(   N(    (   R<   t   childt   expandt   fillt   padding(   t   orig_pack_end(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   pack_end   s    c            s     |  | | | |  d  S(   N(    (   R<   RQ   RR   RS   RT   (   t   orig_pack_start(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt
   pack_start   s    c            s     |  | |  d  S(   N(    (   R<   t   cellRR   (   t   orig_tree_view_column_pack_end(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   tree_view_column_pack_end   s    c            s     |  | |  d  S(   N(    (   R<   RY   RR   (   t    orig_tree_view_column_pack_start(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   tree_view_column_pack_start   s    c         _   s   d  S(   N(    (   t   viewt   positiont   titleRY   t   argst   kwargs(    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   insert_column_with_attributes   s    c            s     |  | |  d  S(   N(    (   R<   RY   RR   (   t   orig_cell_pack_end(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   cell_pack_end   s    c            s     |  | |  d  S(   N(    (   R<   RY   RR   (   t   orig_cell_pack_start(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   cell_pack_start   s    c            s&     f d   }  |  | | |  d  S(   Nc             s'   |  d t  k r |  d  }  n    |    S(   Ni(   t   _unset(   Ra   (   t   func(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   callback   s    (    (   R<   RY   Ri   t	   user_dataRj   (   t   orig_set_cell_data_func(   Ri   s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   set_cell_data_func   s    t   GenericCellRendererc           B   s   e  Z RS(    (   R   RP   (    (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRn      s   c            s#     f d   }  |  | |  d  S(   Nc             s'   |  d t  k r |  d  }  n    |    S(   Ni(   Rh   (   Ra   (   Ri   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRj      s    (    (   R<   Ri   Rk   Rj   (   t   orig_combo_row_separator_func(   Ri   s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   combo_row_separator_func   s    t   ComboBoxEntryc              s)   e  Z   f d    Z d   Z d   Z RS(   c            s     j  j |  d t | d  S(   Nt	   has_entry(   t   ComboBoxRI   t   True(   R<   t   kwds(   R?   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRI   	  s    c         S   s   |  j  |  d  S(   N(   t   set_entry_text_column(   R<   t   text_column(    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   set_text_column  s    c         S   s
   |  j    S(   N(   t   get_entry_text_column(   R<   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   get_text_column  s    (   R   RP   RI   Rx   Rz   (    (   R?   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRq     s   	c              s
     j    S(   N(   Rq   (    (   R?   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   combo_box_entry_new  s    c            s     j  d |   S(   Nt   model(   Rq   (   R|   (   R?   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   combo_box_entry_new_with_model  s    c         S   s   t  j d t d d d  S(   Ns)   install_child_property() is not supportedRA   i   (   RB   RC   RD   (   t	   containerR"   t   pspec(    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   install_child_property  s    	c             s9     j    }    j t  } |  j |  |  j d  |  S(   Ni    (   Rs   t	   ListStoret   strt	   set_modelRv   (   t   comboR|   (   R?   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   new_text   s
    c         S   s    |  j    } | j | g  d  S(   N(   t	   get_modelt   append(   R<   t   textR|   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   append_text'  s    t   HScalec              s   e  Z d   f d   Z RS(   c            s     j  |  d | d  S(   Nt
   adjustment(   RI   (   R<   R   (   t   orig_HScale(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRI   8  s    N(   R   RP   R   RI   (    (   R   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   7  s   t   VScalec              s   e  Z d   f d   Z RS(   c            s     j  |  d | d  S(   NR   (   RI   (   R<   R   (   t   orig_VScale(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRI   =  s    N(   R   RP   R   RI   (    (   R   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   <  s   c         S   s   d  S(   N(   R   (   R   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   <lambda>A  s    c            s&   d t  f d     Y} |   |    S(   Nt   SizeRequestc           B   s   e  Z d    Z RS(   c         S   s8   | j  |  _  | j |  _ t j |  |  j |  j  g  d  S(   N(   t   heightt   widthR    RI   (   R<   t   req(    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRI   I  s    (   R   RP   RI   (    (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   H  s   (   R    (   t   widgetR   (   t   orig_size_request(    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   size_requestG  s    t
   BaseGetterc              s    e  Z d    Z   f d   Z RS(   c         S   s   | |  _  d  S(   N(   t   context(   R<   R   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRI   S  s    c            s7   |  j  j |  }   j d | j d | j d | j  S(   Nt   redt   greent   blue(   R   t   get_background_colort   ColorR   R   R   (   R<   t   statet   color(   R5   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   __getitem__V  s    	(   R   RP   RI   R   (    (   R5   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   R  s   	t   Stylesc              s   e  Z    f d    Z RS(   c            s@   | j    }  |  |  _   j d d d d d d  |  _ d  S(   NR   i    R   R   (   t   get_style_contextt   baseR   t   black(   R<   R   R   (   R5   R   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyRI   ]  s    (   R   RP   RI   (    (   R5   R   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   \  s   t   StyleDescriptorc              s   e  Z   f d    Z RS(   c            s
     |  S(   N(    (   R<   t   instancet   class_(   R   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   __get__c  s    (   R   RP   R   (    (   R   (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   b  s   t	   UnixPrintc           B   s   e  Z RS(    (   R   RP   (    (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   h  s   t   gtkunixprintt   Keysymsc           B   s   e  Z RS(    (   R   RP   (    (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR   n  s   s   gtk.keysymst   KEY_t
   0123456789R   (   i   i    (   i   ic   i    (Y   R   R+   t   version_infot   setdefaultencodingt   git   require_versionR*   R/   R,   R#   R1   R3   R5   R6   t   _2BUTTON_PRESSt   BUTTON_PRESSt   Screent   get_defaultt   screen_get_defaultt   Pixbuft   new_from_filet   pixbuf_new_from_filet   PixbufLoadert   new_with_typet   WindowR;   R>   R?   t   gdkt   pygtk_versiont   MAJOR_VERSIONt   MINOR_VERSIONt   MICRO_VERSIONt   gtk_versiont   classmethodt   ActionRG   RH   t   BoxRV   Rt   RX   t   TreeViewColumnt   TreeViewRc   t
   CellLayoutRm   Rh   t   CellRendererRn   Rs   t   set_row_separator_funcRq   R{   R}   t	   ContainerR   t   combo_box_new_textR   t   Expandert   new_with_mnemonict   expander_new_with_mnemonict	   IconThemet   icon_theme_get_defaultt   Imaget   new_from_pixbuft   image_new_from_pixbuft   new_from_stockt   image_new_from_stockt   Settingst   settings_get_defaultt   set_default_icont   window_set_default_iconR   R   t	   stock_addt   Widgett   get_default_directiont   widget_get_default_directionR   t   hidet   hide_allt   objectt   stylet   keysymsR
   R   R   R   ($   t   versionR/   R1   R3   R6   R;   R>   RG   RH   RV   RX   R[   R]   Rc   Re   Rg   Rm   Rn   Rp   Rq   R{   R}   R   R   R   R   R   R   R   R   t	   unixprintR   R   R!   t   targetR   (    (   R\   RW   R=   RO   R   Ro   RU   R   R?   R   R:   R   Rl   RZ   Rd   Rf   R5   R   s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt
   enable_gtk`   s    



		
		
															
			
c          C   s1   t  j d d  d d l m }  |  t j d <d  S(   Nt   Vtes   0.0i(   R   t   vte(   R   R   R*   R   R+   R,   (   R   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt
   enable_vte|  s    c          C   s:   t  j d d  d d l m }  |  t j d <d |  _ d  S(	   Nt   Popplers   0.18i(   R   t   poppleri   i    (   i   i    i    (   R   R   R*   R   R+   R,   t   pypoppler_version(   R   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   enable_poppler  s    s   1.0c         C   sC   t  j d |   d d l m } | t j d <| j j | j _ d  S(   Nt   WebKiti(   R   t   webkit(	   R   R   R*   R   R+   R,   t   WebViewt   get_inspectort   get_web_inspector(   R   R   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   enable_webkit  s    c          C   s1   t  j d d  d d l m }  |  t j d <d  S(   Nt   GUdevs   1.0i(   R   t   gudev(   R   R   R*   R   R+   R,   (   R   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   enable_gudev  s    c          C   s  t  j d d  d d l m }  |  t j d <t |   |  j j |  _	 |  j
 j |  _ |  j j |  _ |  j j |  _ d   |  _ d   |  _ d d l m } | t j d	 <t |  d d
 l m } | t j d <t |  d d l m } | t j d <t |  d d l m } | t j d <t |  | j |  _ | j |  _ d d l m } | t j d <t | d |  d d l m } | t j d <t |  d  S(   Nt   Gsts   0.10i(   R   t   gstc           S   s   d S(   Ni    i
   i   (   i    i
   i   (    (    (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR     s    c           S   s   d S(   Ni    i
   i(   (   i    i
   i(   (    (    (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyR     s    (   t   GstInterfacess   gst.interfaces(   t   GstAudios	   gst.audio(   t   GstVideos	   gst.video(   t   GstBases   gst.base(   t   GstControllers   gst.controllerR   (   t
   GstPbutilss   gst.pbutils(   R   R   R*   R   R+   R,   R#   t   RegistryR   t   registry_get_defaultt   Elementt   registert   element_registert   ElementFactoryt   maket   element_factory_maket   Capst   new_anyt   caps_new_anyt   get_pygst_versiont   get_gst_versionR   R   R   R   t   BaseTransformt   BaseSinkR   R   (   R   R   R   R   R   R   R   (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt
   enable_gst  s<    




c          C   s}   t  j d d  d d l m }  |  t j d <t |  d d |  j |  _ |  j	 |  _
 |  j |  _ |  j |  _ |  j |  _ d  S(   Nt	   GooCanvass   2.0i(   R  t	   goocanvasR   t   GOO_CANVAS_(   R   R   R*   R  R+   R,   R#   t   CanvasItemSimplet
   ItemSimplet
   CanvasItemt   Itemt   CanvasImageR   t   CanvasGroupt   Groupt
   CanvasRectt   Rect(   R  (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   enable_goocanvas  s    (   t   __doc__R+   RB   t   collectionsR    t   impR   t   ImportErrorR   R*   R   R   R#   R.   R   Rh   R   R   R   R   R   R  R  (    (    (    s2   /usr/lib/python2.7/dist-packages/gi/pygtkcompat.pyt   <module>!   s(   		 				(