Mercurial > pidgin
changeset 4781:b6f33ba0a0c0
[gaim-migrate @ 5101]
Things this does:
- dragging a buddy into a conversation window will actually put it in that
window.
- drag buddies and groups around in your buddy list to your heart's desire
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Fri, 14 Mar 2003 23:47:26 +0000 |
parents | 5d4243c013a2 |
children | fd69b80cb349 |
files | src/buddy.c src/gtkconv.c src/list.c |
diffstat | 3 files changed, 76 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddy.c Fri Mar 14 23:46:32 2003 +0000 +++ b/src/buddy.c Fri Mar 14 23:47:26 2003 +0000 @@ -319,7 +319,7 @@ guint time, gpointer *null) { - if (data->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) { + if (data->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) { GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref); GtkTreeIter iter; @@ -328,26 +328,25 @@ gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow); gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); node = g_value_get_pointer(&val); - if (GAIM_BLIST_NODE_IS_BUDDY(node)) - gtk_selection_data_set (data, - gdk_atom_intern ("GAIM_BUDDY", FALSE), - 8, /* bits */ - (void*)&node, - sizeof (node)); - + gtk_selection_data_set (data, + gdk_atom_intern ("GAIM_BLIST_NODE", FALSE), + 8, /* bits */ + (void*)&node, + sizeof (node)); + gtk_tree_path_free(sourcerow); } - + } static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t) { - if (sd->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) { - struct buddy *b = NULL; + if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE) && sd->data) { + GaimBlistNode *n = NULL; GtkTreePath *path = NULL; GtkTreeViewDropPosition position; - memcpy(&b, sd->data, sizeof(b)); + memcpy(&n, sd->data, sizeof(n)); if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) { /* if we're here, I think it means the drop is ok */ GtkTreeIter iter; @@ -356,15 +355,36 @@ gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); node = g_value_get_pointer(&val); - if (GAIM_BLIST_NODE_IS_BUDDY(node)) { - if (position == GTK_TREE_VIEW_DROP_AFTER) { - gaim_blist_add_buddy(b, (struct group *)node->parent, node); - } else if (position == GTK_TREE_VIEW_DROP_BEFORE) { - gaim_blist_add_buddy(b, (struct group *)node->parent, node->prev); + + if (GAIM_BLIST_NODE_IS_BUDDY(n)) { + struct buddy *b = (struct buddy*)n; + if (GAIM_BLIST_NODE_IS_BUDDY(node)) { + if (position == GTK_TREE_VIEW_DROP_AFTER) { + gaim_blist_add_buddy(b, (struct group*)node->parent, node); + } else if (position == GTK_TREE_VIEW_DROP_BEFORE) { + gaim_blist_add_buddy(b, (struct group*)node->parent, node->prev); + } + } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { + gaim_blist_add_buddy(b, (struct group*)node, NULL); + } + } else if (GAIM_BLIST_NODE_IS_GROUP(n)) { + struct group *g = (struct group*)n; + if (GAIM_BLIST_NODE_IS_GROUP(node)) { + switch (position) { + case GTK_TREE_VIEW_DROP_INTO_OR_AFTER: + case GTK_TREE_VIEW_DROP_AFTER: + gaim_blist_add_group(g, node); + break; + case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE: + case GTK_TREE_VIEW_DROP_BEFORE: + gaim_blist_add_group(g, node->prev); + break; + } + } - } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { - gaim_blist_add_buddy(b, (struct group *)node, NULL); + } + gtk_tree_path_free(path); } } @@ -883,7 +903,7 @@ GtkWidget *sw; GtkWidget *button; GtkSizeGroup *sg; - GtkTargetEntry gte[] = {{"GAIM_BUDDY", GTK_TARGET_SAME_APP, DRAG_ROW}, + GtkTargetEntry gte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW}, {"application/x-im-contact", 0, DRAG_BUDDY}}; if (gtkblist && gtkblist->window) { @@ -1231,6 +1251,12 @@ gaim_gtk_blist_remove(list, node); if (blist_options & OPT_BLIST_POPUP) gtk_window_present(GTK_WINDOW(gtkblist->window)); + } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { + GaimBlistNode *afsad = node->child; + while (afsad) { + gaim_gtk_blist_update(list, afsad); + afsad = afsad->next; + } } }
--- a/src/gtkconv.c Fri Mar 14 23:46:32 2003 +0000 +++ b/src/gtkconv.c Fri Mar 14 23:47:26 2003 +0000 @@ -3258,12 +3258,17 @@ static void conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, - GtkSelectionData *sd, guint info, guint t) + GtkSelectionData *sd, guint info, guint t, struct gaim_conversation *conv) { - if (sd->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) { - struct buddy *b = NULL; - memcpy(&b, sd->data, sizeof(b)); - gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); + struct gaim_window *win = conv->window; + struct gaim_conversation *c; + if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) { + GaimBlistNode *n = NULL; + memcpy(&n, sd->data, sizeof(n)); + if (!GAIM_BLIST_NODE_IS_BUDDY(n)) + return; + c = gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)n)->account, ((struct buddy*)n)->name); + gaim_window_add_conversation (win, c); } /* do_error_dialog("MWAHAHAHA! I AM A TROLL! I AM GOING TO EAT YOU!", @@ -3402,7 +3407,7 @@ { {"text/plain", 0, 0}, {"text/uri-list", 0, 1}, - {"GAIM_BUDDY", 0, 2}, + {"GAIM_BLIST_NODE", 0, 2}, {"STRING", 0, 3} };
--- a/src/list.c Fri Mar 14 23:46:32 2003 +0000 +++ b/src/list.c Fri Mar 14 23:47:26 2003 +0000 @@ -313,7 +313,8 @@ void gaim_blist_add_group (struct group *group, GaimBlistNode *node) { struct gaim_blist_ui_ops *ops; - + gboolean save; + if (!gaimbuddylist) gaimbuddylist = gaim_blist_new(); ops = gaimbuddylist->ui_ops; @@ -323,18 +324,32 @@ return; } - if (gaim_find_group(group->name)) - return; - + if (!node) node = gaim_blist_get_last_sibling(gaimbuddylist->root); + + if (gaim_find_group(group->name)) { + /* This is just being moved */ + GaimBlistNode *node2 = ((GaimBlistNode*)group)->next; + GaimBlistNode *node3 = ((GaimBlistNode*)group)->prev; + ops->remove(gaimbuddylist, (GaimBlistNode*)group); + + if (node2) + node2->prev = node3; + if (node3) + node3->next = node2; + save = TRUE; + } + ((GaimBlistNode*)group)->next = node ? node->next : NULL; ((GaimBlistNode*)group)->prev = node; node->next = (GaimBlistNode*)group; if (ops) ops->update(gaimbuddylist, (GaimBlistNode*)group); + if (save) + gaim_blist_save(); } void gaim_blist_remove_buddy (struct buddy *buddy)