1 # Copyright (C) 2009, Thomas Leonard
2 # See the README file for details, or visit http://0install.net.
6 from zeroinstall
import _
7 from zeroinstall
.support
import tasks
8 from zeroinstall
.gtkui
import gtkutils
14 builderfile
= os
.path
.join(os
.path
.dirname(__file__
), 'zero-install.ui')
16 class Template(gtkutils
.Template
):
17 def __init__(self
, root
):
18 gtkutils
.Template
.__init
__(self
, builderfile
, root
)
20 class Dialog(gtk
.Dialog
):
22 gtk
.Dialog
.__init
__(self
)
23 self
.set_has_separator(False)
24 self
.set_position(gtk
.WIN_POS_CENTER
)
26 def add_mixed_button(self
, message
, stock
, response
):
27 button
= MixedButton(message
, stock
)
28 button
.set_flags(gtk
.CAN_DEFAULT
)
30 self
.add_action_widget(button
, response
)
34 class DialogResponse(tasks
.Blocker
):
36 def __init__(self
, dialog
):
37 tasks
.Blocker
.__init
__(self
, dialog
.get_title())
39 def response(d
, resp
):
43 a
= dialog
.connect('response', response
)
45 class ButtonClickedBlocker(tasks
.Blocker
):
46 def __init__(self
, button
):
47 tasks
.Blocker
.__init
__(self
, "Button click")
52 a
= button
.connect('clicked', lambda b
: self
.trigger())
54 def alert(parent
, message
, type = gtk
.MESSAGE_ERROR
):
55 if type == gtk
.MESSAGE_ERROR
:
59 gtkutils
.show_message_box(parent
, message
, type)
61 def MixedButton(message
, stock
, x_align
= 0.5, button
= None):
66 label
.set_text_with_mnemonic(message
)
67 label
.set_mnemonic_widget(button
)
69 image
= gtk
.image_new_from_stock(stock
, gtk
.ICON_SIZE_BUTTON
)
70 box
= gtk
.HBox(False, 2)
71 align
= gtk
.Alignment(x_align
, 0.5, 0.0, 0.0)
73 box
.pack_start(image
, False, False, 0)
74 box
.pack_end(label
, False, False, 0)