I’m working on the problem that new conversations open when double clicking a contact with an already open conversation. Following code does the job when testing with the Demo plugin, but the IDs are only the names of the contacts so how is it or should it be guaranteed that they are unique as the doc says they are?
diff --git a/pidgin/pidgindisplaywindow.c b/pidgin/pidgindisplaywindow.c
--- a/pidgin/pidgindisplaywindow.c
+++ b/pidgin/pidgindisplaywindow.c
@@ -101,6 +101,18 @@ pidgin_display_window_find_conversation(
return (conversation_a == conversation_b);
}
+static gboolean
+pidgin_display_window_find_conversation_by_id(gconstpointer a,
+ G_GNUC_UNUSED gconstpointer b,
+ gpointer user_data)
+{
+ PidginDisplayItem *item_a = PIDGIN_DISPLAY_ITEM((gpointer)a);
+ const char *a_id = pidgin_display_item_get_id(item_a);
+ const char *id = user_data;
+
+ return g_strcmp0(a_id, id) == 0;
+}
+
/******************************************************************************
* Actions
*****************************************************************************/
@@ -461,6 +473,8 @@ pidgin_display_window_add(PidginDisplayW
if(PIDGIN_IS_CONVERSATION(pidgin_conversation)) {
PidginDisplayItem *item = NULL;
const char *id = NULL;
+ guint position = 0;
+ gboolean found = FALSE;
GtkWidget *parent = gtk_widget_get_parent(pidgin_conversation);
@@ -470,6 +484,13 @@ pidgin_display_window_add(PidginDisplayW
}
id = purple_conversation_get_name(purple_conversation);
+ found = g_list_store_find_with_equal_func_full(window->conversation_model,
+ NULL,
+ pidgin_display_window_find_conversation_by_id,
+ (char*)id,
+ &position);
+
+ if (!found) {
item = pidgin_display_item_new(pidgin_conversation, id);
g_object_set_data(G_OBJECT(item), "conversation", purple_conversation);
@@ -479,6 +500,7 @@ pidgin_display_window_add(PidginDisplayW
g_list_store_append(window->conversation_model, item);
g_clear_object(&item);
+ }
if(GTK_IS_WIDGET(parent)) {
g_object_unref(pidgin_conversation);