
    ?g*&                     2   d dl Z d dlZd dlmZmZ d dlmZ d dl dej                  dz  z  Z	dej                  dz  z  Z
dej                  dz  z  Zdej                  dz  z  Z G d	 d
      Z G d dej                        Z G d dej"                        Zy)    N)GioGLib)SidePage)*g     p@g     f@g     V@g        c                   H    e Zd Z ed      ZdZdZd Zd Zd Z	d Z
d Zd	 Zy
)ModulezManage hotcorner settings	hotcornerprefsc                 \    t        d      }t        t        d      d||d|       }|| _        y )Nz hotcorner, overview, scale, expozHot Cornerszcs-overview)module)_r   sidePage)selfcontent_boxkeywordsr   s       =/usr/share/cinnamon/cinnamon-settings/modules/cs_hotcorner.py__init__zModule.__init__   s/    78Am,mX{TV_cd     c                    | j                   sWt        d       t        j                  j	                  d      | _        | j
                  j                  d| j                         | j
                  j                  d      }g | _	        |D ]/  }|j                  dd      }| j                  j                  |       1 g | _        t        d      D ]1  }| j                  j                  t        || j                               3 t!        t"        j$                  j&                  d	      | _        | j(                  j+                  d
d
       t"        j-                  ddt"        j$                  j&                        }|j/                  d       |j1                  | j(                  dddd       |j1                  | j                  d   dddd       |j1                  | j                  d   dddd       |j1                  | j                  d   dddd       |j1                  | j                  d   dddd       | j2                  j5                  |       | j                  | j
                  d       y y )NzLoading HotCorner modulezorg.cinnamonzchanged::hotcorner-layouthotcorner-layout:      T)halignhexpand          )row_spacingcolumn_spacingr      r      )loadedprintr   Settingsnewsettingsconnecton_settings_changedget_strv
