From bde06289623626da78fd6cb79c351a6ddbcbe835 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 7 Dec 2024 03:46:13 +0200
Subject: [PATCH 53/53] gtk4x: Implement bind() / create() for diplodlg.c
 clause list item factory

See RM #1174

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-gtk-5.0/diplodlg.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/client/gui-gtk-5.0/diplodlg.c b/client/gui-gtk-5.0/diplodlg.c
index 8b905c45ee..c7bd00ccea 100644
--- a/client/gui-gtk-5.0/diplodlg.c
+++ b/client/gui-gtk-5.0/diplodlg.c
@@ -802,6 +802,31 @@ static void diplomacy_response(struct gui_dialog *dlg, int response,
   }
 }
 
+/**********************************************************************//**
+  Clause table cell bind function
+**************************************************************************/
+static void clause_factory_bind(GtkSignalListItemFactory *self,
+                                GtkListItem *list_item,
+                                gpointer user_data)
+{
+  FcClauseRow *row;
+  GtkWidget *child = gtk_list_item_get_child(list_item);
+
+  row = gtk_list_item_get_item(list_item);
+
+  gtk_label_set_text(GTK_LABEL(child), row->clause);
+}
+
+/**********************************************************************//**
+  Clause table cell setup function
+**************************************************************************/
+static void clause_factory_setup(GtkSignalListItemFactory *self,
+                                 GtkListItem *list_item,
+                                 gpointer user_data)
+{
+  gtk_list_item_set_child(list_item, gtk_label_new(""));
+}
+
 /************************************************************************//**
   Setups diplomacy dialog widgets.
 ****************************************************************************/
@@ -816,6 +841,7 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct treaty *ptreaty,
   struct sprite *flag_spr;
   GtkListStore *store;
   GtkCellRenderer *rend;
+  GtkListItemFactory *factory;
   int i;
   struct Diplomacy_dialog *pdialog;
   char plr_buf[4 * MAX_LEN_NAME];
@@ -1037,6 +1063,12 @@ static struct Diplomacy_dialog *create_diplomacy_dialog(struct treaty *ptreaty,
   store = gtk_list_store_new(1, G_TYPE_STRING);
   pdialog->store = store;
 
+  factory = gtk_signal_list_item_factory_new();
+  g_signal_connect(factory, "bind", G_CALLBACK(clause_factory_bind),
+                   nullptr);
+  g_signal_connect(factory, "setup", G_CALLBACK(clause_factory_setup),
+                   nullptr);
+
   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
   gtk_widget_set_hexpand(view, TRUE);
   gtk_widget_set_vexpand(view, TRUE);
-- 
2.45.2

