root/branches/0.3/src/dialogs.py

Revision 550, 2.7 kB (checked in by nicfit, 2 years ago)

Error dialogs (fixes #283)

Line 
1 ################################################################################
2 #  Copyright (C) 2006  Travis Shirk <travis@pobox.com>
3 #
4 #  This program is free software; you can redistribute it and/or modify
5 #  it under the terms of the GNU General Public License as published by
6 #  the Free Software Foundation; either version 2 of the License, or
7 #  (at your option) any later version.
8 #
9 #  This program is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #  GNU General Public License for more details.
13 #
14 #  You should have received a copy of the GNU General Public License
15 #  along with this program; if not, write to the Free Software
16 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 #
18 #  $Id$
19 ################################################################################
20 import gtk
21 import mesk
22 from mesk.i18n import _
23
24 class MessageDialog(gtk.MessageDialog):
25     def __init__(self, parent, modal=True):
26         gtk.MessageDialog.__init__(self, parent=parent, flags=0,
27                                    type=gtk.MESSAGE_INFO,
28                                    buttons=gtk.BUTTONS_OK)
29
30 class WarningDialog(gtk.MessageDialog):
31     def __init__(self, parent, modal=True):
32         gtk.MessageDialog.__init__(self, parent=parent, flags=0,
33                                    type = gtk.MESSAGE_WARNING,
34                                    buttons = gtk.BUTTONS_OK)
35
36 class ErrorDialog(gtk.MessageDialog):
37     def __init__(self, parent, modal=True):
38         gtk.MessageDialog.__init__(self, parent=parent, flags=0,
39                                    type=gtk.MESSAGE_ERROR,
40                                    buttons=gtk.BUTTONS_OK)
41
42 class ConfirmationDialog(gtk.MessageDialog):
43     def __init__(self, parent, modal=True, type=gtk.MESSAGE_QUESTION):
44         gtk.MessageDialog.__init__(self, parent=parent, flags=0, type=type)
45         self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
46         self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
47         self.set_position(gtk.WIN_POS_MOUSE)
48
49     def confirm(self):
50         resp = self.run()
51         self.destroy()
52         return (resp == gtk.RESPONSE_OK)
53
54 class ConfirmationWithDisableOptionDialog(ConfirmationDialog):
55     def __init__(self, parent, modal=True, type=gtk.MESSAGE_QUESTION):
56         ConfirmationDialog.__init__(self, parent=parent, modal=modal, type=type)
57         self.checkbutton = gtk.CheckButton(_('Do not ask me again.'))
58         self.vbox.pack_start(self.checkbutton, expand=False, fill=False)
59         self.checkbutton.show()
60
61     def confirm(self):
62         confirmed = ConfirmationDialog.confirm(self)
63         return (confirmed, self.checkbutton.get_active())
Note: See TracBrowser for help on using the browser.