From e85ac9b55d8570877d51ad749967f0a1c511a871 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 25 Jun 2015 23:32:46 +0100 Subject: [PATCH] linux ui: Move text colors to more accessible SparkleUI class --- SparkleShare/Linux/SparkleSetup.cs | 14 ++++++------- SparkleShare/Linux/SparkleSetupWindow.cs | 26 ------------------------ SparkleShare/Linux/SparkleUI.cs | 15 ++++++++++++++ SparkleShare/Linux/SparkleUIHelpers.cs | 14 +++++++++++++ 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/SparkleShare/Linux/SparkleSetup.cs b/SparkleShare/Linux/SparkleSetup.cs index 5d4d6e2a8..ad698c498 100755 --- a/SparkleShare/Linux/SparkleSetup.cs +++ b/SparkleShare/Linux/SparkleSetup.cs @@ -160,7 +160,7 @@ public void ShowPage (PageType type, string [] warnings) foreach (SparklePlugin plugin in Controller.Plugins) { store.AppendValues ("", new Gdk.Pixbuf (plugin.ImagePath), "" + plugin.Name + "\n" + - "" + plugin.Description + "" + + "" + plugin.Description + "" + "", plugin); } @@ -183,14 +183,14 @@ public void ShowPage (PageType type, string [] warnings) Xalign = 0, UseMarkup = true, Markup = "" + Controller.SelectedPlugin.AddressExample + "" + Program.UI.SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "" }; Label path_example = new Label () { Xalign = 0, UseMarkup = true, Markup = "" + Controller.SelectedPlugin.PathExample + "" + Program.UI.SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "" }; @@ -280,7 +280,7 @@ public void ShowPage (PageType type, string [] warnings) address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "" + example_text + ""; + Program.UI.SecondaryTextColor + "\">" + example_text + ""; }); }; @@ -291,7 +291,7 @@ public void ShowPage (PageType type, string [] warnings) path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "" + example_text + ""; + + Program.UI.SecondaryTextColor + "\">" + example_text + ""; }); }; @@ -704,9 +704,9 @@ public void ShowPage (PageType type, string [] warnings) TreeSelection selection = (column.TreeView as TreeView).Selection; if (selection.IterIsSelected (iter)) - markup = markup.Replace (SecondaryTextColor, SecondaryTextColorSelected); + markup = markup.Replace (Program.UI.SecondaryTextColor, Program.UI.SecondaryTextColorSelected); else - markup = markup.Replace (SecondaryTextColorSelected, SecondaryTextColor); + markup = markup.Replace (Program.UI.SecondaryTextColorSelected, Program.UI.SecondaryTextColor); (cell as CellRendererText).Markup = markup; } diff --git a/SparkleShare/Linux/SparkleSetupWindow.cs b/SparkleShare/Linux/SparkleSetupWindow.cs index 1e00f7012..77b69f896 100755 --- a/SparkleShare/Linux/SparkleSetupWindow.cs +++ b/SparkleShare/Linux/SparkleSetupWindow.cs @@ -29,9 +29,6 @@ public class SparkleSetupWindow : Window { public string Header; public string Description; - public readonly string SecondaryTextColor; - public readonly string SecondaryTextColorSelected; - public SparkleSetupWindow () : base ("SparkleShare Setup") { @@ -48,16 +45,6 @@ public SparkleSetupWindow () : base ("SparkleShare Setup") DeleteEvent += delegate (object sender, DeleteEventArgs args) { args.RetVal = true; }; - Gdk.Color color = SparkleUIHelpers.RGBAToColor (StyleContext.GetColor (StateFlags.Insensitive)); - SecondaryTextColor = SparkleUIHelpers.ColorToHex (color); - - color = MixColors ( - SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetColor (StateFlags.Selected)), - SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Selected)), - 0.39); - - SecondaryTextColorSelected = SparkleUIHelpers.ColorToHex (color); - HBox layout_horizontal = new HBox (false, 0); VBox layout_vertical = new VBox (false, 0); @@ -164,18 +151,5 @@ public void Reset () Present (); base.ShowAll (); } - - - private Gdk.Color MixColors (Gdk.Color first_color, Gdk.Color second_color, double ratio) - { - return new Gdk.Color ( - Convert.ToByte ((255 * (Math.Min (65535, first_color.Red * (1.0 - ratio) + - second_color.Red * ratio))) / 65535), - Convert.ToByte ((255 * (Math.Min (65535, first_color.Green * (1.0 - ratio) + - second_color.Green * ratio))) / 65535), - Convert.ToByte ((255 * (Math.Min (65535, first_color.Blue * (1.0 - ratio) + - second_color.Blue * ratio))) / 65535) - ); - } } } diff --git a/SparkleShare/Linux/SparkleUI.cs b/SparkleShare/Linux/SparkleUI.cs index e5b9a4613..4c5b27b06 100644 --- a/SparkleShare/Linux/SparkleUI.cs +++ b/SparkleShare/Linux/SparkleUI.cs @@ -32,6 +32,10 @@ public class SparkleUI { public SparkleBubbles Bubbles; public SparkleSetup Setup; public SparkleAbout About; + public SparkleNote Note; + + public readonly string SecondaryTextColor; + public readonly string SecondaryTextColorSelected; private Gtk.Application application; @@ -42,6 +46,16 @@ public SparkleUI () this.application.Register (null); this.application.Activated += ApplicationActivatedDelegate; + + Gdk.Color color = SparkleUIHelpers.RGBAToColor (new Label().StyleContext.GetColor (StateFlags.Insensitive)); + SecondaryTextColor = SparkleUIHelpers.ColorToHex (color); + + color = SparkleUIHelpers.MixColors ( + SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetColor (StateFlags.Selected)), + SparkleUIHelpers.RGBAToColor (new TreeView ().StyleContext.GetBackgroundColor (StateFlags.Selected)), + 0.39); + + SecondaryTextColorSelected = SparkleUIHelpers.ColorToHex (color); } @@ -72,6 +86,7 @@ private void ApplicationActivatedDelegate (object sender, EventArgs args) About = new SparkleAbout (); Bubbles = new SparkleBubbles (); StatusIcon = new SparkleStatusIcon (); + Note = new SparkleNote (); Setup.Application = this.application; EventLog.Application = this.application; diff --git a/SparkleShare/Linux/SparkleUIHelpers.cs b/SparkleShare/Linux/SparkleUIHelpers.cs index 5f0ffbf41..d147b00d5 100755 --- a/SparkleShare/Linux/SparkleUIHelpers.cs +++ b/SparkleShare/Linux/SparkleUIHelpers.cs @@ -75,5 +75,19 @@ public static string RGBAToHex (Gdk.RGBA rgba) { return ColorToHex (RGBAToColor (rgba)); } + + + public static Gdk.Color MixColors (Gdk.Color first_color, Gdk.Color second_color, double ratio) + { + return new Gdk.Color ( + Convert.ToByte ((255 * (Math.Min (65535, first_color.Red * (1.0 - ratio) + + second_color.Red * ratio))) / 65535), + Convert.ToByte ((255 * (Math.Min (65535, first_color.Green * (1.0 - ratio) + + second_color.Green * ratio))) / 65535), + Convert.ToByte ((255 * (Math.Min (65535, first_color.Blue * (1.0 - ratio) + + second_color.Blue * ratio))) / 65535) + ); + } } } +