def after_init(self):
		"""Connect Forismatic class
			and map action to mouse keys"""
		self.forism=Forismatic(self.conf,path)
		self.button_actions[1]=self.show_quote
		self.button_actions[2]=self.show_quote_on_site
		self.timer()
class GnomeForismaticApplet(GnomeAppletSkeleton):
	def __init__(self, applet, iid):
		"""Create applet for Forismatic Notify"""
		self.applet=applet
		self.iid=iid
		self.conf = Preference.Config(applet,self.cb_TimePeriod,self.cb_Theme,self.cb_Lang)
		(self.TimePeriod, self.Theme,self.Language) =\
			self.conf.get_settings()
		self.theme_path = os.path.join(path,'Themes',self.Theme)
		self.time = self.TimePeriod*60
		if self.time==0:
			self.time = 300
		GnomeAppletSkeleton.__init__(self, applet, iid)
	
	def init_additional_widgets(self):
		"""Create additional widgets"""
		self.icon_path=\
		os.path.join(self.theme_path,'forismatic_icon_16.png')
		self.pixbuff = gtk.gdk.pixbuf_new_from_file(self.icon_path)
		self.image=gtk.Image()
		#print "thme path from init_add_widgets func: %s"%self.theme_path
		self.image.set_from_pixbuf(self.pixbuff)
		self.ev_box.add(self.image)
	
	def after_init(self):
		"""Connect Forismatic class
			and map action to mouse keys"""
		self.forism=Forismatic(self.conf,path)
		self.button_actions[1]=self.show_quote
		self.button_actions[2]=self.show_quote_on_site
		self.timer()
	
	def on_enter(self, widget,event):
		"""show info when enter cursor on applet icon"""
		try:
			self.delta_time=datetime.datetime.today()-self.start_timer
			self.left_time=self.time-self.delta_time.seconds
			
			self.delta_time_norm=\
			datetime.timedelta(seconds=self.delta_time.seconds)
			
			self.left_time_norm=\
			datetime.timedelta(seconds=self.left_time)
			self.info="Last quote was %s ago\n Next quote after %s" %\
			(self.delta_time_norm,self.left_time_norm)
			#print "on enter notif: %s"%self.info
		except :
			self.info = "Forismatic" 
		self.ev_box.set_tooltip_text(str(self.info)) 
	
	def next_quote(self):
		"""Show next quote"""
		#change icon to refresh-icon:
		self.refresh_path=\
		os.path.join(self.theme_path,'icon_refresh_15.png')
		self.pixbuff = gtk.gdk.pixbuf_new_from_file(self.refresh_path)
		self.image.set_from_pixbuf(self.pixbuff)
		self.applet.show_all()
		#get new quote
		self.forism.save_quote() #remember last quote for next redirect to site
		#return old quote:
		self.pixbuff = gtk.gdk.pixbuf_new_from_file(self.icon_path)
		self.image.set_from_pixbuf(self.pixbuff)
		self.applet.show_all()
		#show quote:
		self.quote = self.forism.get_quote()
		self.forism.show_notify(self.quote)
					
	def timer_handler(self):
		"""Timer handler"""
		self.next_quote()
		self.start_timer=datetime.datetime.today()
		return True
		
	def timer(self):
		"""Timer. Show newt quote after time period"""
		self.TimePeriod = self.conf.get_settings()[0]
		self.time=self.TimePeriod*60
		self.source_event=\
		gobject.timeout_add_seconds(self.time, self.timer_handler)
		#print self.source_event
		self.start_timer=datetime.datetime.today()
				
	def show_quote(self):
		"""Action: show quote not waiting timer handler"""
		gobject.source_remove(self.source_event)
		self.next_quote()
		#thread.start_new_thread(self.forism.save_qote,()) dont work. why????
		self.timer()

	def on_ppm_about(self, event, data=None):
		"""Callback for pop-up menu item 'About', show About dialog"""
		self.about_path=\
		os.path.join(self.theme_path,'forismatic_icon_100.png')
		self.about_pixbuf=gtk.gdk.pixbuf_new_from_file(self.about_path)
		msg_applet_name = u"Forismatic Notify"
		msg_applet_description = \
		u"""Forismatic applet for Python powered GNOME applet"""
		msg_applet_documentation=\
		[u"left mouse key   - show next quote",
		 u"middle mouse key - show last quote on the site",
		 u"right mouse key  - show menu"]
		gnome.ui.About(msg_applet_name, __version__, __license__,
					   msg_applet_description,
					   [__author__,],   # programming
						msg_applet_documentation,   # documentation
						None,   # translating
						self.about_pixbuf,
					   ).show()
	
	def init_ppmenu(self):
		"""Create popup menu for properties"""
		self.ppmenu_xml = """
		<popup name="button3">
			<menuitem name="ItemPreferences" 
				verb="Preferences" 
				label="_Preferences" 
				pixtype="stock" 
				pixname="gtk-preferences"/>
			<menuitem name="ItemShowQuote" 
				verb="ShowQuote" 
				label="_ShowQuote" 
				pixtype="stock" 
				pixname="gtk-web"/>
			<separator/>
			<menuitem name="About Item" 
				verb="About"
				label=" About"
				pixtype="stock" 
				stockid="gtk-about"/>
		</popup> """
		self.ppmenu_verbs = [("About", self.on_ppm_about),
							 ('Preferences', self.show_preferences),
							 ('ShowQuote', self.show_quote_on_site)
							]
	
	def show_preferences(self,*arguments):
		"""Show Preference windows"""	
		print path
		self.pref = Preference.Preference(self.applet, path)

	def show_quote_on_site(self, *arguments):
		"""Open last quote in browser"""
		self.QuoteLink = self.conf.get_Quote()[2]
		webbrowser.open(self.QuoteLink,2, False)
			
	def cb_TimePeriod(self,client, cnxn_id, entry, params):
		"""CallBack function, which runing after changed Time Period"""
		gobject.source_remove(self.source_event)
		self.timer()
		self.TimePeriod = self.conf.get_settings()[0]
		#TODO: add analise left time befo calc time for show next quote
	
	def cb_Theme(self,client, cnxn_id, entry, params):
		"CallBack fuction, run when changing Theme"
		self.Theme = self.conf.get_settings()[1]
		self.theme_path = os.path.join(path,'Themes',self.Theme)
		self.icon_path=\
		os.path.join(self.theme_path,'forismatic_icon_16.png')
		self.pixbuff = gtk.gdk.pixbuf_new_from_file(self.icon_path)
		self.image.set_from_pixbuf(self.pixbuff)
				
	def cb_Lang(self,client, cnxn_id, entry, params):
		"CallBack fuction, run when changing language"
		#change icon to refresh-icon
		self.refresh_path=\
		os.path.join(self.theme_path,'icon_refresh_15.png')
		self.pixbuff = gtk.gdk.pixbuf_new_from_file(self.refresh_path)
		self.image.set_from_pixbuf(self.pixbuff)
		self.forism.save_quote()# need disable waiting finish of function
		#TODO: return old quote
		self.pixbuff = gtk.gdk.pixbuf_new_from_file(self.icon_path)
		self.image.set_from_pixbuf(self.pixbuff)