diff options
author | Jim Raykowski <raykowj@gmail.com> | 2019-12-05 12:14:37 -0900 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-12-09 13:29:32 +0100 |
commit | 6303f8ac291233b1f6888a8d71e769debe0f9fb0 (patch) | |
tree | 3998d247d9a7627731db97e07d16e1e576639b13 /vcl/unx/gtk3 | |
parent | 961c3dd1332901289ee6b67036657d6b8a87c59c (diff) |
tdf#108458 related: Add tooltip handling to TreeView
Supports GtkInstanceTreeView and SalInstanceTreeView
Change-Id: I33984f78c26135319531eace2a3e2e2e28712af1
Reviewed-on: https://gerrit.libreoffice.org/84587
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx/gtk3')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 5c7b8ae9ac5c..504355c09189 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -8037,6 +8037,7 @@ private: gulong m_nDragDataDeleteignalId; gulong m_nDragGetSignalId; gulong m_nKeyPressSignalId; + gulong m_nQueryTooltipSignalId; ImplSVEvent* m_pChangeEvent; DECL_LINK(async_signal_changed, void*, void); @@ -8521,6 +8522,24 @@ private: return pThis->signal_key_press(pEvent); } + static gboolean signalQueryTooltip(GtkWidget* /*pGtkWidget*/, gint x, gint y, + gboolean keyboard_tip, GtkTooltip *tooltip, + gpointer widget) + { + GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget); + GtkTreeIter iter; + GtkTreeView *pTreeView = pThis->m_pTreeView; + GtkTreeModel *pModel = gtk_tree_view_get_model(pTreeView); + GtkTreePath *pPath = nullptr; + if (!gtk_tree_view_get_tooltip_context(pTreeView, &x, &y, keyboard_tip, &pModel, &pPath, &iter)) + return false; + OUString aTooltip = pThis->signal_query_tooltip(GtkInstanceTreeIter(iter)); + gtk_tooltip_set_text(tooltip, OUStringToOString(aTooltip, RTL_TEXTENCODING_UTF8).getStr()); + gtk_tree_view_set_tooltip_row(pTreeView, tooltip, pPath); + gtk_tree_path_free(pPath); + return true; + } + public: GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership) @@ -8543,6 +8562,7 @@ public: , m_nDragDataDeleteignalId(0) , m_nDragGetSignalId(0) , m_nKeyPressSignalId(g_signal_connect(pTreeView, "key-press-event", G_CALLBACK(signalKeyPress), this)) + , m_nQueryTooltipSignalId(g_signal_connect(pTreeView, "query-tooltip", G_CALLBACK(signalQueryTooltip), this)) , m_pChangeEvent(nullptr) { m_pColumns = gtk_tree_view_get_columns(m_pTreeView); @@ -10007,6 +10027,8 @@ public: m_aColumnSignalIds.pop_back(); } g_list_free(m_pColumns); + + g_signal_handler_disconnect(m_pTreeView, m_nQueryTooltipSignalId); } }; |