Moved some stuff around.
[jben2_gui.git] / python / jben / interface / gtk / dialog / dict_mirror_select.py
blob46ea5493c9d8f21ad2c7c5c2fcf8cd05b9c48bcd
1 # -*- coding: utf-8 -*-
3 from __future__ import absolute_import
5 import gtk, gobject
6 from ..widget.storedsize import StoredSizeDialog
7 from jben.dict_downloader import static_mirror_list
10 class DictMirrorSelect(StoredSizeDialog):
12 def __init__(self, app, parent):
13 StoredSizeDialog.__init__(
14 self, "gui.dialog.dict_mirror_select.size", -1, -1,
15 title=_("Select download site"),
16 parent=parent,
17 flags=gtk.DIALOG_MODAL,
18 buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
19 gtk.STOCK_OK, gtk.RESPONSE_OK)
21 self.app = app
22 self._layout()
24 def _layout(self):
25 self.server_list = gtk.combo_box_new_text()
26 for row in static_mirror_list:
27 self.server_list.append_text(row)
28 self.server_list.set_active(0)
29 self.server_list.show()
31 layout = self.get_content_area()
32 layout.pack_start(self.server_list, expand=False)
34 def get_mirror(self):
35 return self.server_list.get_active_text()
37 def run(self):
38 """Single-time run command; hides GTK boilerplate and gets result.
40 Returns the selected mirror's URI.
42 """
43 resp = gtk.Dialog.run(self)
44 if resp == gtk.RESPONSE_OK:
45 result = self.get_mirror()
46 else:
47 result = None
48 self.destroy()
49 return result