Commits

Anonymous committed 1bc5885

Added sample button to main gui and enabled transition from main gui to child windows

  • Participants
  • Parent commits 39e511b

Comments (0)

Files changed (6)

 import gtk
 from widgets import message
 from widgets import guiwidgets
+from user_add import users_manage
 
 
 __author__ = 'Moises Henriquez'
 
 def _(str): return str
 
-class ModFrame(gtk.Frame):
-    '''A preset frame widget to be used for all module sets'''
-    def __init__(self, label):
-        gtk.Frame.__init__(self, label)
-    
 
 class Gui(gtk.Window):
     '''Main GUI interface for the controlcenter.
         body = gtk.VBox()
         self.add(body)
         users = guiwidgets.ModuleSection(label = _('Users'))
-        bt1 = gtk.Button('OK')
-        users.body.pack_start(bt1, False, False, 2)
+        bt1 = gtk.Button(_('Manage Users'))
+        img = gtk.Image()
+
+        users = self.populate_users_module()
         body.pack_start(users, False, False, 2)
-        syst = guiwidgets.ModuleSection( label = _('System'))
-        bt2 = gtk.Button('System')
-        syst.body.pack_start(bt2, 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__':

user_add/user_mod.py

         self.set_property('use-markup', True)
         self.set_property('label', text)
         self.set_property('xalign', 0.0)
-        self.set_property('width-chars', 13)    ## Fixme: Fixed width for these?
+        self.set_property('width-chars', 14)    ## Fixme: Fixed width for these?
         
 
 

user_add/users_manage.py

     def __init__(self):
         gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
         self.set_title(_('User accounts'))
-        self.connect('destroy', gtk.main_quit)
         self.set_position(gtk.WIN_POS_CENTER)
         self.set_default_size(500, 300)
         self.body = gtk.VBox()
         
         btHelp = gtk.Button(_('Help'), gtk.STOCK_HELP)
         btClose = gtk.Button(_('Close'), gtk.STOCK_CLOSE)
-        btClose.connect('clicked', gtk.main_quit)
+        #btClose.connect('clicked', self.do_close)
+        btClose.connect('clicked', lambda a: self.destroy())
 
         right.pack_start(bt_add, False, False, 4)
         right.pack_start(bt_delete, False, False, 4)
         self.statusbar.push(0, _('Welcome to controlcenter'))
         
         self.__modwin = None
+
     def delete_user(self, widget):
         ''' Displays the delte user dialog '''
         
 
 if __name__ == '__main__':
     w = Win()
+    w.connect('destroy', gtk.main_quit)
     w.show_all()
     gtk.main()

widgets/__init__.pyc

Binary file modified.

widgets/guiwidgets.py

     Required Arguments:
         label:  A text string that will be used to identify the module section'''
     def __init__(self, label):
-        gtk.Frame.__init__(self, label)
+        gtk.Frame.__init__(self)
+        lb = gtk.Label()
+        lb.set_property('use-markup', True)
+        lb.set_property('label', '<b>%s</b>'%label)
+        self.set_label_widget(lb)
         self.body = gtk.HBox()
         self.add(self.body)
+        self.set_shadow_type(gtk.SHADOW_NONE)
         
         
-class ModuleIcon(gtk.VBox):
+class ModuleIcon(gtk.Button):
     '''Pre-set launcher to be used in the controlcenter main gui to launch
     a perticular module.
     Retured arguments:
         target:  The target module this launcher executes
     '''
     def __init__(self, label, icon, target):
-        gtk.VBox.__init__(self)
+        gtk.Button.__init__(self)
+        self.set_property('relief', gtk.RELIEF_NONE)
         img = gtk.Image()
         if icon.startswith('gtk-'):
             img.set_from_stock(icon, gtk.ICON_SIZE_DIALOG)
             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)
+        elif '-' in icon:
+            img.set_from_icon_name(icon, gtk.ICON_SIZE_DIALOG)
+        self.set_image(img)
+        self.set_label(_(label))
+        self.set_property('image-position', gtk.POS_TOP)
+        #self.pack_start(img, False, False, 2)
+        #label = gtk.Label(label)
+        #self.pack_start(label, False, False, 2)

widgets/message.pyc

Binary file modified.