propertiesrsplitappendcornersrangeHotCornerConfigurationonConfigChangedHotCornerDisplayGtkAlignFILLcornerDisplayset_size_requestGridset_border_widthattachr   
add_widget)r   oc_listitempropsigrids         r   on_module_selectedzModule.on_module_selected   s   {{,-LL,,^<DMMM!!"=t?W?WXmm,,-?@G DO .C+&&u-. DL1X U##$:1d>R>R$STU "2QU!VD//S9882ciinn8UD!!"%KK**Aq!Q7KKQAq!4KKQAq!4KKQAq!4KKQAq!4MM$$T*$$T]]4FG; r   c                     | j                   j                  d      }| j                  d d = |D ]/  }|j                  dd      }| j                  j	                  |       1 | j                          y )Nr   r   r   )r(   r+   r,   r-   r.   update)r   r(   keyr=   r>   r?   s         r   r*   zModule.on_settings_changed;   s_    --(();<OOA 	*DKKQ'EOO""5)	* 	r   c                 :   | j                   D ]i  }d}| j                  |j                     }|d   }|d   dk(  }	 |d   }|j                  |||       | j                  j                  |j                  |       k | j                  j                          y #  d}Y \xY w)N r   r"   truer   0)r/   r,   index	setValuesr7   setCornerEnabled
queue_draw)r   cornerfunctionpropenableddelays         r   rD   zModule.updateC   s    ll 	GFH??6<<0DAwH1g'GQ Xw6//gF	G 	%%'s   BBc                     | j                   j                          | j                  |   }||d<   |rd|d<   nd|d<   	 t        |      |d<   | j                          y #  |j	                  d       Y &xY w)Nr   rH   r"   falser   rI   )r7   rM   r,   strr.   write_settings)r   rJ   rO   rQ   rR   r?   s         r   r2   zModule.onConfigChangedS   ss    %%'&aE!HE!H	5zE!H 		LLs   A A1c                     g }| j                   D ]"  }|j                  dj                  |             $ | j                  j	                  d|       y )Nr   r   )r,   r.   joinr(   set_strv)r   r=   rP   s      r   rV   zModule.write_settingsf   sC    OO 	+DNN388D>*	+17;r   N)__name__
__module____qualname__r   commentnamecategoryr   rB   r*   rD   r2   rV    r   r   r   r      s7    +,GDH!
H@( &<r   r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)r3   c                     t        j                  j                  | fi | | j                  d| j                         g d| _        y )Ndraw)TTTT)r4   DrawingArear   r)   exposecornerEnabled)r   kwargss     r   r   zHotCornerDisplay.__init__n   s3      00VT[[)5r   c                 "    || j                   |<   y N)rf   )r   rJ   values      r   rL   z!HotCornerDisplay.setCornerEnabledt   s    $)5!r   c                    | j                   |   re|j                  | j                  j                  | j                  j                  | j                  j
                  | j                  j                         y |j                  dddd       y )Nr"         ?)rf   set_source_rgbaactiveColorredgreenbluealpha)r   crrJ   s      r   _setCornerColorz HotCornerDisplay._setCornerColorw   si    e$t//33T5E5E5K5KTM]M]MbMbdhdtdtdzdz{q!Q,r   c                 Z    |j                  |      \  }}|s|j                  |      \  }}|S ri   )lookup_color)r   contextdefaultalternativesucccolors         r   	_getColorzHotCornerDisplay._getColor}   s2    ,,W5u#00=MT5r   c                    | j                         }| j                  |dd      | _        | j                  xj                  dz  c_        | j	                         }|j                  t        j                         |j                  dz  }|j                  dz  }t        j                  ||d|||      }|j                  dddd       |j                  dd	d	d	       |j                  |       |j                  dd|j                  |j                         |j                          |j                  d       d
}| j!                  |d       |j#                  dd       |j%                  |d       |j'                  dd|t(        t*               |j                          | j!                  |d       |j#                  |j                  d       |j%                  |j                  |       |j'                  |j                  d|t*        t,               |j                          | j!                  |d       |j#                  d|j                         |j%                  d|j                  |z
         |j'                  d|j                  |t.        t(               |j                          | j!                  |d       |j#                  |j                  |j                         |j%                  |j                  |z
  |j                         |j'                  |j                  |j                  |t,        t.               |j                          |j1                  dddd       |j                  dd|j                  |j                         |j3                          y)Nsuccess_colorquestion_bg_colorg?r   r   g?rl   r"   g333333?2   r#   T)get_style_contextr|   rn   rr   get_allocationset_antialiascairoANTIALIAS_SUBPIXELwidthheightRadialGradientadd_color_stop_rgb
