diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-10-17 11:36:50 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-10-17 14:35:40 +0200 |
commit | d1b8b1a22136228dd6c31a44c1d19840c27c0cf7 (patch) | |
tree | 6855ca4e19c7c30dfa8f1605a1338a9299d61cd9 | |
parent | 9d04e52257ea85c16d21ca78bebb3fb13fe99c60 (diff) |
Resolves: tdf#128129 add support for left/right expand/collapse
Change-Id: I6c8f11e1e2b4192933541e754a078c4d0ff58206
Reviewed-on: https://gerrit.libreoffice.org/80938
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index f178acd4fc5a..79a5ce12d750 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -7726,6 +7726,7 @@ private: gulong m_nPopupMenuSignalId; gulong m_nDragBeginSignalId; gulong m_nDragEndSignalId; + gulong m_nKeyPressSignalId; ImplSVEvent* m_pChangeEvent; DECL_LINK(async_signal_changed, void*, void); @@ -8104,6 +8105,48 @@ private: g_DragSource = nullptr; } + gboolean signal_key_press(GdkEventKey* pEvent) + { + if (pEvent->keyval != GDK_KEY_Left && pEvent->keyval != GDK_KEY_Right) + return false; + + GtkInstanceTreeIter aIter(nullptr); + if (!get_cursor(&aIter)) + return false; + + if (pEvent->keyval == GDK_KEY_Right) + { + if (iter_has_child(aIter) && !get_row_expanded(aIter)) + { + expand_row(aIter); + return true; + } + return false; + } + + if (iter_has_child(aIter) && get_row_expanded(aIter)) + { + collapse_row(aIter); + return true; + } + + if (iter_parent(aIter)) + { + unselect_all(); + set_cursor(aIter); + select(aIter); + return true; + } + + return false; + } + + static gboolean signalKeyPress(GtkWidget*, GdkEventKey* pEvent, gpointer widget) + { + GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget); + return pThis->signal_key_press(pEvent); + } + public: GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership) @@ -8121,6 +8164,7 @@ public: , m_nPopupMenuSignalId(g_signal_connect(pTreeView, "popup-menu", G_CALLBACK(signalPopupMenu), this)) , m_nDragBeginSignalId(g_signal_connect(pTreeView, "drag-begin", G_CALLBACK(signalDragBegin), this)) , m_nDragEndSignalId(g_signal_connect(pTreeView, "drag-end", G_CALLBACK(signalDragEnd), this)) + , m_nKeyPressSignalId(g_signal_connect(pTreeView, "key-press-event", G_CALLBACK(signalKeyPress), this)) , m_pChangeEvent(nullptr) { m_pColumns = gtk_tree_view_get_columns(m_pTreeView); @@ -9514,6 +9558,7 @@ public: { if (m_pChangeEvent) Application::RemoveUserEvent(m_pChangeEvent); + g_signal_handler_disconnect(m_pTreeView, m_nKeyPressSignalId); g_signal_handler_disconnect(m_pTreeView, m_nDragEndSignalId); g_signal_handler_disconnect(m_pTreeView, m_nDragBeginSignalId); g_signal_handler_disconnect(m_pTreeView, m_nPopupMenuSignalId); |