2 from zeroinstall
.support
import tasks
8 class Dialog(gtk
.Dialog
):
12 gtk
.Dialog
.__init
__(self
)
13 self
.set_has_separator(False)
14 self
.set_position(gtk
.WIN_POS_CENTER
)
16 def add_mixed_button(self
, message
, stock
, response
):
17 button
= MixedButton(message
, stock
)
18 button
.set_flags(gtk
.CAN_DEFAULT
)
20 self
.add_action_widget(button
, response
)
24 class DialogResponse(tasks
.Blocker
):
26 def __init__(self
, dialog
):
27 tasks
.Blocker
.__init
__(self
, dialog
.get_title())
29 def response(d
, resp
):
33 a
= dialog
.connect('response', response
)
35 def alert(parent
, message
, type = gtk
.MESSAGE_ERROR
):
36 if type == gtk
.MESSAGE_ERROR
:
40 box
= gtk
.MessageDialog(parent
, gtk
.DIALOG_DESTROY_WITH_PARENT
,
43 box
.set_position(gtk
.WIN_POS_CENTER
)
46 box
.connect('response', resp
)
49 def MixedButton(message
, stock
, x_align
= 0.5, button
= None):
54 label
.set_text_with_mnemonic(message
)
55 label
.set_mnemonic_widget(button
)
57 image
= gtk
.image_new_from_stock(stock
, gtk
.ICON_SIZE_BUTTON
)
58 box
= gtk
.HBox(False, 2)
59 align
= gtk
.Alignment(x_align
, 0.5, 0.0, 0.0)
61 box
.pack_start(image
, False, False, 0)
62 box
.pack_end(label
, False, False, 0)
68 def frame(page
, title
, content
, expand
= False):
71 label
.set_markup('<b>%s</b>' % title
)
72 frame
.set_label_widget(label
)
73 frame
.set_shadow_type(gtk
.SHADOW_NONE
)
74 if type(content
) in (str, unicode):
75 content
= gtk
.Label(content
)
76 content
.set_alignment(0, 0.5)
77 content
.set_selectable(True)
79 if hasattr(content
, 'set_padding'):
80 content
.set_padding(8, 4)
82 content
.set_border_width(8)
83 page
.pack_start(frame
, expand
, True, 0)