
    fV                        d dl mZmZmZ d dlZ ej
                  d      Zd dlZd dlZd dl	Z	d dl
Zd dlmZ  e        d dlmZmZmZ 	 d dlZd dlZd dlZd dlmZmZ dZd d	lmZmZ d d
lmZ d dlm Z  d dl!m"Z" d dl#m$Z$ d dl%m&Z& d dl'm(Z( d dl)m*Z* d dl+m,Z, d dl-m.Z.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl4m5Z5  e5       Z6d dl7m8Z8 dZ9dZ: G d de;      Z<er G d de      Z=d Z>y# e$ r dZY w xY w)    )divisionprint_functionunicode_literalsN
OnboardGtk)require_gi_versions)GLibGdkGtk)ServiceBasedbus_propertyTF)	KbdWindowKbdPlugWindow)Keyboard)KeyboardWidget)	Indicator)LayoutLoaderSVG)ColorScheme)IconPalette)LayoutFileError)unicode_str)CallOnceTimer)show_confirmation_dialog)Config)	KeyCommononboard
   c                   "   e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd,dZd,dZd,dZd,dZd Zd Zd,dZd Zd Zd-dZ d Z!d  Z"d! Z#d" Z$d.d#Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,e-d+        Z.y)/r   z6
    Main controller class for Onboard using GTK+
    Nc                    t        j                  t        t                     t	        j
                  t        d   j                         t        dd  z          d }d}t        sd}n?t        j                  j                  j                  d       	 t        j                         }|st        j!                  |dz   d	z          | j#                  |      st%        j&                  d       |rh|j)                  t*        j,                        }t.        j0                  rbt.        j2                  t.        j4                  k(  rAt.        j6                  rt.        j6                  j8                  s|st%        j&                  d       t.        j0                  s|rt.        j:                  j<                  sx|j?                  t*        j,                  t*        j@                        }|jC                  t*        jD                  
       t        jG                  d       t%        j&                  d       t        jH                  jK                  t*        j,                  |      | _&        | jO                          t        jG                  d       tQ        jR                          	 t$        jT                  jW                          	 t$        jX                  jW                          y # t        j                  j                  $ r d}d }Y Jw xY w#  Y LxY w#  Y y xY w)Nr       zD-Bus bindings unavailableT)set_as_defaultzD-Bus session bus unavailablez  zqOnboard will start with reduced functionality. Single-instance check, D-Bus service and hover click are disabled.dbus_interfacez"Exiting: Not the primary instance.zEntering mainloop of onboard)-r   set_prgnamestrappr	   set_program_classupperhas_dbusdbusmainloopglibDBusGMainLoop
SessionBus
exceptionsDBusException_loggerwarning_can_show_in_current_desktopsysexitname_has_ownerServiceOnboardKeyboardNAMEconfigxid_modelaunched_byLAUNCHER_GSS
gnome_a11yscreen_keyboard_enabledoptionsallow_multiple_instances
get_objectPATHShowIFACEinfoserviceBusName	_bus_nameinitr
   mainstdoutclosestderr)selfbuserr_msghas_remote_instanceremotes        4/usr/lib/python3/dist-packages/Onboard/OnboardGtk.py__init__zOnboardGtk.__init__N   s(   
 	S"c!fllns12w67 2G MM,,D,Aoo'
 OOGdN88 9 005HHQK ""#9#>#>?   !!V%8%88%%%%==& ??&~~>> ^^,B,G,G,B,G,GIFKK/E/K/KKLLL!EFHHQK LL(()?)D)DcJ  			34
	JJ	JJ ??00 9x		s*   K	 K1 *K8 	!K.-K.1K58K<c                 >   d | _         d| _        d | _        | j                          g | _        d | _        d | _        d | _        t               | _	        t        j                          t        j                  }|rt        || j                         y | j                          y Nr   )keyboard_state_last_mod_maskvk_timerreset_vk_connections_windowstatus_iconservice_keyboardr   _reload_layout_timerr:   rJ   startup_delay_init_delayed)rO   delays     rT   rJ   zOnboardGtk.init   s    " $$)G! 	 $$%++,     c                     t        j                          _         j                  j                  t        j
                   j                          j                  j                  t        j                   j                         t        j                  j                  t        j                  j                  t        j                  d             t!                _        t%         j"                         _        t        j(                  rst+         j&                         _        t        j.                  j1                  d j,                  j3                         z         t        j.                  j5                          nt7         j"                        }|j9                   j&                         |j;                  d j<                          j?                  |jA                         d fd       tC         j&                  |       _         j?                   j,                  d fd         j,                  _"         j,                  t        _#        tH        jK                  d        jM                          t        j(                  s҉ j,                  jO                         jQ                         }t        jR                  }|jT                  rA|jT                  jW                  d      }tY        |d	         |_-        tY        |d
         |_.        |j^                  |j^                  |_/        |j`                  |j`                  |_0         j,                  jc                  |      }|je                         s| j,                  jO                         k7  rtH        jg                  dji                   j,                  jO                         |              j,                  jk                         } j,                  jm                  ||        j,                  jo                          n=tH        jg                  dji                   j,                  jO                         |             t        j(                  stp        rts                _:         j&                  jw                           jy                          tz        j|                  j                          _@         j?                   j                  d j                          j?                   j                  d j                         t{        j                  t                t        d      j                   fd} fd} fd} fd}	 fd}
