~ubuntu-branches/debian/sid/zeroinstall-injector/sid

« back to all changes in this revision

Viewing changes to zeroinstall/0launch-gui/dialog.py

  • Committer: Package Import Robot
  • Author(s): Thomas Leonard
  • Date: 2012-02-12 15:19:54 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20120212151954-u5nef8c1381klr43
Tags: 1.6-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
import gtk
5
5
import os
6
 
from zeroinstall.support import tasks
7
6
from zeroinstall.gtkui import gtkutils
8
7
 
9
 
n_windows = 0
10
 
 
11
8
last_error = None
12
9
 
13
10
builderfile = os.path.join(os.path.dirname(__file__), 'zero-install.ui')
30
27
                button.show_all()
31
28
                return button
32
29
 
33
 
class DialogResponse(tasks.Blocker):
34
 
        response = None
35
 
        def __init__(self, dialog):
36
 
                tasks.Blocker.__init__(self, dialog.get_title())
37
 
                a = None
38
 
                def response(d, resp):
39
 
                        self.response = resp
40
 
                        d.disconnect(a)
41
 
                        self.trigger()
42
 
                a = dialog.connect('response', response)
43
 
 
44
 
class ButtonClickedBlocker(tasks.Blocker):
45
 
        def __init__(self, button):
46
 
                tasks.Blocker.__init__(self, "Button click")
47
 
                a = None
48
 
                def clicked(b):
49
 
                        b.disconnect(a)
50
 
                        self.trigger()
51
 
                a = button.connect('clicked', lambda b: self.trigger())
52
 
 
53
30
def alert(parent, message, type = gtk.MESSAGE_ERROR):
54
31
        if type == gtk.MESSAGE_ERROR:
55
32
                global last_error
57
34
 
58
35
        gtkutils.show_message_box(parent, message, type)
59
36
 
60
 
def MixedButton(message, stock, x_align = 0.5, button = None):
61
 
        if button is None:
62
 
                button = gtk.Button()
63
 
 
64
 
        label = gtk.Label('')
65
 
        label.set_text_with_mnemonic(message)
66
 
        label.set_mnemonic_widget(button)
67
 
 
68
 
        image = gtk.image_new_from_stock(stock, gtk.ICON_SIZE_BUTTON)
69
 
        box = gtk.HBox(False, 2)
70
 
        align = gtk.Alignment(x_align, 0.5, 0.0, 0.0)
71
 
 
72
 
        box.pack_start(image, False, False, 0)
73
 
        box.pack_end(label, False, False, 0)
74
 
 
75
 
        button.add(align)
76
 
        align.add(box)
77
 
        return button
 
37
DialogResponse = gtkutils.DialogResponse
 
38
ButtonClickedBlocker = gtkutils.ButtonClickedBlocker
 
39
MixedButton = gtkutils.MixedButton