Source

controlcenter / gui.py

#!/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/>.

import gtk
from widgets import message
from widgets import guiwidgets
from user_add import users_manage


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

def _(str): return str


class Gui(gtk.Window):
    '''Main GUI interface for the controlcenter.
    This window will incorporate modules and launch them using
    icons from the main interface
    '''
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_title(_('Control Center'))
        self.set_position(gtk.WIN_POS_CENTER)
        self.connect('destroy', gtk.main_quit)
        body = gtk.VBox()
        self.add(body)
        users = guiwidgets.ModuleSection(label = _('Users'))
        bt1 = gtk.Button(_('Manage Users'))
        img = gtk.Image()

        users = self.populate_users_module()
        body.pack_start(users, False, False, 2)
        syst = self.populate_system_module()
        #syst = guiwidgets.ModuleSection( label = _('System'))
        #bt2 = gtk.Button('System')
        #syst.body.pack_start(bt2, False, False, 2)
        body.pack_start(syst, False, False, 2)
    def populate_system_module(self):
        frm = guiwidgets.ModuleSection(label=_('System'))
        bt1 = guiwidgets.ModuleIcon(label=_('Software Sources'), 
            icon = 'preferences-desktop-remote-desktop', target=None)
        bt2 = guiwidgets.ModuleIcon(label=_('Automatic Updates'), 
            icon = 'system-software-update', target=None)
        bt3 = guiwidgets.ModuleIcon(label=_('Network Setup'), 
            icon = 'gnome-fs-network', target=None)
        frm.body.pack_start(bt1, False, False, 2)
        frm.body.pack_start(bt2, False, False, 2)
        frm.body.pack_start(bt3, False, False, 2)
        return frm
    
    def populate_users_module(self):
        frm = guiwidgets.ModuleSection(label = _('Users Management'))
        ### Populate the contents of the frame now
        bt_mng_usrs = guiwidgets.ModuleIcon(label=_('Manage Users'), icon='system-users',
        target=None)
        bt_mng_usrs.connect('clicked', self.launch_users_manage)
        frm.body.pack_start(bt_mng_usrs, False, False, 2)
        grp = guiwidgets.ModuleIcon(label=_('User Groups'), icon='gtk-home',
        target=None)
        frm.body.pack_start(grp, False, False, 2)
        return frm
    
    def launch_users_manage(self, widget=None):
        W = users_manage.Win()
        W.connect('destroy', lambda x: self.deiconify())
        self.iconify()
        W.show_all()
        return
    

    
if __name__ == '__main__':
    w = Gui()
    w.show_all()
    gtk.main()
    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.