set_source	rectanglefillset_line_widthrt   move_toline_toarc_0_DEG_90_DEG_180_DEG_270_DEGrm   stroke)	r   widgetrs   rw   
allocationmiddleXmiddleYpat
cornerSizes	            r   re   zHotCornerDisplay.expose   s   ((*>>'?DWX#%((*

112""a'##q(""7GQ'Rr3S1q#sC0
c
Q:++Z->->?
	
!
R#


1Q


:a 
q!Z1
	R#


:##Q'


:##Z0
zJB
	R#


1j''(


1j''
23
q*##Z6B
	R#


:##Z%6%67


:##J.
0A0AB
z!2!2J(S
	
1aA&
Q:++Z->->?
		r   N)rZ   r[   r\   r   rL   rt   r|   re   r`   r   r   r3   r3   m   s    6*-3r   r3   c                       e Zd Zd Zd Zd Zy)r1   c                    t         j                  j                  | t         j                  j                         || _        || _        d | _        t         j                  t        t              | _
        | j                  j                  dt        d      g       | j                  j                  dt        d      g       | j                  j                  dt        d      g       | j                  j                  dt        d	      g       t         j                  d
      }t         j                  t        d            }t         j                         | _        |j!                  |ddd       |j#                  | j                  ddd       t         j$                  j'                  | j                        | _        t         j+                         }| j(                  j!                  |d       | j(                  j-                  |dd       t         j/                         | _        t         j3                  t        d      d
      | _        | j0                  j7                  | j4                         | j0                  j9                  d       t         j                  d
      | _        t         j                  t        d            }t         j<                  j?                  ddd      | _         | j:                  j!                  |ddd       | j:                  j#                  | j@                  ddd       | j!                  |ddd       | j!                  | j(                  ddd
       | j!                  | j0                  ddd       | j!                  | j:                  ddd       | j(                  jC                  d| jD                         | j4                  jC                  d| jD                         | j                  jC                  d| jD                         | j@                  jC                  d| jD                         | j                  dkD  r*| jG                  t         jH                  jJ                         y y )N)orientationexpozShow all workspacesscalezShow all windowsdesktopzShow the desktopcustomzRun a command   )spacingzEnable this cornerFTr   textr"   zType a command...)placeholder_textmargin_bottomzActivation delay (ms)i  r   changedznotify::activezvalue-changed)&r4   Boxr   OrientationVERTICALupdateCallbackrJ   timer	ListStorerU   functionStorer.   r   LabelSwitchenableSwitch
pack_startpack_endComboBoxnew_with_modelfunctionComboCellRendererTextadd_attributeRevealercommandRevealerEntrycommandEntryaddset_reveal_childhoverDelayBox
SpinButtonnew_with_rangehoverDelaySpinnerr)   on_widget_changed
set_valignr5   END)r   rJ   r   	enableBoxenableLabelrendererTexthoverDelayLabels          r   r   zHotCornerConfiguration.__init__   sC   3??+C+CD,

 ]]34!!61-B+C"DE!!7A.@,A"BC!!9a0B.C"DE!!8Q-?"@AGGAG&	ii"6 78JJL[%q94,,eUA> \\889K9KL++-%%lD9((vqA"||~IIq9L7M]^I_  !2!23--e4 WWQW/))A&=$>?!$!>!>q$!K%%oudAF##D$:$:E5!L	5%3**E5!<,,eUA>**E5!<""9d.D.DE!!)T-C-CD!!"2D4J4JK&&8N8NO::>OOCIIMM* r   c                    d}|dk(  r| j                   j                  d       n|dk(  r| j                   j                  d       nv|dk(  r| j                   j                  d       nUd}| j                   j                  d	       | j                  j                         |k7  r| j                  j	                  |       | j
                  j                  |       | j                  j                         |k7  r| j                  j                  |       | j                   j                  |       | j                  j                  |       | j                  j                  |       | j                  j                  t        |             y )
NFr   r   r   r"   r   r   Tr#   )r   
set_activer   get_textset_textr   r   r   
get_activeset_sensitiver   r   	set_valueint)r   rO   rQ   rR   showCommandEntrys        r   rK   z HotCornerConfiguration.setValues   s5    v))!, ))!,"))!,#))!,  ))+x7!!**84--.>?'')W4((1((1''0((1((U4r   c                     d }| j                   rt        j                  | j                          t        j                  d||       | _         y )Nc                    | j                   j                         }|| j                  j                  |d      }| j                  j                         }t        t        | j                  j                                     }|dk(  r| j                  j                         }| j                  | j                  |||       d | _        y )Nr   r   )r   get_active_iterr   	get_valuer   r   rU   r   r   r   r   r   rJ   r   )r   iterrO   rQ   rR   s        r   applyz7HotCornerConfiguration.on_widget_changed.<locals>.apply  s    %%557D--77a@++668C 6 6 @ @ BCDx'#0099;H##DJJ'5IDJr      )r   r   source_removetimeout_add)r   argsr   s      r   r   z(HotCornerConfiguration.on_widget_changed  s8    	 ::tzz*%%c5$7
r   N)rZ   r[   r\   r   rK   r   r`   r   r   r1   r1      s    ,+\528r   r1   )r   mathgi.repositoryr   r   SettingsWidgetsr   xapp.GSettingsWidgetspir   r   r   r   r   r4   rd   r3   r   r1   r`   r   r   <module>r      s      # $ #DGGEM"DGGEM"
$''%-
 		Y< Y<xJs JXY8SWW Y8r   