Public feed #721695

gyrus.py

public python v1 · immutable
Raw Edit
·published 2007-10-01 14:09 UTC
rendered paste body
#!/usr/bin/env pythonimport osimport pygtkpygtk.require('2.0')import gtkimport gtk.gladeimport gettextimport gnomefrom constanst import *import sessiongettext.bindtextdomain(APPNAME,DIRLOCALE)gettext.textdomain(APPNAME)_ = gettext.gettextgtk.glade.bindtextdomain(APPNAME,DIRLOCALE)gtk.glade.textdomain(APPNAME)class Gyrus:	def __init__ (self):		home = os.getenv("HOME")		# create folder		self.folder = home + "/" + DEFAULT_FOLDER				# get preferences		self.model_session = session.get_model_treeview_sessions ()		session.load_preferences_from_file_xml(self)		# create man container		vbox = gtk.VBox()		# create main window		window = gtk.Window()		window.set_position(1)		window.set_default_size(450,300)		window.set_title (APPNAME)		window.connect ("delete_event",self.quit_program)		window.add (vbox)		# create a UIManager instance		uimanager = gtk.UIManager()		# add the accelerator group to the toplevel window		accelgroup = uimanager.get_accel_group()		window.add_accel_group (accelgroup)		# create an ActionGroup		actiongroup_window = gtk.ActionGroup ('Window Actions')		actiongroup_server = gtk.ActionGroup ('Server Actions')		actiongroup_mailbox = gtk.ActionGroup ('Mailbox Actions')		# change sensitive status		actiongroup_window.set_sensitive (True)		actiongroup_server.set_sensitive (False)		actiongroup_mailbox.set_sensitive (False)		# creat actions	        actiongroup_window.add_actions([			 ('FileMenu', None, _('_File')),			 ('OpenSession', gtk.STOCK_CONNECT, _('Go to server...'),'<control>O', _('Show the list of servers'), session.load_interface(self)),			 ('Quit', gtk.STOCK_QUIT, _('_Quit'), None, _('Quit the Program'), self.quit_program),			 ('EditMenu', None, _('_Edit')),			 ('AclMenu', None, _('_ACL')),			 ('ViewMenu', None, _('_View')),			 ('HelpMenu', None, _('_Help')),			 ('About', gtk.STOCK_ABOUT, None, None, None, self.tmp),			 ])		actiongroup_server.add_actions([			 ('AddMailbox', gtk.STOCK_ADD, _('Add mailbox'), 			 		None, _('Add a mailbox under the one selected'), self.tmp),			 ('EntryNew', gtk.STOCK_ADD, _('New entry'), 			 		'<control><shift>N', _('Create a new ACL entry in current mailbox'), self.tmp),			 ('Find', gtk.STOCK_FIND, _('Find mailbox'), 			 		None, _('Search for a mailbox in current server'), self.tmp),			 ('Refresh', gtk.STOCK_REFRESH, None, 			 		'<control>R', _('Refresh the mailbox list'), self.tmp),			 ('Report', gtk.STOCK_INDEX, _('Create report'), 			 		None, _('Create report of users with quota problems'), self.tmp),			])		actiongroup_mailbox.add_actions([			 ('EntryDelete', gtk.STOCK_REMOVE, _('Delete entry'), 			 		'<control><shift>D', _('Delete selected ACL entry'), self.tmp),			 ('EntryRename', gtk.STOCK_EDIT, _('Rename entry'), 			 		'<control><shift>R', _('Rename selected ACL entry'), self.tmp),			 ('RemoveMailbox', gtk.STOCK_REMOVE, _('Remove mailbox'), 			 		None, _('Remove current mailbox from the server'), self.tmp),			])		# add the actiongroup to the uimanager		uimanager.insert_action_group (actiongroup_window,0)		uimanager.insert_action_group (actiongroup_server,0)		uimanager.insert_action_group (actiongroup_mailbox,0)		# ad a UI description		uimanager.add_ui_from_string (UI)		# create a MenuBar		menubar = uimanager.get_widget ('/MainMenu')		vbox.pack_start (menubar, False)		# create a Toolbar		toolbar = uimanager.get_widget ('/MainToolbar')		vbox.pack_start (toolbar, False)		# create notebook		notebook = gtk.Notebook()			vbox.pack_start (notebook, False)		window.show_all()		return		def main(self):        	"Begin cicle main"		gtk.main()	def quit_program(self,data1=None,data2=None):		"Quit of program"		print "Quitting program"		gtk.main_quit()		def tmp(self,data=None):		print "temporal callback"if __name__ == "__main__":	gnome.init(APPNAME,VERSION)		gyrus = Gyrus()	gyrus.main()