[chronojump] DB:1.91 ColorBackground can be changed on preferences
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB:1.91 ColorBackground can be changed on preferences
- Date: Fri, 20 Mar 2020 12:11:21 +0000 (UTC)
commit b5bcd36760c96a5299e3c952ad884bb3200ec791
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Mar 20 13:10:26 2020 +0100
DB:1.91 ColorBackground can be changed on preferences
src/gui/app1/chronojump.cs | 4 +++-
src/gui/app1/menu.cs | 7 +++++--
src/gui/preferences.cs | 14 +++++++++++++-
src/preferences.cs | 10 +++++++++-
src/sqlite/main.cs | 11 ++++++++++-
src/sqlite/preferences.cs | 4 ++++
src/utilGtk.cs | 25 +++++++++++++++++++++++++
7 files changed, 69 insertions(+), 6 deletions(-)
---
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 2e85f8fe..e91096a6 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -700,7 +700,7 @@ public partial class ChronoJumpWindow
} else
LogB.Information("Ping discarded (Compujump)");
- menu_initialize();
+ menu_initialize_colors();
testNewStuff();
@@ -3078,6 +3078,8 @@ public partial class ChronoJumpWindow
if(pen_black_force_ai != null)
pen_black_force_ai.SetLineAttributes (preferences.forceSensorGraphsLineWidth,
Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
+ menu_initialize_colors();
+
// update force_capture_drawingarea
if(current_menuitem_mode == Constants.Menuitem_modes.FORCESENSOR &&
radiobutton_force_sensor_analyze_manual.Active)
forceSensorDoGraphAI();
diff --git a/src/gui/app1/menu.cs b/src/gui/app1/menu.cs
index 41539829..5f3e6513 100644
--- a/src/gui/app1/menu.cs
+++ b/src/gui/app1/menu.cs
@@ -53,10 +53,13 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_persons_open_2;
[Widget] Gtk.Image image_persons_open_plus_2;
- private void menu_initialize()
+ private void menu_initialize_colors()
{
- Gdk.Color color = UtilGtk.YELLOW;
+ //Gdk.Color color = UtilGtk.YELLOW;
//Gdk.Color color = UtilGtk.BLUE_CHRONOJUMP;
+
+ Gdk.Color color = UtilGtk.ColorParse(preferences.colorBackgroundString);
+
UtilGtk.ViewportColor(viewport_hpaned_contacts_main, color);
UtilGtk.ViewportColor(viewport_menu_top, color);
UtilGtk.ViewportColor(viewport_menu, color);
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index b9a38575..76383367 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -650,6 +650,14 @@ public class PreferencesWindow
if (colorSelectionDialog.Run () == (int) ResponseType.Ok) {
colorBackground = colorSelectionDialog.ColorSelection.CurrentColor;
paintColorDrawingArea(colorBackground);
+
+ /*
+ LogB.Information(string.Format("color: red {0}, green {1}, blue {2}",
+ colorBackground.Red, colorBackground.Green,
colorBackground.Blue));
+ LogB.Information(string.Format("color: red {0}, green {1}, blue {2}",
+ colorBackground.Red/256.0,
colorBackground.Green/256.0, colorBackground.Blue/256.0));
+ */
+ LogB.Information("color to string: " +
UtilGtk.ColorToColorString(colorBackground));
}
colorSelectionDialog.Hide ();
@@ -1743,7 +1751,11 @@ public class PreferencesWindow
SqlitePreferences.Update("personPhoto",
PreferencesWindowBox.check_appearance_person_photo.Active.ToString(), true);
preferences.personPhoto = PreferencesWindowBox.check_appearance_person_photo.Active;
}
-
+
+ preferences.colorBackgroundString = Preferences.PreferencesChange(
+ SqlitePreferences.ColorBackground, preferences.colorBackgroundString,
+ UtilGtk.ColorToColorString(colorBackground)); //this does the reverse of
Gdk.Color.Parse on UtilGtk.ColorParse()
+
if( preferences.digitsNumber != Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals)) ) {
SqlitePreferences.Update("digitsNumber", UtilGtk.ComboGetActive(combo_decimals),
true);
preferences.digitsNumber = Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals));
diff --git a/src/preferences.cs b/src/preferences.cs
index 31a83b57..dc0d111b 100644
--- a/src/preferences.cs
+++ b/src/preferences.cs
@@ -32,7 +32,8 @@ public class Preferences
public MaximizedTypes maximized;
public bool personWinHide;
public bool personPhoto;
- public string colorBackgroundString = "#0e1e46";
+ //public string colorBackgroundString = "#0e1e46";
+ public string colorBackgroundString;
public enum UnitsEnum { METRIC, IMPERIAL };
public UnitsEnum units;
@@ -388,6 +389,13 @@ public class Preferences
return dNew;
}
+ public static string PreferencesChange(string prefName, string prefValue, string sNew)
+ {
+ if(prefValue != sNew)
+ SqlitePreferences.Update(prefName, sNew, true);
+
+ return sNew;
+ }
~Preferences() {}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 7795a99a..5e9eb480 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "1.90";
+ static string lastChronojumpDatabaseVersion = "1.91";
public Sqlite() {
}
@@ -2671,6 +2671,14 @@ class Sqlite
currentVersion = updateVersion("1.90");
}
+ if(currentVersion == "1.90")
+ {
+ LogB.SQL("Inserted into preferences: ColorBackground");
+
+ SqlitePreferences.Insert (SqlitePreferences.ColorBackground, "#0e1e46");
+
+ currentVersion = updateVersion("1.91");
+ }
/*
if(currentVersion == "1.79")
@@ -2885,6 +2893,7 @@ class Sqlite
//changes [from - to - desc]
//just testing: 1.79 - 1.80 Converted DB to 1.80 Created table ForceSensorElasticBandGlue and moved
stiffnessString records there
//
+ //1.90 - 1.91 Converted DB to 1.91 Inserted into preferences: ColorBackground
//1.89 - 1.90 Converted DB to 1.90 Inserted into preferences: units
//1.88 - 1.89 Converted DB to 1.89 Inserted into preferences: encoderCaptureFeedbackEccon
//1.87 - 1.88 Converted DB to 1.88 Inserted into preferences:
encoderCaptureInertialEccOverloadMode
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index e72685d7..3ab137df 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -28,6 +28,7 @@ using System.Collections; //ArrayList
class SqlitePreferences : Sqlite
{
public const string UnitsStr = "units";
+ public const string ColorBackground = "colorBackground";
//contacts
public const string JumpsDjGraphHeights = "jumpsDjGraphHeights";
@@ -115,6 +116,7 @@ class SqlitePreferences : Sqlite
Insert ("maximized", Preferences.MaximizedTypes.NO.ToString(), dbcmdTr);
Insert ("personWinHide", "False", dbcmdTr);
Insert ("personPhoto", "True", dbcmdTr);
+ Insert (ColorBackground, "#0e1e46", dbcmdTr);
Insert (UnitsStr, Preferences.UnitsEnum.METRIC.ToString(), dbcmdTr);
Insert ("encoderCaptureShowOnlyBars", "False", dbcmdTr);
Insert ("encoderCaptureShowNRepetitions", "-1", dbcmdTr);
@@ -357,6 +359,8 @@ class SqlitePreferences : Sqlite
preferences.personWinHide = reader[1].ToString() == "True";
else if(reader[0].ToString() == "personPhoto")
preferences.personPhoto = reader[1].ToString() == "True";
+ else if(reader[0].ToString() == ColorBackground)
+ preferences.colorBackgroundString = reader[1].ToString();
else if(reader[0].ToString() == UnitsStr)
preferences.units = (Preferences.UnitsEnum)
Enum.Parse(typeof(Preferences.UnitsEnum), reader[1].ToString());
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index f71ace50..747580a3 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -25,6 +25,7 @@ using System.Collections.Generic; //List<T>
using System.IO;
using Gtk;
using Gdk;
+using System.Text.RegularExpressions; //Regex
//this class tries to be a space for methods that are used in different classes
//only Gtk related methods (not used bu the server) this is the differnece with Util
@@ -747,6 +748,30 @@ public class UtilGtk
Gdk.Color.Parse(colorString, ref color);
return color;
}
+ //reverse of previous method
+ public static string ColorToColorString (Gdk.Color color)
+ {
+ string str = color.ToString(); //returns this: rgb:8b8b/6969/1414 or this: rgb:ffff/a5a5/0
(if blue is 0)
+ Match match = Regex.Match(str, @"rgb:(\w+)/(\w+)/(\w+)");
+ LogB.Information("ColorToColorString match groups: " + match.Groups.Count.ToString());
+ if(match.Groups.Count == 4)
+ {
+ return string.Format("#{0}{1}{2}", colHexTwoChars(match.Groups[1].Value),
+ colHexTwoChars(match.Groups[2].Value),
colHexTwoChars(match.Groups[3].Value));
+ } else
+ return "#0e1e46"; //default if there are problems
+ }
+ private static string colHexTwoChars(string colorString)
+ {
+ if(colorString.Length == 1) //if "0" return "00"
+ return colorString + colorString;
+ if(colorString.Length == 2) //if "ce" return "ce"
+ return colorString;
+ if(colorString.Length == 4) //if "cece" return "ce")
+ return colorString.Substring(0,2);
+
+ return colorString;
+ }
public static void PaintColorDrawingArea(Gtk.DrawingArea da, Gdk.Color color)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]