--- a/pidgin/pidginconversation.c Fri Oct 27 00:27:12 2023 -0500
+++ b/pidgin/pidginconversation.c Fri Oct 27 01:46:24 2023 -0500
@@ -24,8 +24,7 @@
+#include "pidginautoadjustment.h" #include "pidginconversation.h"
#include "pidgininfopane.h"
@@ -45,9 +44,11 @@
PurpleConversation *conversation;
+ GtkAdjustment *history_adjustment; GtkNoSelection *history_selection;
G_DEFINE_TYPE(PidginConversation, pidgin_conversation, GTK_TYPE_BOX)
@@ -115,16 +116,46 @@
/******************************************************************************
*****************************************************************************/
-pidgin_conversation_send_message_cb(TalkatuInput *input, gpointer data) {
+pidgin_conversation_input_key_pressed_cb(G_GNUC_UNUSED GtkEventControllerKey *self, + G_GNUC_UNUSED guint keycode, PidginConversation *conversation = data;
- const char *contents = NULL;
+ gboolean handled = TRUE; + if(keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter) { + GtkTextBuffer *buffer = NULL; + if(state == GDK_SHIFT_MASK || state == GDK_CONTROL_MASK) { - contents = talkatu_message_get_contents(TALKATU_MESSAGE(input));
+ buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(conversation->input)); + gtk_text_buffer_get_start_iter(buffer, &start); + gtk_text_buffer_get_end_iter(buffer, &end); + contents = gtk_text_buffer_get_text(buffer, &start, &end, TRUE); + purple_conversation_send(conversation->conversation, contents); + g_clear_pointer(&contents, g_free); - purple_conversation_send(conversation->conversation, contents);
+ gtk_text_buffer_set_text(buffer, "", -1); + } else if(keyval == GDK_KEY_Page_Up) { + pidgin_auto_adjustment_decrement(PIDGIN_AUTO_ADJUSTMENT(conversation->history_adjustment)); + } else if(keyval == GDK_KEY_Page_Down) { + pidgin_auto_adjustment_increment(PIDGIN_AUTO_ADJUSTMENT(conversation->history_adjustment)); - talkatu_message_set_contents(TALKATU_MESSAGE(input), "");
@@ -340,14 +371,16 @@
gtk_widget_class_bind_template_child(widget_class, PidginConversation,
gtk_widget_class_bind_template_child(widget_class, PidginConversation,
- gtk_widget_class_bind_template_child(widget_class, PidginConversation,
gtk_widget_class_bind_template_child(widget_class, PidginConversation,
+ gtk_widget_class_bind_template_child(widget_class, PidginConversation, + gtk_widget_class_bind_template_child(widget_class, PidginConversation, gtk_widget_class_bind_template_callback(widget_class,
- pidgin_conversation_send_message_cb);
+ pidgin_conversation_input_key_pressed_cb); gtk_widget_class_bind_template_callback(widget_class,
pidgin_conversation_get_author_attributes);
gtk_widget_class_bind_template_callback(widget_class,
--- a/pidgin/resources/Conversations/conversation.ui Fri Oct 27 00:27:12 2023 -0500
+++ b/pidgin/resources/Conversations/conversation.ui Fri Oct 27 01:46:24 2023 -0500
@@ -54,7 +54,7 @@
<object class="GtkScrolledWindow">
<property name="hexpand">1</property>
<property name="vadjustment">
- <object class="PidginAutoAdjustment"/>
+ <object class="PidginAutoAdjustment" id="history_adjustment"/> <property name="vexpand">1</property>
@@ -83,13 +83,18 @@
- <object class="TalkatuEditor" id="editor">
+ <object class="GtkSeparator"/> + <object class="GtkScrolledWindow"> <property name="vexpand">0</property>
- <property name="orientation">vertical</property>
- <child internal-child="input">
- <object class="TalkatuInput" id="input">
- <property name="send-binding">return|kp-enter</property>
- <signal name="send-message" handler="pidgin_conversation_send_message_cb"/>
+ <object class="GtkTextView" id="input"> + <object class="GtkEventControllerKey"> + <signal name="key-pressed" handler="pidgin_conversation_input_key_pressed_cb"/>