[Libreoffice-commits] core.git: cui/source include/vcl vcl/inc vcl/source vcl/unx xmlsecurity/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon May 17 18:37:07 UTC 2021


 cui/source/options/optgenrl.cxx              |    2 
 cui/source/options/optinet2.cxx              |    2 
 cui/source/tabpages/autocdlg.cxx             |    2 
 include/vcl/weld.hxx                         |    2 
 vcl/inc/salvtables.hxx                       |    2 
 vcl/source/app/salvtables.cxx                |    2 
 vcl/unx/gtk3/gtkinst.cxx                     |   87 +++++++++++++++++++--------
 xmlsecurity/source/dialogs/macrosecurity.cxx |    8 +-
 8 files changed, 74 insertions(+), 33 deletions(-)

New commits:
commit eb510f21572a35c89ae57ca060a02439e572cbd0
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon May 17 16:58:17 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 17 20:36:25 2021 +0200

    gtk4: reenable button
    
    rename label_line_wrap to label_wrap while I'm at it
    
    Change-Id: I3964c4b40d86fb6ef1fd3733088ffd80e57415ea
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115714
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx
index 6fcef33199c3..66c734af1194 100644
--- a/cui/source/options/optgenrl.cxx
+++ b/cui/source/options/optgenrl.cxx
@@ -315,7 +315,7 @@ void SvxGeneralTabPage::InitCryptography()
             {
                  m_xSigningKeyLB->set_size_request(nMaxWidth, -1);
                  m_xEncryptionKeyLB->set_size_request(nMaxWidth, -1);
-                 m_xEncryptToSelfCB->set_label_line_wrap(true);
+                 m_xEncryptToSelfCB->set_label_wrap(true);
                  m_xEncryptToSelfCB->set_size_request(nMaxWidth, -1);
             }
         }
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx
index f8648bac62a4..8f33c6a96700 100644
--- a/cui/source/options/optinet2.cxx
+++ b/cui/source/options/optinet2.cxx
@@ -496,7 +496,7 @@ SvxSecurityTabPage::SvxSecurityTabPage(weld::Container* pPage, weld::DialogContr
     int nMaxWidth = m_xSavePasswordsCB->get_approximate_digit_width() * 40;
     if (aPrefSize.Width() > nMaxWidth)
     {
-        m_xSavePasswordsCB->set_label_line_wrap(true);
+        m_xSavePasswordsCB->set_label_wrap(true);
         m_xSavePasswordsCB->set_size_request(nMaxWidth, -1);
     }
 
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index f1f4ee2bd0b1..8c21991be52b 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -1914,7 +1914,7 @@ OfaAutoCompleteTabPage::OfaAutoCompleteTabPage(weld::Container* pPage, weld::Dia
     int nMaxWidth = m_xCBRemoveList->get_approximate_digit_width() * 40;
     if (aPrefSize.Width() > nMaxWidth)
     {
-        m_xCBRemoveList->set_label_line_wrap(true);
+        m_xCBRemoveList->set_label_wrap(true);
         m_xCBRemoveList->set_size_request(nMaxWidth, -1);
     }
 
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index e55ca8d6b534..cd8958dd602b 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1381,7 +1381,7 @@ public:
     virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0;
     virtual void set_from_icon_name(const OUString& rIconName) = 0;
     virtual OUString get_label() const = 0;
-    virtual void set_label_line_wrap(bool wrap) = 0;
+    virtual void set_label_wrap(bool wrap) = 0;
     void clicked() { signal_clicked(); }
 
     // font size is in points, not pixels, e.g. see Window::[G]etPointFont
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 361d26e3d9fe..207e326e43f5 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1021,7 +1021,7 @@ public:
 
     virtual void set_from_icon_name(const OUString& rIconName) override;
 
-    virtual void set_label_line_wrap(bool wrap) override;
+    virtual void set_label_wrap(bool wrap) override;
 
     virtual OUString get_label() const override;
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 813d74470139..d3b60a55c38f 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2596,7 +2596,7 @@ void SalInstanceButton::set_from_icon_name(const OUString& rIconName)
     m_xButton->SetModeImage(Image(StockImage::Yes, rIconName));
 }
 
-void SalInstanceButton::set_label_line_wrap(bool wrap)
+void SalInstanceButton::set_label_wrap(bool wrap)
 {
     WinBits nBits = m_xButton->GetStyle();
     nBits &= ~WB_WORDBREAK;
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 82a506ebc74b..0ca6d49d504f 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -3711,7 +3711,6 @@ GdkPixbuf* load_icon_by_name(const OUString& rIconName)
 
 namespace
 {
-#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkPixbuf* getPixbuf(const css::uno::Reference<css::graphic::XGraphic>& rImage)
     {
         Image aImage(rImage);
@@ -3733,6 +3732,7 @@ namespace
         return load_icon_from_stream(*xMemStm);
     }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkPixbuf* getPixbuf(const VirtualDevice& rDevice)
     {
         Size aSize(rDevice.GetOutputSizePixel());
@@ -3792,29 +3792,52 @@ namespace
     }
 #endif
 
-#if !GTK_CHECK_VERSION(4, 0, 0)
     GtkWidget* image_new_from_virtual_device(const VirtualDevice& rImageSurface)
     {
         GtkWidget* pImage = nullptr;
         cairo_surface_t* surface = get_underlying_cairo_surface(rImageSurface);
 
         Size aSize(rImageSurface.GetOutputSizePixel());
+#if GTK_CHECK_VERSION(4, 0, 0)
+        double x_scale(1.0), y_scale(1.0);
+        cairo_surface_get_device_scale(surface, &x_scale, &y_scale);
+        cairo_surface_t* target = cairo_surface_create_similar_image(surface,
+                                                                     CAIRO_FORMAT_ARGB32,
+                                                                     aSize.Width() * x_scale,
+                                                                     aSize.Height() * y_scale);
+        cairo_surface_set_device_scale(target, x_scale, y_scale);
+#else
         cairo_surface_t* target = cairo_surface_create_similar(surface,
                                                                cairo_surface_get_content(surface),
                                                                aSize.Width(),
                                                                aSize.Height());
-
+#endif
         cairo_t* cr = cairo_create(target);
         cairo_set_source_surface(cr, surface, 0, 0);
         cairo_paint(cr);
         cairo_destroy(cr);
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+        GBytes* bytes = g_bytes_new_with_free_func(cairo_image_surface_get_data(target),
+                                                   cairo_image_surface_get_height(target) *
+                                                   cairo_image_surface_get_stride(target),
+                                                   reinterpret_cast<GDestroyNotify>(cairo_surface_destroy),
+                                                   cairo_surface_reference(target));
+
+        GdkTexture* texture = gdk_memory_texture_new(cairo_image_surface_get_width(target),
+                                                     cairo_image_surface_get_height(target),
+                                                     GDK_MEMORY_DEFAULT,
+                                                     bytes,
+                                                     cairo_image_surface_get_stride(target));
+
+        g_bytes_unref (bytes);
+
+        pImage = gtk_image_new_from_paintable(GDK_PAINTABLE(texture));
+#else
         pImage = gtk_image_new_from_surface(target);
 #endif
         cairo_surface_destroy(target);
         return pImage;
     }
-#endif
 
 #if !GTK_CHECK_VERSION(4, 0, 0)
 class MenuHelper
@@ -5516,7 +5539,9 @@ private:
     {
         if (GTK_IS_LABEL(pWidget))
         {
-#if !GTK_CHECK_VERSION(4, 0, 0)
+#if GTK_CHECK_VERSION(4, 0, 0)
+            gtk_label_set_wrap(GTK_LABEL(pWidget), true);
+#else
             gtk_label_set_line_wrap(GTK_LABEL(pWidget), true);
 #endif
             gtk_label_set_width_chars(GTK_LABEL(pWidget), 22);
@@ -7571,6 +7596,13 @@ void set_font(GtkLabel* pLabel, const vcl::Font& rFont)
 }
 
 #if !GTK_CHECK_VERSION(4, 0, 0)
+
+}
+
+#endif
+
+namespace {
+
 class GtkInstanceButton : public GtkInstanceWidget, public virtual weld::Button
 {
 private:
@@ -7690,37 +7722,49 @@ public:
 #if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_button_set_always_show_image(m_pButton, true);
         gtk_button_set_image_position(m_pButton, GTK_POS_LEFT);
-        if (pDevice)
-            gtk_button_set_image(m_pButton, image_new_from_virtual_device(*pDevice));
-        else
-            gtk_button_set_image(m_pButton, nullptr);
+#endif
+        GtkWidget* pImage = pDevice ? image_new_from_virtual_device(*pDevice) : nullptr;
+#if GTK_CHECK_VERSION(4, 0, 0)
+        gtk_button_set_child(m_pButton, pImage);
 #else
-        (void)pDevice;
+        gtk_button_set_image(m_pButton, pImage);
 #endif
     }
 
     virtual void set_from_icon_name(const OUString& rIconName) override
     {
         GdkPixbuf* pixbuf = load_icon_by_name(rIconName);
+        GtkWidget* pImage;
         if (!pixbuf)
-            gtk_button_set_image(m_pButton, nullptr);
+            pImage = nullptr;
         else
         {
-            gtk_button_set_image(m_pButton, gtk_image_new_from_pixbuf(pixbuf));
+            pImage = gtk_image_new_from_pixbuf(pixbuf);
             g_object_unref(pixbuf);
         }
+#if GTK_CHECK_VERSION(4, 0, 0)
+        gtk_button_set_child(m_pButton, pImage);
+#else
+        gtk_button_set_image(m_pButton, pImage);
+#endif
     }
 
     virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override
     {
         GdkPixbuf* pixbuf = getPixbuf(rImage);
+        GtkWidget* pImage;
         if (!pixbuf)
-            gtk_button_set_image(m_pButton, nullptr);
+            pImage = nullptr;
         else
         {
-            gtk_button_set_image(m_pButton, gtk_image_new_from_pixbuf(pixbuf));
+            pImage = gtk_image_new_from_pixbuf(pixbuf);
             g_object_unref(pixbuf);
         }
+#if GTK_CHECK_VERSION(4, 0, 0)
+        gtk_button_set_child(m_pButton, pImage);
+#else
+        gtk_button_set_image(m_pButton, pImage);
+#endif
     }
 
     virtual void set_custom_button(VirtualDevice* pDevice) override
@@ -7733,10 +7777,14 @@ public:
         return ::get_label(m_pButton);
     }
 
-    virtual void set_label_line_wrap(bool wrap) override
+    virtual void set_label_wrap(bool wrap) override
     {
         GtkWidget* pChild = get_label_widget();
+#if GTK_CHECK_VERSION(4, 0, 0)
+        gtk_label_set_wrap(GTK_LABEL(pChild), wrap);
+#else
         gtk_label_set_line_wrap(GTK_LABEL(pChild), wrap);
+#endif
     }
 
     virtual void set_font(const vcl::Font& rFont) override
@@ -7788,8 +7836,6 @@ public:
 
 }
 
-#endif
-
 void GtkInstanceDialog::asyncresponse(gint ret)
 {
     SolarMutexGuard aGuard;
@@ -18502,16 +18548,11 @@ public:
 
     virtual std::unique_ptr<weld::Button> weld_button(const OString &id) override
     {
-#if !GTK_CHECK_VERSION(4, 0, 0)
         GtkButton* pButton = GTK_BUTTON(gtk_builder_get_object(m_pBuilder, id.getStr()));
         if (!pButton)
             return nullptr;
         auto_add_parentless_widgets_to_container(GTK_WIDGET(pButton));
         return std::make_unique<GtkInstanceButton>(pButton, this, false);
-#else
-        (void)id;
-        return nullptr;
-#endif
     }
 
     virtual std::unique_ptr<weld::MenuButton> weld_menu_button(const OString &id) override
diff --git a/xmlsecurity/source/dialogs/macrosecurity.cxx b/xmlsecurity/source/dialogs/macrosecurity.cxx
index ac4d7bc5188b..b7a5112b5401 100644
--- a/xmlsecurity/source/dialogs/macrosecurity.cxx
+++ b/xmlsecurity/source/dialogs/macrosecurity.cxx
@@ -115,13 +115,13 @@ MacroSecurityLevelTP::MacroSecurityLevelTP(weld::Container* pParent, MacroSecuri
     int nMaxWidth = m_xLowRB->get_approximate_digit_width() * 60;
     if (nPrefWidth > nMaxWidth)
     {
-        m_xLowRB->set_label_line_wrap(true);
+        m_xLowRB->set_label_wrap(true);
         m_xLowRB->set_size_request(nMaxWidth, -1);
-        m_xMediumRB->set_label_line_wrap(true);
+        m_xMediumRB->set_label_wrap(true);
         m_xMediumRB->set_size_request(nMaxWidth, -1);
-        m_xHighRB->set_label_line_wrap(true);
+        m_xHighRB->set_label_wrap(true);
         m_xHighRB->set_size_request(nMaxWidth, -1);
-        m_xVeryHighRB->set_label_line_wrap(true);
+        m_xVeryHighRB->set_label_wrap(true);
         m_xVeryHighRB->set_size_request(nMaxWidth, -1);
     }
 


More information about the Libreoffice-commits mailing list