Commits

Konstantine Rybnikov committed b6f56d0

Almost done the GUI!

Comments (0)

Files changed (1)

                 os.system('/usr/sbin/freetype-backend rfremix')
             else: # 1 or else is for original fonts
                 os.system(' /usr/sbin/freetype-backend fedora')
-        if self.wmanager_button.get_property('sensitive'):
-            if self.wmanager_button.state == 0: # gdm
-                print "yeeeeah! GDM!"
-            else: # kdm
-                print "woohooo!! KDM!!"
+        print '======================================='
+        for key, val in self.ACTIONS_MAP.iteritems():
+            print "%s -> %s" % (key, val)
+        print '======================================='
+
+        if 'disable_ipv6' in self.ACTIONS_MAP:
+            pass
+
+        if 'sudo_users' in self.ACTIONS_MAP:
+            pass
+
+        if 'autologin_users' in self.ACTIONS_MAP:
+            pass
+
+        if 'c_m_backspace' in self.ACTIONS_MAP:
+            pass
+
+        if 'kdm_gdm' in self.ACTIONS_MAP:
+            pass
+        
         return RESULT_SUCCESS
 
+    def callb_radio(self, widget, data=None):
+        if widget.get_active():
+            self.ACTIONS_MAP[data['key']] = data['val']
+
+    def callb_checkbox(self, widget, data=None):
+        if widget.get_active():
+            self.ACTIONS_MAP[data['key']] = data['val']
+        else:
+            if data['key'] in self.ACTIONS_MAP:
+                del self.ACTIONS_MAP[data['key']]
+    
     def createScreen(self):
+        self.ACTIONS_MAP = {}
         self.vbox = gtk.VBox()
-
+        
         label = gtk.Label(_("Now your can enable some parameters, which are disabled in original\n"
                             "Fedora, such as fonts style, icons, encoding autodetection and others.\n"
                             "These are global parameter, they will be enabled for all users."))
         label.set_alignment(0.0, 0.5)
         second_tab_vbox.pack_start(label, False, True, 0)
         
-        __active_already_set = False # is gdm is not present and someone is (kdm) -- let's set that one. Else -- gdm is active anyway.
         box = gtk.VBox()
-        self.wmanager_button = gtk.RadioButton(None, (_("GDM (default)")))
+        self.wmanager_button = gtk.RadioButton(None, _("GDM (default)"))
         self.wmanager_button.set_active(True)
         if not os.path.exists('/usr/bin/gdm'):
             self.wmanager_button.set_sensitive(False)
         else:
-            __active_already_set = True
+            self.ACTIONS_MAP['kdm_gdm'] = 'gdm'
+        
+        self.wmanager_button.connect("toggled", self.callb_radio, dict(key='kdm_gdm', val='gdm'))
+        
         box.pack_start(self.wmanager_button)
-        self.wmanager_button = gtk.RadioButton(self.wmanager_button, (_("KDM")))
+        self.wmanager_button = gtk.RadioButton(self.wmanager_button, _("KDM"))
         self.wmanager_button.set_active(True)
         if not os.path.exists('/usr/bin/kdm'):
             self.wmanager_button.set_sensitive(False)
         else:
-            if __active_already_set is False:
-                self.wmanager_button.set_active(True)
+            if 'kdm_gdm' not in self.ACTIONS_MAP:
+                self.ACTIONS_MAP['kdm_gdm'] = 'kdm'
+        
+        self.wmanager_button.connect("toggled", self.callb_radio, dict(key='kdm_gdm', val='kdm'))
         
         box.pack_start(self.wmanager_button)
         
         second_tab_vbox.pack_start(box, False, True, 0)
+
+        #
+        # C-M-Backspace option
+        #
+        box = gtk.VBox()
+        c_m_checkbox = gtk.CheckButton(label=_('Enable Ctrl+Alt+Backspace combination to restart X-server'))
+        c_m_checkbox.connect("toggled", self.callb_checkbox, dict(key='c_m_backspace', val=True))
+        box.pack_start(c_m_checkbox, False, True, 0)
+        second_tab_vbox.pack_start(box, False, True, 0)
+        
+        # user_opt = gtk.combo_box_new_text()
+        # user_opt.append_text(_('Choose user:'))
+        # user_opt.append_text('kost')
+        # user_opt.append_text('most')
+        # user_opt.append_text('dost')
+        # user_opt.connect('changed', changed_user_opt)
+        # user_opt.set_active(0)
+        # hbox.pack_start(user_opt)
+        # add_sudo_checkbox = gtk.CheckButton(label=_('use SUDO for this user'))
+
+        import grp, pwd
+        users = [grp.getgrgid(user[3])[0] for user in pwd.getpwall() if grp.getgrgid(user[3])[2] >= 500]
+        
+        box = gtk.VBox()
+        hbox = gtk.HBox()
+        #
+        # Autologin
+        #
+        self.ACTIONS_MAP['autologin_users'] = []
+        
+        def autologin_and_sudo_callb(var, widget, data=None):
+            if widget.get_active():
+                if data['user'] not in var:
+                    var.append(data['user'])
+            else:
+                if data['user'] in var:
+                    del var[var.index(data['user'])]
+        
+        def autologin_callb(widget, data=None):
+            return autologin_and_sudo_callb(self.ACTIONS_MAP['autologin_users'], widget, data)
+        
+        autologin_box = gtk.VBox()
+        autologin_box.pack_start(gtk.Label(_("Use autologin for users:")))
+        AUTOLOGIN_MAP = {}
+        for user in users:
+            checkbox = gtk.CheckButton(label=user)
+            autologin_box.pack_start(checkbox)
+            checkbox.connect("toggled", autologin_callb, {'user': user})
+        hbox.pack_start(autologin_box)
+        
+        #
+        # Sudo
+        #
+        self.ACTIONS_MAP['sudo_users'] = []
+        
+        def sudo_callb(widget, data=None):
+            return autologin_and_sudo_callb(self.ACTIONS_MAP['sudo_users'], widget, data)
+        
+        sudo_box = gtk.VBox()
+        sudo_box.pack_start(gtk.Label(_("Allow sudo for users:")))
+        for user in users:
+            checkbox = gtk.CheckButton(label=user)
+            sudo_box.pack_start(checkbox)
+            checkbox.connect("toggled", sudo_callb, {'user': user})
+        hbox.pack_start(sudo_box)
+        
+        box.pack_start(hbox, False, True, 0)
+        second_tab_vbox.pack_start(box, False, True, 0)
+        
+        #
+        # IPv6 settings
+        #
+        box = gtk.VBox()
+        checkbox = gtk.CheckButton(label=_("Disable IPv6 support"))
+        checkbox.connect("toggled", self.callb_checkbox, dict(key="disable_ipv6", val=True))
+        box.pack_start(checkbox)
+        second_tab_vbox.pack_start(box, False, True, 0)
         
         self.vbox.pack_start(notebook)
-    
+        
     def initializeUI(self):
         pass