comparison src/buddy.c @ 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 e23a7e166680
children 1e28e7d802a1
comparison
equal deleted inserted replaced
4780:5d4243c013a2 4781:b6f33ba0a0c0
317 GtkSelectionData *data, 317 GtkSelectionData *data,
318 guint info, 318 guint info,
319 guint time, 319 guint time,
320 gpointer *null) 320 gpointer *null)
321 { 321 {
322 if (data->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) { 322 if (data->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) {
323 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row"); 323 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row");
324 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref); 324 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref);
325 GtkTreeIter iter; 325 GtkTreeIter iter;
326 GaimBlistNode *node = NULL; 326 GaimBlistNode *node = NULL;
327 GValue val = {0}; 327 GValue val = {0};
328 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow); 328 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow);
329 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); 329 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
330 node = g_value_get_pointer(&val); 330 node = g_value_get_pointer(&val);
331 if (GAIM_BLIST_NODE_IS_BUDDY(node)) 331 gtk_selection_data_set (data,
332 gtk_selection_data_set (data, 332 gdk_atom_intern ("GAIM_BLIST_NODE", FALSE),
333 gdk_atom_intern ("GAIM_BUDDY", FALSE), 333 8, /* bits */
334 8, /* bits */ 334 (void*)&node,
335 (void*)&node, 335 sizeof (node));
336 sizeof (node)); 336
337
338 gtk_tree_path_free(sourcerow); 337 gtk_tree_path_free(sourcerow);
339 } 338 }
340 339
341 } 340 }
342 341
343 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, 342 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
344 GtkSelectionData *sd, guint info, guint t) 343 GtkSelectionData *sd, guint info, guint t)
345 { 344 {
346 if (sd->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) { 345 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE) && sd->data) {
347 struct buddy *b = NULL; 346 GaimBlistNode *n = NULL;
348 GtkTreePath *path = NULL; 347 GtkTreePath *path = NULL;
349 GtkTreeViewDropPosition position; 348 GtkTreeViewDropPosition position;
350 memcpy(&b, sd->data, sizeof(b)); 349 memcpy(&n, sd->data, sizeof(n));
351 if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) { 350 if(gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget), x, y, &path, &position)) {
352 /* if we're here, I think it means the drop is ok */ 351 /* if we're here, I think it means the drop is ok */
353 GtkTreeIter iter; 352 GtkTreeIter iter;
354 GaimBlistNode *node; 353 GaimBlistNode *node;
355 GValue val = {0}; 354 GValue val = {0};
356 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path); 355 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
357 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val); 356 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
358 node = g_value_get_pointer(&val); 357 node = g_value_get_pointer(&val);
359 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { 358
360 if (position == GTK_TREE_VIEW_DROP_AFTER) { 359 if (GAIM_BLIST_NODE_IS_BUDDY(n)) {
361 gaim_blist_add_buddy(b, (struct group *)node->parent, node); 360 struct buddy *b = (struct buddy*)n;
362 } else if (position == GTK_TREE_VIEW_DROP_BEFORE) { 361 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
363 gaim_blist_add_buddy(b, (struct group *)node->parent, node->prev); 362 if (position == GTK_TREE_VIEW_DROP_AFTER) {
363 gaim_blist_add_buddy(b, (struct group*)node->parent, node);
364 } else if (position == GTK_TREE_VIEW_DROP_BEFORE) {
365 gaim_blist_add_buddy(b, (struct group*)node->parent, node->prev);
366 }
367 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
368 gaim_blist_add_buddy(b, (struct group*)node, NULL);
369 }
370 } else if (GAIM_BLIST_NODE_IS_GROUP(n)) {
371 struct group *g = (struct group*)n;
372 if (GAIM_BLIST_NODE_IS_GROUP(node)) {
373 switch (position) {
374 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
375 case GTK_TREE_VIEW_DROP_AFTER:
376 gaim_blist_add_group(g, node);
377 break;
378 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
379 case GTK_TREE_VIEW_DROP_BEFORE:
380 gaim_blist_add_group(g, node->prev);
381 break;
382 }
383
364 } 384 }
365 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { 385
366 gaim_blist_add_buddy(b, (struct group *)node, NULL);
367 } 386 }
387
368 gtk_tree_path_free(path); 388 gtk_tree_path_free(path);
369 } 389 }
370 } 390 }
371 } 391 }
372 392
881 GtkCellRenderer *rend; 901 GtkCellRenderer *rend;
882 GtkTreeViewColumn *column; 902 GtkTreeViewColumn *column;
883 GtkWidget *sw; 903 GtkWidget *sw;
884 GtkWidget *button; 904 GtkWidget *button;
885 GtkSizeGroup *sg; 905 GtkSizeGroup *sg;
886 GtkTargetEntry gte[] = {{"GAIM_BUDDY", GTK_TARGET_SAME_APP, DRAG_ROW}, 906 GtkTargetEntry gte[] = {{"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, DRAG_ROW},
887 {"application/x-im-contact", 0, DRAG_BUDDY}}; 907 {"application/x-im-contact", 0, DRAG_BUDDY}};
888 908
889 if (gtkblist && gtkblist->window) { 909 if (gtkblist && gtkblist->window) {
890 gtk_widget_show(gtkblist->window); 910 gtk_widget_show(gtkblist->window);
891 return; 911 return;
1229 1249
1230 } else if (GAIM_BLIST_NODE_IS_BUDDY(node) && !new_entry) { 1250 } else if (GAIM_BLIST_NODE_IS_BUDDY(node) && !new_entry) {
1231 gaim_gtk_blist_remove(list, node); 1251 gaim_gtk_blist_remove(list, node);
1232 if (blist_options & OPT_BLIST_POPUP) 1252 if (blist_options & OPT_BLIST_POPUP)
1233 gtk_window_present(GTK_WINDOW(gtkblist->window)); 1253 gtk_window_present(GTK_WINDOW(gtkblist->window));
1254 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
1255 GaimBlistNode *afsad = node->child;
1256 while (afsad) {
1257 gaim_gtk_blist_update(list, afsad);
1258 afsad = afsad->next;
1259 }
1234 } 1260 }
1235 } 1261 }
1236 1262
1237 static void gaim_gtk_blist_destroy(struct gaim_buddy_list *list) 1263 static void gaim_gtk_blist_destroy(struct gaim_buddy_list *list)
1238 { 1264 {