/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/dialog.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-10-20 11:18:37 UTC
  • Revision ID: Szilveszter.Farkas@gmail.com-20061020111837-e2a99e1d4db9f0f7
Removed completed TODO items.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pass
22
22
 
23
23
import gtk
24
 
 
25
 
 
26
 
def _message_dialog(type, primary, secondary, parent=None, buttons=gtk.BUTTONS_OK):
 
24
import gtk.glade
 
25
 
 
26
 
 
27
def about():
 
28
    """ Display the AboutDialog. """
 
29
    import olive
 
30
 
 
31
    # Load AboutDialog description
 
32
    dglade = gtk.glade.XML(olive.gladefile, 'aboutdialog')
 
33
    dialog = dglade.get_widget('aboutdialog')
 
34
 
 
35
    # Set version
 
36
    dialog.set_version(olive.__version__)
 
37
    
 
38
    # Destroy the dialog
 
39
    if dialog.run() == gtk.RESPONSE_CANCEL:
 
40
        dialog.destroy()
 
41
 
 
42
def _message_dialog(type, primary, secondary):
27
43
    """ Display a given type of MessageDialog with the given message.
28
44
    
29
 
    :param type: message dialog type
 
45
    :param type: error | warning | info
30
46
    
31
47
    :param message: the message you want to display.
32
48
    """
33
 
    dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL, type=type, parent=parent,
34
 
                               buttons=buttons)
35
 
    dialog.set_markup('<big><b>' + primary + '</b></big>')
 
49
    if type == 'error':
 
50
        dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL,
 
51
                                   type=gtk.MESSAGE_ERROR,
 
52
                                   buttons=gtk.BUTTONS_OK)
 
53
        dialog.set_markup('<big><b>' + primary + '</b></big>')
 
54
    elif type == 'warning':
 
55
        dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL,
 
56
                                   type=gtk.MESSAGE_WARNING,
 
57
                                   buttons=gtk.BUTTONS_OK)
 
58
        dialog.set_markup('<big><b>' + primary + '</b></big>')
 
59
    elif type == 'info':
 
60
        dialog = gtk.MessageDialog(flags=gtk.DIALOG_MODAL,
 
61
                                   type=gtk.MESSAGE_INFO,
 
62
                                   buttons=gtk.BUTTONS_OK)
 
63
        dialog.set_markup('<big><b>' + primary + '</b></big>')
 
64
    else:
 
65
        return
 
66
    
36
67
    dialog.format_secondary_markup(secondary)
37
 
    response = dialog.run()
38
 
    dialog.destroy()
39
 
    return response
 
68
    
 
69
    if dialog.run() == gtk.RESPONSE_OK:
 
70
        dialog.destroy()
40
71
 
41
 
def error_dialog(primary, secondary, parent=None):
 
72
def error_dialog(primary, secondary):
42
73
    """ Display an error dialog with the given message. """
43
 
    return _message_dialog(gtk.MESSAGE_ERROR, primary, secondary, parent)
 
74
    _message_dialog('error', primary, secondary)
44
75
 
45
 
def info_dialog(primary, secondary, parent=None):
 
76
def info_dialog(primary, secondary):
46
77
    """ Display an info dialog with the given message. """
47
 
    return _message_dialog(gtk.MESSAGE_INFO, primary, secondary, parent)
 
78
    _message_dialog('info', primary, secondary)
48
79
 
49
 
def warning_dialog(primary, secondary, parent=None):
 
80
def warning_dialog(primary, secondary):
50
81
    """ Display a warning dialog with the given message. """
51
 
    return _message_dialog(gtk.MESSAGE_WARNING, primary, secondary, parent)
52
 
 
53
 
def question_dialog(primary, secondary, parent=None):
54
 
    """ Display a dialog with the given question. """
55
 
    return _message_dialog(gtk.MESSAGE_QUESTION, primary, secondary, parent, gtk.BUTTONS_YES_NO)
 
82
    _message_dialog('warning', primary, secondary)