Hi,

Here is a patch to implement this. I'm not sure if we should consider
this as a bug or a new feature, any ideas?

Comments on the patch?

Thanks.


-- 
Guillaume
 http://www.postgresql.fr
 http://dalibo.com
>From e1395157f8b2a3ab9ddc27c652dae694009ab245 Mon Sep 17 00:00:00 2001
From: Guillaume Lelarge <[email protected]>
Date: Sat, 16 Oct 2010 01:04:58 +0200
Subject: [PATCH] Store/retrieve custom colours in colour picker

We don't set the custom colours a user could record. This patch adds this
ability by setting the custom colours before opening the standard dialog and
by storing the colours if the user clicked OK.

Implements #247.
---
 pgadmin/ctl/ctlColourPicker.cpp     |    8 ++++++++
 pgadmin/include/utils/sysSettings.h |    4 ++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/pgadmin/ctl/ctlColourPicker.cpp b/pgadmin/ctl/ctlColourPicker.cpp
index ffd8850..f0f71ca 100644
--- a/pgadmin/ctl/ctlColourPicker.cpp
+++ b/pgadmin/ctl/ctlColourPicker.cpp
@@ -36,6 +36,10 @@ void ctlColourPicker::DoProcessLeftClick(wxMouseEvent& event)
 {
     wxColourData clrData;
 
+    // Initialise custom colours
+    for (int index=0; index<16; index++)
+        clrData.SetCustomColour(index, settings->GetCustomColour(index));
+
     // If there is an initial colour, set it for wxColourDialog
     if (m_colour_clr.IsOk())
         clrData.SetColour(m_colour_clr);
@@ -51,6 +55,10 @@ void ctlColourPicker::DoProcessLeftClick(wxMouseEvent& event)
     {
         clrData = dialog.GetColourData();
 		SetColour(clrData.GetColour());
+
+        // Store custom colours
+        for (int index=0; index<16; index++)
+            settings->SetCustomColour(index, clrData.GetCustomColour(index).GetAsString(wxC2S_HTML_SYNTAX));
     }
 }
 
diff --git a/pgadmin/include/utils/sysSettings.h b/pgadmin/include/utils/sysSettings.h
index 0d0ee55..f64a572 100644
--- a/pgadmin/include/utils/sysSettings.h
+++ b/pgadmin/include/utils/sysSettings.h
@@ -135,6 +135,10 @@ public:
 	long  GetHistoryMaxQuerySize() const { long l; Read(wxT("History/MaxQuerySize"), &l, 1024L); return l; }
 	void SetHistoryMaxQuerySize(const long newval) { Write(wxT("History/MaxQuerySize"), newval); }
 
+    // Custom Colours options
+    wxString GetCustomColour(int index) const { wxString s; Read(wxT("CustomColour") + NumToStr((long) index), &s, wxT("#ffffff")); return s; }
+	void SetCustomColour(int index, const wxString &newval) { Write(wxT("CustomColour") + NumToStr((long) index), newval); }
+
     // Status Colours options
     wxString GetIdleProcessColour() const { wxString s; Read(wxT("IdleProcessColour"), &s, wxT("#5fa4d9")); return s; }
 	void SetIdleProcessColour(const wxString &newval) { Write(wxT("IdleProcessColour"), newval); }
-- 
1.7.0.4

-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to