[chronojump] Better method to use colorBackground using Config (public static)



commit 3dc75c5ba69d58ef2810c3878b34724a80e97f43
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 20 14:29:17 2020 +0100

    Better method to use colorBackground using Config (public static)

 src/config.cs              | 4 ++++
 src/gui/app1/chronojump.cs | 8 ++++----
 src/gui/dialogMessage.cs   | 6 ++----
 src/gui/genericWindow.cs   | 9 +++------
 4 files changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/src/config.cs b/src/config.cs
index a302883e..de959711 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -24,6 +24,10 @@ using System.IO;
 
 public class Config
 {
+       //to avoid passing this info to all the windows and dialogs, just read it here
+       public static Gdk.Color ColorBackground;
+       public static bool ColorBackgroundIsDark;
+
        public enum SessionModeEnum { STANDARD, UNIQUE, MONTHLY }
 
        public Preferences.MaximizedTypes Maximized;
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 6abbe13e..8161f090 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -553,8 +553,8 @@ public partial class ChronoJumpWindow
                //at initialization of chronojump and gives problems if this signals are raised while 
preferences are loading
                loadPreferencesAtStart ();
 
-               DialogMessage.colorBackground = preferences.colorBackground;
-               GenericWindow.colorBackground = preferences.colorBackground;
+               Config.ColorBackground = preferences.colorBackground;
+               Config.ColorBackgroundIsDark = UtilGtk.ColorIsDark(preferences.colorBackground);
 
                checkbutton_video_contacts.Visible = true;
 
@@ -2851,8 +2851,8 @@ public partial class ChronoJumpWindow
                //repaint labels that are on the background
                //TODO: only if color changed or personWinHide
                doLabelsContrast(configChronojump.PersonWinHide);
-               DialogMessage.colorBackground = preferences.colorBackground;
-               GenericWindow.colorBackground = preferences.colorBackground;
+               Config.ColorBackground = preferences.colorBackground;
+               Config.ColorBackgroundIsDark = UtilGtk.ColorIsDark(preferences.colorBackground);
 
                // update force_capture_drawingarea
                if(current_menuitem_mode == Constants.Menuitem_modes.FORCESENSOR && 
radiobutton_force_sensor_analyze_manual.Active)
diff --git a/src/gui/dialogMessage.cs b/src/gui/dialogMessage.cs
index 8932c6a2..511f8e71 100644
--- a/src/gui/dialogMessage.cs
+++ b/src/gui/dialogMessage.cs
@@ -25,8 +25,6 @@ using Glade;
 
 public class DialogMessage
 {
-       public static Gdk.Color colorBackground; //static to avoid passing colorBackground on all its calls
-
        [Widget] Gtk.Dialog dialog_message;
        [Widget] Gtk.ScrolledWindow scrolledwindow;
        [Widget] Gtk.Label label_message;
@@ -60,7 +58,7 @@ public class DialogMessage
                if(objectToShow == "hbox_stiffness_formula")
                {
                        hbox_stiffness_formula.Show();
-                       UtilGtk.ContrastLabelsHBox (UtilGtk.ColorIsDark(colorBackground), 
hbox_stiffness_formula);
+                       UtilGtk.ContrastLabelsHBox (Config.ColorBackgroundIsDark, hbox_stiffness_formula);
                }
                else if(objectToShow == "button_go_r_mac")
                {
@@ -84,7 +82,7 @@ public class DialogMessage
 
                //put an icon to window
                UtilGtk.IconWindow(dialog_message);
-               UtilGtk.DialogColor(dialog_message, colorBackground);
+               UtilGtk.DialogColor(dialog_message, Config.ColorBackground);
        
                //with this, user doesn't see a moving/changing creation window
                //if uncommented, then does weird bug in windows not showing dialog as its correct size until 
window is moves
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index db1a67e7..b5becefa 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -31,8 +31,6 @@ using Mono.Unix;
 
 public class GenericWindow
 {
-       public static Gdk.Color colorBackground; //static to avoid passing colorBackground on all its calls
-
        [Widget] Gtk.Window generic_window;
        [Widget] Gtk.Label label_header;
        [Widget] Gtk.Box hbox_error;
@@ -133,10 +131,9 @@ public class GenericWindow
        
                //put an icon to window
                UtilGtk.IconWindow(generic_window);
-               UtilGtk.WindowColor(generic_window, colorBackground);
-               bool bgIsDark = UtilGtk.ColorIsDark(colorBackground);
-               UtilGtk.ContrastLabelsLabel (bgIsDark, label_header);
-               UtilGtk.ContrastLabelsLabel (bgIsDark, label_error);
+               UtilGtk.WindowColor(generic_window, Config.ColorBackground);
+               UtilGtk.ContrastLabelsLabel (Config.ColorBackgroundIsDark, label_header);
+               UtilGtk.ContrastLabelsLabel (Config.ColorBackgroundIsDark, label_error);
                
                generic_window.Resizable = false;
                setTitle(title);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]