summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-12-27 17:18:44 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-01-01 13:19:28 +0100
commitb199e335c01f265ba2604c020928b63356b42d15 (patch)
tree1015423b1bb5b45ce28e8a4a47ea6e20188b8795 /vcl
parentf0fc4ac88d0d82ee81e0a55bdc54421f955705f0 (diff)
weld NumberFormatPropertyPanel
including GtkMenuToolButton hackery to support a toggled state Change-Id: Ia1cf5fd7d56c2e475194cd2d0431611f278f5a33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85873 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx54
1 files changed, 47 insertions, 7 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 1addc51082d2..6630ee15f2fc 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -7052,6 +7052,17 @@ private:
gtk_container_forall(GTK_CONTAINER(pWidget), find_menu_button, user_data);
}
+ static void find_menupeer_button(GtkWidget *pWidget, gpointer user_data)
+ {
+ if (g_strcmp0(gtk_widget_get_name(pWidget), "GtkButton") == 0)
+ {
+ GtkWidget **ppButton = static_cast<GtkWidget**>(user_data);
+ *ppButton = pWidget;
+ }
+ else if (GTK_IS_CONTAINER(pWidget))
+ gtk_container_forall(GTK_CONTAINER(pWidget), find_menupeer_button, user_data);
+ }
+
static void collect(GtkWidget* pItem, gpointer widget)
{
if (GTK_IS_TOOL_BUTTON(pItem))
@@ -7139,8 +7150,24 @@ public:
disable_item_notify_events();
GtkToolButton* pToolButton = m_aMap.find(rIdent)->second;
- assert(GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton) || !bActive);
- if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton))
+
+ assert(GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton) || GTK_IS_MENU_TOOL_BUTTON(pToolButton) || !bActive);
+ if (GTK_IS_MENU_TOOL_BUTTON(pToolButton))
+ {
+ GtkButton* pButton = nullptr;
+ // there is no GtkMenuToggleToolButton so abuse the CHECKED state of the GtkMenuToolButton button
+ // to emulate one
+ find_menupeer_button(GTK_WIDGET(pToolButton), &pButton);
+ if (pButton)
+ {
+ GtkStyleContext *pWidgetContext = gtk_widget_get_style_context(GTK_WIDGET(pButton));
+ auto eState = gtk_style_context_get_state(pWidgetContext) & ~GTK_STATE_FLAG_CHECKED;
+ if (bActive)
+ eState |= GTK_STATE_FLAG_CHECKED;
+ gtk_style_context_set_state(pWidgetContext, static_cast<GtkStateFlags>(eState));
+ }
+ }
+ else if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton))
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton), bActive);
enable_item_notify_events();
@@ -7148,12 +7175,25 @@ public:
virtual bool get_item_active(const OString& rIdent) const override
{
- auto aFind = m_aMenuButtonMap.find(rIdent);
- if (aFind != m_aMenuButtonMap.end())
- return aFind->second->get_active();
-
GtkToolButton* pToolButton = m_aMap.find(rIdent)->second;
- return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton));
+
+ assert(GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton) || GTK_IS_MENU_TOOL_BUTTON(pToolButton));
+ if (GTK_IS_MENU_TOOL_BUTTON(pToolButton))
+ {
+ GtkButton* pButton = nullptr;
+ // there is no GtkMenuToggleToolButton so abuse the CHECKED state of the GtkMenuToolButton button
+ // to emulate one
+ find_menupeer_button(GTK_WIDGET(pToolButton), &pButton);
+ if (pButton)
+ {
+ GtkStyleContext *pWidgetContext = gtk_widget_get_style_context(GTK_WIDGET(pButton));
+ return gtk_style_context_get_state(pWidgetContext) & GTK_STATE_FLAG_CHECKED;
+ }
+ }
+ else if (GTK_IS_TOGGLE_TOOL_BUTTON(pToolButton))
+ return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton));
+
+ return false;
}
virtual void set_menu_item_active(const OString& rIdent, bool bActive) override