Mercurial > pidgin
comparison pidgin/gtkpounce.c @ 32672:3828a61c44da
A boring and large patch so I can merge heads.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 23 Dec 2011 08:21:58 +0000 |
parents | ea07a6230b57 |
children |
comparison
equal
deleted
inserted
replaced
32671:0e69949b3e61 | 32672:3828a61c44da |
---|---|
408 static void | 408 static void |
409 pounce_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, | 409 pounce_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
410 GtkSelectionData *sd, guint info, guint t, gpointer data) | 410 GtkSelectionData *sd, guint info, guint t, gpointer data) |
411 { | 411 { |
412 PidginPounceDialog *dialog; | 412 PidginPounceDialog *dialog; |
413 GdkAtom target = gtk_selection_data_get_target(sd); | 413 |
414 const guchar *sd_data = gtk_selection_data_get_data(sd); | 414 if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) |
415 | |
416 if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) | |
417 { | 415 { |
418 PurpleBlistNode *node = NULL; | 416 PurpleBlistNode *node = NULL; |
419 PurpleBuddy *buddy; | 417 PurpleBuddy *buddy; |
420 | 418 |
421 memcpy(&node, sd_data, sizeof(node)); | 419 memcpy(&node, sd->data, sizeof(node)); |
422 | 420 |
423 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) | 421 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
424 buddy = purple_contact_get_priority_buddy((PurpleContact *)node); | 422 buddy = purple_contact_get_priority_buddy((PurpleContact *)node); |
425 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) | 423 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
426 buddy = (PurpleBuddy *)node; | 424 buddy = (PurpleBuddy *)node; |
427 else | 425 else |
428 return; | 426 return; |
429 | 427 |
430 dialog = (PidginPounceDialog *)data; | 428 dialog = (PidginPounceDialog *)data; |
431 | 429 |
432 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), buddy->name); | 430 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), purple_buddy_get_name(buddy)); |
433 dialog->account = buddy->account; | 431 dialog->account = purple_buddy_get_account(buddy); |
434 pidgin_account_option_menu_set_selected(dialog->account_menu, buddy->account); | 432 pidgin_account_option_menu_set_selected(dialog->account_menu, purple_buddy_get_account(buddy)); |
435 | 433 |
436 gtk_drag_finish(dc, TRUE, (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t); | 434 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
437 } | 435 } |
438 else if (target == gdk_atom_intern("application/x-im-contact", FALSE)) | 436 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
439 { | 437 { |
440 char *protocol = NULL; | 438 char *protocol = NULL; |
441 char *username = NULL; | 439 char *username = NULL; |
442 PurpleAccount *account; | 440 PurpleAccount *account; |
443 | 441 |
444 if (pidgin_parse_x_im_contact((const char *) sd_data, FALSE, &account, | 442 if (pidgin_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
445 &protocol, &username, NULL)) | 443 &protocol, &username, NULL)) |
446 { | 444 { |
447 if (account == NULL) | 445 if (account == NULL) |
448 { | 446 { |
449 purple_notify_error(NULL, NULL, | 447 purple_notify_error(NULL, NULL, |
461 } | 459 } |
462 | 460 |
463 g_free(username); | 461 g_free(username); |
464 g_free(protocol); | 462 g_free(protocol); |
465 | 463 |
466 gtk_drag_finish(dc, TRUE, (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t); | 464 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
467 } | 465 } |
468 } | 466 } |
469 | 467 |
470 static const GtkTargetEntry dnd_targets[] = | 468 static const GtkTargetEntry dnd_targets[] = |
471 { | 469 { |
476 static void | 474 static void |
477 reset_send_msg_entry(PidginPounceDialog *dialog, GtkWidget *dontcare) | 475 reset_send_msg_entry(PidginPounceDialog *dialog, GtkWidget *dontcare) |
478 { | 476 { |
479 PurpleAccount *account = pidgin_account_option_menu_get_selected(dialog->account_menu); | 477 PurpleAccount *account = pidgin_account_option_menu_get_selected(dialog->account_menu); |
480 gtk_imhtml_setup_entry(GTK_IMHTML(dialog->send_msg_entry), | 478 gtk_imhtml_setup_entry(GTK_IMHTML(dialog->send_msg_entry), |
481 (account && account->gc) ? account->gc->flags : PURPLE_CONNECTION_HTML); | 479 (account && purple_account_get_connection(account)) ? purple_connection_get_flags(purple_account_get_connection(account)) : PURPLE_CONNECTION_HTML); |
482 } | 480 } |
483 | 481 |
484 void | 482 void |
485 pidgin_pounce_editor_show(PurpleAccount *account, const char *name, | 483 pidgin_pounce_editor_show(PurpleAccount *account, const char *name, |
486 PurplePounce *cur_pounce) | 484 PurplePounce *cur_pounce) |
540 | 538 |
541 g_signal_connect(G_OBJECT(window), "delete_event", | 539 g_signal_connect(G_OBJECT(window), "delete_event", |
542 G_CALLBACK(delete_win_cb), dialog); | 540 G_CALLBACK(delete_win_cb), dialog); |
543 | 541 |
544 /* Create the parent vbox for everything. */ | 542 /* Create the parent vbox for everything. */ |
545 vbox1 = gtk_dialog_get_content_area(GTK_DIALOG(window)); | 543 vbox1 = GTK_DIALOG(window)->vbox; |
546 | 544 |
547 /* Create the vbox that will contain all the prefs stuff. */ | 545 /* Create the vbox that will contain all the prefs stuff. */ |
548 vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); | 546 vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
549 gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); | 547 gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); |
550 | 548 |
1018 } | 1016 } |
1019 | 1017 |
1020 static gboolean | 1018 static gboolean |
1021 pounces_manager_configure_cb(GtkWidget *widget, GdkEventConfigure *event, PouncesManager *dialog) | 1019 pounces_manager_configure_cb(GtkWidget *widget, GdkEventConfigure *event, PouncesManager *dialog) |
1022 { | 1020 { |
1021 #if GTK_CHECK_VERSION(2,18,0) | |
1023 if (gtk_widget_get_visible(widget)) { | 1022 if (gtk_widget_get_visible(widget)) { |
1023 #else | |
1024 if (GTK_WIDGET_VISIBLE(widget)) { | |
1025 #endif | |
1024 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/pounces/dialog/width", event->width); | 1026 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/pounces/dialog/width", event->width); |
1025 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/pounces/dialog/height", event->height); | 1027 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/pounces/dialog/height", event->height); |
1026 } | 1028 } |
1027 | 1029 |
1028 return FALSE; | 1030 return FALSE; |
1419 } | 1421 } |
1420 | 1422 |
1421 if (purple_pounce_action_is_enabled(pounce, "popup-notify")) | 1423 if (purple_pounce_action_is_enabled(pounce, "popup-notify")) |
1422 { | 1424 { |
1423 char *tmp; | 1425 char *tmp; |
1424 const char *name_shown; | |
1425 const char *reason; | 1426 const char *reason; |
1426 reason = purple_pounce_action_get_attribute(pounce, "popup-notify", | 1427 reason = purple_pounce_action_get_attribute(pounce, "popup-notify", |
1427 "reason"); | 1428 "reason"); |
1428 | 1429 |
1429 /* | 1430 /* |
1452 (events & PURPLE_POUNCE_MESSAGE_RECEIVED) ? | 1453 (events & PURPLE_POUNCE_MESSAGE_RECEIVED) ? |
1453 _("Sent a message") : | 1454 _("Sent a message") : |
1454 _("Unknown.... Please report this!") | 1455 _("Unknown.... Please report this!") |
1455 ); | 1456 ); |
1456 | 1457 |
1457 /* | |
1458 * Ok here is where I change the second argument, title, from | |
1459 * NULL to the account alias if we have it or the account | |
1460 * name if that's all we have | |
1461 */ | |
1462 if ((name_shown = purple_account_get_alias(account)) == NULL) | |
1463 name_shown = purple_account_get_username(account); | |
1464 | |
1465 pidgin_notify_pounce_add(account, pounce, alias, tmp, reason, | 1458 pidgin_notify_pounce_add(account, pounce, alias, tmp, reason, |
1466 purple_date_format_full(NULL)); | 1459 purple_date_format_full(NULL)); |
1467 | 1460 |
1468 g_free(tmp); | 1461 g_free(tmp); |
1469 } | 1462 } |
1483 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); | 1476 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, pouncee); |
1484 | 1477 |
1485 purple_conversation_write(conv, NULL, message, | 1478 purple_conversation_write(conv, NULL, message, |
1486 PURPLE_MESSAGE_SEND, time(NULL)); | 1479 PURPLE_MESSAGE_SEND, time(NULL)); |
1487 | 1480 |
1488 serv_send_im(account->gc, (char *)pouncee, (char *)message, 0); | 1481 serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0); |
1489 } | 1482 } |
1490 } | 1483 } |
1491 | 1484 |
1492 if (purple_pounce_action_is_enabled(pounce, "execute-command")) | 1485 if (purple_pounce_action_is_enabled(pounce, "execute-command")) |
1493 { | 1486 { |