Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fw-interfaces.git;a=commitdiff;h=814e08aac4343626d00b8849c3062fd00c5b6574
commit 814e08aac4343626d00b8849c3062fd00c5b6574 Author: bouleetbil <bouleet...@frogdev.info> Date: Sat Apr 10 00:03:45 2010 +0000 fw-interfaces.py *added some fix *use checkbox instead radiobox *now it's usable *rc scripts can use /etc/sysconfig/interfaces *will do it more generic later *the same system can be used for select login-manager *after that can be well to have a gui for launch GUI Frugalware diff --git a/fw-interfaces.py b/fw-interfaces.py index 3204971..8ccc9a6 100644 --- a/fw-interfaces.py +++ b/fw-interfaces.py @@ -35,7 +35,11 @@ USE_WICD = 0 USE_FWUTILS = 1 #by default use frugalware +cen_fw=1 +cen_nm=2 +cen_wicd="3" debug=0 + def fprint(texte): global debug if debug == 1: @@ -53,12 +57,15 @@ def analyseLine(Line): if key == "USE_FWUTILS": if value == "1": + fprint("use fw") USE_FWUTILS = 1 if key == "USE_NM": if value == "1": + fprint("use nm") USE_NM = 1 if key == "USE_WICD": if value == "1": + fprint("use wicd") USE_WICD = 1 except: @@ -138,7 +145,7 @@ def find_pkg(packagename): return found def sysexec(cmd): - fprint("executing"+ cmd) + fprint("executing : "+ cmd) os.system(cmd) def install_pkg(packagename): @@ -153,7 +160,7 @@ def install_pkg(packagename): def install_service(servicename): sysexec("service "+servicename+" add") -MessageOk=False +#MessageOk=False #should be launch as root if (os.environ["USER"] != "root"): message_box(title='Error', @@ -161,52 +168,73 @@ if (os.environ["USER"] != "root"): buttons=('Ok',)) sys.exit(0) - +MessageOk=True class Start: def fct_rappel(self, widget, donnees=None): global USE_NM global USE_WICD global USE_FWUTILS - global MessageOk - USE_NM = 0 - USE_WICD = 0 - USE_FWUTILS =0 - if MessageOk: - MessageOk=False - if donnees == "2": - print "Use NetworkManager" - #ask to pacman-g2 - if find_pkg("networkmanager"): + global cen_wicd + global cen_fw + global cen_nm + + + fprint("La %s a ete %s." % (donnees, ("desactivee", "activee")[widget.get_active()])) + if not widget.get_active() : + if not RadioButtonnm.get_active() and not RadioButtonwicd.get_active() and not RadioButtonfw.get_active(): + widget.set_active(True) + return True + USE_WICD=0 + USE_NM=0 + USE_FWUTILS=0 + + if donnees == cen_nm: + fprint("Use NetworkManager") + #ask to pacman-g2 + if find_pkg("networkmanager"): + USE_NM = 1 + install_service("networkmanager") + RadioButtonfw.set_active(False) + RadioButtonwicd.set_active(False) + else: + result = message_box(title='Missing package', + message='Do you want install networkmanager ?', + buttons=('Ok',"Cancel")) + if result == 'Ok': USE_NM = 1 + install_pkg("networkmanager") install_service("networkmanager") + RadioButtonfw.set_active(False) + RadioButtonwicd.set_active(False) else: - result = message_box(title='Missing package', - message='Do you want install networkmanager ?', - buttons=('Ok',"Cancel")) - if result == 'Ok': - install_pkg("networkmanager") - install_service("networkmanager") - - elif donnees == "3": - print "Use Wicd" - #ask to pacman-g2 - if find_pkg("wicd"): + widget.set_active(False) + elif donnees == cen_wicd: + fprint("Use Wicd") + #ask to pacman-g2 + if find_pkg("wicd"): + USE_WICD = 1 + install_service("wicd") + RadioButtonnm.set_active(False) + RadioButtonfw.set_active(False) + else: + result = message_box(title='Missing package', + message='Do you want install wicd ?', + buttons=('Ok',"Cancel")) + if result == 'Ok': USE_WICD = 1 + install_pkg("wicd") install_service("wicd") + RadioButtonnm.set_active(False) + RadioButtonfw.set_active(False) + else: - result = message_box(title='Missing package', - message='Do you want install wicd ?', - buttons=('Ok',"Cancel")) - if result == 'Ok': - install_pkg("wicd") - install_service("wicd") - - else: - print "Use Frugalware netconfig" - USE_FWUTILS = 1 - else: - MessageOk=True + widget.set_active(False) + else: + fprint("Use Frugalware netconfig") + USE_FWUTILS = 1 + RadioButtonnm.set_active(False) + RadioButtonwicd.set_active(False) def clic_about(self, widget, data=None): message_box(title='About', @@ -224,7 +252,7 @@ class Start: global USE_WICD global USE_FWUTILS #save - print "Save configuration" + fprint("Save configuration") #Fix me : for now erase source f = open(ConfigFile, "w") f.write("USE_WICD="+str(USE_WICD)+"\n") @@ -234,14 +262,20 @@ class Start: gtk.main_quit() return False - - def read_config(): - return True + def __init__(self): - - self.fenetre = gtk.Window(gtk.WINDOW_TOPLEVEL) + global RadioButtonfw + global RadioButtonwicd + global RadioButtonnm + global USE_NM + global USE_WICD + global USE_FWUTILS + global cen_wicd + global cen_fw + global cen_nm + self.fenetre = gtk.Window(gtk.WINDOW_TOPLEVEL) self.fenetre.connect("delete_event", self.quitter_pgm) self.fenetre.set_title("fw-interfaces") @@ -267,26 +301,28 @@ class Start: boite1.pack_start(boite2, True, True, 0) boite2.show() - bouton = gtk.RadioButton(None, "Frugalware Interface") - bouton.connect("toggled", self.fct_rappel, "1") - if USE_FWUTILS == 1: - bouton.set_active(True) - boite2.pack_start(bouton, True, True, 0) - bouton.show() + RadioButtonfw = gtk.CheckButton("Frugalware Interface") + boite2.pack_start(RadioButtonfw, True, True, 0) + RadioButtonfw.show() - bouton = gtk.RadioButton(bouton, "NetworkManager") - bouton.connect("toggled", self.fct_rappel, "2") - if USE_NM == 1: - bouton.set_active(True) - boite2.pack_start(bouton, True, True, 0) - bouton.show() + RadioButtonnm = gtk.CheckButton("NetworkManager") + boite2.pack_start(RadioButtonnm, True, True, 0) + RadioButtonnm.show() - bouton = gtk.RadioButton(bouton, "Wicd") - bouton.connect("toggled", self.fct_rappel, "3") - if USE_WICD == 1: - bouton.set_active(True) - boite2.pack_start(bouton, True, True, 0) - bouton.show() + RadioButtonwicd = gtk.CheckButton("Wicd") + boite2.pack_start(RadioButtonwicd, True, True, 0) + RadioButtonwicd.show() + + if USE_NM == 1: + RadioButtonnm.set_active(True) + elif USE_WICD == 1: + RadioButtonwicd.set_active(True) + else : + RadioButtonfw.set_active(True) + + RadioButtonfw.connect("toggled", self.fct_rappel, cen_fw) + RadioButtonnm.connect("toggled", self.fct_rappel, cen_nm) + RadioButtonwicd.connect("toggled", self.fct_rappel, cen_wicd) separateur = gtk.HSeparator() boite1.pack_start(separateur, False, True, 0) @@ -311,8 +347,7 @@ class Start: boutonClose.grab_default() boutonClose.show() - - self.fenetre.show() + self.fenetre.show() def main(): gtk.main() _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git