using System; using Gtk; using lliurex.controlcenter; using System.Collections.Generic; public partial class MainWindow: Gtk.Window { private static MainWindow instance; public List appboxes; private bool step1,step2,step3,step4,step5,step6,step7,step8,step9,step10; public MainWindow (): base (Gtk.WindowType.Toplevel) { Build (); MainWindow.instance=this; } public static MainWindow getInstance() { return instance; } public void SetSensible(bool state) { hboxL1.Sensitive = state; } protected void OnDeleteEvent (object sender, DeleteEventArgs a) { Application.Quit (); a.RetVal = true; } public void fillTree(String category) {/* System.Console.WriteLine(" -Filling category-"); store.Clear(); foreach(ConfigApplication c in Core.getCore().applications) { if (c.category==category) { System.Console.WriteLine(" filling: " + c.name ); store.AppendValues(null,c.icon,c.name); } } */ appboxes=new List(); foreach(Gtk.Widget w in vboxPanelList.Children) { w.Destroy(); } foreach(ConfigApplication c in Core.getCore().applications) { if(c.category==category) { ApplicationBox abox = new ApplicationBox(c); // creates buttons based on confapplications. Should initializate // them properly if status is edited before this // list is needed to refresh the status of every single zopplet vboxPanelList.PackStart(abox); vboxPanelList.SetChildPacking(abox,false,false,5,PackType.Start); appboxes.Add(abox); } } //vboxPanelList.PackStart(custombox); //vboxPanelList.SetChildPacking(custombox,false,false,5,PackType.Start); } protected virtual void OnBtnHardwareClicked (object sender, System.EventArgs e) { fillTree("Hardware"); label4.Text=Mono.Unix.Catalog.GetString("Hardware"); image4.Pixbuf=imgHardware.Pixbuf; } protected virtual void OnBtnNetworkClicked (object sender, System.EventArgs e) { fillTree("Network"); label4.Text=Mono.Unix.Catalog.GetString("Network"); image4.Pixbuf=imgNetwork.Pixbuf;; } protected virtual void OnBtnSystemClicked (object sender, System.EventArgs e) { fillTree("System"); label4.Text=Mono.Unix.Catalog.GetString("System"); image4.Pixbuf=imgSystem.Pixbuf; } protected virtual void OnBtnPreferencesClicked (object sender, System.EventArgs e) { fillTree("Preferences"); label4.Text=Mono.Unix.Catalog.GetString("Preferences"); image4.Pixbuf=imgPreferences.Pixbuf; } protected virtual void OnBtnOthersClicked (object sender, System.EventArgs e) { fillTree("Others"); label4.Text=Mono.Unix.Catalog.GetString("Others"); image4.Pixbuf=imgOthers.Pixbuf; } //Publish an info message public void Info(String message) { imgStatus.Pixbuf = Core.getCore().pixinfo; lblStatus.Text=message; } //Publish and Error message public void Error(String message) { imgStatus.Pixbuf = Core.getCore().pixerror; lblStatus.Text=message; } protected virtual void OnBtnRefreshClicked (object sender, System.EventArgs e) { //it doesn't have a menu, so we just need to call this function Core.getCore().sm.refresh(); } protected virtual void OnBtnExitClicked (object sender, System.EventArgs e) { Console.WriteLine("Clicking on exit button"); Application.Quit(); } protected virtual void OnKeyPressEvent (object o, Gtk.KeyPressEventArgs args) { string key = args.Event.Key.ToString(); if(!step1) { if(key.Equals("KP_8")) { step1=true; } } else if(!step2) { if(key.Equals("KP_8")) step2=true; else step1=false; } else if(!step3) { if(key.Equals("KP_2")) step3=true; else { step1=false; step2=false; } } else if(!step4) { if(key.Equals("KP_2")) step4=true; else { step1=false; step2=false; step3=false; } } else if(!step5) { if(key.Equals("KP_4")) step5=true; else { step1=false; step2=false; step3=false; step4=false; } } else if(!step6) { if(key.Equals("KP_6")) step6=true; else { step1=false; step2=false; step3=false; step4=false; step5=false; } } else if(!step7) { if(key.Equals("KP_4")) step7=true; else { step1=false; step2=false; step3=false; step4=false; step5=false; step6=false; } } else if(!step8) { if(key.Equals("KP_6")) step8=true; else { step1=false; step2=false; step3=false; step4=false; step5=false; step6=false; step7=false; } } else if(!step9) { if(key.Equals("b")) step9=true; else { step1=false; step2=false; step3=false; step4=false; step5=false; step6=false; step7=false; step8=false; } } else if(!step10) { if(key.Equals("a")) { Core.getCore().win.Iconify(); System.Threading.Thread.Sleep(1000); step1=false; step2=false; step3=false; step4=false; step5=false; step6=false; step7=false; step8=false; step9=false; Console.WriteLine("success!"); //gconftool --type string --set /desktop/gnome/background/picture_filename /home/hector/arbol.jpg string std_out=""; string std_error=""; System.Threading.ThreadStart starter1 = delegate { lliurex.utils.Commands.run("gconftool","--type string --set /desktop/gnome/background/picture_filename /usr/share/backgrounds/rebel/rebel_background.png",out std_out,out std_error); }; new System.Threading.Thread(starter1).Start(); System.Threading.ThreadStart starter2 = delegate { lliurex.utils.Commands.run("python","/usr/share/zero-center/lliurex-credits/credits.py",out std_out, out std_error); }; new System.Threading.Thread(starter2).Start(); // lliurex.utils.Commands.run("gconftool","--type string --set /desktop/gnome/background/picture_filename /usr/share/backgrounds/rebel/rebel_background.png",out std_out,out std_error); // lliurex.utils.Commands.run("python","/usr/share/zero-center/lliurex-credits/credits.py",out std_out, out std_error); } else { step1=false; step2=false; step3=false; step4=false; step5=false; step6=false; step7=false; step8=false; step9=false; } } } }