<s> import logging <EOL> import gobject <EOL> import xpcom <EOL> from xpcom . components import interfaces <EOL> class HistoryListener ( gobject . GObject ) : <EOL> _com_interfaces_ = interfaces . nsISHistoryListener <EOL> __gsignals__ = { <EOL> '<STR_LIT>' : ( gobject . SIGNAL_RUN_FIRST , <EOL> gobject . TYPE_NONE , <EOL> ( [ int ] ) ) , <EOL> '<STR_LIT>' : ( gobject . SIGNAL_RUN_FIRST , gobject . TYPE_NONE , <EOL> ( [ str ] ) ) <EOL> } <EOL> def __init__ ( self ) : <EOL> gobject . GObject . __init__ ( self ) <EOL> self . _wrapped_self = xpcom . server . WrapObject ( self , interfaces . nsISHistoryListener ) <EOL> weak_ref = xpcom . client . WeakReference ( self . _wrapped_self ) <EOL> def setup ( self , web_navigation ) : <EOL> self . _session_history = web_navigation . sessionHistory <EOL> self . _session_history . addSHistoryListener ( self . _wrapped_self ) <EOL> def OnHistoryGoBack ( self , back_uri ) : <EOL> logging . debug ( "<STR_LIT>" % back_uri . spec ) <EOL> self . emit ( '<STR_LIT>' , back_uri . spec ) <EOL> self . emit ( '<STR_LIT>' , self . _session_history . index - <NUM_LIT:1> ) <EOL> return True <EOL> def OnHistoryGoForward ( self , forward_uri ) : <EOL> logging . debug ( "<STR_LIT>" % forward_uri . spec ) <EOL> self . emit ( '<STR_LIT>' , forward_uri . spec ) <EOL> self . emit ( '<STR_LIT>' , self . _session_history . index + <NUM_LIT:1> ) <EOL> return True <EOL> def OnHistoryGotoIndex ( self , index , goto_uri ) : <EOL> logging . debug ( "<STR_LIT>" % ( index , goto_uri . spec ) ) <EOL> self . emit ( '<STR_LIT>' , goto_uri . spec ) <EOL> self . emit ( '<STR_LIT>' , index ) <EOL> return True <EOL> def OnHistoryNewEntry ( self , new_uri ) : <EOL> logging . debug ( "<STR_LIT>" % new_uri . spec ) <EOL> self . emit ( '<STR_LIT>' , new_uri . spec ) <EOL> self . emit ( '<STR_LIT>' , self . _session_history . index + <NUM_LIT:1> ) <EOL> def OnHistoryPurge ( self , num_entries ) : <EOL> logging . debug ( "<STR_LIT>" % num_entries ) <EOL> return True <EOL> def OnHistoryReload ( self , reload_uri , reload_flags ) : <EOL> self . emit ( '<STR_LIT>' , reload_uri . spec ) <EOL> logging . debug ( "<STR_LIT>" % reload_uri . spec ) <EOL> return True </s>
