From 728f7b187dc29dc1eab9f32ded66b76cc2231aa1 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 31 Jul 2020 14:14:23 +0100 Subject: transfer any expander or expander toggles when using custom renderers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I10857c236c5915ef7dcb08dd42ad1bd499063b89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99872 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- vcl/unx/gtk3/gtk3gtkinst.cxx | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'vcl/unx') diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 8b146867a287..20078e3950bb 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -10085,6 +10085,9 @@ public: GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, nColumn)); assert(pColumn && "wrong count"); + GtkCellRenderer* pExpander = nullptr; + GtkCellRenderer* pToggle = nullptr; + // migrate existing editable setting to the new renderer gboolean is_editable(false); void* pEditCellData(nullptr); @@ -10092,18 +10095,54 @@ public: for (GList* pRenderer = g_list_first(pRenderers); pRenderer; pRenderer = g_list_next(pRenderer)) { GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data); + + void* pData = g_object_get_data(G_OBJECT(pCellRenderer), "g-lo-CellIndex"); + auto nCellIndex = reinterpret_cast(pData); + if (GTK_IS_CELL_RENDERER_TEXT(pCellRenderer)) { g_object_get(pCellRenderer, "editable", &is_editable, nullptr); - pEditCellData = g_object_get_data(G_OBJECT(pCellRenderer), "g-lo-CellIndex"); + pEditCellData = pData; break; } + else if (GTK_IS_CELL_RENDERER_TOGGLE(pCellRenderer)) + { + if (nCellIndex == m_nExpanderToggleCol) + { + pToggle = pCellRenderer; + g_object_ref(pToggle); + } + } + else if (GTK_IS_CELL_RENDERER_PIXBUF(pCellRenderer)) + { + if (nCellIndex == m_nExpanderImageCol) + { + pExpander = pCellRenderer; + g_object_ref(pExpander); + } + } + } g_list_free(pRenderers); GtkCellRenderer* pRenderer; gtk_cell_layout_clear(GTK_CELL_LAYOUT(pColumn)); + if (pExpander) + { + gtk_tree_view_column_pack_start(pColumn, pExpander, false); + gtk_tree_view_column_add_attribute(pColumn, pExpander, "pixbuf", m_nExpanderImageCol); + g_object_unref(pExpander); + } + if (pToggle) + { + gtk_tree_view_column_pack_start(pColumn, pToggle, false); + gtk_tree_view_column_add_attribute(pColumn, pToggle, "active", m_nExpanderToggleCol); + gtk_tree_view_column_add_attribute(pColumn, pToggle, "active", m_nExpanderToggleCol); + gtk_tree_view_column_add_attribute(pColumn, pToggle, "visible", m_aToggleTriStateMap[m_nExpanderToggleCol]); + g_object_unref(pToggle); + } + if (bEnable) { pRenderer = custom_cell_renderer_surface_new(); -- cgit