summaryrefslogtreecommitdiff
path: root/gtk2_ardour/stripable_colorpicker.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-03-11 02:23:34 +0100
committerRobin Gareus <robin@gareus.org>2017-03-11 02:23:34 +0100
commit0a87fbe820385308fea2857e3caf434d64508bf0 (patch)
tree088e8dc52872a8733643621ae8d02f593f2004ed /gtk2_ardour/stripable_colorpicker.cc
parentd0fc7d37ab74cc90ed42d021864c4f3ee4cc7088 (diff)
Allow to customize color-picker-palette
Diffstat (limited to 'gtk2_ardour/stripable_colorpicker.cc')
-rw-r--r--gtk2_ardour/stripable_colorpicker.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/gtk2_ardour/stripable_colorpicker.cc b/gtk2_ardour/stripable_colorpicker.cc
index 6f89e615f3..a7db947df8 100644
--- a/gtk2_ardour/stripable_colorpicker.cc
+++ b/gtk2_ardour/stripable_colorpicker.cc
@@ -20,13 +20,18 @@
#include "pbd/i18n.h"
#include "stripable_colorpicker.h"
+#include "ui_config.h"
#include "utils.h"
using namespace Gtk;
using namespace ARDOUR_UI_UTILS;
+bool StripableColorDialog::palette_initialized = false;
+Gtk::ColorSelection::SlotChangePaletteHook StripableColorDialog::gtk_palette_changed_hook;
+
StripableColorDialog::StripableColorDialog ()
{
+ initialize_color_palette ();
signal_response().connect (sigc::mem_fun (*this, &StripableColorDialog::finish_color_edit));
}
@@ -36,6 +41,32 @@ StripableColorDialog::~StripableColorDialog ()
}
void
+StripableColorDialog::palette_changed_hook (const Glib::RefPtr<Gdk::Screen>& s, const Gdk::ArrayHandle_Color& c)
+{
+ std::string p = std::string (ColorSelection::palette_to_string (c));
+ UIConfiguration::instance ().set_stripable_color_palette (p);
+ gtk_palette_changed_hook (s, c);
+}
+
+void
+StripableColorDialog::initialize_color_palette ()
+{
+ // non-static member, because it needs a screen()
+ if (palette_initialized) {
+ return;
+ }
+ gtk_palette_changed_hook =
+ get_colorsel()->set_change_palette_hook (&StripableColorDialog::palette_changed_hook);
+
+ std::string cp = UIConfiguration::instance ().get_stripable_color_palette ();
+ if (!cp.empty()) {
+ Gdk::ArrayHandle_Color c = ColorSelection::palette_from_string (cp);
+ gtk_palette_changed_hook (get_screen (), c);
+ }
+ palette_initialized = true;
+}
+
+void
StripableColorDialog::reset ()
{
hide ();