override protected void PreInstallation(CStatusWindow sw) { //Herunterladen sw.Mainlabel = Catalog.GetString(CConfiguration.txtDownloadTheme); GetThemeFile(sw); sw.SetProgress("1/" + installationSteps); //Entpacken sw.Mainlabel = Catalog.GetString(CConfiguration.txtExtracting); System.Collections.ArrayList al = new System.Collections.ArrayList(); al = CUtility.UncompressFile(LocalThemeFile, Path.GetTempPath(), false, null, al); Folder = ((string)(al[0])).Split('/'); //Console.WriteLine(Folder[0]); sw.SetProgress("2/" + installationSteps); //Convertieren sw.Mainlabel = Catalog.GetString(CConfiguration.txtConvertingIcons); sw.SetProgress("3/" + installationSteps); CIconThemeManager iconmanager = new CIconThemeManager(); iconmanager.ThemeName = Folder[0]; iconmanager.StatusWindow = sw; iconmanager.ImportIcons(Path.GetTempPath() + Folder[0]); sw.SetProgress("4/" + installationSteps); iconmanager.SaveAllIcons(config.IconInstallPath + "/", true); //Sichern client = new GConf.Client(); sw.Mainlabel = Catalog.GetString(CConfiguration.txtSavingForRestore); prevIconTheme = (string)client.Get(GConfIconThemeKey); sw.SetProgress("5/" + installationSteps); }
//Downloads the selected theme if non-existant on the hd public void GetThemeFile(CStatusWindow sw, string downloadTo) { Gtk.ProgressBar bar = null; //Set the user hint if a status window is available if (sw != null) { bar = sw.DetailProgressBar; sw.Mainlabel = CConfiguration.txtDownloadTheme; } //user choosen download location available? if (downloadTo == "" || downloadTo == null) { downloadTo = LocalThemeFile; } else { downloadTo = Path.GetFullPath(downloadTo) + config.DirectorySeperator + Path.GetFileName(LocalThemeFile); } Console.Out.WriteLine("Downloading theme to : " + downloadTo); //Finally - download the theme if (this is CBackgroundTheme) { DownloadFile((this as CBackgroundTheme).Image.URL, downloadTo, sw.DetailProgressBar); } else { DownloadFile(DownloadUrl, downloadTo, bar); } }
protected override void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel=Catalog.GetString(CConfiguration.txtInstalling); client.Set(GConfApplicationKey,ConOutp.ToString().Split('/')[0]); sw.Mainlabel=Catalog.GetString(CConfiguration.txtInstallDone); }
override protected void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel = CConfiguration.txtInstalling; client.Set(GConfShowSplashKey, true); client.Set(GConfSplashImageKey, InstallThemeFile); }
protected override void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel=CConfiguration.txtInstalling; client.Set(GConfShowSplashKey,true); client.Set(GConfSplashImageKey,InstallThemeFile); }
protected override void PreInstallation(CStatusWindow sw) { //Herunterladen sw.Mainlabel=Catalog.GetString(CConfiguration.txtDownloadTheme); GetThemeFile(sw); sw.SetProgress("1/"+installationSteps); //Entpacken sw.Mainlabel=Catalog.GetString(CConfiguration.txtExtracting); System.Collections.ArrayList al = new System.Collections.ArrayList(); al = CUtility.UncompressFile(LocalThemeFile,Path.GetTempPath(),false, null,al); Folder = ((string)(al[0])).Split('/'); //Console.WriteLine(Folder[0]); sw.SetProgress("2/"+installationSteps); //Convertieren sw.Mainlabel=Catalog.GetString(CConfiguration.txtConvertingIcons); sw.SetProgress("3/"+installationSteps); CIconThemeManager iconmanager = new CIconThemeManager(); iconmanager.ThemeName = Folder[0]; iconmanager.StatusWindow = sw; iconmanager.ImportIcons(Path.GetTempPath()+Folder[0]); sw.SetProgress("4/"+installationSteps); iconmanager.SaveAllIcons(config.IconInstallPath+"/",true); //Sichern client = new GConf.Client(); sw.Mainlabel=Catalog.GetString(CConfiguration.txtSavingForRestore); prevIconTheme=(string)client.Get(GConfIconThemeKey); sw.SetProgress("5/"+installationSteps); }
override protected void PreInstallation(CStatusWindow sw) { string tarParams = ""; client = new GConf.Client(); LocalThemeFile = config.ThemesPath + Path.GetFileName(DownloadUrl); string InstallThemeFile = config.ApplicationInstallPath + Path.GetFileName(DownloadUrl); tarParams = CUtility.GetTarParams(Path.GetExtension(DownloadUrl)); sw.Mainlabel = Catalog.GetString(CConfiguration.txtDownloadTheme); //Herunterladen if (!File.Exists(InstallThemeFile)) { GetThemeFile(sw); } sw.SetProgress("1/" + installationSteps); //Entpacken sw.Mainlabel = Catalog.GetString(CConfiguration.txtExtracting); Console.WriteLine("Command: tar" + tarParams + LocalThemeFile + " -C " + config.ApplicationInstallPath); ConOutp = CUtility.Execute("tar", tarParams + LocalThemeFile + " -C " + config.ApplicationInstallPath); sw.SetProgress("2/" + installationSteps); //Sichern sw.Mainlabel = Catalog.GetString(CConfiguration.txtSavingForRestore); previousApplicationTheme = (string)client.Get(GConfApplicationKey); sw.SetProgress("3/" + installationSteps); }
override protected void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel = CConfiguration.txtInstalling; client.Set(GConfBgKey, InstallThemeFile); client.Set(GConfISKey, currentStyleString); }
protected override void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel=Catalog.GetString(CConfiguration.txtInstalling); System.Threading.Thread.Sleep(500); client.Set(GConfDecorationKey,ConOutp.ToString().Split('/')[0]); sw.Mainlabel=Catalog.GetString(CConfiguration.txtInstallDone); }
override protected void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel = Catalog.GetString(CConfiguration.txtInstalling); System.Threading.Thread.Sleep(500); client.Set(GConfDecorationKey, ConOutp.ToString().Split('/')[0]); sw.Mainlabel = Catalog.GetString(CConfiguration.txtInstallDone); }
override protected void PreInstallation(CStatusWindow sw) { gdmConfAvailable = File.Exists(gdmconf); gdmConfCustomAvailable = File.Exists(gdmconfcustom); if (!gdmConfAvailable) { throw new Exception(Catalog.GetString("Installation is not possible!") + "-" + Catalog.GetString(String.Format("No {0} available", gdmconf))); } if (!installationIsPossible) { throw new Exception(Catalog.GetString("Installation is not possible!") + "-" + Catalog.GetString("Only GDM is supported")); } //TODO: grep ersetzen durch IniWorker sb = CUtility.Execute("grep", "GraphicalThemeRand= " + gdmconf); if (sb.Length < 1) { Console.WriteLine("Warning:grep returned no GraphicalThemeRand-Entry\""); randomThemeActive = false; } else { randomThemeActive = bool.Parse(sb.ToString().Split('=')[1]); } //Falls nicht vorhanden wird sie erzeugt if (!gdmConfCustomAvailable) { try{ FileStream fs = File.Create(gdmconfcustomtemp); fs.Close(); CUtility.ExecuteSu(config, "mv " + gdmconfcustomtemp + " " + gdmconfcustom); } catch { throw new Exception("Gdm.conf-custom couldn't be created, aborting!"); } } sw.SetProgress("1/" + installationSteps); //Datei einlesen iworker = new CIniWorker(gdmconfcustom); iworker.CreateSections("daemon;security;xdmcp;gui;greeter;chooser;debug;servers", ';'); //Entpackparameter tarParams = @"tar " + CUtility.GetTarParams(DownloadUrl); //Herunterladen GetThemeFile(sw); sw.SetProgress("2/" + installationSteps); //Entpacken sw.Mainlabel = CConfiguration.txtExtracting; sb = CUtility.ExecuteSu(config, @tarParams + @LocalThemeFile + " -C " + @config.GdmInstallPath); FolderName = sb.ToString().Split('/'); if (FolderName[0] == "") { throw new Exception(Catalog.GetString("Couldn't get any usefull information from the tar-command...aborting")); } //Console.WriteLine(FolderName[0]); sw.SetProgress("3/" + installationSteps); }
//Die für die jeweilige Option richtige XMLDatei herunterladen wenn sie veraltet ist private void getXMLFile(bool ForceReload) { DateTime localFileDate; int daysBetween = 0; string remoteUri = config.XmlFileUrl(); string localFileName = config.ArtFilePath(); bool downloadFile = false; if (!ForceReload) { if (File.Exists(localFileName)) { localFileDate = File.GetLastWriteTime(localFileName).Date; daysBetween = DateTime.Now.Date.Subtract(localFileDate).Days; if (daysBetween >= config.XmlRefreshInterval) { Console.WriteLine("Xml file too old ({0} day(s) since last download - downloading new one", daysBetween); downloadFile = true; } } else { downloadFile = true; } } else { downloadFile = true; } if (downloadFile) { CStatusWindow sw = new CStatusWindow(Catalog.GetString("Downloading new XML file"), 1, false, true, true); sw.ButtonSensitive = false; sw.ExtInfoLabel = Catalog.GetString("Downloading") + ": " + remoteUri; sw.Mainlabel = Catalog.GetString("<i>XML file is being downloaded</i>\n\nThis program needs a descriptive " + "file that contains information about \n\n1) where the theme is located," + "\n2) what kind of theme is it, \n3) How often someone downloaded it," + " and so on \n\nSo please be patient while the download progress is going on.."); sw.SetProgress(Catalog.GetString("downloading... (no progress available)")); sw.Invalidate(); try { (new CFileDownloader(config)).DownloadFile(remoteUri, localFileName, sw.DetailProgressBar); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Warning: Could not download xml file!"), ex.Message, Gtk.Stock.DialogError, true); } sw.Close(); } }
override protected void PreInstallation(CStatusWindow sw) { InstallThemeFile = config.SplashInstallPath + Path.GetFileName(DownloadUrl); //Neuer GConfClient client = new GConf.Client(); //Sicherung sw.Mainlabel = CConfiguration.txtSavingForRestore; splashWasActive = (bool)client.Get(GConfShowSplashKey); prevSplash = (string)client.Get(GConfSplashImageKey); sw.SetProgress("1/" + installationSteps); sw.Mainlabel = CConfiguration.txtDownloadTheme; //Herunterladen if (!File.Exists(InstallThemeFile)) { GetThemeFile(sw); File.Copy(LocalThemeFile, InstallThemeFile); } sw.SetProgress("2/" + installationSteps); }
/* * 2 Dateien sind wichtig: * /etc/gdm/gdm.conf um herauszufinden ob u.U Multiselect gewählt ist * /etc/gdm/gdm.conf-custom um die gewählten Themes herauszulesen und zu setzen */ protected override void Installation(CStatusWindow sw) { //Eintrag "GraphicalTheme=Themename" sw.Mainlabel=CConfiguration.txtInstalling; if (!randomThemeActive){ //Sichern previousTheme = iworker.getValue("greeter","GraphicalTheme",true); //Console.WriteLine("PreviousTheme: "+previousTheme); iworker.setValue("greeter","GraphicalTheme",FolderName[0],true); //Kopieren an einen Ort an dem Schreibberechtigung vorhanden ist iworker.Save(gdmconfcustomtemp); //Per gksudo den Benutzer für diese Aktion zum Superuser werden lassen CUtility.ExecuteSu(config,"mv "+gdmconfcustomtemp+" /etc/gdm/"); } else{ //TODO: für Random } //GDM die Änderungen mitteilen CUtility.Execute("gdmflexiserver", "--command=\"UPDATE_CONFIG greeter/GraphicalTheme\""); }
protected override void PreInstallation(CStatusWindow sw) { string tarParams=""; client = new GConf.Client(); tarParams=CUtility.GetTarParams(Path.GetExtension(DownloadUrl)); sw.Mainlabel=Catalog.GetString(CConfiguration.txtDownloadTheme); if (!File.Exists(LocalThemeFile)) GetThemeFile(sw); sw.SetProgress("1/"+installationSteps); //Entpacken sw.Mainlabel=Catalog.GetString(CConfiguration.txtExtracting); Console.WriteLine("Command: tar"+tarParams+LocalThemeFile+" -C "+config.DecorationInstallPath); ConOutp = CUtility.Execute("tar",tarParams+LocalThemeFile+" -C "+config.DecorationInstallPath); sw.SetProgress("2/"+installationSteps); //Sichern sw.Mainlabel=Catalog.GetString(CConfiguration.txtSavingForRestore); previousDecorationTheme = (string)client.Get(GConfDecorationKey); sw.SetProgress("3/"+installationSteps); }
/* * 2 Dateien sind wichtig: * /etc/gdm/gdm.conf um herauszufinden ob u.U Multiselect gewählt ist * /etc/gdm/gdm.conf-custom um die gewählten Themes herauszulesen und zu setzen */ override protected void Installation(CStatusWindow sw) { //Eintrag "GraphicalTheme=Themename" sw.Mainlabel = CConfiguration.txtInstalling; if (!randomThemeActive) { //Sichern previousTheme = iworker.getValue("greeter", "GraphicalTheme", true); //Console.WriteLine("PreviousTheme: "+previousTheme); iworker.setValue("greeter", "GraphicalTheme", FolderName[0], true); //Kopieren an einen Ort an dem Schreibberechtigung vorhanden ist iworker.Save(gdmconfcustomtemp); //Per gksudo den Benutzer für diese Aktion zum Superuser werden lassen CUtility.ExecuteSu(config, "mv " + gdmconfcustomtemp + " /etc/gdm/"); } else { //TODO: für Random } //GDM die Änderungen mitteilen CUtility.Execute("gdmflexiserver", "--command=\"UPDATE_CONFIG greeter/GraphicalTheme\""); }
//Theme installieren und Revert verfügbar machen public virtual void StartInstallation() { CStatusWindow sw = new CStatusWindow(Catalog.GetString(String.Format("Installing \"{0}\"", Name)), installationSteps, false, false, true); sw.Mainlabel = Catalog.GetString("<i>Installing</i>\n\nYour selection is being downloaded and installed...please be" + " patient while the installation procedure proceeds. After everything's done, this" + " window will get closed.\n\n Have fun with your new theme, Greetings Tom"); try{ PreInstallation(sw); Installation(sw); PostInstallation(sw); sw.SetProgress(installationSteps + "/" + installationSteps); sw.Mainlabel = CConfiguration.txtInstallDone; sw.DetailProgressBar.Fraction = 1.0; sw.DetailProgressBar.Text = Catalog.GetString("All changes have been applied"); //Hint:It's enough to change the caption to the stock item!! No need for image transformations! sw.ButtonCaption = "gtk-ok"; } catch (Exception ex) { sw.Close(); CInfoWindow iw = new CInfoWindow("<b>" + Catalog.GetString("Theme installation failed!") + "</b>", Catalog.GetString("This message was reported from the installation function:\n\n"), Gtk.Stock.DialogError, true); iw.Description = ex.Message; } }
//Downloads the selected theme if non-existant on the hd public void GetThemeFile(CStatusWindow sw, string downloadTo) { Gtk.ProgressBar bar=null; //Set the user hint if a status window is available if (sw!=null){ bar=sw.DetailProgressBar; sw.Mainlabel=CConfiguration.txtDownloadTheme; } //user choosen download location available? if (downloadTo=="" || downloadTo==null) downloadTo = LocalThemeFile; else downloadTo = Path.GetFullPath(downloadTo)+config.DirectorySeperator+Path.GetFileName(LocalThemeFile); Console.Out.WriteLine("Downloading theme to : "+ downloadTo); //Finally - download the theme if (this is CBackgroundTheme) DownloadFile((this as CBackgroundTheme).Image.URL, downloadTo, sw.DetailProgressBar); else DownloadFile(DownloadUrl, downloadTo, bar); }
public void GetThemeFile(CStatusWindow sw) { GetThemeFile(sw,null); }
protected override void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel=Catalog.GetString(CConfiguration.txtInstalling); client.Set(GConfIconThemeKey,Folder[0]); }
override protected void PostInstallation(CStatusWindow sw) { sw.Mainlabel = Catalog.GetString(CConfiguration.txtInstallDone); revertIsAvailable = true; }
public void GetAllThumbs() { ArrayList list = getThemeList(); ArrayList downloadList = new ArrayList(); CTheme theme; int themeCount=list.Count; CStatusWindow w= new CStatusWindow(Catalog.GetString("Reading thumbnails on harddisc"),themeCount,true,false,true); w.ButtonSensitive=false; //Thumbs von der Platte lesen for (int i=0;i<(int)(themeCount);i++){ theme = ((CTheme)list[i]); w.SetProgress((i+1).ToString()+"/"+themeCount.ToString()); w.ExtInfoLabel = theme.SmallThumbnailUrl; if (!theme.LocalThumbExists) downloadList.Add(theme); else theme.GetThumbnailImage(w.DetailProgressBar); } //Thumbs herunterladen int downloadCount=downloadList.Count; if (downloadCount>0){ w.Headline=Catalog.GetString("Downloading missing thumbnails"); w.ButtonSensitive=true; w.SetProgressStep(downloadList.Count); Console.WriteLine("New files: "+downloadList.Count); //Thread[] ta = new Thread[downloadCount]; for (int i=0;i<downloadList.Count;i++){ if (w.CloseRequested){ break; } theme = ((CTheme)downloadList[i]); w.SetProgress((i+1).ToString()+"/"+downloadCount.ToString()); w.ExtInfoLabel = Path.GetFileName(theme.SmallThumbnailUrl); /*Threading ta[i] = new Thread(new ThreadStart(theme.GetThumbnailImage)); ta[i].Start(); // Threads werden gestartet */ try{ theme.GetThumbnailImage(w.DetailProgressBar); } catch (Exception ex){ Console.WriteLine("Error while downloading file: "+ex.Message); } } /* Threading bool done=false; while (!done){ done=true; for (int k=0;k<downloadCount;k++){ if (ta[k].ThreadState != ThreadState.Stopped) done=false; } } */ } w.Close(); }
private void OnPreviewButtonClicked(object sender, EventArgs e) { CStatusWindow sw=new CStatusWindow(Catalog.GetString("Downloading the preview file"),1,false,true,true); sw.SetProgress("1/1 - " +Catalog.GetString("Connected to art.gnome.org")); sw.Mainlabel=Catalog.GetString("<i>Downloading the preview file</i>\n\nYour preview is being downloaded. After the download has been finished,"+ " the preview will be rescaled if it's not fitting the preview window. See the lower bar to follow the progress."); sw.ButtonSensitive=false; try{ man.Theme.GetPreviewImage(sw.DetailProgressBar); sw.Close(); new CPreviewWindow(man.Theme,true); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Error: the preview image could not be loaded!"),ex.Message,Gtk.Stock.DialogError,true); } }
//Die für die jeweilige Option richtige XMLDatei herunterladen wenn sie veraltet ist private void getXMLFile(bool ForceReload) { DateTime localFileDate; int daysBetween=0; string remoteUri = config.XmlFileUrl(); string localFileName = config.ArtFilePath(); bool downloadFile=false; if (!ForceReload){ if (File.Exists(localFileName)) { localFileDate = File.GetLastWriteTime(localFileName).Date; daysBetween = DateTime.Now.Date.Subtract(localFileDate).Days; if ( daysBetween >= config.XmlRefreshInterval) { Console.WriteLine("Xml file too old ({0} day(s) since last download - downloading new one",daysBetween); downloadFile = true; } } else { downloadFile=true; } } else downloadFile=true; if (downloadFile){ CStatusWindow sw= new CStatusWindow(Catalog.GetString("Downloading new XML file"),1,false,true,true); sw.ButtonSensitive=false; sw.ExtInfoLabel=Catalog.GetString("Downloading")+": " + remoteUri; sw.Mainlabel=Catalog.GetString("<i>XML file is being downloaded</i>\n\nThis program needs a descriptive "+ "file that contains information about \n\n1) where the theme is located,"+ "\n2) what kind of theme is it, \n3) How often someone downloaded it,"+ " and so on \n\nSo please be patient while the download progress is going on.."); sw.SetProgress(Catalog.GetString("downloading... (no progress available)")); sw.Invalidate(); try { (new CFileDownloader(config)).DownloadFile(remoteUri,localFileName,sw.DetailProgressBar); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Warning: Could not download xml file!"),ex.Message,Gtk.Stock.DialogError,true); } sw.Close(); } }
protected override void PostInstallation(CStatusWindow sw) { revertIsAvailable=true; }
protected override void PreInstallation(CStatusWindow sw) { }
protected abstract void Installation(CStatusWindow sw);
override protected void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel = Catalog.GetString(CConfiguration.txtInstalling); client.Set(GConfIconThemeKey, Folder[0]); }
override protected void PreInstallation(CStatusWindow sw) { InstallThemeFile = config.SplashInstallPath + Path.GetFileName(Image.URL); //Set the localPreviewFile to the downloaded file to fasten the preview localPreviewFile = LocalThemeFile; Console.WriteLine(LocalPreviewFile); sw.Mainlabel = CConfiguration.txtSavingForRestore; //Sichern client = new GConf.Client(); prevBackground = (string)client.Get(GConfBgKey); prevStyle = (string)client.Get(GConfISKey); sw.SetProgress("1/" + installationSteps); //Index und Type wurden vorher schon gwählt sw.Mainlabel = CConfiguration.txtDownloadTheme; if (!File.Exists(LocalThemeFile)) { if (!File.Exists(LocalPreviewFile)) { GetThemeFile(sw); } else { File.Copy(LocalPreviewFile, LocalThemeFile); Console.Out.WriteLine(LocalPreviewFile + " --- " + LocalThemeFile); } } try{ File.Copy(LocalThemeFile, InstallThemeFile); } catch {} ///home/.../.gnome2/backgrounds.xml einlesen und Background anhängen... //Just a hack...TODO:paste in XMLDoc if (!File.Exists(config.HomePath + ".gnome2/backgrounds.xml")) { StreamWriter locFile = new StreamWriter(config.HomePath + ".gnome2/backgrounds.xml"); locFile.WriteLine("<?xml version=\"1.0\"?>"); locFile.WriteLine("<!DOCTYPE wallpapers SYSTEM \"gnome-wp-list.dtd\"[]>"); locFile.WriteLine(" <wallpapers>"); locFile.WriteLine(" </wallpapers>"); locFile.Close(); } XmlDocument doc = new XmlDocument(); doc.Load(config.HomePath + ".gnome2/backgrounds.xml"); //Nach schon vorhandenem Eintrag in Backgrounds suchen XmlNode foundNode = doc.SelectSingleNode("wallpapers/wallpaper[filename='" + InstallThemeFile + "']"); if (foundNode != null) { XmlNodeList list = foundNode.ChildNodes; //Console.WriteLine("Count:"+list.Count); foreach (XmlNode node in list) { if (node.Name == "options") { Console.WriteLine(node.InnerText); node.InnerText = currentStyleString; break; } } } else { XmlNode newElem; XmlNode wallpaper = doc.CreateNode(XmlNodeType.Element, "wallpaper", ""); ((XmlElement)wallpaper).SetAttribute("deleted", "false"); newElem = doc.CreateNode(XmlNodeType.Element, "name", ""); newElem.InnerText = Path.GetFileName(InstallThemeFile); wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "filename", ""); newElem.InnerText = InstallThemeFile; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "options", ""); newElem.InnerText = currentStyleString; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "shade_type", ""); newElem.InnerText = "solid"; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "pcolor", ""); newElem.InnerText = "#dadab0b08282"; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "scolor", ""); newElem.InnerText = "#dadab0b08282"; wallpaper.AppendChild(newElem); doc.DocumentElement.AppendChild(wallpaper); } doc.Save(config.HomePath + ".gnome2/backgrounds.xml"); sw.SetProgress("2/" + installationSteps); }
//Theme installieren und Revert verfügbar machen public virtual void StartInstallation() { CStatusWindow sw=new CStatusWindow(Catalog.GetString(String.Format("Installing \"{0}\"",Name)),installationSteps,false,false,true); sw.Mainlabel=Catalog.GetString("<i>Installing</i>\n\nYour selection is being downloaded and installed...please be"+ " patient while the installation procedure proceeds. After everything's done, this"+ " window will get closed.\n\n Have fun with your new theme, Greetings Tom"); try{ PreInstallation(sw); Installation(sw); PostInstallation(sw); sw.SetProgress(installationSteps+"/"+installationSteps); sw.Mainlabel=CConfiguration.txtInstallDone; sw.DetailProgressBar.Fraction=1.0; sw.DetailProgressBar.Text = Catalog.GetString("All changes have been applied"); //Hint:It's enough to change the caption to the stock item!! No need for image transformations! sw.ButtonCaption = "gtk-ok"; } catch (Exception ex) { sw.Close(); CInfoWindow iw = new CInfoWindow("<b>"+Catalog.GetString("Theme installation failed!")+"</b>",Catalog.GetString("This message was reported from the installation function:\n\n"),Gtk.Stock.DialogError,true); iw.Description = ex.Message; } }
protected override void PreInstallation(CStatusWindow sw) { InstallThemeFile = config.SplashInstallPath+Path.GetFileName(Image.URL); //Set the localPreviewFile to the downloaded file to fasten the preview localPreviewFile = LocalThemeFile; Console.WriteLine(LocalPreviewFile); sw.Mainlabel=CConfiguration.txtSavingForRestore; //Sichern client = new GConf.Client(); prevBackground=(string)client.Get(GConfBgKey); prevStyle = (string)client.Get(GConfISKey); sw.SetProgress("1/"+installationSteps); //Index und Type wurden vorher schon gwählt sw.Mainlabel=CConfiguration.txtDownloadTheme; if (!File.Exists(LocalThemeFile)) { if (!File.Exists(LocalPreviewFile)) { GetThemeFile(sw); } else { File.Copy(LocalPreviewFile,LocalThemeFile); Console.Out.WriteLine(LocalPreviewFile + " --- " + LocalThemeFile); } } try{File.Copy(LocalThemeFile,InstallThemeFile);} catch{} ///home/.../.gnome2/backgrounds.xml einlesen und Background anhängen... //Just a hack...TODO:paste in XMLDoc if (!File.Exists(config.HomePath+".gnome2/backgrounds.xml")){ StreamWriter locFile = new StreamWriter(config.HomePath+".gnome2/backgrounds.xml"); locFile.WriteLine("<?xml version=\"1.0\"?>"); locFile.WriteLine("<!DOCTYPE wallpapers SYSTEM \"gnome-wp-list.dtd\"[]>"); locFile.WriteLine(" <wallpapers>"); locFile.WriteLine(" </wallpapers>"); locFile.Close(); } XmlDocument doc = new XmlDocument(); doc.Load(config.HomePath+".gnome2/backgrounds.xml"); //Nach schon vorhandenem Eintrag in Backgrounds suchen XmlNode foundNode = doc.SelectSingleNode("wallpapers/wallpaper[filename='"+InstallThemeFile+"']"); if (foundNode != null){ XmlNodeList list = foundNode.ChildNodes; //Console.WriteLine("Count:"+list.Count); foreach (XmlNode node in list){ if (node.Name=="options"){ Console.WriteLine(node.InnerText); node.InnerText=currentStyleString; break; } } } else { XmlNode newElem; XmlNode wallpaper = doc.CreateNode(XmlNodeType.Element,"wallpaper",""); ((XmlElement)wallpaper).SetAttribute("deleted","false"); newElem = doc.CreateNode(XmlNodeType.Element, "name", ""); newElem.InnerText = Path.GetFileName(InstallThemeFile); wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "filename", ""); newElem.InnerText = InstallThemeFile; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "options", ""); newElem.InnerText = currentStyleString; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "shade_type", ""); newElem.InnerText = "solid"; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "pcolor", ""); newElem.InnerText = "#dadab0b08282"; wallpaper.AppendChild(newElem); newElem = doc.CreateNode(XmlNodeType.Element, "scolor", ""); newElem.InnerText = "#dadab0b08282"; wallpaper.AppendChild(newElem); doc.DocumentElement.AppendChild(wallpaper); } doc.Save(config.HomePath+".gnome2/backgrounds.xml"); sw.SetProgress("2/"+installationSteps); }
//3 Methoden: PreInstallation(), PostInstallation() und Installation(); //Eine wird vor der Installation ausgeführt, eine nachher und eine zur eigentlichen Installation protected abstract void PreInstallation(CStatusWindow sw);
public void GetThemeFile(CStatusWindow sw) { GetThemeFile(sw, null); }
override protected void PostInstallation(CStatusWindow sw) { //Revert verfügbar machen revertIsAvailable = true; }
protected override void PreInstallation(CStatusWindow sw) { InstallThemeFile=config.SplashInstallPath+Path.GetFileName(DownloadUrl); //Neuer GConfClient client = new GConf.Client(); //Sicherung sw.Mainlabel=CConfiguration.txtSavingForRestore; splashWasActive = (bool)client.Get(GConfShowSplashKey); prevSplash = (string)client.Get(GConfSplashImageKey); sw.SetProgress("1/"+installationSteps); sw.Mainlabel=CConfiguration.txtDownloadTheme; //Herunterladen if (!File.Exists(InstallThemeFile)){ GetThemeFile(sw); File.Copy(LocalThemeFile,InstallThemeFile); } sw.SetProgress("2/"+installationSteps); }
private void OnSaveButtonClicked(object sender, EventArgs e) { CStatusWindow sw=new CStatusWindow(Catalog.GetString("Downloading the theme"),1,false,true,true); sw.ExtInfoLabel = Catalog.GetString("Download location")+": "+config.ThemesDownloadPath; sw.ButtonSensitive=false; try{ man.Theme.GetThemeFile(sw,config.ThemesDownloadPath); sw.Close(); } catch (Exception ex) { sw.Close(); new CInfoWindow(Catalog.GetString("Error")+":"+Catalog.GetString("Download failed!"),ex.Message,Gtk.Stock.DialogError,true); } }
protected override void PostInstallation(CStatusWindow sw) { sw.Mainlabel=Catalog.GetString(CConfiguration.txtInstallDone); revertIsAvailable=true; }
public void GetAllThumbs() { ArrayList list = getThemeList(); ArrayList downloadList = new ArrayList(); CTheme theme; int themeCount = list.Count; CStatusWindow w = new CStatusWindow(Catalog.GetString("Reading thumbnails on harddisc"), themeCount, true, false, true); w.ButtonSensitive = false; //Thumbs von der Platte lesen for (int i = 0; i < (int)(themeCount); i++) { theme = ((CTheme)list[i]); w.SetProgress((i + 1).ToString() + "/" + themeCount.ToString()); w.ExtInfoLabel = theme.SmallThumbnailUrl; if (!theme.LocalThumbExists) { downloadList.Add(theme); } else { theme.GetThumbnailImage(w.DetailProgressBar); } } //Thumbs herunterladen int downloadCount = downloadList.Count; if (downloadCount > 0) { w.Headline = Catalog.GetString("Downloading missing thumbnails"); w.ButtonSensitive = true; w.SetProgressStep(downloadList.Count); Console.WriteLine("New files: " + downloadList.Count); //Thread[] ta = new Thread[downloadCount]; for (int i = 0; i < downloadList.Count; i++) { if (w.CloseRequested) { break; } theme = ((CTheme)downloadList[i]); w.SetProgress((i + 1).ToString() + "/" + downloadCount.ToString()); w.ExtInfoLabel = Path.GetFileName(theme.SmallThumbnailUrl); /*Threading * ta[i] = new Thread(new ThreadStart(theme.GetThumbnailImage)); * ta[i].Start(); // Threads werden gestartet */ try{ theme.GetThumbnailImage(w.DetailProgressBar); } catch (Exception ex) { Console.WriteLine("Error while downloading file: " + ex.Message); } } /* Threading * bool done=false; * while (!done){ * done=true; * for (int k=0;k<downloadCount;k++){ * if (ta[k].ThreadState != ThreadState.Stopped) * done=false; * } * * } */ } w.Close(); }
protected override void PreInstallation(CStatusWindow sw) { gdmConfAvailable=File.Exists(gdmconf); gdmConfCustomAvailable=File.Exists(gdmconfcustom); if (!gdmConfAvailable) throw new Exception(Catalog.GetString("Installation is not possible!")+"-"+Catalog.GetString(String.Format("No {0} available",gdmconf))); if (!installationIsPossible) throw new Exception(Catalog.GetString("Installation is not possible!")+"-"+Catalog.GetString("Only GDM is supported")); //TODO: grep ersetzen durch IniWorker sb = CUtility.Execute("grep","GraphicalThemeRand= "+gdmconf); if (sb.Length<1){ Console.WriteLine("Warning:grep returned no GraphicalThemeRand-Entry\""); randomThemeActive=false; } else randomThemeActive=bool.Parse(sb.ToString().Split('=')[1]); //Falls nicht vorhanden wird sie erzeugt if (!gdmConfCustomAvailable){ try{ FileStream fs = File.Create(gdmconfcustomtemp); fs.Close(); CUtility.ExecuteSu(config,"mv "+gdmconfcustomtemp+" "+gdmconfcustom); } catch {throw new Exception("Gdm.conf-custom couldn't be created, aborting!");} } sw.SetProgress("1/"+installationSteps); //Datei einlesen iworker = new CIniWorker(gdmconfcustom); iworker.CreateSections("daemon;security;xdmcp;gui;greeter;chooser;debug;servers",';'); //Entpackparameter tarParams = @"tar "+CUtility.GetTarParams(DownloadUrl); //Herunterladen GetThemeFile(sw); sw.SetProgress("2/"+installationSteps); //Entpacken sw.Mainlabel = CConfiguration.txtExtracting; sb = CUtility.ExecuteSu(config,@tarParams+@LocalThemeFile+" -C "[email protected]); FolderName=sb.ToString().Split('/'); if (FolderName[0]=="") throw new Exception(Catalog.GetString("Couldn't get any usefull information from the tar-command...aborting")); //Console.WriteLine(FolderName[0]); sw.SetProgress("3/"+installationSteps); }
protected override void PostInstallation(CStatusWindow sw) { //Revert verfügbar machen revertIsAvailable=true; }
override protected void PostInstallation(CStatusWindow sw) { }
override protected void PostInstallation(CStatusWindow sw) { revertIsAvailable = true; }
override protected void Installation(CStatusWindow sw) { throw new Exception(Catalog.GetString("Not yet implemented!!")); }
protected override void Installation(CStatusWindow sw) { //Installieren sw.Mainlabel=CConfiguration.txtInstalling; client.Set(GConfBgKey,InstallThemeFile); client.Set(GConfISKey,currentStyleString); }
protected override void Installation(CStatusWindow sw) { throw new Exception(Catalog.GetString("Not yet implemented!!")); }