# HG changeset patch
# Node ID cb94e0e9aace
# Parent  edbbedfee064
diff --git a/talkatu/data/history.ui b/talkatu/data/history.ui
new file mode 100644
--- /dev/null
+++ b/talkatu/data/history.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Talkatu - GTK widgets for chat applications
+Copyright (C) 2017-2022 Gary Kramlich <grim@reaperworld.com>
+
+This library is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this library; if not, see <https://www.gnu.org/licenses/>.
+-->
+<interface>
+  <requires lib="gtk" version="4.0"/>
+  <!-- interface-license-type gplv2 -->
+  <!-- interface-name Talkatu -->
+  <!-- interface-description GTK widgets for chat applications -->
+  <!-- interface-copyright Gary Kramlich <grim@reaperworld.com> -->
+  <template id="TalkatuHistory" class="GtkWidget">
+    <child>
+      <object class="GtkListBox" id="list_box">
+      </object>
+    </child>
+  </template>
+</interface>
\ No newline at end of file
diff --git a/talkatu/data/talkatu.gresource.xml b/talkatu/data/talkatu.gresource.xml
--- a/talkatu/data/talkatu.gresource.xml
+++ b/talkatu/data/talkatu.gresource.xml
@@ -4,6 +4,7 @@
     <file compressed="true">attachmentdialog.ui</file>
     <file compressed="true">attachmentpreview.ui</file>
     <file compressed="true">editor.ui</file>
+    <file compressed="true">history.ui</file>
     <file compressed="true">historyrow.ui</file>
     <file compressed="true">linkdialog.ui</file>
     <file compressed="true">toolbar.ui</file>
diff --git a/talkatu/talkatuhistory.h b/talkatu/talkatuhistory.h
--- a/talkatu/talkatuhistory.h
+++ b/talkatu/talkatuhistory.h
@@ -1,6 +1,6 @@
 /*
  * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2017-2022 Gary Kramlich <grim@reaperworld.com>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@
 
 #define TALKATU_TYPE_HISTORY (talkatu_history_get_type())
 
-G_DECLARE_FINAL_TYPE(TalkatuHistory, talkatu_history, TALKATU, HISTORY, GtkListBox)
+G_DECLARE_FINAL_TYPE(TalkatuHistory, talkatu_history, TALKATU, HISTORY, GtkWidget)
 
 GtkWidget *talkatu_history_new(void);
 
diff --git a/talkatu/talkatuhistory.c b/talkatu/talkatuhistory.c
--- a/talkatu/talkatuhistory.c
+++ b/talkatu/talkatuhistory.c
@@ -1,6 +1,6 @@
 /*
  * Talkatu - GTK widgets for chat applications
- * Copyright (C) 2017-2020 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2017-2022 Gary Kramlich <grim@reaperworld.com>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -30,20 +30,32 @@
  * A #TalkatuView subclass that is used to display a conversation.
  */
 struct _TalkatuHistory {
-	GtkListBox parent;
+	GtkWidget parent;
+
+	GtkListBox *list_box;
 };
 
-G_DEFINE_TYPE(TalkatuHistory, talkatu_history, GTK_TYPE_LIST_BOX)
+G_DEFINE_TYPE(TalkatuHistory, talkatu_history, GTK_TYPE_WIDGET)
 
 /******************************************************************************
  * GObject Stuff
  *****************************************************************************/
 static void
 talkatu_history_init(TalkatuHistory *history) {
+	gtk_widget_init_template(GTK_WIDGET(history));
 }
 
 static void
 talkatu_history_class_init(TalkatuHistoryClass *klass) {
+	GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+	gtk_widget_class_set_template_from_resource(
+		widget_class,
+		"/org/imfreedom/keep/talkatu/talkatu/ui/history.ui"
+	);
+
+	gtk_widget_class_bind_template_child(widget_class, TalkatuHistory,
+	                                     list_box);
 }
 
 /******************************************************************************
@@ -58,10 +70,10 @@
  * Returns: (transfer full): The new #TalkatuHistory instance.
  */
 GtkWidget *talkatu_history_new(void) {
-	return GTK_WIDGET(g_object_new(
+	return g_object_new(
 		TALKATU_TYPE_HISTORY,
 		NULL
-	));
+	);
 }
 
 /**
@@ -82,5 +94,5 @@
 	g_return_if_fail(TALKATU_IS_MESSAGE(message));
 
 	row = talkatu_history_row_new(message);
-	gtk_container_add(GTK_CONTAINER(history), row);
+	gtk_list_box_append(GTK_LIST_BOX(history->list_box), row);
 }
