Re-enable links in Pidgin.Message

Thu, 03 Jul 2025 22:00:13 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 03 Jul 2025 22:00:13 -0500
changeset 43277
286947581188
parent 43276
2ffc42909b30
child 43278
87aae4564a73

Re-enable links in Pidgin.Message

This was disabled in /r/3970 as we thought it was breaking formatting. I've
since put together a proof of concept that proves that you can set the pango
attributes to null or empty and the formatting gets removed.

That means the bug is somewhere in our code, but I haven't yet found it. But
in the mean time, it makes sense to turn links back on as they're super
useful.

Testing Done:
Joined an irc channel and sent a link from pidgin2 and verified that it was displayed and operated correctly.

Reviewed at https://reviews.imfreedom.org/r/4047/

pidgin/pidginmessage.c file | annotate | diff | comparison | revisions
pidgin/resources/Conversations/message.ui file | annotate | diff | comparison | revisions
--- a/pidgin/pidginmessage.c	Thu Jul 03 01:56:45 2025 -0500
+++ b/pidgin/pidginmessage.c	Thu Jul 03 22:00:13 2025 -0500
@@ -146,6 +146,23 @@
 	return NULL;
 }
 
+static char *
+pidgin_message_process_message_contents_cb(G_GNUC_UNUSED GObject *self,
+                                           const char *contents,
+                                           G_GNUC_UNUSED gpointer data)
+{
+	char *escaped = NULL;
+	char *linkified = NULL;
+
+	escaped = g_markup_escape_text(contents, -1);
+
+	linkified = purple_markup_linkify(escaped);
+
+	g_free(escaped);
+
+	return linkified;
+}
+
 static gboolean
 pidgin_message_query_tooltip_contents_cb(GtkWidget *self,
                                          G_GNUC_UNUSED gint x,
@@ -330,6 +347,8 @@
 	gtk_widget_class_bind_template_callback(widget_class,
 	                                        pidgin_message_query_tooltip_contents_cb);
 	gtk_widget_class_bind_template_callback(widget_class,
+	                                        pidgin_message_process_message_contents_cb);
+	gtk_widget_class_bind_template_callback(widget_class,
 	                                        pidgin_message_query_tooltip_edited_cb);
 	gtk_widget_class_bind_template_callback(widget_class,
 	                                        pidgin_message_query_tooltip_timestamp_cb);
--- a/pidgin/resources/Conversations/message.ui	Thu Jul 03 01:56:45 2025 -0500
+++ b/pidgin/resources/Conversations/message.ui	Thu Jul 03 22:00:13 2025 -0500
@@ -76,10 +76,13 @@
             <property name="wrap-mode">word-char</property>
             <property name="xalign">0</property>
             <property name="yalign">0</property>
+            <property name="use-markup">true</property>
             <binding name="label">
-              <lookup name="contents" type="PurpleMessage">
-                <lookup name="message">PidginMessage</lookup>
-              </lookup>
+              <closure type="gchararray" function="pidgin_message_process_message_contents_cb">
+                <lookup name="contents" type="PurpleMessage">
+                  <lookup name="message">PidginMessage</lookup>
+                </lookup>
+              </closure>
             </binding>
             <binding name="attributes">
               <closure type="PangoAttrList" function="pidgin_message_get_message_attributes">

mercurial