summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk3
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-01-24 11:11:05 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-01-24 15:56:59 +0100
commite2ff4206d60df486bf02931ce69c47857de6b04e (patch)
tree390da9ab99357d02d388952ad5feb91db731af51 /vcl/unx/gtk3
parentf3d8750b07ff3ab89b27f0b1274b71de4924def6 (diff)
gtk4: adapt to window_[g|s]et_default_widget
Change-Id: I916e5db05f8ea10ecc8b319cc77a671ca7cbcb93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128859 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx/gtk3')
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx84
1 files changed, 54 insertions, 30 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 39ebfb67bb38..ebc162dfcf65 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -3510,18 +3510,6 @@ public:
return false;
}
- virtual void set_has_default(bool has_default) override
- {
- g_object_set(G_OBJECT(m_pWidget), "has-default", has_default, nullptr);
- }
-
- virtual bool get_has_default() const override
- {
- gboolean has_default(false);
- g_object_get(G_OBJECT(m_pWidget), "has-default", &has_default, nullptr);
- return has_default;
- }
-
virtual void show() override
{
gtk_widget_show(m_pWidget);
@@ -3876,7 +3864,7 @@ public:
return m_pWidget;
}
- GtkWindow* getWindow()
+ GtkWindow* getWindow() const
{
return GTK_WINDOW(widget_get_toplevel(m_pWidget));
}
@@ -5692,18 +5680,6 @@ private:
gulong m_nSetFocusChildSignalId;
bool m_bChildHasFocus;
- static void implResetDefault(GtkWidget *pWidget, gpointer user_data)
- {
- if (GTK_IS_BUTTON(pWidget))
- g_object_set(G_OBJECT(pWidget), "has-default", false, nullptr);
-#if !GTK_CHECK_VERSION(4, 0, 0)
- if (GTK_IS_CONTAINER(pWidget))
- gtk_container_forall(GTK_CONTAINER(pWidget), implResetDefault, user_data);
-#else
- (void)user_data;
-#endif
- }
-
void signal_set_focus_child(bool bChildHasFocus)
{
if (m_bChildHasFocus != bChildHasFocus)
@@ -5807,11 +5783,6 @@ public:
g_object_unref(pChild);
}
- virtual void recursively_unset_default_buttons() override
- {
- implResetDefault(GTK_WIDGET(m_pContainer), nullptr);
- }
-
virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() override
{
// This will cause a GtkSalFrame to be created. With WB_SYSTEMCHILDWINDOW set it
@@ -6034,6 +6005,21 @@ private:
gulong m_nToplevelFocusChangedSignalId;
#if !GTK_CHECK_VERSION(4, 0, 0)
+ static void implResetDefault(GtkWidget *pWidget, gpointer user_data)
+ {
+ if (GTK_IS_BUTTON(pWidget))
+ g_object_set(G_OBJECT(pWidget), "has-default", false, nullptr);
+ if (GTK_IS_CONTAINER(pWidget))
+ gtk_container_forall(GTK_CONTAINER(pWidget), implResetDefault, user_data);
+ }
+
+ void recursively_unset_default_buttons()
+ {
+ implResetDefault(GTK_WIDGET(m_pWindow), nullptr);
+ }
+#endif
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
static gboolean help_pressed(GtkAccelGroup*, GObject*, guint, GdkModifierType, gpointer widget)
{
GtkInstanceWindow* pThis = static_cast<GtkInstanceWindow*>(widget);
@@ -6191,6 +6177,44 @@ public:
gtk_window_present(m_pWindow);
}
+ virtual void change_default_widget(weld::Widget* pOld, weld::Widget* pNew) override
+ {
+#if GTK_CHECK_VERSION(4, 0, 0)
+ GtkInstanceWidget* pGtkNew = dynamic_cast<GtkInstanceWidget*>(pNew);
+ GtkWidget* pWidgetNew = pGtkNew ? pGtkNew->getWidget() : nullptr;
+ gtk_window_set_default_widget(m_pWindow, pWidgetNew);
+ (void)pOld;
+#else
+ if (!pOld)
+ recursively_unset_default_buttons();
+ else
+ {
+ GtkInstanceWidget* pGtkOld = dynamic_cast<GtkInstanceWidget*>(pOld);
+ GtkWidget* pWidgetOld = pGtkOld->getWidget();
+ g_object_set(G_OBJECT(pWidgetOld), "has-default", false, nullptr);
+ }
+ if (pNew)
+ {
+ GtkInstanceWidget* pGtkNew = dynamic_cast<GtkInstanceWidget*>(pNew);
+ GtkWidget* pWidgetNew = pGtkNew->getWidget();
+ g_object_set(G_OBJECT(pWidgetNew), "has-default", true, nullptr);
+ }
+#endif
+ }
+
+ virtual bool is_default_widget(const weld::Widget* pCandidate) const override
+ {
+ const GtkInstanceWidget* pGtkCandidate = dynamic_cast<const GtkInstanceWidget*>(pCandidate);
+ GtkWidget* pWidget = pGtkCandidate->getWidget();
+#if GTK_CHECK_VERSION(4, 0, 0)
+ return gtk_window_get_default_widget(m_pWindow) == pWidget;
+#else
+ gboolean has_default(false);
+ g_object_get(G_OBJECT(pWidget), "has-default", &has_default, nullptr);
+ return has_default;
+#endif
+ }
+
virtual void set_window_state(const OString& rStr) override
{
WindowStateData aData;