t        j"                  j                  |       t        j"                  j                   fd       t        j"                  j                   fd       t        j"                  j                  |       t        j                  j                   fd       t        j                  j                   j                         t        j                  j                   j                         t        j                  j                  |       t        j                  j                  |	       t        j                  j                  |	       t        j                  j                  |       t        j                  j                  |	       t        j                  j                  |
       t        j                  j                   j                         t        j                  j                   fd       t        j                  |       t        j                   j                         t        j                  |       t        j                  |       t        j                  j                  |       t        j                  j                  |       t        j                  j                  |       t        j                  j                  |       t        j                  |       t        j                  j                   fd       t        j                  j                   fd       t        j                  j                   fd       t        j                  j                   fd       t        j                  j                  |       t        j                  j                   fd       t        j                  j                  |       t        j                  j                   fd       t        j                  j                   fd       t        j                  j                   fd        t        j                  j                   fd!       t        j                  j                   fd"       t        j                  j                  |       t        j                  j                   j"                  j                         t        j                  j                   j                         t        j"                  j                  |       t        j                  j                  |       t        j                  rt        j                  j                  |       t                _{         j                  j                   j"                          j?                   j                  jA                         d fd#       t        j                   j                         t        j                  j                   j                          j                  t        j                         d$t        j                  v r~tH        jK                  d%       d&t        j                  _        tH        jK                  d'       d(t        _        t        j                  j                          t        j                           j                          t        j(                  st        j                  rt        j                  j                  s4t        j                  j                  st        j                  d&       n8t        j                         st        d)      }tH        j                  d*ji                  |             t        | j,                  t        j!                               }|d&k(  rt        j                  d&       nd(t        _        nt        j                  j                  st        d+      }tH        j                  d*ji                  |             t        | j,                  t        j!                               }|d&k(  rt        j                  d&       nd(t        _        t        j#                         st        j%                         r7t        j'                   j,                        sd(t        j                  _        y y y ),Nscriptsz%d
	activatedzquit-onboardc                 $    j                         S Ndo_quit_onboardxrO   s    rT   <lambda>z*OnboardGtk._init_delayed.<locals>.<lambda>       $"6"6"8 rd   c                 $    j                         S ri   rj   rl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>   s    d&:&:&< rd   zLoading initial layoutrm   r   r    zlimiting window size: {} to {}z"not limiting window size: {} to {}zkeys-changedzstate-changed2   c                 (     j                         S ri   )reload_layout_and_presentrm   oncerO   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>!  s    T-K-K(L rd   c                 (     j                         S ri   )
_update_uirt   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>"  s    T__(= rd   c                 (     j                         S ri   )_update_ui_no_resizert   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>#  s    T-F-F(G rd   c                 <     j                   j                        S ri   )keyboard_widgetupdate_transparencyrt   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>%  s    d4//CCD rd   c                 <     j                   j                        S ri   )r{   update_inactive_transparencyrt   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>'  s    d4//LLM rd   c                 8    j                   j                         S ri   )keyboardupdate_input_event_sourcerl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>-  s    $(MM$K$K$M rd   c                 8    j                   j                         S ri   )r   update_touch_input_moderl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>/  s    $(MM$I$I$K rd   c                 8    j                   j                         S ri   )r]   update_sticky_staterl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>5  s    dll668 rd   c                 8    j                   j                         S ri   )r{   "update_docking_aspect_change_rangerl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>B  s    d**//1 rd   c                 8    j                   j                         S ri   )r   update_auto_showrl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>W      dmm446 rd   c                 8    j                   j                         S ri   )r   update_auto_hiderl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>Y  r   rd   c                 8    j                   j                         S ri   )r   update_tablet_mode_detectionrl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>[  s    dmm@@B rd   c                 8    j                   j                         S ri   )r    update_keyboard_device_detectionrl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>]  s    dmmDDF rd   c                 :    j                   j                  |       S ri   r   on_word_suggestions_enabledrl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>a      !%!J!J1!M rd   c                 8    j                   j                         S ri   )r   on_active_lang_id_changedrl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>e  s    !%!H!H!J rd   c                 8    j                   j                         S ri   r   on_spell_checker_changedrl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>g      !%!G!G!I rd   c                 :    j                   j                  |       S ri   r   rl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>i  r   rd   c                 8    j                   j                         S ri   r   rl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>k  r   rd   c                 8    j                   j                         S ri   )r   on_punctuator_changedrl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>m  s    !%!D!D!F rd   c                 $    j                         S ri   rj   rl   s    rT   rn   z*OnboardGtk._init_delayed.<locals>.<lambda>  ro   rd   RUNNING_UNDER_GDMz.RUNNING_UNDER_GDM set, turning on icon paletteTz,RUNNING_UNDER_GDM set, turning off indicatorFa  Onboard is configured to appear with the dialog to unlock the screen; for example to dismiss the password-protected screensaver.

However the system is not configured anymore to use Onboard to unlock the screen. A possible reason can be that another application configured the system to use something else.

Would you like to reconfigure the system to show Onboard when unlocking the screen?zshowing dialog: '{}'zOnboard is configured to appear with the dialog to unlock the screen; for example to dismiss the password-protected screensaver.

However this function is disabled in the system.

Would you like to activate it?)oskUtil	_osk_utilset_unix_signal_handlersignalSIGTERM
on_sigtermSIGINT	on_sigintr5   pathappendosjoinr:   install_dirr   r   r   r{   r;   r   r]   rL   writeget_idflushr   set_layout_viewconnect_on_icon_palette_acticated
do_connectget_menur   applicationmain_windowr2   rF   reload_layoutget_rectcopyr@   sizesplitintwhrm   y
limit_sizeis_emptydebugformatget_screen_orientationwrite_window_rectrestore_window_rectr*   r8   r_   set_startup_visibility_keep_windows_on_topr	   Keymapget_defaultkeymapcb_keys_changedcb_state_changedevent_handler_setcb_any_eventr   enqueuekey_synth_notify_addinput_event_source_notify_addtouch_input_notify_add show_secondary_labels_notify_addwindowwindow_state_sticky_notify_addwindow_decoration_notify_add_on_window_options_changedforce_to_top_notify_addkeep_aspect_ratio_notify_addtransparency_notify_add"background_transparency_notify_add!transparent_background_notify_add'enable_inactive_transparency_notify_add inactive_transparency_notify_adddocking_notify_add_update_docking&docking_aspect_change_range_notify_addlayout_filename_notify_addtheme_notify_addon_theme_changedkey_label_font_notify_addkey_label_overrides_notify_addtheme_settings color_scheme_filename_notify_addtheme_attributes_notify_addsnippets_notify_add	auto_showenabled_notify_addhide_on_key_press_notify_add tablet_mode_detection_notify_add,keyboard_device_detection_enabled_notify_addword_suggestionsshow_context_line_notify_addauto_learn_notify_addtyping_assistanceactive_language_notify_addspell_check_backend_notify_addauto_capitalization_notify_add'spelling_suggestions_enabled_notify_add*delayed_word_separators_enabled_notify_addwordlist_buttons_notify_addscanner_on_scanner_enabledwindow_handles_notify_add_on_window_handles_changedshow_click_buttons_notify_addlockdownlockdown_notify_addmousetweaksstate_notify_addr   r^   set_keyboardshow_status_icon_notify_addshow_hide_status_iconicpin_use_notify_addcb_icp_in_use_toggledshow_status_iconenvironin_useapplyshow_hide_taskbaronboard_xembed_enabledgssembedded_keyboard_enabledembedded_keyboard_commandenable_gss_embedding#is_onboard_in_xembed_command_string_r3   r   is_force_to_topis_auto_show_enabledare_word_suggestions_enabledcheck_gnome_accessibilityenabled)rO   r	  rectr@   r   orientationr   	update_uiupdate_ui_no_resizer|   r~   questionreplyru   s   `            @rT   rb   zOnboardGtk._init_delayed   s	    ..v~~tO..v}}dnnMV%7%7CD !
  .dmm< ?? ))=)=>DL JJVdll&9&9&;;<JJdmm,C 4 45KKT%D%DEOOCLLNN8: %T%9%93?DLOODLL.<> $( !\\ 	-. <<((*//1DnnG||||))#.T!WT!Wyy$ yy$  <<**40D==?t||,,..>#VDLL$9$9$;TBD"llAAC..{DA002B#VDLL$9$9$;TBD
 $:4$@D! 	335 	!!# jj,,.^T5I5IJ_d6K6KLlD1 |##L=	GD 	 N 	% 	,,];55 7N 	O.. 0L 	M88C 	448	:22++	---d.M.MN229=--.AB889LM77	B==>QR667ST(()=)=><<2	3
 	))-8 	 5 56((7--m<>>}M77F<<]K99)D 	""=1 	++6	8556	899B	DEEF	H 	<<YG22 4N 	O55!4	6  ;; =K 	L  ?? AJ 	K  ?? AN 	OGG IJ 	KJJ LG 	H;;!4	6 	))$--*K*KL//0O0OP 	55i@++I6//0CD %;%%dmm4((113^8	: 	**4+E+EF

