³ò üš³Ec@s0dZddklZdefd„ƒYZdS(s  This module documents a class that implements the indentation popup menu item for the text editor. @author: Lateef Alabi-Oki @organization: The Scribes Project @copyright: Copyright © 2005 Lateef Alabi-Oki @license: GNU GPLv2 or Later @contact: mystilleef@gmail.com iÿÿÿÿ(t ImageMenuItemtIndentPopupMenuItemcBsMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(sK This class creates the indentation popup menu item for the text editor. cCs±ddkl}ti||ƒ|i|ƒ|iƒ|iƒ|iid|i ƒ|_ |i id|i ƒ|_ |i id|i ƒ|_|iid|iƒ|_dS(só Initialize the popup menu item. @param self: Reference to the IndentPopupMenuItem instance. @type self: A IndentPopupMenuItem object. @param scribesview: The text editor's text view. @type scribesview: A ScribesTextView object. iÿÿÿÿ(tmsg0008tactivates map-eventsfocus-in-eventN(ti18nRRt__init__t%_IndentPopupMenuItem__init_attributest#_IndentPopupMenuItem__create_wigetst$_IndentPopupMenuItem__set_propertiestindent_menuitemtconnectt'_IndentPopupMenuItem__popup_activate_cbt!_IndentPopupMenuItem__signal_id_1tunindent_menuitemt!_IndentPopupMenuItem__signal_id_2t(_IndentPopupMenuItem__popup_map_event_cbt!_IndentPopupMenuItem__signal_id_3t scribesviewt*_IndentPopupMenuItem__popup_focus_event_cbt!_IndentPopupMenuItem__signal_id_4(tselfteditorR((splugins/Indent/PopupMenuItem.pyR&s    cCsa|i|_||_d|_d|_d|_d|_d|_d|_ d|_ d|_ dS(s Initialize the popup menu item's attributes. @param self: Reference to the IndentPopupMenuItem instance. @type self: A IndentPopupMenuItem object. @param scribesview: The text editor's text view. @type scribesview: A ScribesTextView object. N( ttextviewRRtNonetmenutimageR R R RRR(RR((splugins/Indent/PopupMenuItem.pyt__init_attributes:s          c Cs«ddkl}l}l}|ƒ|_|iid|ƒ|ƒ|_ddkl}ddk l }l }ddkl }l }|||ƒ|_|||ƒ|_dS(s˜ Create the popup menu item's interface. @param self: Reference to the IndentPopupMenuItem instance. @type self: A IndentPopupMenuItem object. iÿÿÿÿ(tImagetSTOCK_JUSTIFY_CENTERtMenutstock(tcreate_menuitem(tmsg0009tmsg0010(tSTOCK_UNINDENTt STOCK_INDENTN(tgtkRRRRt set_propertyRt SCRIBES.utilsRRR R!R"R#R R ( RRRRRR R!R"R#((splugins/Indent/PopupMenuItem.pyt__create_wigetsPs  cCsk|i|iƒ|i|iƒ|ii|iƒ|ii|iƒ|iio|i dt ƒndS(s Set the menu item's properties. @param self: Reference to the IndentPopupMenuItem instance. @type self: A IndentPopupMenuItem object. t sensitiveN( t set_imageRt set_submenuRtappendR R Rt is_readonlyR%tFalse(R((splugins/Indent/PopupMenuItem.pyt__set_propertiesbs cCsR||ijo|iiidƒn||ijo|iiidƒntS(sa Handles callback when the "activate" signal is emitted. @param self: Reference to the IndentPopupMenuItem instance. @type self: A IndentPopupMenuItem object. @param menuitem: A menuitem for the IndentPopupMenuItem. @type menuitem: A gtk.MenuItem object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. t indent_linet unindent_line(R RttriggermanagerttriggerR tTrue(Rtmenuitem((splugins/Indent/PopupMenuItem.pyt__popup_activate_cbqs c Cs‚|idtƒddkl}||iiƒ}|iii|ƒ}y|iiiƒ\}}WnNtj oB|i ƒdjo|idt ƒn|idtƒt SnX|i ƒ}|i ƒ} || jo?|i ƒdjo|idt ƒn|idtƒt Snt} xMt || dƒD]8} |iii| ƒ}|i ƒd jo t } q2q2W|id| ƒt S( s Handles callback when the "map-event" signal is emitted. This function determines whether or not the unindent menuitem should be enabled. @param self: Reference to the IndentPopupMenuItem instance. @type self: A IndentPopupMenuItem object. @param menuitem: The the unindent menu item. @type menuitem: A gtk.MenuItem object. @param event: An event that occurs when the unindent menu item is displayed. @type event: A gtk.Event object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. R(iÿÿÿÿ(tget_cursor_linet s i(R7s (R7s (R7s ( R%R-tSCRIBES.cursorR6Rt textbuffertget_iter_at_linetget_selection_boundst ValueErrortget_charR3tget_linetrange( RR4teventR6t cursor_linetbegin_positiontbegin_selectiont end_selectiontfirst_selected_linetlast_selected_linetindentation_is_possibletline((splugins/Indent/PopupMenuItem.pyt__popup_map_event_cb„s4    cCs›|io-|ii|iƒo|ii|iƒn|io-|ii|iƒo|ii|iƒn|io-|ii|iƒo|ii|iƒn|io-|ii|iƒo|ii|iƒn|io|ii ƒn|io|ii ƒn|i o|i i ƒn|i o|i i ƒn|i ƒ|`|`|` |` |`|`|`|`|`|` ~d}tS(s% Handles callback when the "focus-in-event" event is emitted. This function destroys this object when the textview's popup menu is hidden. @param self: Reference to the IndentPopupMenuItem instance. @type self: An IndentPopupMenuItem object. @param event: An event emitted when the editor's textview gains focus. @type event: A gtk.Event object. @param textview: Reference to the editor's textview. @type textview: A ScribesTextView object. @return: True to propagate signals to parent widgets. @type: A Boolean Object. N(R R thandler_is_connectedt disconnectRR RRRtdestroyRRRRR-(RR@R((splugins/Indent/PopupMenuItem.pyt__popup_focus_event_cb³s.          ( t__name__t __module__t__doc__RRRRR RR(((splugins/Indent/PopupMenuItem.pyR!s      /N(RPR$RR(((splugins/Indent/PopupMenuItem.pyss