782c0bc by Philip Van Hoof at 2006-07-28 1
import gtk
2
import gnome
56a8745 by Philip Van Hoof at 2006-07-27 3
import tinymail
a266b70 by Philip Van Hoof at 2006-07-29 4
import tinymail.ui
5
import tinymail.uigtk
78c0f21 by Philip Van Hoof at 2006-11-25 6
import tinymail.camel
48ce6bf by Philip Van Hoof at 2006-07-31 7
import gc
a266b70 by Philip Van Hoof at 2006-07-29 8
b19104b by Mark Doffman at 2007-09-25 9
from pyplatformfactory import PyPlatformFactory
10
00d1db8 by Philip Van Hoof at 2006-07-30 11
def on_refresh_folder (folder, cancelled, headerstree):
664c80a by Philip Van Hoof at 2006-09-05 12
	listm = tinymail.uigtk.GtkHeaderListModel ()
00d1db8 by Philip Van Hoof at 2006-07-30 13
	listm.set_folder (folder, False)
14
	headerstree.set_model (listm)
182b2af by Philip Van Hoof at 2006-07-31 15
	progressbar.hide ()
00d1db8 by Philip Van Hoof at 2006-07-30 16
48ce6bf by Philip Van Hoof at 2006-07-31 17
	# I know. But this does significantly speed
18
	# up the garbage collecting. Only use it for
19
	# targets that have few memory resources
20
21
	gc.collect()
22
23
6b8fbc5 by Philip Van Hoof at 2006-12-08 24
def on_status (folder, what, status, oftotal, headerstree) :
25
	progressbar.set_fraction (status / oftotal)
00d1db8 by Philip Van Hoof at 2006-07-30 26
27
def on_headerstree_selected (treeselection, msgview) :
9d04be9 by Philip Van Hoof at 2006-07-30 28
	model, iter = treeselection.get_selected ()
858e2b7 by Philip Van Hoof at 2006-07-31 29
	if iter:
664c80a by Philip Van Hoof at 2006-09-05 30
		header = model.get_value (iter, tinymail.uigtk.GTK_HEADER_LIST_MODEL_INSTANCE_COLUMN)
858e2b7 by Philip Van Hoof at 2006-07-31 31
		if header:
32
			folder = header.get_folder ()
3159d49 by Philip Van Hoof at 2006-11-09 33
			msg = folder.get_msg (header)
858e2b7 by Philip Van Hoof at 2006-07-31 34
			msgview.set_msg (msg)
9d04be9 by Philip Van Hoof at 2006-07-30 35
83b1768 by Philip Van Hoof at 2006-07-29 36
def on_folderstree_selected (treeselection, headerstree) :
37
	model, iter = treeselection.get_selected ()
aac7c9e by Philip Van Hoof at 2007-03-14 38
	folder = model.get_value(iter, tinymail.uigtk.GTK_FOLDER_STORE_TREE_MODEL_INSTANCE_COLUMN)
83b1768 by Philip Van Hoof at 2006-07-29 39
	if folder:
182b2af by Philip Van Hoof at 2006-07-31 40
		progressbar.show ()
00d1db8 by Philip Van Hoof at 2006-07-30 41
		folder.refresh_async (on_refresh_folder, on_status, headerstree)
56a8745 by Philip Van Hoof at 2006-07-27 42
782c0bc by Philip Van Hoof at 2006-07-28 43
props = { gnome.PARAM_APP_DATADIR : "/usr/share" }
44
pr = gnome.program_init ("E-Mail", "1.0", properties=props)
6e6280b by Sergio Villar Senin at 2009-10-22 45
builder = gtk.Builder()
46
builder.add_from_file("tinymail-python-test.ui")
47
widget = builder.get_object("window")
48
progressbar = builder.get_object ("progressbar")
182b2af by Philip Van Hoof at 2006-07-31 49
progressbar.hide ()
6e6280b by Sergio Villar Senin at 2009-10-22 50
folderstree = builder.get_object ("folderstree")
51
headerstree = builder.get_object ("headerstree")
52
vpaned = builder.get_object ("vpaned")
83b1768 by Philip Van Hoof at 2006-07-29 53
renderer = gtk.CellRendererText ();
54
column = gtk.TreeViewColumn ("Folder", renderer, text=0)
182b2af by Philip Van Hoof at 2006-07-31 55
column.set_fixed_width (100)
56
column.set_sizing (gtk.TREE_VIEW_COLUMN_FIXED)
83b1768 by Philip Van Hoof at 2006-07-29 57
folderstree.append_column (column)
58
renderer = gtk.CellRendererText ();
59
column = gtk.TreeViewColumn ("From", renderer, text=0)
00d1db8 by Philip Van Hoof at 2006-07-30 60
column.set_fixed_width (100)
182b2af by Philip Van Hoof at 2006-07-31 61
column.set_sizing (gtk.TREE_VIEW_COLUMN_FIXED)
83b1768 by Philip Van Hoof at 2006-07-29 62
headerstree.append_column (column)
63
renderer = gtk.CellRendererText ();
64
column = gtk.TreeViewColumn ("Subject", renderer, text=2)
182b2af by Philip Van Hoof at 2006-07-31 65
column.set_fixed_width (200)
66
column.set_sizing (gtk.TREE_VIEW_COLUMN_FIXED)
67
headerstree.append_column (column)
68
renderer = gtk.CellRendererText ();
69
column = gtk.TreeViewColumn ("Received", renderer, text=7)
00d1db8 by Philip Van Hoof at 2006-07-30 70
column.set_fixed_width (100)
182b2af by Philip Van Hoof at 2006-07-31 71
column.set_sizing (gtk.TREE_VIEW_COLUMN_FIXED)
83b1768 by Philip Van Hoof at 2006-07-29 72
headerstree.append_column (column)
b19104b by Mark Doffman at 2007-09-25 73
platfact = PyPlatformFactory()
00d1db8 by Philip Van Hoof at 2006-07-30 74
msgview = platfact.new_msg_view ()
75
msgview.show ()
76
vpaned.pack2 (msgview, True, True)
782c0bc by Philip Van Hoof at 2006-07-28 77
account_store = platfact.new_account_store ()
00d1db8 by Philip Van Hoof at 2006-07-30 78
device = account_store.get_device ()
79
device.force_online ()
197ef09 by Philip Van Hoof at 2006-11-25 80
query = tinymail.FolderStoreQuery ()
dcd47c1 by Philip Van Hoof at 2006-11-25 81
query.add_item ("", tinymail.FOLDER_STORE_QUERY_OPTION_SUBSCRIBED)
f9208c3 by Mark Doffman at 2007-09-04 82
accounts = tinymail.uigtk.GtkFolderStoreTreeModel (query)
5e11989 by Philip Van Hoof at 2006-09-08 83
account_store.get_accounts (accounts, tinymail.ACCOUNT_STORE_STORE_ACCOUNTS)
4e45270 by Philip Van Hoof at 2006-07-29 84
folderstree.set_model (accounts)
83b1768 by Philip Van Hoof at 2006-07-29 85
folderstree.get_selection().connect("changed", on_folderstree_selected, headerstree)
00d1db8 by Philip Van Hoof at 2006-07-30 86
headerstree.get_selection().connect("changed", on_headerstree_selected, msgview)
6e6280b by Sergio Villar Senin at 2009-10-22 87
builder.connect_signals(self)
782c0bc by Philip Van Hoof at 2006-07-28 88
gtk.main()