$$T%?%?@""6#:#:; "**,LLIJ $FJJLLGH&+F#
 JJLLN 	  (( ::77::77++D1
 ??A B C  6 = =h GH015171G1G1IK D=//549F1zz;;  "B  CH
 OO$:$A$A($KL4X59\\5;5K5K5MOE }33D98=5 '')//100>',F$ ? 2rd   c                 N    t         j                  d       | j                          y)z'
        Exit onboard on kill.
        zSIGTERM receivedNr2   r   rk   rO   s    rT   r   zOnboardGtk.on_sigterm  s     	()rd   c                 N    t         j                  d       | j                          y)z/
        Exit onboard on Ctrl+C press.
        zSIGINT receivedNr$  r%  s    rT   r   zOnboardGtk.on_sigint  s     	'(rd   c                 b    |j                  ||      }| j                  j                  ||f       y ri   )r   r\   r   )rO   instancer   handler
handler_ids        rT   r   zOnboardGtk.do_connect  s-    %%fg6
  (J!78rd   c                 R    | j                   r| j                   j                          yy)a  
        This method shows or hides the taskbard depending on whether there
        is an alternative way to unminimize the Onboard window.
        This method should be called every time such an alternative way
        is activated or deactivated.
        N)r]   update_taskbar_hintr%  s    rT   r  zOnboardGtk.show_hide_taskbar  s      <<LL,,. rd   c                 8    | j                   j                          y ri   r   toggle_visiblerO   widgets     rT   r   z%OnboardGtk._on_icon_palette_acticated  s    $$&rd   c                 x    t         j                  d       | j                          t         j                  d       y)z
        This is the callback that gets executed when the user toggles
        the gsettings key named in_use of the icon_palette. It also
        handles the showing/hiding of the taskar.
        z Entered in on_icp_in_use_toggledzLeaving on_icp_in_use_toggledN)r2   r   show_hide_icp)rO   
