Source

vlmaddon / view / message.py

Full commit
#!/usr/bin/env python

#    This file is part of the vectorlinux multimedia bonus disc.
#
#    This file 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.
#
#    This file 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 this file.  If not, see <http://www.gnu.org/licenses/>.

import gtk
import threading
import time
__author__ = 'Moises Henriquez'
__author_email__ = 'moc.liamg@xnl.E0M'[::-1]


def _(str):
    return str

class FailedPackagesDialog(gtk.Dialog):
    """Dialog used to show that some packages failed to install
    """
    def __init__(self, list_reason = []):
        gtk.Dialog.__init__(self)
        self.set_title(_('Errors during installation'))
        carea = self.get_content_area()
        aarea = self.get_action_area()
        bannerc = gtk.HBox()
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
        bannerc.pack_start(img, False, False, 8)
        banner = gtk.Label()
        banner.set_property('label',
                _('The following packages failed to install.') + '\n\n' + \
                        _('Please report this error to the developer'))
        bannerc.pack_start(banner, False, False, 8)
        carea.pack_start(bannerc, False, False, 0)
        scv = gtk.ScrolledWindow()
#        carea.pack_start(scv, True, True, 0)
        store = gtk.ListStore(str, str)
        for item in list_reason:
            store.append([item[0], item[1].strip().replace('\\n ','\n')])
        tree = gtk.TreeView(model = store)
        cr0 = gtk.CellRendererText()
        cr1 = gtk.CellRendererText()
        col0 = gtk.TreeViewColumn('Application', cr0)
        col0.add_attribute(cr0, 'markup', 0)
        col1 = gtk.TreeViewColumn('Returned Error', cr1)
        col1.add_attribute(cr1, 'markup', 1)
        tree = gtk.TreeView()
        tree.set_model(store)
        tree.set_headers_visible(True)
        scv.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        tree.append_column(col0)
        tree.append_column(col1)
        scv.add(tree)
        carea.pack_start(scv, True, True, 0)

        btClose = gtk.Button(stock = gtk.STOCK_CLOSE)
        btClose.connect('clicked', self._close)
        aarea.pack_start(btClose, False, False, 0)
        self.resize(480, 300)

        self.show_all()

    def _close(self, widget=None):
        self.destroy()

def Error(parent = None, text = None, title = 'Error'):
    """Generic error message dialog"""
    dia = gtk.MessageDialog(
            parent = parent,
            type = gtk.MESSAGE_ERROR,
            buttons = gtk.BUTTONS_OK,
            )
    dia.set_markup(text)
    dia.set_title(title)
    return dia

def Info(parent = None, text = None, title = 'Info'):
    dia = gtk.MessageDialog(
            parent = parent,
            type = gtk.MESSAGE_INFO,
            buttons = gtk.BUTTONS_OK,
            )
    dia.set_markup(text)
    dia.set_title(title)
    return dia