-
Notifications
You must be signed in to change notification settings - Fork 1
/
pge_recentchooser.py
72 lines (61 loc) · 1.87 KB
/
pge_recentchooser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python2.5
#
# PyGTKEditor
#
# Copyright (c) 2007 Khertan (Benoit HERVIER)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# Khertan (Benoit HERVIER) khertan@khertan.net
import hildon
import gtk
import osso
import pango
from portrait import FremantleRotation
import pge_editor
import os
from subprocess import *
import commands
import gobject
import pge_preferences
class Dialog(hildon.Dialog):
def __init__(self):
hildon.Dialog.__init__ (self)
self.set_title('Choose a file to open')
self.selected = None
vbox = gtk.VBox()
p1 = hildon.PannableArea()
p1.add_with_viewport(vbox)
rm = gtk.recent_manager_get_default()
ritems = rm.get_items()
ritems.sort(lambda x,y: y.get_modified()-x.get_modified())
if (len(ritems)>0):
# vbox.add(gtk.Label('Recent Files'))
for index,item in enumerate(ritems):
b=hildon.Button(0,1)
label = item.get_uri_display()
i = gtk.image_new_from_stock(gtk.STOCK_FILE,gtk.ICON_SIZE_BUTTON)
# i = gtk.image_new_from_icon_name(item.get_mime_type(),gtk.ICON_SIZE_BUTTON)
# i = gtk.image_new_from_pixbuf(item.get_icon(gtk.ICON_SIZE_LARGE_TOOLBAR))
b.set_image(i)
b.set_title(os.path.basename(label))
b.set_value(label)
b.set_alignment(0.0,0.0,0.0,0.5)
vbox.add(b)
b.connect("clicked", self._clicked, label)
# vbox
p1.set_size_request(-1,350)
self.vbox.add(p1)
self.vbox.show_all()
def _clicked(self,w,label):
self.selected = label
self.destroy()
def get(self):
self.run()
return self.selected
if __name__ == "__main__":
print Dialog().get()
gtk.main()