initial import of ussd-pad
[ussd-widget] / ussd-pad / src / opt / ussd-pad / ui / dialog / OptionDialog.py
1 import gtk
2
3
4 class OptionDialog(gtk.Dialog):
5
6     def __init__(self, title):
7     
8         self.__num_of_options = 0
9         self.__choice = -1
10     
11         gtk.Dialog.__init__(self)
12         self.set_title(title)
13         
14         self.realize()
15         
16         self.window.property_change("_HILDON_PORTRAIT_MODE_SUPPORT",
17                                     "CARDINAL", 32,
18                                     gtk.gdk.PROP_MODE_REPLACE,
19                                     [1])
20
21     def add_option(self, icon, label):
22     
23         def on_choice(src, i):
24             self.__choice = i
25             self.response(gtk.RESPONSE_ACCEPT)
26     
27         hbox = gtk.HBox()
28         hbox.show()
29         if (icon):
30             img = gtk.Image()
31             img.set_from_pixbuf(icon)
32             img.show()
33             hbox.add(img)
34         #end if
35         lbl = gtk.Label(label)
36         lbl.show()
37         hbox.add(lbl)
38
39         btn = gtk.Button()
40         btn.set_size_request(-1, 70)
41         self.vbox.add(btn)
42         btn.show()
43         btn.add(hbox)
44         btn.connect("clicked", on_choice, self.__num_of_options)
45         self.__num_of_options += 1
46
47
48     def get_choice(self):
49     
50         return self.__choice
51
52
53     def run(self):
54     
55         self.show()
56         resp = gtk.Dialog.run(self)
57         self.destroy()
58         
59         if (resp == gtk.RESPONSE_ACCEPT):
60             return 0
61         else:
62             return 1
63