summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-04-29 15:06:42 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-04-29 22:10:36 +0200
commit754bea8c6a17889f9d4d23bf98847b6b67253220 (patch)
treebce7aa56ed341674fcb70975738cd879ef904238 /vcl
parent15652c6cdfe62486d9f0e5f76de624c631f5cc24 (diff)
remove the padding around the dropdown button of GtkMenuToolButtons
the default is very wide in the default gtk themes, try and minimize that padding as the existing designs generally assume a very narrow dropdown Change-Id: Ibb3b0280067e981b7c782b6023fc3d36dbc0d364 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93167 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 42a97247beb2..c9ef82ec8657 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -7661,6 +7661,7 @@ class GtkInstanceToolbar : public GtkInstanceWidget, public virtual weld::Toolba
{
private:
GtkToolbar* m_pToolbar;
+ GtkCssProvider *m_pMenuButtonProvider;
std::map<OString, GtkToolItem*> m_aMap;
std::map<OString, std::unique_ptr<GtkInstanceMenuButton>> m_aMenuButtonMap;
@@ -7718,6 +7719,39 @@ private:
// left in the main document and not in the toolbar
gtk_button_set_focus_on_click(GTK_BUTTON(pMenuButton), false);
g_signal_connect(pMenuButton, "toggled", G_CALLBACK(signalItemToggled), this);
+
+ if (pMenuButton)
+ {
+ // by default the GtkMenuButton down arrow button is as wide as
+ // a normal button and LibreOffice's original ones are very
+ // narrow, that assumption is fairly baked into the toolbar and
+ // sidebar designs, try and minimize the width of the dropdown
+ // zone.
+ GtkStyleContext *pButtonContext = gtk_widget_get_style_context(GTK_WIDGET(pMenuButton));
+
+ if (!m_pMenuButtonProvider)
+ {
+ m_pMenuButtonProvider = gtk_css_provider_new();
+ static const gchar data[] = "* { "
+ "padding: 0;"
+ "margin-left: 0px;"
+ "margin-right: 0px;"
+ "min-width: 4px;"
+ "}";
+ const gchar olddata[] = "* { "
+ "padding: 0;"
+ "margin-left: 0px;"
+ "margin-right: 0px;"
+ "}";
+ gtk_css_provider_load_from_data(m_pMenuButtonProvider, gtk_check_version(3, 20, 0) == nullptr ? data : olddata, -1, nullptr);
+ }
+
+ gtk_style_context_add_provider(pButtonContext,
+ GTK_STYLE_PROVIDER(m_pMenuButtonProvider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gtk_style_context_add_class(pButtonContext, "small-button");
+ }
+
}
if (!GTK_IS_TOOL_BUTTON(pToolItem))
return;
@@ -7788,6 +7822,7 @@ public:
GtkInstanceToolbar(GtkToolbar* pToolbar, GtkInstanceBuilder* pBuilder, bool bTakeOwnership)
: GtkInstanceWidget(GTK_WIDGET(pToolbar), pBuilder, bTakeOwnership)
, m_pToolbar(pToolbar)
+ , m_pMenuButtonProvider(nullptr)
{
gtk_container_foreach(GTK_CONTAINER(pToolbar), collect, this);
}