qulogic/pidgin

a8e758b503eb
Parents bdd5204a9e10
Children 011b13928d5e
Simplify PidginInfoPane by using bindings everywhere

I also had to update purple_markup_linkify to use lower case tags for pango.
That said, I'm not sure why they were upper case in the first place, that might
be _very_ old.

I played around with a tooltip on the topic since it can be ellipsized but you
can't click the links in a tooltip so that was a bust. I also tried making the
top label expand on hover but that didn't work well either. So we'll most
likely end up putting the full topic in a "Conversation Info" pane that'll swap
out with the member list and stuff.

Testing Done:
Checked in with the turtles. Also opened a dm and a channel without issue.

Reviewed at https://reviews.imfreedom.org/r/2845/
--- a/libpurple/purplemarkup.c Sun Nov 19 04:15:49 2023 -0600
+++ b/libpurple/purplemarkup.c Mon Nov 27 21:01:20 2023 -0600
@@ -880,7 +880,7 @@
url_buf = g_strndup(c, t - c);
tmpurlbuf = purple_unescape_html(url_buf);
- g_string_append_printf(ret, "<A HREF=\"%s%s\">%s</A>",
+ g_string_append_printf(ret, "<a href=\"%s%s\">%s</a>",
urlprefix,
tmpurlbuf, url_buf);
g_free(tmpurlbuf);
@@ -926,9 +926,9 @@
}
} else if(*c == '<') {
inside_html = TRUE;
- if (!g_ascii_strncasecmp(c, "<A", 2)) {
+ if (!g_ascii_strncasecmp(c, "<a", 2)) {
while (1) {
- if (!g_ascii_strncasecmp(c, "/A>", 3)) {
+ if (!g_ascii_strncasecmp(c, "/a>", 3)) {
inside_html = FALSE;
break;
}
@@ -975,7 +975,7 @@
g_free(url_buf);
url_buf = g_strndup(c, t - c);
tmpurlbuf = purple_unescape_html(url_buf);
- g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>",
+ g_string_append_printf(ret, "<a href=\"%s\">%s</a>",
tmpurlbuf, url_buf);
g_free(url_buf);
g_free(tmpurlbuf);
@@ -1037,7 +1037,7 @@
tmpurlbuf = purple_unescape_html(url_buf);
if (purple_email_is_valid(tmpurlbuf)) {
- g_string_append_printf(ret, "<A HREF=\"mailto:%s\">%s</A>",
+ g_string_append_printf(ret, "<a href=\"mailto:%s\">%s</a>",
tmpurlbuf, url_buf);
} else {
g_string_append(ret, url_buf);
--- a/pidgin/pidgininfopane.c Sun Nov 19 04:15:49 2023 -0600
+++ b/pidgin/pidgininfopane.c Mon Nov 27 21:01:20 2023 -0600
@@ -22,25 +22,12 @@
#include "pidgin/pidgininfopane.h"
-#include "pidgin/gtkblist.h"
-#include "pidgin/gtkutils.h"
-#include "pidgin/pidginavatar.h"
-#include "pidgin/pidgincore.h"
-#include "pidgin/pidginpresenceicon.h"
-
struct _PidginInfoPane {
GtkBox parent;
PurpleConversation *conversation;
- GtkWidget *hbox;
- GtkWidget *avatar;
-
- GtkWidget *name;
- GBinding *name_binding;
-
GtkWidget *topic;
- GBinding *topic_binding;
};
enum {
@@ -53,25 +40,19 @@
G_DEFINE_TYPE(PidginInfoPane, pidgin_info_pane, GTK_TYPE_BOX)
/******************************************************************************
- * Helpers
+ * Callbacks
*****************************************************************************/
-static gboolean
-pidgin_info_pane_topic_to_label(G_GNUC_UNUSED GBinding *binding,
- const GValue *from_value,
- GValue *to_value,
- gpointer data)
+static char *
+pidgin_info_pane_linkify_text_cb(GObject *self, const char *topic,
+ G_GNUC_UNUSED gpointer data)
{
- PidginInfoPane *pane = data;
- const char *topic = NULL;
- gboolean visible = FALSE;
+ PidginInfoPane *pane = PIDGIN_INFO_PANE(self);
+ char *ret = NULL;
- topic = g_value_get_string(from_value);
- visible = !purple_strempty(topic);
- g_value_set_string(to_value, topic);
+ ret = purple_markup_linkify(topic);
+ gtk_widget_set_visible(pane->topic, !purple_strempty(ret));
- gtk_widget_set_visible(pane->topic, visible);
-
- return TRUE;
+ return ret;
}
/******************************************************************************
@@ -150,10 +131,10 @@
"/im/pidgin/Pidgin3/Conversations/infopane.ui"
);
- gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, hbox);
- gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, avatar);
- gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, name);
gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, topic);
+
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_info_pane_linkify_text_cb);
}
/******************************************************************************
@@ -184,29 +165,5 @@
return;
}
- /* Remove the old bindings. */
- g_clear_pointer(&pane->name_binding, g_binding_unbind);
- g_clear_pointer(&pane->topic_binding, g_binding_unbind);
-
- /* Tell the avatar about the new conversation. */
- pidgin_avatar_set_conversation(PIDGIN_AVATAR(pane->avatar),
- pane->conversation);
-
- if(PURPLE_IS_CONVERSATION(conversation)) {
- pane->name_binding =
- g_object_bind_property(G_OBJECT(conversation), "name",
- G_OBJECT(pane->name), "label",
- G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
-
- pane->topic_binding =
- g_object_bind_property_full(G_OBJECT(conversation), "topic",
- G_OBJECT(pane->topic), "label",
- G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE,
- pidgin_info_pane_topic_to_label,
- NULL,
- pane, NULL);
- }
-
- /* Notify that we changed. */
g_object_notify_by_pspec(G_OBJECT(pane), properties[PROP_CONVERSATION]);
}
--- a/pidgin/resources/Conversations/infopane.ui Sun Nov 19 04:15:49 2023 -0600
+++ b/pidgin/resources/Conversations/infopane.ui Mon Nov 27 21:01:20 2023 -0600
@@ -25,10 +25,14 @@
<!-- interface-copyright Pidgin Developers <devel@pidgin.im> -->
<template class="PidginInfoPane" parent="GtkBox">
<child>
- <object class="GtkBox" id="hbox">
+ <object class="GtkBox">
<property name="spacing">6</property>
<child>
- <object class="PidginAvatar" id="avatar"/>
+ <object class="PidginAvatar">
+ <binding name="conversation">
+ <lookup name="conversation">PidginInfoPane</lookup>
+ </binding>
+ </object>
</child>
<child>
<object class="GtkBox">
@@ -37,17 +41,31 @@
<property name="valign">center</property>
<child>
<object class="GtkLabel" id="name">
- <property name="label" translatable="1">[Place Holder]</property>
+ <binding name="label">
+ <lookup name="name" type="PurpleConversation">
+ <lookup name="conversation">PidginInfoPane</lookup>
+ </lookup>
+ </binding>
<property name="xalign">0</property>
- <attributes>
- <attribute name="weight" value="bold"></attribute>
- <attribute name="scale" value="1.2"></attribute>
- </attributes>
+ <style>
+ <class name="title-2"/>
+ </style>
</object>
</child>
<child>
<object class="GtkLabel" id="topic">
- <property name="wrap">1</property>
+ <binding name="label">
+ <closure type="gchararray" function="pidgin_info_pane_linkify_text_cb">
+ <lookup name="topic" type="PurpleConversation">
+ <lookup name="conversation">PidginInfoPane</lookup>
+ </lookup>
+ </closure>
+ </binding>
+ <property name="ellipsize">end</property>
+ <property name="lines">2</property>
+ <property name="use-markup">yes</property>
+ <property name="wrap">yes</property>
+ <property name="wrap-mode">word-char</property>
<property name="xalign">0</property>
</object>
</child>