Source

controlcenter / widgets / message.py

Full commit
#!/usr/bin/env python

#    This file is part of controlcenter.
#
#    controlcenter is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License v2 as published by
#    the Free Software Foundation.
#
#    controlcenter is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with controlcenter.  If not, see <http://www.gnu.org/licenses/>.

__author__ = 'Moises Henriquez'
__author_email__ = 'moc.liamg]ta[xnl.E0M'.replace(']ta[', '@')[::-1]

import gtk

def _(str): return str

class Error(gtk.MessageDialog):
    '''Pre-set gtk message dialog to display an error message'''
    def __init__(self, parent=None, text=None):
        gtk.MessageDialog.__init__(self, type=gtk.MESSAGE_ERROR, parent=parent,
        buttons = gtk.BUTTONS_OK)
        self.set_property('text', text)
        self.set_property('title', _('Error'))
    
class Warning(gtk.MessageDialog):
    '''Pre-set gtk dialog to display a warning message'''
    def __init__(self, parent=None, text=None):
        gtk.MessageDialog.__init__(self, type=gtk.MESSAGE_WARNING, parent=parent,
        buttons=gtk.BUTTONS_OK)
        self.set_property('text', text)
        self.set_property('title', _('Warning'))
        
class Info(gtk.MessageDialog):
    '''Pre-set gtk dialog to display an informational message'''
    def __init__(self, parent=None, text=None):
        gtk.MessageDialog.__init____(self, type=gtk.MESSAGE_INFO, parent=parent,
        buttons = gtk.BUTTONS_OK)
        self.set_property('title', _('Info'))
        self.set_property('text', text)

class Question(gtk.MessageDialog):
    '''Preset gtk message dialog to display a question to the user and get
    their response via a gtk.RESPONSE constant. Response is either 
    gtk.RESPONSE_OK or gtk.RESPONSE_CANCEL'''
    def __init__(self, parent=None, text=None):
        gtk.MessageDialog.__init__(self, type=gtk.MESSAGE_QUESTION, parent=parent,
        buttons=gtk.BUTTONS_YES_NO)
        self.set_property('title', _('Question'))
        self.set_property('text', text)