icp_in_uses     rT   r  z OnboardGtk.cb_icp_in_use_toggled  s*     	8956rd   c                    | j                   j                  rt        j                         }|rO| j                   j	                         s$| j                   j                  j                          | j                          y | j                   j	                         s$| j                   j                  j                          | j                          y y ri   )r]   r	  r:   is_icon_palette_in_use
is_visibleshowr  hide)rO   r8  s     rT   r3  zOnboardGtk.show_hide_icp  s    <<002D||..0LL$$))+&&( ||..0LL$$))+&&( rd   c                     |r| j                   j                  d       n| j                   j                  d       | j                          | j                          y)z
        Callback called when gsettings detects that the gsettings key specifying
        whether the status icon should be shown or not is changed. It also
        handles the showing/hiding of the taskar.
        TFN)r^   set_visibler3  r  )rO   r  s     rT   r  z OnboardGtk.show_hide_status_icon  sG     ((.((/ rd   c                 8    | j                   j                          y)z
        Callback called when status icon clicked.
        Toggles whether Onboard window visibile or not.

        TODO would be nice if appeared to iconify to taskbar
        Nr.  r0  s     rT   cb_status_icon_clickedz!OnboardGtk.cb_status_icon_clicked  s     	$$&rd   c                 $    | j                          y)z keyboard group change Nreload_layout_delayedr%  s    rT   cb_group_changedzOnboardGtk.cb_group_changed$      ""$rd   c                 $    | j                          y)z keyboard map change Nr?  )rO   r   s     rT   r   zOnboardGtk.cb_keys_changed(  rB  rd   c                     |j                         }t        j                  dj                  |             | j                  |k(  r| j                          || _        y| j                  j                  |       || _        y)z  keyboard modifier state change z keyboard state changed to 0x{:x}N)get_modifier_stater2   r   r   rY   r@  r   set_modifiers)rO   r   mod_masks      rT   r   zOnboardGtk.cb_state_changed,  sk    ,,.8vh'	)(* &&( ' MM''1&rd   c                     | j                         r9| j                  d       t        j                  | j                         d| _        yy)zI
        Timer callback for polling until virtkey becomes valid.
        Tforce_updateNF)get_vkr   r   source_removerZ   r%  s    rT   cb_vk_timerzOnboardGtk.cb_vk_timer;  s=     ;;=D1t}}- DMrd   c                     | j                   r5| j                   j                          | j                   j                          y y ri   )r   invalidate_uicommit_ui_updatesr%  s    rT   rw   zOnboardGtk._update_uiF  s.    ==MM'')MM++- rd   c                     | j                   r5| j                   j                          | j                   j                          y y ri   )r   invalidate_ui_no_resizerP  r%  s    rT   ry   zOnboardGtk._update_ui_no_resizeK  s.    ==MM113MM++- rd   c                 X    | j                   j                          | j                          y ri   )r{   update_window_handlesrw   rO   values     rT   r   z%OnboardGtk._on_window_handles_changedP  s    224rd   c                 X    | j                          | j                  j                          y ri   )_update_window_optionsr   rP  rU  s     rT   r   z%OnboardGtk._on_window_options_changedT  s    ##%'')rd   c                     | j                   }|rQ|j                          |j                  r|j                  j                          | j                  j	                          y y ri   )r]   update_window_optionsr	  r   rO  )rO   rV  r   s      rT   rX  z!OnboardGtk._update_window_optionsX  sF    ((*zz

