diff --git a/.gitignore b/.gitignore index 86b4fbc2..f1e9c0a1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ plugins/wmpa/wmpa_h.h plugins/wmpa/wmpa_i.c src/pixmaps/inline_pngs.h +src/xtm/obj/* win32/build/* win32/ipch/* win32/xchat.opensdf diff --git a/src/xtm/Main.Designer.cs b/src/xtm/Main.Designer.cs new file mode 100644 index 00000000..16d4ebcc --- /dev/null +++ b/src/xtm/Main.Designer.cs @@ -0,0 +1,302 @@ +namespace thememan +{ + partial class XTM + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(XTM)); + this.themelist = new System.Windows.Forms.ListBox(); + this.themecolor0 = new System.Windows.Forms.Label(); + this.themecolor1 = new System.Windows.Forms.Label(); + this.themecolor2 = new System.Windows.Forms.Label(); + this.themecolor3 = new System.Windows.Forms.Label(); + this.themecolor4 = new System.Windows.Forms.Label(); + this.themecolor5 = new System.Windows.Forms.Label(); + this.themecolor6 = new System.Windows.Forms.Label(); + this.themecolor7 = new System.Windows.Forms.Label(); + this.themecolor8 = new System.Windows.Forms.Label(); + this.themecolor9 = new System.Windows.Forms.Label(); + this.themecolora = new System.Windows.Forms.Label(); + this.themecolorb = new System.Windows.Forms.Label(); + this.themecolorc = new System.Windows.Forms.Label(); + this.themecolord = new System.Windows.Forms.Label(); + this.themecolore = new System.Windows.Forms.Label(); + this.themecolorf = new System.Windows.Forms.Label(); + this.themecolorfg = new System.Windows.Forms.Label(); + this.themecolortextbg = new System.Windows.Forms.Label(); + this.importbutton = new System.Windows.Forms.Button(); + this.applybutton = new System.Windows.Forms.Button(); + this.themecolorfgmarked = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // themelist + // + this.themelist.FormattingEnabled = true; + this.themelist.Location = new System.Drawing.Point(12, 12); + this.themelist.Name = "themelist"; + this.themelist.Size = new System.Drawing.Size(154, 199); + this.themelist.TabIndex = 0; + this.themelist.SelectedIndexChanged += new System.EventHandler(this.theme_selected); + // + // themecolor0 + // + this.themecolor0.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor0.Location = new System.Drawing.Point(189, 36); + this.themecolor0.Name = "themecolor0"; + this.themecolor0.Size = new System.Drawing.Size(40, 40); + this.themecolor0.TabIndex = 6; + // + // themecolor1 + // + this.themecolor1.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor1.Location = new System.Drawing.Point(239, 36); + this.themecolor1.Name = "themecolor1"; + this.themecolor1.Size = new System.Drawing.Size(40, 40); + this.themecolor1.TabIndex = 10; + // + // themecolor2 + // + this.themecolor2.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor2.Location = new System.Drawing.Point(289, 36); + this.themecolor2.Name = "themecolor2"; + this.themecolor2.Size = new System.Drawing.Size(40, 40); + this.themecolor2.TabIndex = 14; + // + // themecolor3 + // + this.themecolor3.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor3.Location = new System.Drawing.Point(339, 36); + this.themecolor3.Name = "themecolor3"; + this.themecolor3.Size = new System.Drawing.Size(40, 40); + this.themecolor3.TabIndex = 18; + // + // themecolor4 + // + this.themecolor4.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor4.Location = new System.Drawing.Point(189, 87); + this.themecolor4.Name = "themecolor4"; + this.themecolor4.Size = new System.Drawing.Size(40, 40); + this.themecolor4.TabIndex = 4; + // + // themecolor5 + // + this.themecolor5.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor5.Location = new System.Drawing.Point(239, 87); + this.themecolor5.Name = "themecolor5"; + this.themecolor5.Size = new System.Drawing.Size(40, 40); + this.themecolor5.TabIndex = 8; + // + // themecolor6 + // + this.themecolor6.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor6.Location = new System.Drawing.Point(289, 87); + this.themecolor6.Name = "themecolor6"; + this.themecolor6.Size = new System.Drawing.Size(40, 40); + this.themecolor6.TabIndex = 12; + // + // themecolor7 + // + this.themecolor7.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor7.Location = new System.Drawing.Point(339, 87); + this.themecolor7.Name = "themecolor7"; + this.themecolor7.Size = new System.Drawing.Size(40, 40); + this.themecolor7.TabIndex = 16; + // + // themecolor8 + // + this.themecolor8.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor8.Location = new System.Drawing.Point(189, 138); + this.themecolor8.Name = "themecolor8"; + this.themecolor8.Size = new System.Drawing.Size(40, 40); + this.themecolor8.TabIndex = 5; + // + // themecolor9 + // + this.themecolor9.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolor9.Location = new System.Drawing.Point(239, 138); + this.themecolor9.Name = "themecolor9"; + this.themecolor9.Size = new System.Drawing.Size(40, 40); + this.themecolor9.TabIndex = 9; + // + // themecolora + // + this.themecolora.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolora.Location = new System.Drawing.Point(289, 138); + this.themecolora.Name = "themecolora"; + this.themecolora.Size = new System.Drawing.Size(40, 40); + this.themecolora.TabIndex = 13; + // + // themecolorb + // + this.themecolorb.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolorb.Location = new System.Drawing.Point(339, 138); + this.themecolorb.Name = "themecolorb"; + this.themecolorb.Size = new System.Drawing.Size(40, 40); + this.themecolorb.TabIndex = 17; + // + // themecolorc + // + this.themecolorc.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolorc.Location = new System.Drawing.Point(189, 189); + this.themecolorc.Name = "themecolorc"; + this.themecolorc.Size = new System.Drawing.Size(40, 40); + this.themecolorc.TabIndex = 7; + // + // themecolord + // + this.themecolord.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolord.Location = new System.Drawing.Point(239, 189); + this.themecolord.Name = "themecolord"; + this.themecolord.Size = new System.Drawing.Size(40, 40); + this.themecolord.TabIndex = 11; + // + // themecolore + // + this.themecolore.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolore.Location = new System.Drawing.Point(289, 189); + this.themecolore.Name = "themecolore"; + this.themecolore.Size = new System.Drawing.Size(40, 40); + this.themecolore.TabIndex = 15; + // + // themecolorf + // + this.themecolorf.BackColor = System.Drawing.SystemColors.HotTrack; + this.themecolorf.Location = new System.Drawing.Point(339, 189); + this.themecolorf.Name = "themecolorf"; + this.themecolorf.Size = new System.Drawing.Size(40, 40); + this.themecolorf.TabIndex = 19; + // + // themecolorfg + // + this.themecolorfg.AutoSize = true; + this.themecolorfg.BackColor = System.Drawing.Color.Transparent; + this.themecolorfg.Location = new System.Drawing.Point(190, 18); + this.themecolorfg.Name = "themecolorfg"; + this.themecolorfg.Size = new System.Drawing.Size(66, 13); + this.themecolorfg.TabIndex = 21; + this.themecolorfg.Text = "Sample Text"; + // + // themecolortextbg + // + this.themecolortextbg.Location = new System.Drawing.Point(180, 15); + this.themecolortextbg.Name = "themecolortextbg"; + this.themecolortextbg.Size = new System.Drawing.Size(208, 223); + this.themecolortextbg.TabIndex = 20; + // + // importbutton + // + this.importbutton.Location = new System.Drawing.Point(90, 220); + this.importbutton.Name = "importbutton"; + this.importbutton.Size = new System.Drawing.Size(60, 23); + this.importbutton.TabIndex = 2; + this.importbutton.Text = "Import"; + this.importbutton.UseVisualStyleBackColor = true; + this.importbutton.Click += new System.EventHandler(this.importbutton_Click_1); + // + // applybutton + // + this.applybutton.Location = new System.Drawing.Point(23, 220); + this.applybutton.Name = "applybutton"; + this.applybutton.Size = new System.Drawing.Size(60, 23); + this.applybutton.TabIndex = 1; + this.applybutton.Text = "Apply"; + this.applybutton.UseVisualStyleBackColor = true; + this.applybutton.Click += new System.EventHandler(this.applybutton_Click_1); + // + // themecolorfgmarked + // + this.themecolorfgmarked.AutoSize = true; + this.themecolorfgmarked.Location = new System.Drawing.Point(313, 18); + this.themecolorfgmarked.Name = "themecolorfgmarked"; + this.themecolorfgmarked.Size = new System.Drawing.Size(67, 13); + this.themecolorfgmarked.TabIndex = 22; + this.themecolorfgmarked.Text = "Marked Text"; + // + // XTM + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(397, 248); + this.Controls.Add(this.themecolorfgmarked); + this.Controls.Add(this.themecolorfg); + this.Controls.Add(this.themecolorf); + this.Controls.Add(this.themecolor3); + this.Controls.Add(this.themecolorb); + this.Controls.Add(this.themecolor7); + this.Controls.Add(this.themecolore); + this.Controls.Add(this.themecolor2); + this.Controls.Add(this.themecolora); + this.Controls.Add(this.themecolor6); + this.Controls.Add(this.themecolord); + this.Controls.Add(this.themecolor1); + this.Controls.Add(this.themecolor9); + this.Controls.Add(this.themecolor5); + this.Controls.Add(this.themecolorc); + this.Controls.Add(this.themecolor0); + this.Controls.Add(this.themecolor8); + this.Controls.Add(this.themecolor4); + this.Controls.Add(this.importbutton); + this.Controls.Add(this.applybutton); + this.Controls.Add(this.themelist); + this.Controls.Add(this.themecolortextbg); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Name = "XTM"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "XChat Theme Manager"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox themelist; + private System.Windows.Forms.Label themecolor0; + private System.Windows.Forms.Label themecolor1; + private System.Windows.Forms.Label themecolor2; + private System.Windows.Forms.Label themecolor3; + private System.Windows.Forms.Label themecolor4; + private System.Windows.Forms.Label themecolor5; + private System.Windows.Forms.Label themecolor6; + private System.Windows.Forms.Label themecolor7; + private System.Windows.Forms.Label themecolor8; + private System.Windows.Forms.Label themecolor9; + private System.Windows.Forms.Label themecolora; + private System.Windows.Forms.Label themecolorb; + private System.Windows.Forms.Label themecolorc; + private System.Windows.Forms.Label themecolord; + private System.Windows.Forms.Label themecolore; + private System.Windows.Forms.Label themecolorf; + private System.Windows.Forms.Label themecolorfg; + private System.Windows.Forms.Label themecolortextbg; + private System.Windows.Forms.Button importbutton; + private System.Windows.Forms.Button applybutton; + private System.Windows.Forms.Label themecolorfgmarked; + } +} + diff --git a/src/xtm/Main.cs b/src/xtm/Main.cs new file mode 100644 index 00000000..e740e994 --- /dev/null +++ b/src/xtm/Main.cs @@ -0,0 +1,269 @@ +/* XChat Theme Manager + * + * Copyright (C) 2012 Patrick Griffs + * Copyright (C) 2012 Berke Viktor + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +using System; +using System.Collections.Generic; +using System.Collections; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +/* using System.IO.Compression; */ +using System.IO.Packaging; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Net; + +namespace thememan +{ + public partial class XTM : Form + { + public string appdata = (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\X-Chat 2\\"); + public string home = (Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/.xchat2/"); + + public string xchatdir; + public string themedir = "themes\\"; + + OpenFileDialog importDialog; + + public XTM () + { + InitializeComponent (); + + if (File.Exists ("portable-mode")) + xchatdir = ("config\\"); + else if (Directory.Exists (appdata)) + xchatdir = (appdata); + else if (Directory.Exists (home)) { + xchatdir = (home); themedir = "themes/"; + } else + Console.WriteLine("Install not found"); + + ListThemes(); + } + + private void ListThemes() + { + themelist.Items.Clear(); + + if (Directory.Exists(xchatdir + themedir)) + { + foreach (string theme in Directory.GetDirectories(xchatdir + themedir)) + { + themelist.Items.Add(theme.Remove(0, xchatdir.Length + themedir.Length)); + } + } + else + { + Directory.CreateDirectory(xchatdir + themedir); + } + + if (themelist.Items.Count == 0) + { + applybutton.Enabled = false; + } + else + { + themelist.SetSelected(0, true); + } + } + + private void ShowColors(List> themecolors) + { + List labels = this.Controls.OfType