Source

controlcenter / widgets / guiwidgets.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 ModuleSection(gtk.Frame):
    '''Container to be used as a module section holder. This will hold several
    ModuleIcon objects.
    Required Arguments:
        label:  A text string that will be used to identify the module section'''
    def __init__(self, label):
        gtk.Frame.__init__(self, label)
        self.body = gtk.HBox()
        self.add(self.body)
        
        
class ModuleIcon(gtk.VBox):
    '''Pre-set launcher to be used in the controlcenter main gui to launch
    a perticular module.
    Retured arguments:
        label :  Text to be displayed
        icon  :  Icon to display (can be a gtk.ICON constant or icon name or path)
        target:  The target module this launcher executes
    '''
    def __init__(self, label, icon, target):
        gtk.VBox.__init__(self)
        img = gtk.Image()
        if icon.startswith('gtk-'):
            img.set_from_stock(icon, gtk.ICON_SIZE_DIALOG)
        elif '.' in icon:
            img.set_from_icon_name(icon, gtk.ICON_SIZE_DIALOG)
        elif '/' in icon:
            img.set_from_file(icon)
        self.pack_start(img, False, False, 2)
        label = gtk.Label(label)
        self.pack_start(label, False, False, 2)