summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-05-21 15:18:33 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-05-21 20:53:48 +0200
commit4cd4946b7c04e192d2f2fa164eae87224f4d0b5d (patch)
treeb4fd9776c6e22fdbc80a87a821091ccc666758b3
parent89cc421a6b246df36415fc3fbbec00435ffc5a85 (diff)
gtk4: reenable ToggleButton
Change-Id: If6458ef0a5ad21532c9aa96ed52779993353b572 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115939 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx26
1 files changed, 18 insertions, 8 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 9171de7f2f50..56d05b1dc6aa 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -8086,8 +8086,6 @@ GtkInstanceButton* GtkInstanceDialog::has_click_handler(int nResponse)
return pButton;
}
-#if !GTK_CHECK_VERSION(4, 0, 0)
-
namespace {
class GtkInstanceToggleButton : public GtkInstanceButton, public virtual weld::ToggleButton
@@ -8114,7 +8112,7 @@ public:
virtual void set_active(bool active) override
{
disable_notify_events();
- gtk_toggle_button_set_inconsistent(m_pToggleButton, false);
+ set_inconsistent(false);
gtk_toggle_button_set_active(m_pToggleButton, active);
enable_notify_events();
}
@@ -8126,12 +8124,23 @@ public:
virtual void set_inconsistent(bool inconsistent) override
{
+#if GTK_CHECK_VERSION(4, 0, 0)
+ if (inconsistent)
+ gtk_widget_set_state_flags(GTK_WIDGET(m_pToggleButton), GTK_STATE_FLAG_INCONSISTENT, false);
+ else
+ gtk_widget_unset_state_flags(GTK_WIDGET(m_pToggleButton), GTK_STATE_FLAG_INCONSISTENT);
+#else
gtk_toggle_button_set_inconsistent(m_pToggleButton, inconsistent);
+#endif
}
virtual bool get_inconsistent() const override
{
+#if GTK_CHECK_VERSION(4, 0, 0)
+ return gtk_widget_get_state_flags(GTK_WIDGET(m_pToggleButton)) & GTK_STATE_FLAG_INCONSISTENT;
+#else
return gtk_toggle_button_get_inconsistent(m_pToggleButton);
+#endif
}
virtual void disable_notify_events() override
@@ -8152,6 +8161,12 @@ public:
}
};
+}
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
+
+namespace {
+
void do_grab(GtkWidget* pWidget)
{
#if !GTK_CHECK_VERSION(4, 0, 0)
@@ -18947,16 +18962,11 @@ public:
virtual std::unique_ptr<weld::ToggleButton> weld_toggle_button(const OString &id) override
{
-#if !GTK_CHECK_VERSION(4, 0, 0)
GtkToggleButton* pToggleButton = GTK_TOGGLE_BUTTON(gtk_builder_get_object(m_pBuilder, id.getStr()));
if (!pToggleButton)
return nullptr;
auto_add_parentless_widgets_to_container(GTK_WIDGET(pToggleButton));
return std::make_unique<GtkInstanceToggleButton>(pToggleButton, this, false);
-#else
- (void)id;
- return nullptr;
-#endif
}
virtual std::unique_ptr<weld::RadioButton> weld_radio_button(const OString &id) override