diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc index d8363504fb73..20693a71c617 100644 --- a/vcl/inc/strings.hrc +++ b/vcl/inc/strings.hrc @@ -135,4 +135,6 @@ #define RID_STR_ACC_SCROLLBAR_NAME_HORIZONTAL NC_("RID_STR_ACC_SCROLLBAR_NAME_HORIZONTAL", "Horizontal scroll bar") #define RID_STR_ACC_PANEL_DESCRIPTION NC_("RID_STR_ACC_PANEL_DESCRIPTION", "Please press enter to go into child control for more operations") +#define RID_STR_PICK_COLOR NC_("RID_STR_PICK_COLOR", "Pick a Color") + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/ColorDialog.cxx b/vcl/source/app/ColorDialog.cxx index 32042bec9e5c..589af550dc88 100644 --- a/vcl/source/app/ColorDialog.cxx +++ b/vcl/source/app/ColorDialog.cxx @@ -29,6 +29,7 @@ ColorDialog::ColorDialog(weld::Window* pParent, vcl::ColorPickerMode eMode) std::unique_ptr pDialog = GetSalInstance()->CreateColorChooserDialog(pParent, eMode); assert(pDialog); + pDialog->set_modal(true); m_pColorChooserDialogController = std::make_shared(std::move(pDialog)); } diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 2b8c4b539182..d90e834bd5e6 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -4489,6 +4489,11 @@ namespace return aColor; } + Color toVclColor(const GdkRGBA& rColor) + { + return Color(rColor.red * 255, rColor.green * 255, rColor.blue * 255); + } + OUString get_label(GtkLabel* pLabel) { const gchar* pStr = gtk_label_get_label(pLabel); @@ -7957,23 +7962,32 @@ public: class GtkInstanceColorChooserDialog : public GtkInstanceDialog, public virtual weld::ColorChooserDialog { - ScopedVclPtr m_pAbstractColorPickerDialog; + GtkColorChooserDialog* m_pColorChooserDialog; public: - GtkInstanceColorChooserDialog(AbstractColorPickerDialog* pColorDialog) - : GtkInstanceDialog( - dynamic_cast(pColorDialog->GetDialog())->getWindow(), nullptr, - false) - , m_pAbstractColorPickerDialog(pColorDialog) + GtkInstanceColorChooserDialog(GtkColorChooserDialog* pColorChooserDialog) + : GtkInstanceDialog(GTK_WINDOW(pColorChooserDialog), nullptr, true) + , m_pColorChooserDialog(pColorChooserDialog) { + assert(m_pColorChooserDialog); + gtk_color_chooser_set_use_alpha(GTK_COLOR_CHOOSER(m_pColorChooserDialog), false); + + // directly show the advanced color editor + g_object_set(G_OBJECT(m_pColorChooserDialog), "show-editor", true, nullptr); } virtual void set_color(const Color& rColor) override { - m_pAbstractColorPickerDialog->SetColor(rColor); + GdkRGBA aColor = toGdkColor(rColor); + gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(m_pColorChooserDialog), &aColor); } - virtual Color get_color() const override { return m_pAbstractColorPickerDialog->GetColor(); } + virtual Color get_color() const override + { + GdkRGBA aColor; + gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(m_pColorChooserDialog), &aColor); + return toVclColor(aColor); + } }; } @@ -25160,13 +25174,12 @@ weld::MessageDialog* GtkInstance::CreateMessageDialog(weld::Widget* pParent, Vcl } std::unique_ptr -GtkInstance::CreateColorChooserDialog(weld::Window* pParent, vcl::ColorPickerMode eMode) +GtkInstance::CreateColorChooserDialog(weld::Window* pParent, vcl::ColorPickerMode) { - VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create(); - assert(pFact); - VclPtr pDialog - = pFact->CreateColorPickerDialog(pParent, COL_BLACK, eMode); - assert(pDialog); + GtkInstanceWindow* pWindow = dynamic_cast(pParent); + GtkWindow* pGtkParent = pWindow ? pWindow->getWindow() : nullptr; + GtkColorChooserDialog* pDialog = GTK_COLOR_CHOOSER_DIALOG( + gtk_color_chooser_dialog_new(VclResId(RID_STR_PICK_COLOR).toUtf8().getStr(), pGtkParent)); return std::make_unique(pDialog); }