002MM'')	 rd   c                 b    | j                          t        j                  | j                         y ri   )rX  r   idle_add_update_docking_delayedrU  s     rT   r   zOnboardGtk._update_docking`  s"    ##% 	d223rd   c                 l    | j                   j                          | j                  j                          y ri   )r]   on_docking_notifyr   rO  r%  s    rT   r]  z"OnboardGtk._update_docking_delayedf  s"    &&(##%rd   c                     |dk(  r!t        j                  d| j                         y |dv r t        j                  | j                         y y )Nzgtk-theme-namer    )zgtk-xft-dpiz gtk-xft-antialiasgtk-xft-hintingzgtk-xft-hintstyle)r   timeout_add_secondson_gtk_theme_changedr\  on_gtk_font_dpi_changed)rO   names     rT   on_gdk_setting_changedz!OnboardGtk.on_gdk_setting_changedk  sG    ##$$Q(A(AB + + MM$667+rd   c                 ,    t         j                          y)zG
        Switch onboard themes in sync with gtk-theme changes.
        N)r:   
load_theme)rO   	gtk_themes     rT   rb  zOnboardGtk.on_gtk_theme_changedx  s     	rd   c                 X    | j                   j                          | j                          y)zv
        Refresh the key's pango layout objects so that they can adapt
        to the new system dpi setting.
        F)r{   refresh_pango_layoutsrw   r%  s    rT   rc  z"OnboardGtk.on_gtk_font_dpi_changed~  s#    
 	224rd   c                 L    t         j                          | j                          y ri   )r:   apply_themer   )rO   themes     rT   r   zOnboardGtk.on_theme_changed  s    rd   c                     t         j                  sg|r#| j                  | j                  j                  g}ng }t        j                  dj                  |             | j                  j                  |       y y )Nzkeep_windows_on_top {})	r:   r;   r]   r	  r2   r   r   r   keep_windows_on_top)rO   enablewindowss      rT   r   zOnboardGtk._keep_windows_on_top  sX    <<)9)9:MM299'BCNN..w7 rd   c                 &    | j                  d       y NFr   r%  s    rT   on_focusable_gui_openingz#OnboardGtk.on_focusable_gui_opening  s    !!%(rd   c                 &    | j                  d       y NTrt  r%  s    rT   on_focusable_gui_closedz"OnboardGtk.on_focusable_gui_closed  s    !!$'rd   c                 \    | j                  d       | j                  j                          y)z`
        Reload the layout and briefly show the window
        with active transparency
        TrI  N)r   r{   r|   r%  s    rT   rs   z$OnboardGtk.reload_layout_and_present  s'    
 	$/002rd   c                 P    | j                   j                  d| j                         y)a  
        Delay reloading the layout on keyboard map or group changes
        This is mainly for LP #1313176 when Caps-lock is set up as
        an accelerator to switch between keyboard "input sources" (layouts)
        in unity-control-center->Text Entry (aka region panel).
        Without waiting until after the shortcut turns off numlock,
        the next "input source" (layout) is skipped and a second one
        is selected.
        g      ?N)r`   startr   r%  s    rT   r@  z OnboardGtk.reload_layout_delayed  s      	!!''D,>,>?rd   c                    d}| j                         }|r1	 |j                          |j                         |j                         f}| j                  |k7  s|rD|| _	        t        j                  }t        j                  j                  }	 | j                  ||       |s3| j$                  s&t'        j(                  d| j*                        | _        yyy# t        j
                  $ r* | j                          d}t        j                  d       Y w xY w# t        $ rR}t        j                  dt!        |      z   dz          | j                  t        j#                         |       Y d}~d}~ww xY w)zp
        Checks if the X keyboard layout has changed and
        (re)loads Onboards layout accordingly.
        )NNTzCKeyboard layout changed, but retrieving keyboard information failedzLayout error: z!. Falling back to default layout.Nr    )rK  reloadget_layout_as_stringget_current_group_namer   errorr[   r2   r3   rX   r:   layout_filenamer   color_scheme_filenameload_layoutr   r   get_fallback_layout_filenamerZ   r   ra  rM  )rO   rJ  rX   vkr  r  exs          rT   r   zOnboardGtk.reload_layout  sA   
 &[[]?		"$"9"9";"$";";"="? .0L"0D$44O$*$9$9$O$O!8  2GH $-- 44Q8H8HIDM (r- 99 ?# !> ?? # 8.R@Cffg   !D!D!F!68 8	8s*   0C 	D :DD	E,AE''E,c                    t         j                  d|z          |rt         j                  d|z          | j                         }|rt        j                  |      nd }t               j	                  |||      }| j                  j                  |||       | j                  r<| j                  j                  r%| j                  j                  j                          y y y )NzLoading keyboard layout zLoading color scheme )r2   rF   rK  r   loadr   r   
set_layoutr]   r	  
queue_draw)rO   r  r  r  color_schemelayouts         rT   r  zOnboardGtk.load_layout  s    //AB!LL03HHI[[] 0 #''(=>59 	 "''O\J  r:<<DLL,,LL'') -<rd   c                 p   | j                   s&	 t        j                         | _         | j                   S | j                   S # t        j                  $ rc}t	        j                         }|| j
                  dz   kD  r(t        j                  dt        |      z          || _        Y d }~| j                   S d }~ww xY w)Ng?zvk: )	_vkr   Virtkeyr  time_vk_error_timer2   r3   r   )rO   ets      rT   rK  zOnboardGtk.get_vk  s    xx,;;= xxtxx 99 ,IIKt**R//OOF[^$;<*+D'xx,s   ? B5AB00B5c                      d | _         d| _        y rW   )r  r  r%  s    rT   r[   zOnboardGtk.reset_vk  s    rd   c                 8    | j                   j                          y ri   )r]   emit_quit_onboardr%  s    rT   r  zOnboardGtk.emit_quit_onboard  s    &&(rd   c                 n    t         j                  d       | j                          | j                          y )NzEntered do_quit_onboard)r2   r   final_cleanupcleanupr%  s    rT   rk   zOnboardGtk.do_quit_onboard  s$    /0rd   c                 l   | j                   j                          t        j                          | j                  D ]  \  }}|j                  |        | j                  re| j                  j                  r5| j                  j                  j                          d | j                  _        | j                  j                          | j                  j                          d | _	        | j                  j                          | j                  j                          d | _
        t        j                          y ri   )r`   stopr:   r  r\   
