[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 31 14:22:52 UTC 2020


 vcl/unx/gtk3/gtk3gtkinst.cxx |   32 ++++++++++++++++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

New commits:
commit 954e9bb965c37a34d87d59e40d1820ba0ea565d3
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jul 31 12:05:59 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jul 31 16:22:18 2020 +0200

    if the default renderer was editable, make the custom one editable too
    
    Change-Id: Ib4c80560943cff7c65d9eed342e3d5bb9d838e5f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99866
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 658c09ab756d..8b146867a287 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -10084,10 +10084,29 @@ public:
         assert(n_children() == 0 && "tree must be empty");
         GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(m_pColumns, nColumn));
         assert(pColumn && "wrong count");
+
+        // migrate existing editable setting to the new renderer
+        gboolean is_editable(false);
+        void* pEditCellData(nullptr);
+        GList *pRenderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(pColumn));
+        for (GList* pRenderer = g_list_first(pRenderers); pRenderer; pRenderer = g_list_next(pRenderer))
+        {
+            GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data);
+            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");
+                break;
+            }
+        }
+        g_list_free(pRenderers);
+
+        GtkCellRenderer* pRenderer;
+
         gtk_cell_layout_clear(GTK_CELL_LAYOUT(pColumn));
         if (bEnable)
         {
-            GtkCellRenderer *pRenderer = custom_cell_renderer_surface_new();
+            pRenderer = custom_cell_renderer_surface_new();
             GValue value = G_VALUE_INIT;
             g_value_init(&value, G_TYPE_POINTER);
             g_value_set_pointer(&value, static_cast<gpointer>(this));
@@ -10098,10 +10117,19 @@ public:
         }
         else
         {
-            GtkCellRenderer *pRenderer = gtk_cell_renderer_text_new();
+            pRenderer = gtk_cell_renderer_text_new();
             gtk_tree_view_column_pack_start(pColumn, pRenderer, true);
             gtk_tree_view_column_add_attribute(pColumn, pRenderer, "text", m_nTextCol);
         }
+
+        if (is_editable)
+        {
+            g_object_set(pRenderer, "editable", true, "editable-set", true, nullptr);
+            g_object_set_data(G_OBJECT(pRenderer), "g-lo-CellIndex", pEditCellData);
+            g_signal_connect(pRenderer, "editing-started", G_CALLBACK(signalCellEditingStarted), this);
+            g_signal_connect(pRenderer, "editing-canceled", G_CALLBACK(signalCellEditingCanceled), this);
+            g_signal_connect(pRenderer, "edited", G_CALLBACK(signalCellEdited), this);
+        }
     }
 
     virtual void queue_draw() override


More information about the Libreoffice-commits mailing list