talkatu/talkatu

Parents de98b38d13a2
Children 9dc271918fe6
Port TalkatuHistory to Gtk4 by subclassing GtkWidget instead of GtkListBox

Testing Done:
Compiled the widget and resources.

Reviewed at https://reviews.imfreedom.org/r/1261/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/talkatu/data/history.ui Sun Jan 30 17:01:20 2022 -0600
@@ -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
--- a/talkatu/data/talkatu.gresource.xml Sun Jan 30 14:55:19 2022 -0600
+++ b/talkatu/data/talkatu.gresource.xml Sun Jan 30 17:01:20 2022 -0600
@@ -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>
--- a/talkatu/talkatuhistory.c Sun Jan 30 14:55:19 2022 -0600
+++ b/talkatu/talkatuhistory.c Sun Jan 30 17:01:20 2022 -0600
@@ -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);
}
--- a/talkatu/talkatuhistory.h Sun Jan 30 14:55:19 2022 -0600
+++ b/talkatu/talkatuhistory.h Sun Jan 30 17:01:20 2022 -0600
@@ -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);