pidgin/pidgin

Remove ui_data from PurpleBlistNode

2021-02-03, Gary Kramlich
9e2dd7dcdc0e
Parents e87c321f05fa
Children 81e94476e3ac
Remove ui_data from PurpleBlistNode

Testing Done:
Ran both finch and pidgin, didn't haven't anyone in the finch blist to test but it seemed ok.

Reviewed at https://reviews.imfreedom.org/r/472/
--- a/ChangeLog.API Wed Feb 03 18:27:42 2021 -0600
+++ b/ChangeLog.API Wed Feb 03 18:28:59 2021 -0600
@@ -339,6 +339,8 @@
* purple_blist_get_ui_data
* purple_blist_load
* purple_blist_new
+ * purple_blist_node_get_ui_data
+ * purple_blist_node_set_ui_data
* purple_blist_set_ui_data
* purple_set_blist
* purple_blist_update_buddy_icon
--- a/finch/gntblist.c Wed Feb 03 18:27:42 2021 -0600
+++ b/finch/gntblist.c Wed Feb 03 18:28:59 2021 -0600
@@ -39,6 +39,8 @@
#define PREF_ROOT "/finch/blist"
#define TYPING_TIMEOUT_S 4
+#define UI_DATA "ui-finch"
+
#define SHOW_EMPTY_GROUP_TIMEOUT 60
struct _FinchBuddyList {
@@ -145,7 +147,8 @@
if (PURPLE_IS_BUDDY(node)) {
PurpleBuddy *buddy = (PurpleBuddy*)node;
- FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
+ FinchBlistNode *fnode = g_object_get_data(G_OBJECT(node), UI_DATA);
+
if (!purple_buddy_get_contact(buddy))
return FALSE; /* When a new buddy is added and show-offline is set */
if (PURPLE_BUDDY_IS_ONLINE(buddy))
@@ -294,31 +297,30 @@
};
static GList *managers;
+static void
+finch_blist_node_free(FinchBlistNode *node) {
+ if(node->signed_timer) {
+ g_source_remove(node->signed_timer);
+ }
+
+ g_free(node);
+}
+
static FinchBlistNode *
create_finch_blist_node(PurpleBlistNode *node, gpointer row)
{
- FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
+ FinchBlistNode *fnode = g_object_get_data(G_OBJECT(node), UI_DATA);
if (!fnode) {
fnode = g_new0(FinchBlistNode, 1);
fnode->signed_timer = 0;
- purple_blist_node_set_ui_data(node, fnode);
+
+ g_object_set_data_full(G_OBJECT(node), UI_DATA, fnode,
+ (GDestroyNotify)finch_blist_node_free);
}
fnode->row = row;
return fnode;
}
-static void
-reset_blist_node_ui_data(PurpleBlistNode *node)
-{
- FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
- if (fnode == NULL)
- return;
- if (fnode->signed_timer)
- g_source_remove(fnode->signed_timer);
- g_free(fnode);
- purple_blist_node_set_ui_data(node, NULL);
-}
-
static int
get_display_color(PurpleBlistNode *node)
{
@@ -349,7 +351,7 @@
get_blist_node_flag(FinchBuddyList *ggblist, PurpleBlistNode *node)
{
GntTextFormatFlags flag = 0;
- FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
+ FinchBlistNode *fnode = g_object_get_data(G_OBJECT(node), UI_DATA);
if (ggblist->tagged && g_list_find(ggblist->tagged, node))
flag |= GNT_TEXT_FLAG_BOLD;
@@ -358,7 +360,7 @@
flag |= GNT_TEXT_FLAG_BLINK;
else if (PURPLE_IS_CONTACT(node)) {
node = PURPLE_BLIST_NODE(purple_contact_get_priority_buddy(PURPLE_CONTACT(node)));
- fnode = purple_blist_node_get_ui_data(node);
+ fnode = g_object_get_data(G_OBJECT(node), UI_DATA);
if (fnode && fnode->signed_timer)
flag |= GNT_TEXT_FLAG_BLINK;
}
@@ -382,20 +384,23 @@
static void
add_node(PurpleBlistNode *node, FinchBuddyList *ggblist)
{
- if (purple_blist_node_get_ui_data(node))
+ if(g_object_get_data(G_OBJECT(node), UI_DATA)) {
return;
-
- if (!ggblist->manager->can_add_node(node))
+ }
+
+ if(!ggblist->manager->can_add_node(node)) {
return;
-
- if (PURPLE_IS_BUDDY(node))
+ }
+
+ if(PURPLE_IS_BUDDY(node)) {
add_buddy((PurpleBuddy*)node, ggblist);
- else if (PURPLE_IS_CONTACT(node))
+ } else if (PURPLE_IS_CONTACT(node)) {
add_contact((PurpleContact*)node, ggblist);
- else if (PURPLE_IS_GROUP(node))
+ } else if (PURPLE_IS_GROUP(node)) {
add_group((PurpleGroup*)node, ggblist);
- else if (PURPLE_IS_CHAT(node))
+ } else if (PURPLE_IS_CHAT(node)) {
add_chat((PurpleChat *)node, ggblist);
+ }
draw_tooltip(ggblist);
}
@@ -419,7 +424,7 @@
FinchBuddyList *ggblist = FINCH_BUDDY_LIST(list);
PurpleBlistNode *parent;
- if (ggblist == NULL || purple_blist_node_get_ui_data(node) == NULL)
+ if (ggblist == NULL || g_object_get_data(G_OBJECT(node), UI_DATA) == NULL)
return;
if (PURPLE_IS_GROUP(node) && ggblist->new_group) {
@@ -427,7 +432,6 @@
}
gnt_tree_remove(GNT_TREE(ggblist->tree), node);
- reset_blist_node_ui_data(node);
if (ggblist->tagged)
ggblist->tagged = g_list_remove(ggblist->tagged, node);
@@ -458,17 +462,20 @@
g_return_if_fail(node != NULL);
ggblist = FINCH_BUDDY_LIST(list);
- if (ggblist->window == NULL)
+ if (ggblist->window == NULL) {
return;
-
- if (purple_blist_node_get_ui_data(node)!= NULL) {
- gnt_tree_change_text(GNT_TREE(ggblist->tree), node,
- 0, get_display_name(node));
+ }
+
+ if(g_object_get_data(G_OBJECT(node), UI_DATA) != NULL) {
+ gnt_tree_change_text(GNT_TREE(ggblist->tree), node, 0,
+ get_display_name(node));
gnt_tree_sort_row(GNT_TREE(ggblist->tree), node);
blist_update_row_flags(ggblist, node);
if (gnt_tree_get_parent_key(GNT_TREE(ggblist->tree), node) !=
ggblist->manager->find_parent(node))
+ {
node_remove(list, node);
+ }
}
if (PURPLE_IS_BUDDY(node)) {
@@ -478,7 +485,7 @@
} else if (PURPLE_IS_CHAT(node)) {
add_node(node, FINCH_BUDDY_LIST(list));
} else if (PURPLE_IS_CONTACT(node)) {
- if (purple_blist_node_get_ui_data(node)== NULL) {
+ if (g_object_get_data(G_OBJECT(node), UI_DATA) == NULL) {
/* The core seems to expect the UI to add the buddies. */
for (node = purple_blist_node_get_first_child(node); node; node = purple_blist_node_get_sibling_next(node))
add_node(node, FINCH_BUDDY_LIST(list));
@@ -726,7 +733,7 @@
/* Select the group */
if (ggblist->tree) {
- FinchBlistNode *fnode = purple_blist_node_get_ui_data((PurpleBlistNode*)grp);
+ FinchBlistNode *fnode = g_object_get_data(G_OBJECT(grp), UI_DATA);
if (!fnode)
add_node((PurpleBlistNode*)grp, ggblist);
gnt_tree_set_selected(GNT_TREE(ggblist->tree), grp);
@@ -758,8 +765,9 @@
{
gpointer parent;
PurpleBlistNode *node = (PurpleBlistNode *)group;
- if (purple_blist_node_get_ui_data(node))
+ if(g_object_get_data(G_OBJECT(node), UI_DATA)) {
return;
+ }
parent = ggblist->manager->find_parent((PurpleBlistNode*)group);
create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group,
gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
@@ -831,10 +839,12 @@
{
gpointer parent;
PurpleBlistNode *node = (PurpleBlistNode *)chat;
- if (purple_blist_node_get_ui_data(node))
+ if(g_object_get_data(G_OBJECT(node), UI_DATA)) {
return;
- if (!purple_account_is_connected(purple_chat_get_account(chat)))
+ }
+ if(!purple_account_is_connected(purple_chat_get_account(chat))) {
return;
+ }
parent = ggblist->manager->find_parent((PurpleBlistNode*)chat);
@@ -850,8 +860,9 @@
PurpleBlistNode *node = (PurpleBlistNode*)contact;
const char *name;
- if (purple_blist_node_get_ui_data(node))
+ if(g_object_get_data(G_OBJECT(node), UI_DATA)) {
return;
+ }
name = get_display_name(node);
if (name == NULL)
@@ -873,8 +884,9 @@
PurpleBlistNode *node = (PurpleBlistNode *)buddy;
PurpleContact *contact;
- if (purple_blist_node_get_ui_data(node))
+ if(g_object_get_data(G_OBJECT(node), UI_DATA)) {
return;
+ }
contact = purple_buddy_get_contact(buddy);
parent = ggblist->manager->find_parent((PurpleBlistNode*)buddy);
@@ -1831,15 +1843,8 @@
static void
reset_blist_window(GntWidget *window, gpointer null)
{
- PurpleBlistNode *node;
purple_signals_disconnect_by_handle(finch_blist_get_handle());
- node = purple_blist_get_default_root();
- while (node) {
- reset_blist_node_ui_data(node);
- node = purple_blist_node_next(node, TRUE);
- }
-
if (ggblist->typing)
g_source_remove(ggblist->typing);
remove_peripherals(ggblist);
@@ -1948,7 +1953,7 @@
static void
redraw_blist(const char *name, PurplePrefType type, gconstpointer val, gpointer data)
{
- PurpleBlistNode *node, *sel;
+ PurpleBlistNode *sel;
FinchBlistManager *manager;
if (ggblist == NULL)
@@ -1976,10 +1981,6 @@
sel = gnt_tree_get_selection_data(GNT_TREE(ggblist->tree));
gnt_tree_remove_all(GNT_TREE(ggblist->tree));
- for (node = purple_blist_get_default_root(); node;
- node = purple_blist_node_next(node, TRUE)) {
- reset_blist_node_ui_data(node);
- }
populate_buddylist();
gnt_tree_set_selected(GNT_TREE(ggblist->tree), sel);
draw_tooltip(ggblist);
@@ -2372,7 +2373,7 @@
buddy_recent_signed_on_off(gpointer data)
{
PurpleBlistNode *node = data;
- FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
+ FinchBlistNode *fnode = g_object_get_data(G_OBJECT(node), UI_DATA);
g_source_remove(fnode->signed_timer);
fnode->signed_timer = 0;
@@ -2393,12 +2394,14 @@
buddy_signed_on_off_cb(gpointer data)
{
PurpleBlistNode *node = data;
- FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
- if (!ggblist || !fnode)
+ FinchBlistNode *fnode = g_object_get_data(G_OBJECT(node), UI_DATA);
+ if(!ggblist || !fnode) {
return FALSE;
-
- if (fnode->signed_timer)
+ }
+
+ if(fnode->signed_timer) {
g_source_remove(fnode->signed_timer);
+ }
g_object_ref(node);
fnode->signed_timer = g_timeout_add_seconds(6, (GSourceFunc)buddy_recent_signed_on_off, data);
--- a/libpurple/blistnode.c Wed Feb 03 18:27:42 2021 -0600
+++ b/libpurple/blistnode.c Wed Feb 03 18:28:59 2021 -0600
@@ -99,21 +99,6 @@
return node? node->prev : NULL;
}
-void *
-purple_blist_node_get_ui_data(const PurpleBlistNode *node)
-{
- g_return_val_if_fail(PURPLE_IS_BLIST_NODE(node), NULL);
-
- return node->ui_data;
-}
-
-void
-purple_blist_node_set_ui_data(PurpleBlistNode *node, void *ui_data) {
- g_return_if_fail(PURPLE_IS_BLIST_NODE(node));
-
- node->ui_data = ui_data;
-}
-
void purple_blist_node_remove_setting(PurpleBlistNode *node, const char *key)
{
PurpleBlistNodePrivate *priv = NULL;
--- a/libpurple/blistnode.h Wed Feb 03 18:27:42 2021 -0600
+++ b/libpurple/blistnode.h Wed Feb 03 18:28:59 2021 -0600
@@ -51,8 +51,6 @@
* @next: The sibling after this buddy.
* @parent: The parent of this node.
* @child: The child of this node.
- * @ui_data: The UI data associated with this node. This is a convenience
- * field provided to the UIs -- it is not used by the libpurple core.
*
* A Buddy list node. This can represent a group, a buddy, or anything else.
* This is a base class for PurpleBuddy, PurpleContact, PurpleGroup, and for
@@ -66,8 +64,6 @@
PurpleBlistNode *next;
PurpleBlistNode *parent;
PurpleBlistNode *child;
-
- gpointer ui_data;
};
struct _PurpleBlistNodeClass {
@@ -157,25 +153,6 @@
PurpleBlistNode *purple_blist_node_get_sibling_prev(PurpleBlistNode *node);
/**
- * purple_blist_node_get_ui_data:
- * @node: The node.
- *
- * Returns the UI data of a given node.
- *
- * Returns: The UI data.
- */
-gpointer purple_blist_node_get_ui_data(const PurpleBlistNode *node);
-
-/**
- * purple_blist_node_set_ui_data:
- * @node: The node.
- * @ui_data: The UI data.
- *
- * Sets the UI data of a given node.
- */
-void purple_blist_node_set_ui_data(PurpleBlistNode *node, gpointer ui_data);
-
-/**
* purple_blist_node_get_settings:
* @node: The node to from which to get settings
*
--- a/pidgin/gtkblist.c Wed Feb 03 18:27:42 2021 -0600
+++ b/pidgin/gtkblist.c Wed Feb 03 18:28:59 2021 -0600
@@ -63,6 +63,8 @@
#include <gtk/gtk.h>
#include <gdk/gdk.h>
+#define UI_DATA "ui-pidgin"
+
typedef struct
{
PurpleAccount *account;
@@ -358,9 +360,12 @@
static PurpleConversation *
find_conversation_with_buddy(PurpleBuddy *buddy)
{
- PidginBlistNode *ui = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(buddy));
- if (ui)
+ PidginBlistNode *ui = g_object_get_data(G_OBJECT(buddy), UI_DATA);
+
+ if(ui) {
return ui->conv.conv;
+ }
+
return PURPLE_CONVERSATION(purple_conversations_find_im_with_account(
purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)));
}
@@ -577,8 +582,7 @@
if (PURPLE_IS_CONTACT(node)) {
PurpleContact *contact = PURPLE_CONTACT(node);
- PidginBlistNode *gtknode =
- (PidginBlistNode *)purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
/*
* Using purple_contact_get_alias here breaks because we
@@ -910,7 +914,7 @@
static void
pidgin_blist_update_privacy_cb(PurpleBuddy *buddy)
{
- PidginBlistNode *ui_data = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(buddy));
+ PidginBlistNode *ui_data = g_object_get_data(G_OBJECT(buddy), UI_DATA);
if (ui_data == NULL || ui_data->row == NULL)
return;
pidgin_blist_update_buddy(purple_blist_get_default(),
@@ -1218,7 +1222,7 @@
for(cnode = purple_blist_node_get_first_child(node); cnode; cnode = purple_blist_node_get_sibling_next(cnode)) {
if (PURPLE_IS_CONTACT(cnode)) {
- gtknode = purple_blist_node_get_ui_data(cnode);
+ gtknode = g_object_get_data(G_OBJECT(cnode), UI_DATA);
if (!gtknode->contact_expanded)
continue;
gtknode->contact_expanded = FALSE;
@@ -1342,10 +1346,11 @@
PurpleBlistNode *bnode;
GtkTreePath *path;
- if(!PURPLE_IS_CONTACT(node))
+ if(!PURPLE_IS_CONTACT(node)) {
return;
-
- gtknode = purple_blist_node_get_ui_data(node);
+ }
+
+ gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
gtknode->contact_expanded = TRUE;
@@ -1378,7 +1383,7 @@
if(!PURPLE_IS_CONTACT(node))
return;
- gtknode = purple_blist_node_get_ui_data(node);
+ gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
gtknode->contact_expanded = FALSE;
@@ -1509,7 +1514,7 @@
contact = purple_buddy_get_contact(buddy);
if (contact) {
- PidginBlistNode *node = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(contact));
+ PidginBlistNode *node = g_object_get_data(G_OBJECT(contact), UI_DATA);
contact_expanded = node->contact_expanded;
}
@@ -1829,7 +1834,7 @@
static GtkWidget *
create_buddy_menu(PurpleBlistNode *node, PurpleBuddy *b)
{
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
GtkWidget *menu;
GtkWidget *menuitem;
gboolean show_offline = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_offline_buddies");
@@ -1893,7 +1898,7 @@
static gboolean
pidgin_blist_show_context_menu(GtkWidget *tv, PurpleBlistNode *node, GdkEvent *event)
{
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
GtkWidget *menu = NULL;
gboolean handled = FALSE;
@@ -1963,7 +1968,7 @@
return FALSE;
gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
- gtknode = purple_blist_node_get_ui_data(node);
+ gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
/* Right click draws a context menu */
if (gdk_event_triggers_context_menu((GdkEvent *)event)) {
@@ -2297,7 +2302,7 @@
&iter, path);
gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel),
&iter, NODE_COLUMN, &node, -1);
- gtknode = purple_blist_node_get_ui_data(node);
+ gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
if (PURPLE_IS_CONTACT(n)) {
PurpleContact *c = (PurpleContact*)n;
@@ -3110,7 +3115,7 @@
return FALSE;
}
- gtknode = purple_blist_node_get_ui_data(node);
+ gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
if (!gtknode->contact_expanded) {
GtkTreeIter i;
@@ -3140,7 +3145,7 @@
if(!buddy)
return FALSE;
- gtknode = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(buddy));
+ gtknode = g_object_get_data(G_OBJECT(buddy), UI_DATA);
return (purple_account_is_connected(purple_buddy_get_account(buddy)) &&
(purple_presence_is_online(purple_buddy_get_presence(buddy)) ||
@@ -3277,7 +3282,7 @@
PurpleProtocolChatEntry *pce;
char *name, *value;
PurpleChatConversation *conv;
- PidginBlistNode *bnode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *bnode = g_object_get_data(G_OBJECT(node), UI_DATA);
chat = (PurpleChat *)node;
protocol = purple_protocols_find(purple_account_get_protocol_id(purple_chat_get_account(chat)));
@@ -3446,7 +3451,7 @@
/* Last Seen */
if (full && c && !PURPLE_BUDDY_IS_ONLINE(b))
{
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(c));
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(c), UI_DATA);
PurpleBlistNode *bnode;
int lastseen = 0;
@@ -3576,7 +3581,7 @@
pidgin_blist_get_emblem(PurpleBlistNode *node)
{
PurpleBuddy *buddy = NULL;
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
PurpleProtocol *protocol;
const char *name = NULL;
char *filename, *path;
@@ -3588,7 +3593,9 @@
buddy = purple_contact_get_priority_buddy((PurpleContact*)node);
}
} else if(PURPLE_IS_BUDDY(node)) {
+ PidginBlistNode *pidgin_node = NULL;
buddy = (PurpleBuddy*)node;
+
p = purple_buddy_get_presence(buddy);
if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
/* This emblem comes from the small emoticon set now,
@@ -3598,7 +3605,8 @@
return _pidgin_blist_get_cached_emblem(path);
}
- if (((PidginBlistNode*)purple_blist_node_get_ui_data(node->parent))->contact_expanded) {
+ pidgin_node = g_object_get_data(G_OBJECT(node->parent), UI_DATA);
+ if(pidgin_node->contact_expanded) {
if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons"))
return NULL;
return pidgin_create_protocol_icon(purple_buddy_get_account((PurpleBuddy*)node), PIDGIN_PROTOCOL_ICON_SMALL);
@@ -3687,7 +3695,7 @@
{
GdkPixbuf *ret;
const char *icon = NULL;
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
PidginBlistNode *gtkbuddynode = NULL;
PurpleBuddy *buddy = NULL;
PurpleChat *chat = NULL;
@@ -3697,12 +3705,13 @@
if(PURPLE_IS_CONTACT(node)) {
if(!gtknode->contact_expanded) {
buddy = purple_contact_get_priority_buddy((PurpleContact*)node);
- if (buddy != NULL)
- gtkbuddynode = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(buddy));
+ if(buddy != NULL) {
+ gtkbuddynode = g_object_get_data(G_OBJECT(buddy), UI_DATA);
+ }
}
} else if(PURPLE_IS_BUDDY(node)) {
buddy = (PurpleBuddy*)node;
- gtkbuddynode = purple_blist_node_get_ui_data(node);
+ gtkbuddynode = g_object_get_data(G_OBJECT(node), UI_DATA);
} else if(PURPLE_IS_CHAT(node)) {
chat = (PurpleChat*)node;
} else {
@@ -3731,7 +3740,7 @@
if(conv != NULL) {
PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
if (gtkconv == NULL && size == PIDGIN_STATUS_ICON_SMALL) {
- PidginBlistNode *ui = purple_blist_node_get_ui_data(&(buddy->node));
+ PidginBlistNode *ui = g_object_get_data(G_OBJECT(buddy), UI_DATA);
if (ui == NULL || (ui->conv.flags & PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE))
return gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview),
PIDGIN_STOCK_STATUS_MESSAGE, icon_size, "GtkTreeView");
@@ -3815,7 +3824,7 @@
gchar *contact_alias;
if (conv != NULL) {
- PidginBlistNode *ui = purple_blist_node_get_ui_data(&(b->node));
+ PidginBlistNode *ui = g_object_get_data(G_OBJECT(b), UI_DATA);
if (ui) {
if (ui->conv.flags & PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE)
hidden_conv = TRUE;
@@ -3827,8 +3836,9 @@
/* XXX Good luck cleaning up this crap */
contact = PURPLE_CONTACT(PURPLE_BLIST_NODE(b)->parent);
- if(contact)
- gtkcontactnode = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(contact));
+ if(contact) {
+ gtkcontactnode = g_object_get_data(G_OBJECT(contact), UI_DATA);
+ }
g_object_get(contact, "alias", &contact_alias, NULL);
@@ -4049,7 +4059,7 @@
static void pidgin_blist_hide_node(PurpleBuddyList *list, PurpleBlistNode *node, gboolean update)
{
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
GtkTreeIter iter;
if (!gtknode || !gtknode->row || !gtkblist)
@@ -4216,7 +4226,7 @@
static void
written_msg_update_ui_cb(PurpleConversation *conv, PurpleMessage *msg, PurpleBlistNode *node)
{
- PidginBlistNode *ui = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *ui = g_object_get_data(G_OBJECT(node), UI_DATA);
if (ui->conv.conv != conv)
return;
@@ -4237,7 +4247,7 @@
static void
displayed_msg_update_ui_cb(PidginConversation *gtkconv, PurpleBlistNode *node)
{
- PidginBlistNode *ui = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *ui = g_object_get_data(G_OBJECT(node), UI_DATA);
if (ui->conv.conv != gtkconv->active_conv)
return;
ui->conv.flags &= ~(PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE |
@@ -4254,7 +4264,7 @@
GSList *buddies = purple_blist_find_buddies(account, purple_conversation_get_name(conv));
while (buddies) {
PurpleBlistNode *buddy = buddies->data;
- PidginBlistNode *ui = purple_blist_node_get_ui_data(buddy);
+ PidginBlistNode *ui = g_object_get_data(G_OBJECT(buddy), UI_DATA);
buddies = g_slist_delete_link(buddies, buddies);
if (!ui)
continue;
@@ -4272,7 +4282,7 @@
PidginBlistNode *ui;
if (!chat)
return;
- ui = purple_blist_node_get_ui_data(&(chat->node));
+ ui = g_object_get_data(G_OBJECT(chat), UI_DATA);
if (!ui)
return;
ui->conv.conv = conv;
@@ -4289,15 +4299,31 @@
/**********************************************************************************
* Public API Functions *
**********************************************************************************/
+static void
+pidgin_blist_node_free(PidginBlistNode *node) {
+ if(node->recent_signonoff_timer > 0) {
+ g_source_remove(node->recent_signonoff_timer);
+ }
+
+ purple_signals_disconnect_by_handle(node);
+
+ g_free(node);
+}
static void
-pidgin_blist_new_node(PurpleBuddyList *list, PurpleBlistNode *node)
-{
- purple_blist_node_set_ui_data(node, g_new0(PidginBlistNode, 1));
-}
-
-gboolean pidgin_blist_node_is_contact_expanded(PurpleBlistNode *node)
-{
+pidgin_blist_new_node(PurpleBuddyList *list, PurpleBlistNode *node) {
+ PidginBlistNode *pidgin_node = NULL;
+
+ pidgin_node = g_new0(PidginBlistNode, 1);
+
+ g_object_set_data_full(G_OBJECT(node), UI_DATA, pidgin_node,
+ (GDestroyNotify)pidgin_blist_node_free);
+}
+
+gboolean
+pidgin_blist_node_is_contact_expanded(PurpleBlistNode *node) {
+ PidginBlistNode *pidgin_node = NULL;
+
if (PURPLE_IS_BUDDY(node)) {
node = node->parent;
if (node == NULL)
@@ -4306,7 +4332,9 @@
g_return_val_if_fail(PURPLE_IS_CONTACT(node), FALSE);
- return ((PidginBlistNode *)purple_blist_node_get_ui_data(node))->contact_expanded;
+ pidgin_node = g_object_get_data(G_OBJECT(node), UI_DATA);
+
+ return pidgin_node->contact_expanded;
}
enum {
@@ -4356,7 +4384,7 @@
PidginBlistNode *gtknode;
GtkTreePath *path;
- gtknode = purple_blist_node_get_ui_data(node);
+ gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
if (gtknode && gtknode->row)
{
path = gtk_tree_row_reference_get_path(gtknode->row);
@@ -5518,7 +5546,7 @@
}
static gboolean get_iter_from_node(PurpleBlistNode *node, GtkTreeIter *iter) {
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
GtkTreePath *path;
if (!gtknode) {
@@ -5548,33 +5576,14 @@
return TRUE;
}
-static void pidgin_blist_remove(PurpleBuddyList *list, PurpleBlistNode *node)
-{
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
-
+static void
+pidgin_blist_remove(PurpleBuddyList *list, PurpleBlistNode *node) {
purple_request_close_with_handle(node);
pidgin_blist_hide_node(list, node, TRUE);
- if(node->parent)
+ if(node->parent) {
pidgin_blist_update(list, node->parent);
-
- /* There's something I don't understand here - Ethan */
- /* Ethan said that back in 2003, but this g_free has been left commented
- * out ever since. I can't find any reason at all why this is bad and
- * valgrind found several reasons why it's good. If this causes problems
- * comment it out again. Stu */
- /* Of course it still causes problems - this breaks dragging buddies into
- * contacts, the dragged buddy mysteriously 'disappears'. Stu. */
- /* I think it's fixed now. Stu. */
-
- if(gtknode) {
- if(gtknode->recent_signonoff_timer > 0)
- g_source_remove(gtknode->recent_signonoff_timer);
-
- purple_signals_disconnect_by_handle(gtknode);
- g_free(gtknode);
- purple_blist_node_set_ui_data(node, NULL);
}
}
@@ -5619,7 +5628,7 @@
static gboolean insert_node(PurpleBuddyList *list, PurpleBlistNode *node, GtkTreeIter *iter)
{
GtkTreeIter parent_iter = {0, NULL, NULL, NULL}, cur, *curptr = NULL;
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(node);
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
GtkTreePath *newpath;
if(!iter)
@@ -5644,7 +5653,7 @@
gtk_tree_row_reference_free(gtknode->row);
} else {
pidgin_blist_new_node(list, node);
- gtknode = purple_blist_node_get_ui_data(node);
+ gtknode = g_object_get_data(G_OBJECT(node), UI_DATA);
}
newpath = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel),
@@ -5662,7 +5671,7 @@
if(node->parent) {
GtkTreePath *expand = NULL;
- PidginBlistNode *gtkparentnode = purple_blist_node_get_ui_data(node->parent);
+ PidginBlistNode *gtkparentnode = g_object_get_data(G_OBJECT(node->parent), UI_DATA);
if(PURPLE_IS_GROUP(node->parent)) {
if(!purple_blist_node_get_bool(node->parent, "collapsed"))
@@ -5852,17 +5861,20 @@
static void buddy_node(PurpleBuddy *buddy, GtkTreeIter *iter, PurpleBlistNode *node)
{
PurplePresence *presence = purple_buddy_get_presence(buddy);
+ PidginBlistNode *pidgin_node = NULL;
GdkPixbuf *status, *avatar, *emblem, *protocol_icon;
GdkRGBA *color = NULL;
char *mark;
char *idle = NULL;
- gboolean expanded = ((PidginBlistNode *)purple_blist_node_get_ui_data(node->parent))->contact_expanded;
gboolean selected = (gtkblist->selected_node == node);
gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
PidginBlistTheme *theme;
- if (editing_blist)
+ if(editing_blist) {
return;
+ }
+
+ pidgin_node = g_object_get_data(G_OBJECT(node->parent), UI_DATA);
status = pidgin_blist_get_status_icon(PURPLE_BLIST_NODE(buddy),
biglist ? PIDGIN_STATUS_ICON_LARGE : PIDGIN_STATUS_ICON_SMALL);
@@ -5940,7 +5952,7 @@
PROTOCOL_ICON_VISIBLE_COLUMN, purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons"),
BGCOLOR_COLUMN, color,
CONTACT_EXPANDER_COLUMN, NULL,
- CONTACT_EXPANDER_VISIBLE_COLUMN, expanded,
+ CONTACT_EXPANDER_VISIBLE_COLUMN, pidgin_node->contact_expanded,
GROUP_EXPANDER_VISIBLE_COLUMN, FALSE,
-1);
@@ -5992,7 +6004,7 @@
if(!insert_node(list, cnode, &iter))
return;
- gtknode = purple_blist_node_get_ui_data(cnode);
+ gtknode = g_object_get_data(G_OBJECT(cnode), UI_DATA);
if(gtknode->contact_expanded) {
GdkPixbuf *status;
@@ -6069,7 +6081,7 @@
/* First things first, update the contact */
pidgin_blist_update_contact(list, node);
- gtkparentnode = purple_blist_node_get_ui_data(node->parent);
+ gtkparentnode = g_object_get_data(G_OBJECT(node->parent), UI_DATA);
if (gtkparentnode->contact_expanded && buddy_is_displayable(buddy))
{
@@ -6119,7 +6131,7 @@
if (!insert_node(list, node, &iter))
return;
- ui = purple_blist_node_get_ui_data(node);
+ ui = g_object_get_data(G_OBJECT(node), UI_DATA);
conv = ui->conv.conv;
if (conv && pidgin_conv_is_hidden(PIDGIN_CONVERSATION(conv))) {
hidden = (ui->conv.flags & PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE);
@@ -6200,22 +6212,26 @@
static void pidgin_blist_update(PurpleBuddyList *list, PurpleBlistNode *node)
{
- if (list)
+ if(list) {
gtkblist = PIDGIN_BUDDY_LIST(list);
- if(!gtkblist || !gtkblist->treeview || !node)
+ }
+ if(!gtkblist || !gtkblist->treeview || !node) {
return;
-
- if (purple_blist_node_get_ui_data(node) == NULL)
+ }
+
+ if(g_object_get_data(G_OBJECT(node), UI_DATA) == NULL) {
pidgin_blist_new_node(list, node);
-
- if (PURPLE_IS_GROUP(node))
+ }
+
+ if(PURPLE_IS_GROUP(node)) {
pidgin_blist_update_group(list, node);
- else if (PURPLE_IS_CONTACT(node))
+ } else if(PURPLE_IS_CONTACT(node)) {
pidgin_blist_update_contact(list, node);
- else if (PURPLE_IS_BUDDY(node))
+ } else if(PURPLE_IS_BUDDY(node)) {
pidgin_blist_update_buddy(list, node, TRUE);
- else if (PURPLE_IS_CHAT(node))
+ } else if(PURPLE_IS_CHAT(node)) {
pidgin_blist_update_chat(list, node);
+ }
}
static void pidgin_blist_set_visible(PurpleBuddyList *list, gboolean show)
@@ -6750,7 +6766,7 @@
static gboolean buddy_signonoff_timeout_cb(PurpleBuddy *buddy)
{
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(buddy));
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(buddy), UI_DATA);
gtknode->recent_signonoff = FALSE;
gtknode->recent_signonoff_timer = 0;
@@ -6760,16 +6776,16 @@
return FALSE;
}
-static void buddy_signonoff_cb(PurpleBuddy *buddy)
-{
- PidginBlistNode *gtknode = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(buddy));
-
- if(!gtknode) {
+static void
+buddy_signonoff_cb(PurpleBuddy *buddy) {
+ PidginBlistNode *gtknode = g_object_get_data(G_OBJECT(buddy), UI_DATA);
+
+ if(gtknode == NULL) {
pidgin_blist_new_node(purple_blist_get_default(),
PURPLE_BLIST_NODE(buddy));
- }
-
- gtknode = purple_blist_node_get_ui_data(PURPLE_BLIST_NODE(buddy));
+
+ gtknode = g_object_get_data(G_OBJECT(buddy), UI_DATA);
+ }
gtknode->recent_signonoff = TRUE;