Holding the pointer over an interface in the main window shows a tooltip
[zeroinstall.git] / dialog.py
blob699d8946e01c4ceac8d9476770d261eb227fea0e
1 import gtk
3 n_windows = 0
5 class Dialog(gtk.Dialog):
6 def __init__(self):
7 global n_windows
8 gtk.Dialog.__init__(self)
9 self.set_has_separator(False)
10 self.set_position(gtk.WIN_POS_CENTER)
12 def destroyed(widget):
13 global n_windows
14 n_windows -= 1
15 if n_windows == 0:
16 gtk.main_quit()
17 self.connect('destroy', destroyed)
19 n_windows += 1
21 def add_mixed_button(self, message, stock, response):
22 button = gtk.Button()
24 label = gtk.Label('')
25 label.set_text_with_mnemonic(message)
26 label.set_mnemonic_widget(button)
28 image = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_BUTTON)
29 box = gtk.HBox(False, 2)
30 align = gtk.Alignment(0.5, 0.5, 0.0, 0.0)
32 box.pack_start(image, False, False, 0)
33 box.pack_end(label, False, False, 0)
35 button.add(align)
36 align.add(box)
37 button.set_flags(gtk.CAN_DEFAULT)
39 self.add_action_widget(button, response)
40 button.show_all()
42 def alert(parent, message):
43 box = gtk.MessageDialog(parent, gtk.DIALOG_DESTROY_WITH_PARENT,
44 gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
45 str(message))
46 box.set_position(gtk.WIN_POS_CENTER)
47 box.connect('response', lambda b, r: box.destroy())
48 box.show()