;ς Krσ>c@sxdZdkZdkZdkZdklZdkZdklZdklZdk l Z defd„ƒYZ dS(s%This file contains the MainGUI class.N(sjoin(sLibGladeApplication(sGtkAttributesFacade(s cipherGUIListsMainGUIcBsžtZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„ZRS(sŸThis is the main window for the application. HACK: To do cut, copy, and paste I'm using the emit method. I suspect that the PyGTK API will eventually update the TextView class to include the methods *_clipboard just as the C API does. The following private variables are used: _last_text_view - This is the last TextView that was focused. _cipherGUI - This is an instance of a class from the ciphergui package associated with the currently selected cipher. _cipherGUIInstances - Whenever a new ciphergui instance is created, it is cached here so that its key is not lost when the user switches between ciphers. cCs?ti|ttidƒƒ|i|_h|_|i ƒdS(s Init the GUI.s gcipher.gladeN( sLibGladeApplications__init__sselfsjoinsConstsGLADEDIRsdecrypted_text_views_last_text_views_cipherGUIInstancess_initCipherMenu(sself((s ./MainGUI.pys__init__#s    c Cs²t}t}|iƒx„|D]|}|\}}}}t i ||ƒ}| o |}n|i d|i|ƒ|iƒ|ii|ƒt|||ƒqW|iidƒdS(sτInitialize the Cipher menu. This menu must be dynamic since it must contain the list of ciphers, so it can't be created just using Glade. Place the menu items before the separator and the "Key..." menu item. sactivateN(sNonesgroups cipherGUIListslsreversesis classNamesguiNames labelNames descriptionsgtks RadioMenuItemsmenuItemsconnect_objectsselfson_cipher_activatesshows cipher_menusprependssetattrsGiesemit( sselfsgroups descriptionsguiNamesisls classNames labelNamesmenuItem((s ./MainGUI.pys_initCipherMenu+s    cCs#|i|i|i|iiƒdS(s;Decrypt encrypted_text_view and update decrypted_text_view.N(sselfs _transfersencrypted_text_viewsdecrypted_text_views _cipherGUIsdecrypt(sselfsw((s ./MainGUI.pyson_decrypt_activateBscCs#|i|i|i|iiƒdS(s;Encrypt decrypted_text_view and update encrypted_text_view.N(sselfs _transfersdecrypted_text_viewsencrypted_text_views _cipherGUIsencrypt(sselfsw((s ./MainGUI.pyson_encrypt_activateGscCs|iidƒdS(s&Do self._last_text_view.cut_clipboard.s cut-clipboardN(sselfs_last_text_viewsemit(sselfsw((s ./MainGUI.pyson_cut_activateLscCs|iidƒdS(s'Do self._last_text_view.copy_clipboard.scopy-clipboardN(sselfs_last_text_viewsemit(sselfsw((s ./MainGUI.pyson_copy_activatePscCs|iidƒdS(s(Do self._last_text_view.paste_clipboard.spaste-clipboardN(sselfs_last_text_viewsemit(sselfsw((s ./MainGUI.pyson_paste_activateTscCs4|ii}t|iƒo|i|iŒndS(sADelete the selected text in self._last_text_view, if appropriate.N(sselfs_last_text_viewsbuffersbufslensselection_boundssdelete(sselfswsbuf((s ./MainGUI.pyson_clear_activateXs cCs |i|i|id„ƒdS(s.Copy the encrypted text to the decrypted text.cCs|S(N(ss(ss((s ./MainGUI.pysasN(sselfs _transfersencrypted_text_viewsdecrypted_text_view(sselfsw((s ./MainGUI.pyson_copy_up_activate^scCs |i|i|id„ƒdS(s.Copy the decrypted text to the encrypted text.cCs|S(N(ss(ss((s ./MainGUI.pysfsN(sselfs _transfersdecrypted_text_viewsencrypted_text_view(sselfsw((s ./MainGUI.pyson_copy_down_activatecscCs’|ii|ƒo|i||_nFtd|tƒtƒ|ƒ}t ||ƒ}|ƒ|_|i|