summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorHeiko Tietze <tietze.heiko@gmail.com>2020-04-08 12:58:34 +0200
committerHeiko Tietze <heiko.tietze@documentfoundation.org>2020-04-15 17:35:44 +0200
commit9b1c9ac6edcdeae431d6104c586ca7feffbb6483 (patch)
tree395bddaa18a31abfbc8a86277028b0d6087eb130 /vcl
parent0db34d1c5dd7d06435c5a5d58a42da2cbe007006 (diff)
Related tdf#130778: New About dialog
More flexible dialog logo & about images as SVGs Change-Id: Icefa035893e241a7dee6aa28236e6b89b38477de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91908 Tested-by: Jenkins Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/salvtables.hxx3
-rw-r--r--vcl/source/app/salvtables.cxx57
-rw-r--r--vcl/source/window/builder.cxx4
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx124
4 files changed, 1 insertions, 187 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index dd3575b79c38..1553538ea932 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -22,9 +22,6 @@ public:
virtual std::unique_ptr<weld::MessageDialog>
weld_message_dialog(const OString& id, bool bTakeOwnership = true) override;
- virtual std::unique_ptr<weld::AboutDialog>
- weld_about_dialog(const OString& id, bool bTakeOwnership = true) override;
-
virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id,
bool bTakeOwnership = true) override;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 13f596d5bc36..ed219871af24 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1615,48 +1615,6 @@ public:
}
};
-class SalInstanceAboutDialog : public SalInstanceDialog, public virtual weld::AboutDialog
-{
-private:
- VclPtr<vcl::AboutDialog> m_xAboutDialog;
-
-public:
- SalInstanceAboutDialog(vcl::AboutDialog* pDialog, SalInstanceBuilder* pBuilder,
- bool bTakeOwnership)
- : SalInstanceDialog(pDialog, pBuilder, bTakeOwnership)
- , m_xAboutDialog(pDialog)
- {
- }
- virtual void set_version(const OUString& rVersion) override
- {
- m_xAboutDialog->SetVersion(rVersion);
- }
- virtual void set_copyright(const OUString& rCopyright) override
- {
- m_xAboutDialog->SetCopyright(rCopyright);
- }
- virtual void set_website(const OUString& rURL) override
- {
- m_xAboutDialog->SetWebsiteLink(rURL);
- }
- virtual void set_website_label(const OUString& rLabel) override
- {
- m_xAboutDialog->SetWebsiteLabel(rLabel);
- }
- virtual OUString get_website_label() const override
- {
- return m_xAboutDialog->GetWebsiteLabel();
- }
- virtual void set_logo(const css::uno::Reference<css::graphic::XGraphic>& rImage) override
- {
- m_xAboutDialog->SetLogo(Image(rImage));
- }
- virtual void set_background(const css::uno::Reference<css::graphic::XGraphic>& rImage) override
- {
- m_xAboutDialog->SetBackground(Image(rImage));
- }
-};
-
class SalInstanceAssistant : public SalInstanceDialog, public virtual weld::Assistant
{
private:
@@ -6270,21 +6228,6 @@ std::unique_ptr<weld::MessageDialog> SalInstanceBuilder::weld_message_dialog(con
return pRet;
}
-std::unique_ptr<weld::AboutDialog> SalInstanceBuilder::weld_about_dialog(const OString& id,
- bool bTakeOwnership)
-{
- vcl::AboutDialog* pAboutDialog = m_xBuilder->get<vcl::AboutDialog>(id);
- std::unique_ptr<weld::AboutDialog> pRet(
- pAboutDialog ? new SalInstanceAboutDialog(pAboutDialog, this, false) : nullptr);
- if (bTakeOwnership && pAboutDialog)
- {
- assert(!m_aOwnedToplevel && "only one toplevel per .ui allowed");
- m_aOwnedToplevel.set(pAboutDialog);
- m_xBuilder->drop_ownership(pAboutDialog);
- }
- return pRet;
-}
-
std::unique_ptr<weld::Dialog> SalInstanceBuilder::weld_dialog(const OString& id,
bool bTakeOwnership)
{
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 361953129edd..020182cbe055 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1842,7 +1842,7 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
extractButtonImage(id, rMap, name == "GtkRadioButton");
VclPtr<vcl::Window> xWindow;
- if (name == "GtkDialog" || name == "GtkAboutDialog" || name == "GtkAssistant")
+ if (name == "GtkDialog" || name == "GtkAssistant")
{
// WB_ALLOWMENUBAR because we don't know in advance if we will encounter
// a menubar, and menubars need a BorderWindow in the toplevel, and
@@ -1855,8 +1855,6 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString &
Dialog::InitFlag eInit = !pParent ? Dialog::InitFlag::NoParent : Dialog::InitFlag::Default;
if (name == "GtkAssistant")
xWindow = VclPtr<vcl::RoadmapWizard>::Create(pParent, nBits, eInit);
- else if (name == "GtkAboutDialog")
- xWindow = VclPtr<vcl::AboutDialog>::Create(pParent, nBits, eInit);
else
xWindow = VclPtr<Dialog>::Create(pParent, nBits, eInit);
#if HAVE_FEATURE_DESKTOP
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 584741d17e11..070958751aed 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -4730,103 +4730,6 @@ public:
}
};
-class GtkInstanceAboutDialog final : public GtkInstanceDialog, public virtual weld::AboutDialog
-{
-private:
- GtkAboutDialog* m_pAboutDialog;
- GtkCssProvider* m_pCssProvider;
- std::unique_ptr<utl::TempFile> mxBackgroundImage;
-public:
- GtkInstanceAboutDialog(GtkAboutDialog* pAboutDialog, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
- : GtkInstanceDialog(GTK_WINDOW(pAboutDialog), pBuilder, bTakeOwnership)
- , m_pAboutDialog(pAboutDialog)
- , m_pCssProvider(nullptr)
- {
- // in GtkAboutDialog apply_use_header_bar if headerbar is false it
- // automatically adds a default close button which it doesn't if
- // headerbar is true and which doesn't appear in the .ui
- if (GtkWidget* pDefaultButton = gtk_dialog_get_widget_for_response(GTK_DIALOG(pAboutDialog), GTK_RESPONSE_DELETE_EVENT))
- gtk_widget_destroy(pDefaultButton);
- }
-
- virtual void set_version(const OUString& rVersion) override
- {
- gtk_about_dialog_set_version(m_pAboutDialog, OUStringToOString(rVersion, RTL_TEXTENCODING_UTF8).getStr());
- }
-
- virtual void set_copyright(const OUString& rCopyright) override
- {
- gtk_about_dialog_set_copyright(m_pAboutDialog, OUStringToOString(rCopyright, RTL_TEXTENCODING_UTF8).getStr());
- }
-
- virtual void set_website(const OUString& rURL) override
- {
- OString sURL(OUStringToOString(rURL, RTL_TEXTENCODING_UTF8));
- gtk_about_dialog_set_website(m_pAboutDialog, sURL.isEmpty() ? nullptr : sURL.getStr());
- }
-
- virtual void set_website_label(const OUString& rLabel) override
- {
- OString sLabel(OUStringToOString(rLabel, RTL_TEXTENCODING_UTF8));
- gtk_about_dialog_set_website_label(m_pAboutDialog, sLabel.isEmpty() ? nullptr : sLabel.getStr());
- }
-
- virtual OUString get_website_label() const override
- {
- const gchar* pText = gtk_about_dialog_get_website_label(m_pAboutDialog);
- return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8);
- }
-
- virtual void set_logo(const css::uno::Reference<css::graphic::XGraphic>& rImage) override
- {
- GdkPixbuf* pixbuf = rImage.is() ? getPixbuf(rImage) : nullptr;
- if (!pixbuf)
- gtk_about_dialog_set_logo(m_pAboutDialog, nullptr);
- else
- {
- gtk_about_dialog_set_logo(m_pAboutDialog, pixbuf);
- g_object_unref(pixbuf);
- }
- }
-
- virtual void set_background(const css::uno::Reference<css::graphic::XGraphic>& rImage) override
- {
- GtkStyleContext *pStyleContext = gtk_widget_get_style_context(GTK_WIDGET(m_pAboutDialog));
- if (m_pCssProvider)
- {
- gtk_style_context_remove_provider(pStyleContext, GTK_STYLE_PROVIDER(m_pCssProvider));
- m_pCssProvider= nullptr;
- }
-
- mxBackgroundImage.reset();
-
- if (rImage.is())
- {
- mxBackgroundImage.reset(new utl::TempFile());
- mxBackgroundImage->EnableKillingFile(true);
-
- Image aImage(rImage);
-
- vcl::PNGWriter aPNGWriter(aImage.GetBitmapEx());
- SvStream* pStream = mxBackgroundImage->GetStream(StreamMode::WRITE);
- aPNGWriter.Write(*pStream);
- mxBackgroundImage->CloseStream();
-
- m_pCssProvider = gtk_css_provider_new();
- OUString aBuffer = "* { background-image: url(\"" + mxBackgroundImage->GetURL() + "\"); }";
- OString aResult = OUStringToOString(aBuffer, RTL_TEXTENCODING_UTF8);
- gtk_css_provider_load_from_data(m_pCssProvider, aResult.getStr(), aResult.getLength(), nullptr);
- gtk_style_context_add_provider(pStyleContext, GTK_STYLE_PROVIDER(m_pCssProvider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- }
- }
-
- virtual ~GtkInstanceAboutDialog() override
- {
- set_background(nullptr);
- }
-};
-
class GtkInstanceAssistant : public GtkInstanceDialog, public virtual weld::Assistant
{
private:
@@ -14117,24 +14020,6 @@ private:
set_primary_text(pMessageDialog, (*m_pStringReplace)(get_primary_text(pMessageDialog)));
set_secondary_text(pMessageDialog, (*m_pStringReplace)(get_secondary_text(pMessageDialog)));
}
- else if (GTK_IS_ABOUT_DIALOG(pWindow))
- {
- GtkAboutDialog* pAboutDialog = GTK_ABOUT_DIALOG(pWindow);
- const gchar *pComments = gtk_about_dialog_get_comments(pAboutDialog);
- if (pComments)
- {
- OUString sComments(pComments, strlen(pComments), RTL_TEXTENCODING_UTF8);
- sComments = (*m_pStringReplace)(sComments);
- gtk_about_dialog_set_comments(pAboutDialog, OUStringToOString(sComments, RTL_TEXTENCODING_UTF8).getStr());
- }
- const gchar *pProgramName = gtk_about_dialog_get_program_name(pAboutDialog);
- if (pProgramName)
- {
- OUString sProgramName(pProgramName, strlen(pProgramName), RTL_TEXTENCODING_UTF8);
- sProgramName = (*m_pStringReplace)(sProgramName);
- gtk_about_dialog_set_program_name(pAboutDialog, OUStringToOString(sProgramName, RTL_TEXTENCODING_UTF8).getStr());
- }
- }
}
}
}
@@ -14283,15 +14168,6 @@ public:
return std::make_unique<GtkInstanceMessageDialog>(pMessageDialog, this, bTakeOwnership);
}
- virtual std::unique_ptr<weld::AboutDialog> weld_about_dialog(const OString &id, bool bTakeOwnership) override
- {
- GtkAboutDialog* pAboutDialog = GTK_ABOUT_DIALOG(gtk_builder_get_object(m_pBuilder, id.getStr()));
- if (!pAboutDialog)
- return nullptr;
- gtk_window_set_transient_for(GTK_WINDOW(pAboutDialog), GTK_WINDOW(gtk_widget_get_toplevel(m_pParentWidget)));
- return std::make_unique<GtkInstanceAboutDialog>(pAboutDialog, this, bTakeOwnership);
- }
-
virtual std::unique_ptr<weld::Assistant> weld_assistant(const OString &id, bool bTakeOwnership) override
{
GtkAssistant* pAssistant = GTK_ASSISTANT(gtk_builder_get_object(m_pBuilder, id.getStr()));