diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-03 16:04:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-09-03 20:10:36 +0200 |
commit | 09601f9470cb342ccfd8a513e4a2460adf047b63 (patch) | |
tree | 339b0c5f5f1c1b5de1b88d604fd53297c241e4ec /vcl | |
parent | 0be6e21857f868d85049fca2c8e02fc5e8802120 (diff) |
set small button provider at screen instead of at each widget
and make the small close button in the menubar use that same provider
add a small-button pattern to match buttons in toolbars
Change-Id: I13623519d6fa51d9bd474589fa00e2fcc0c1e599
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102013
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkdata.cxx | 47 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 30 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtksalmenu.cxx | 20 |
3 files changed, 37 insertions, 60 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx index 912bc52d116b..cdded04ae8c2 100644 --- a/vcl/unx/gtk3/gtk3gtkdata.cxx +++ b/vcl/unx/gtk3/gtk3gtkdata.cxx @@ -498,22 +498,45 @@ void GtkSalData::Init() GtkSalDisplay *pDisplay = new GtkSalDisplay( pGdkDisp ); SetDisplay( pDisplay ); - //FIXME: unwind keyboard extension bits - - // add signal handler to notify screen size changes int nScreens = gdk_display_get_n_screens( pGdkDisp ); for( int n = 0; n < nScreens; n++ ) { GdkScreen *pScreen = gdk_display_get_screen( pGdkDisp, n ); - if( pScreen ) - { - pDisplay->screenSizeChanged( pScreen ); - pDisplay->monitorsChanged( pScreen ); - g_signal_connect( G_OBJECT(pScreen), "size-changed", - G_CALLBACK(signalScreenSizeChanged), pDisplay ); - g_signal_connect( G_OBJECT(pScreen), "monitors-changed", - G_CALLBACK(signalMonitorsChanged), GetGtkDisplay() ); - } + if (!pScreen) + continue; + + pDisplay->screenSizeChanged( pScreen ); + pDisplay->monitorsChanged( pScreen ); + // add signal handler to notify screen size changes + g_signal_connect( G_OBJECT(pScreen), "size-changed", + G_CALLBACK(signalScreenSizeChanged), pDisplay ); + g_signal_connect( G_OBJECT(pScreen), "monitors-changed", + G_CALLBACK(signalMonitorsChanged), GetGtkDisplay() ); + + /* + set a provider to allow certain buttons to have no padding + + a) little close button in menubar to close back to start-center + b) small buttons in view->data sources + c) small toolbar button in infobars + */ + GtkCssProvider* pSmallButtonProvider = gtk_css_provider_new(); + static const gchar data[] = "button.small-button, toolbar.small-button button { " + "padding: 0;" + "margin-left: 0px;" + "margin-right: 0px;" + "min-height: 18px;" + "min-width: 18px;" + "}"; + static const gchar olddata[] = "button.small-button, toolbar.small-button button { " + "padding: 0;" + "margin-left: 0px;" + "margin-right: 0px;" + "}"; + gtk_css_provider_load_from_data(pSmallButtonProvider, gtk_check_version(3, 20, 0) == nullptr ? data : olddata, -1, nullptr); + + gtk_style_context_add_provider_for_screen(pScreen, GTK_STYLE_PROVIDER(pSmallButtonProvider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 18c3baa0341c..ab92be3f3c27 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -7931,7 +7931,6 @@ private: gtk_style_context_add_provider(pButtonContext, GTK_STYLE_PROVIDER(m_pMenuButtonProvider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - gtk_style_context_add_class(pButtonContext, "small-button"); } } @@ -15551,7 +15550,6 @@ private: GtkBuilder* m_pBuilder; GSList* m_pObjectList; GtkWidget* m_pParentWidget; - GtkCssProvider *m_pSmallButtonProvider; gulong m_nNotifySignalId; std::vector<GtkButton*> m_aMnemonicButtons; std::vector<GtkLabel*> m_aMnemonicLabels; @@ -15643,33 +15641,6 @@ private: } if (gtk_button_get_use_underline(pButton) && !gtk_button_get_use_stock(pButton)) m_aMnemonicButtons.push_back(pButton); - - GtkStyleContext *pButtonContext = gtk_widget_get_style_context(pWidget); - if (gtk_style_context_has_class(pButtonContext, "small-button")) - { - if (!m_pSmallButtonProvider) - { - m_pSmallButtonProvider = gtk_css_provider_new(); - static const gchar data[] = "* { " - "padding: 0;" - "margin-left: 0px;" - "margin-right: 0px;" - "min-height: 18px;" - "min-width: 18px;" - "}"; - const gchar olddata[] = "* { " - "padding: 0;" - "margin-left: 0px;" - "margin-right: 0px;" - "}"; - gtk_css_provider_load_from_data(m_pSmallButtonProvider, gtk_check_version(3, 20, 0) == nullptr ? data : olddata, -1, nullptr); - } - - gtk_style_context_add_provider(pButtonContext, - GTK_STYLE_PROVIDER(m_pSmallButtonProvider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - } - } else if (GTK_IS_LABEL(pWidget)) { @@ -15752,7 +15723,6 @@ public: : weld::Builder() , m_pStringReplace(Translate::GetReadStringHook()) , m_pParentWidget(pParent) - , m_pSmallButtonProvider(nullptr) , m_nNotifySignalId(0) , m_xInterimGlue(pInterimGlue) { diff --git a/vcl/unx/gtk3/gtk3gtksalmenu.cxx b/vcl/unx/gtk3/gtk3gtksalmenu.cxx index 1ed0192de700..4a32af2043df 100644 --- a/vcl/unx/gtk3/gtk3gtksalmenu.cxx +++ b/vcl/unx/gtk3/gtk3gtksalmenu.cxx @@ -657,6 +657,8 @@ void GtkSalMenu::ShowCloseButton(bool bShow) MenuBar *pVclMenuBar = static_cast<MenuBar*>(mpVCLMenu.get()); mpCloseButton = gtk_button_new(); + gtk_widget_set_margin_start(mpCloseButton, 8); + gtk_widget_set_margin_end(mpCloseButton, 8); g_signal_connect(mpCloseButton, "clicked", G_CALLBACK(CloseMenuBar), pVclMenuBar); gtk_button_set_relief(GTK_BUTTON(mpCloseButton), GTK_RELIEF_NONE); @@ -665,24 +667,6 @@ void GtkSalMenu::ShowCloseButton(bool bShow) GtkStyleContext *pButtonContext = gtk_widget_get_style_context(GTK_WIDGET(mpCloseButton)); - GtkCssProvider *pProvider = gtk_css_provider_new(); - static const gchar data[] = "* { " - "padding: 0;" - "margin-left: 8px;" - "margin-right: 8px;" - "min-width: 18px;" - "min-height: 18px;" - "}"; - const gchar olddata[] = "* { " - "padding: 0;" - "margin-left: 8px;" - "margin-right: 8px;" - "}"; - gtk_css_provider_load_from_data(pProvider, gtk_check_version(3, 20, 0) == nullptr ? data : olddata, -1, nullptr); - gtk_style_context_add_provider(pButtonContext, - GTK_STYLE_PROVIDER(pProvider), - GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - gtk_style_context_add_class(pButtonContext, "flat"); gtk_style_context_add_class(pButtonContext, "small-button"); |