disconnectr   r   finalizer^   r]   destroyr
   	main_quit)rO   r(  r*  s      rT   r  zOnboardGtk.cleanup  s    !!&&( %)$5$5 	, Hj
+	, ==}}$$%%..0(,%MM!!#  "rd   c                 ,    t         j                          y ri   )r:   r  r%  s    rT   r  zOnboardGtk.final_cleanup  s    rd   c                 v   d}t         j                  j                  rt        j                  j                  dd      }t         j                  j                  j                  d      }|D ]'  }||k(  s	|dk(  r| s| j                  d      s#d}&d}) |s%t        j                  dj                  ||             |S )	a\  
        When GNOME's "Typing Assistent" is enabled in GNOME Shell, Onboard
        starts simultaneously with the Shell's built-in screen keyboard.
        With GNOME Shell 3.5.4-0ubuntu2 there is no known way to choose
        one over the other (LP: 879942).

        Adding NotShowIn=GNOME; to onboard-autostart.desktop prevents it
        from running not only in GNOME Shell, but also in the GMOME Fallback
        session, which is undesirable. Both share the same xdg-desktop name.

        -> Do it ourselves: optionally check for GNOME Shell and yield to the
        built-in keyboard.
        TXDG_CURRENT_DESKTOPr!   ,GNOMEzorg.gnome.ShellFz`Command line option not-show-in={} forbids running in current desktop environment '{}'; exiting.)r:   r@   not_show_inr   r  getr   r7   r2   rF   r   )rP   resultcurrentnamesrd  s        rT   r4   z'OnboardGtk._can_show_in_current_desktop  s      >>%%jjnn%:B?GNN..44S9E 	(7? w3#5#56G#H%*F"'	(  J$fUG46 rd   ri   )T)F)/__name__
__module____qualname____doc__r   rU   rJ   rb   r   r   r   r  r   r  r3  r  r=  rA  r   r   rM  rw   ry   r   r   rX  r   r]  re  rb  rc  r   r   ru  rx  rs   r@  r   r  rK  r[   r  rk   r  r  staticmethodr4    rd   rT   r   r   G   s     HVp!2S-j9
/'7)!'%%'	.
.
**4&
88)(3
@$JL*  )
2 ( (rd   c                      e Zd ZdZdZdZdZdZd Ze	j                  j                  e      d        Ze	j                  j                  e      d	        Ze	j                  j                  e      d
        Zej                   r#e	j                  j                  ed      d        Z eed      d        Z eed      d        Zej*                  d        Zy)r8   z/
        Onboard's main D-Bus service.
        zorg.onboard.Onboardz/org/onboard/Onboard/Keyboardzorg.onboard.Onboard.KeyboardzD-Busc                     t        j                  | t        j                         | j                  | j
                         |j                  | _        |j                  | _	        y ri   )
r   rU   r+   r/   r9   rC   r   	_keyboardr{   _keyboard_widget)rO   r'   s     rT   rU   zServiceOnboardKeyboard.__init__U  s>      t'8$))TYYO \\DN$'$7$7D!rd   r#   c                 :    | j                   j                  d       y rw  r  request_visibilityr%  s    rT   rD   zServiceOnboardKeyboard.ShowZ  s    NN--d3rd   c                 :    | j                   j                  d       y rs  r  r%  s    rT   HidezServiceOnboardKeyboard.Hide^  s    NN--e4rd   c                 8    | j                   j                          y ri   )r  request_visibility_toggler%  s    rT   ToggleVisiblez$ServiceOnboardKeyboard.ToggleVisibleb  s    NN446rd   za(sada{is}a{sb}))r$   out_signaturec                    g }| j                   j                         D ]  }| j                  j                  |      }|j	                         r/|j                         s@|j                  j                         D ci c]  \  }}|s	|| }}}|j                  |j                         t        |      ||j                         g        |S c c}}w ri   )r  	iter_keysr  get_key_screen_rectr   is_path_visiblelabelsitemsr   r   list	get_state)rO   r  keyrmlr  s          rT   GetKeyStatez"ServiceOnboardKeyboard.GetKeyStateh  s     >>335 9C--AA#FA::<C,?,?,A47JJ4D4D4F!LDAq!!a%!L!Lszz|'+Aw'-'*}}'8 9	9  "Ms   :
CCb)r$   	signaturec                 6    | j                   j                         S ri   )r  r7  r%  s    rT   VisiblezServiceOnboardKeyboard.Visiblew  s    >>,,..rd   c                 L    | j                   j                  | j                        S ri   )r  is_auto_show_lockedLOCK_REASONr%  s    rT   AutoShowPausedz%ServiceOnboardKeyboard.AutoShowPaused|  s    >>55d6F6FGGrd   c                     |r&| j                   j                  | j                         y | j                   j                  | j                         y ri   )r  auto_show_lock_and_hider  auto_show_unlockrU  s     rT   r  z%ServiceOnboardKeyboard.AutoShowPaused  s5    66t7G7GH//0@0@Ard   N)r  r  r  r  r9   rC   rE   r  rU   r+   rG   methodrD   r  r  r:   is_running_from_sourcer  r   r  r  setterr  rd   rT   r8   r8   J  s    	 %..	8
 
		E		2	4 
3	4 
		E		2	5 
3	5 
		E		2	7 
3	7 ((\\  /A ! C
C
 
es	;	/ 
<	/ 
es	;	H 
<	H 
			B 
	Brd   r8   c                 L   	 | j                   }	 |t        j                  j$                  k(  r|j'                          nB|t        j                  j(                  k(  r%|j+                  | j,                  j.                         t1        j2                  |        y # t        $ r d }Y w xY wri   )type
ValueErrorr	   	EventTypeVISIBILITY_NOTIFYstate	CONFIGURErm   r   widthheightWINDOW_STATEwindow_stateUNMAPr   r   get_xidprintNOTHINGrA  SETTINGre  settingrd  r
   main_do_event)eventr   r  as       rT   r   r     s    zz 	 s}}$$$  "
 
&&	&&&u}}'9'9:e7  s   B B#"B#)?
__future__r   r   r   logging	getLoggerr2   r5   r  r   os.pathr   Onboard.Versionr   gi.repositoryr   r	   r
   r+   dbus.servicedbus.mainloop.glibOnboard.DBusUtilsr   r   r*   ImportErrorOnboard.KbdWindowr   r   Onboard.Keyboardr   Onboard.KeyboardWidgetr   Onboard.Indicatorr   Onboard.LayoutLoaderSVGr   Onboard.Appearancer   Onboard.IconPaletter   Onboard.Exceptionsr   Onboard.utilsr   Onboard.Timerr   r   Onboard.WindowUtilsr   Onboard.oskr   Onboard.Configr   r:   Onboard.KeyCommonr   r'   DEFAULT_FONTSIZEobjectr   r8   r   r  rd   rT   <module>r     s   0 B A 
'

L
) 
    /   ( (<H = , 2 - 3 / / 3 / 3 <  "	 (  D ;B ;B|!y  Hs   	C C('C(