[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 11 14:38:02 UTC 2021


 vcl/unx/gtk3/gtkdata.cxx |   58 ++++++++++++++++++++++++++++-------------------
 1 file changed, 35 insertions(+), 23 deletions(-)

New commits:
commit 27f2084cbe0f505e59420e90235bfd7a668ae96e
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue May 11 13:51:00 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 11 16:37:17 2021 +0200

    gtk4: style provider is at GdkDisplay rather than GdkScreen now
    
    Change-Id: I9ae0d2e306c7470237ab16436dd80518c911deb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115401
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtkdata.cxx b/vcl/unx/gtk3/gtkdata.cxx
index a30e4df0b853..4cea5bc5d223 100644
--- a/vcl/unx/gtk3/gtkdata.cxx
+++ b/vcl/unx/gtk3/gtkdata.cxx
@@ -443,6 +443,37 @@ bool GtkSalData::Yield( bool bWait, bool bHandleAllCurrentEvents )
     return bWasEvent;
 }
 
+static GtkStyleProvider* CreateSmallButtonProvider()
+{
+    /*
+       set a provider to allow certain widgets to have no padding
+
+       a) little close button in menubar to close back to start-center
+       b) and small buttons in view->data sources (button.small-button)
+       c) small toolbar button in infobars (toolbar.small-button button)
+       d) comboboxes in the data browser for tdf#137695 (box#combobox button.small-button,
+          which would instead be combobox button.small-button if we didn't replace GtkComboBox,
+          see GtkInstanceComboBox for an explanation for why we do that)
+       e) entry in the data browser for tdf#137695 (entry.small-button)
+    */
+    GtkCssProvider* pSmallButtonProvider = gtk_css_provider_new();
+    static const gchar data[] =
+      "button.small-button, toolbar.small-button button, combobox.small-button *.combo, box#combobox.small-button *.combo, entry.small-button { "
+      "padding: 0;"
+      "margin-left: 0px;"
+      "margin-right: 0px;"
+      "min-height: 18px;"
+      "min-width: 18px;"
+      "}";
+#if GTK_CHECK_VERSION(4, 0, 0)
+    gtk_css_provider_load_from_data(pSmallButtonProvider, data, -1);
+#else
+    gtk_css_provider_load_from_data(pSmallButtonProvider, data, -1, nullptr);
+#endif
+
+    return GTK_STYLE_PROVIDER(pSmallButtonProvider);
+}
+
 void GtkSalData::Init()
 {
     SAL_INFO( "vcl.gtk", "GtkMainloop::Init()" );
@@ -554,31 +585,12 @@ void GtkSalData::Init()
         g_signal_connect( G_OBJECT(pScreen), "monitors-changed",
                           G_CALLBACK(signalMonitorsChanged), GetGtkDisplay() );
 
-        /*
-           set a provider to allow certain widgets to have no padding
-
-           a) little close button in menubar to close back to start-center
-           b) and small buttons in view->data sources (button.small-button)
-           c) small toolbar button in infobars (toolbar.small-button button)
-           d) comboboxes in the data browser for tdf#137695 (box#combobox button.small-button,
-              which would instead be combobox button.small-button if we didn't replace GtkComboBox,
-              see GtkInstanceComboBox for an explanation for why we do that)
-           e) entry in the data browser for tdf#137695 (entry.small-button)
-        */
-        GtkCssProvider* pSmallButtonProvider = gtk_css_provider_new();
-        static const gchar data[] =
-          "button.small-button, toolbar.small-button button, combobox.small-button *.combo, box#combobox.small-button *.combo, entry.small-button { "
-          "padding: 0;"
-          "margin-left: 0px;"
-          "margin-right: 0px;"
-          "min-height: 18px;"
-          "min-width: 18px;"
-          "}";
-        gtk_css_provider_load_from_data(pSmallButtonProvider, data, -1, nullptr);
-
-        gtk_style_context_add_provider_for_screen(pScreen, GTK_STYLE_PROVIDER(pSmallButtonProvider),
+        gtk_style_context_add_provider_for_screen(pScreen, CreateSmallButtonProvider(),
             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
     }
+#else
+    gtk_style_context_add_provider_for_display(pGdkDisp, CreateSmallButtonProvider(),
+            GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 #endif
 }
 


More information about the Libreoffice-commits mailing list