comparison src/gtkutils.c @ 10335:20e750dd21a0

[gaim-migrate @ 11542] Whitespace and Windows warning removal from Kevin. Thanks mon ami! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 09 Dec 2004 02:55:18 +0000
parents 95ca0db2d01d
children 64bc206c7473
comparison
equal deleted inserted replaced
10334:5aa8ed1ec91e 10335:20e750dd21a0
1398 1398
1399 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); 1399 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
1400 gaim_notify_error(NULL, NULL, 1400 gaim_notify_error(NULL, NULL,
1401 _("Failed to load image"), 1401 _("Failed to load image"),
1402 str); 1402 str);
1403 1403
1404 g_error_free(err); 1404 g_error_free(err);
1405 g_free(str); 1405 g_free(str);
1406 1406
1407 return; 1407 return;
1408 } 1408 }
1409 1409
1410 gaim_buddy_icons_set_for_user(data->account, data->who, filedata, size); 1410 gaim_buddy_icons_set_for_user(data->account, data->who, filedata, size);
1411 g_free(filedata); 1411 g_free(filedata);
1412 break; 1412 break;
1413 case DND_FILE_TRANSFER: 1413 case DND_FILE_TRANSFER:
1414 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename); 1414 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename);
1418 gtkconv = GAIM_GTK_CONVERSATION(conv); 1418 gtkconv = GAIM_GTK_CONVERSATION(conv);
1419 1419
1420 if (!g_file_get_contents(data->filename, &filedata, &size, 1420 if (!g_file_get_contents(data->filename, &filedata, &size,
1421 &err)) { 1421 &err)) {
1422 char *str; 1422 char *str;
1423 1423
1424 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); 1424 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
1425 gaim_notify_error(NULL, NULL, 1425 gaim_notify_error(NULL, NULL,
1426 _("Failed to load image"), 1426 _("Failed to load image"),
1427 str); 1427 str);
1428 1428
1429 g_error_free(err); 1429 g_error_free(err);
1430 g_free(str); 1430 g_free(str);
1431 1431
1432 return; 1432 return;
1433 } 1433 }
1434 id = gaim_imgstore_add(filedata, size, data->filename); 1434 id = gaim_imgstore_add(filedata, size, data->filename);
1435 g_free(filedata); 1435 g_free(filedata);
1436 1436
1437 gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter, 1437 gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter,
1438 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer)); 1438 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer));
1439 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter); 1439 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter);
1440 gaim_imgstore_unref(id); 1440 gaim_imgstore_unref(id);
1441 1441
1442 break; 1442 break;
1443 } 1443 }
1444 free(data->filename); 1444 free(data->filename);
1445 free(data->who); 1445 free(data->who);
1446 free(data); 1446 free(data);
1459 GList *tmp; 1459 GList *tmp;
1460 GdkPixbuf *pb; 1460 GdkPixbuf *pb;
1461 GList *files = gaim_uri_list_extract_filenames(sd->data); 1461 GList *files = gaim_uri_list_extract_filenames(sd->data);
1462 GaimConnection *gc = gaim_account_get_connection(account); 1462 GaimConnection *gc = gaim_account_get_connection(account);
1463 GaimPluginProtocolInfo *prpl_info = NULL; 1463 GaimPluginProtocolInfo *prpl_info = NULL;
1464 gboolean file_send_ok = FALSE;
1465 #ifndef _WIN32
1464 GaimDesktopItem *item; 1466 GaimDesktopItem *item;
1465 gboolean file_send_ok = FALSE; 1467 #endif
1466 1468
1467 g_return_if_fail(account != NULL); 1469 g_return_if_fail(account != NULL);
1468 g_return_if_fail(who != NULL); 1470 g_return_if_fail(who != NULL);
1469 1471
1470 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) { 1472 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) {
1471 gchar *filename = tmp->data; 1473 gchar *filename = tmp->data;
1472 gchar *basename = g_path_get_basename(filename); 1474 gchar *basename = g_path_get_basename(filename);
1473 1475
1474 /* Set the default action: don't send anything */ 1476 /* Set the default action: don't send anything */
1475 file_send_ok = FALSE; 1477 file_send_ok = FALSE;
1476 1478
1477 /* XXX - Make ft API support creating a transfer with more than one file */ 1479 /* XXX - Make ft API support creating a transfer with more than one file */
1478 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { 1480 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
1485 char *str; 1487 char *str;
1486 1488
1487 str = g_strdup_printf(_("Cannot send folder %s."), basename); 1489 str = g_strdup_printf(_("Cannot send folder %s."), basename);
1488 gaim_notify_error(NULL, NULL, 1490 gaim_notify_error(NULL, NULL,
1489 str,_("Gaim cannot transfer a folder. You will need to send the files within individually")); 1491 str,_("Gaim cannot transfer a folder. You will need to send the files within individually"));
1490 1492
1491 g_free(str); 1493 g_free(str);
1492 1494
1493 continue; 1495 continue;
1494 } 1496 }
1495 1497
1496 /* Are we dealing with an image? */ 1498 /* Are we dealing with an image? */
1497 pb = gdk_pixbuf_new_from_file(filename, NULL); 1499 pb = gdk_pixbuf_new_from_file(filename, NULL);
1498 if (pb) { 1500 if (pb) {
1499 _DndData *data = g_malloc(sizeof(_DndData)); 1501 _DndData *data = g_malloc(sizeof(_DndData));
1500 gboolean ft = FALSE, im = FALSE; 1502 gboolean ft = FALSE, im = FALSE;
1501 1503
1502 data->who = g_strdup(who); 1504 data->who = g_strdup(who);
1503 data->filename = g_strdup(filename); 1505 data->filename = g_strdup(filename);
1504 data->account = account; 1506 data->account = account;
1505 1507
1506 if (gc) 1508 if (gc)
1507 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 1509 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
1508 if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE) 1510 if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE)
1509 im = TRUE; 1511 im = TRUE;
1510 1512
1511 if (prpl_info && prpl_info->send_file) 1513 if (prpl_info && prpl_info->send_file)
1512 ft = prpl_info->can_receive_file(gc, who); 1514 ft = prpl_info->can_receive_file(gc, who);
1513 1515
1514 if (im && ft) 1516 if (im && ft)
1515 gaim_request_choice(NULL, NULL, 1517 gaim_request_choice(NULL, NULL,
1516 _("You have dragged an image"), 1518 _("You have dragged an image"),
1517 _("You can send this image as a file transfer," 1519 _("You can send this image as a file transfer,"
1518 " embed it into this message, or use it as the buddy icon for this user."), 1520 " embed it into this message, or use it as the buddy icon for this user."),
1519 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback, 1521 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback,
1520 "Cancel", (GCallback)dnd_image_cancel_callback, data, 1522 "Cancel", (GCallback)dnd_image_cancel_callback, data,
1521 _("Set as buddy icon"), DND_BUDDY_ICON, 1523 _("Set as buddy icon"), DND_BUDDY_ICON,
1522 _("Send image file"), DND_FILE_TRANSFER, 1524 _("Send image file"), DND_FILE_TRANSFER,
1523 _("Insert in message"), DND_IM_IMAGE, NULL); 1525 _("Insert in message"), DND_IM_IMAGE, NULL);
1524 else if (!(im || ft)) 1526 else if (!(im || ft))
1525 gaim_request_yes_no(NULL, NULL, _("You have dragged an image"), 1527 gaim_request_yes_no(NULL, NULL, _("You have dragged an image"),
1526 _("Would you like to set it as the buddy icon for this user?"), 1528 _("Would you like to set it as the buddy icon for this user?"),
1527 0, data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb); 1529 0, data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb);
1528 else 1530 else
1529 gaim_request_choice(NULL, NULL, 1531 gaim_request_choice(NULL, NULL,
1530 _("You have dragged an image"), 1532 _("You have dragged an image"),
1531 ft ? _("You can send this image as a file transfer or" 1533 ft ? _("You can send this image as a file transfer or"
1532 "embed it into this message, or use it as the buddy icon for this user.") : 1534 "embed it into this message, or use it as the buddy icon for this user.") :
1533 _("You can insert this image into this message, or use it as the buddy icon for this user"), 1535 _("You can insert this image into this message, or use it as the buddy icon for this user"),
1534 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback, 1536 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback,
1535 "Cancel", (GCallback)dnd_image_cancel_callback, data, 1537 "Cancel", (GCallback)dnd_image_cancel_callback, data,
1536 _("Set as buddy icon"), DND_BUDDY_ICON, 1538 _("Set as buddy icon"), DND_BUDDY_ICON,
1537 ft ? _("Send image file") : _("Insert in message"), ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, NULL); 1539 ft ? _("Send image file") : _("Insert in message"), ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, NULL);
1538 return; 1540 return;
1539 } 1541 }
1540 1542
1541 #ifndef _WIN32 1543 #ifndef _WIN32
1542 /* Are we trying to send a .desktop file? */ 1544 /* Are we trying to send a .desktop file? */
1543 else if (g_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) { 1545 else if (g_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) {
1544 GaimDesktopItemType dtype; 1546 GaimDesktopItemType dtype;
1545 char key[64]; 1547 char key[64];
1546 char *dot; 1548 char *dot;
1547 const char *itemname = NULL; 1549 const char *itemname = NULL;
1548 1550
1549 #if GTK_CHECK_VERSION(2,6,0) 1551 #if GTK_CHECK_VERSION(2,6,0)
1550 char **langs; 1552 char **langs;
1551 int i; 1553 int i;
1552 langs = g_get_language_names(); 1554 langs = g_get_language_names();
1553 for (i = 0; langs[i]; i++) { 1555 for (i = 0; langs[i]; i++) {
1556 break; 1558 break;
1557 } 1559 }
1558 #else 1560 #else
1559 const char *lang = g_getenv("LANG"); 1561 const char *lang = g_getenv("LANG");
1560 dot = strchr(lang, '.'); 1562 dot = strchr(lang, '.');
1561 if (dot) 1563 if (dot)
1562 *dot = '\0'; 1564 *dot = '\0';
1563 g_snprintf(key, sizeof(key), "Name[%s]", lang); 1565 g_snprintf(key, sizeof(key), "Name[%s]", lang);
1564 itemname = gaim_desktop_item_get_string(item, key); 1566 itemname = gaim_desktop_item_get_string(item, key);
1565 #endif 1567 #endif
1566 if (!itemname) 1568 if (!itemname)
1572 GaimGtkConversation *gtkconv; 1574 GaimGtkConversation *gtkconv;
1573 1575
1574 case GAIM_DESKTOP_ITEM_TYPE_LINK: 1576 case GAIM_DESKTOP_ITEM_TYPE_LINK:
1575 conv = gaim_conversation_new(GAIM_CONV_IM, account, who); 1577 conv = gaim_conversation_new(GAIM_CONV_IM, account, who);
1576 gtkconv = GAIM_GTK_CONVERSATION(conv); 1578 gtkconv = GAIM_GTK_CONVERSATION(conv);
1577 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), 1579 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry),
1578 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer), 1580 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer),
1579 gaim_desktop_item_get_string(item, "URL"), itemname); 1581 gaim_desktop_item_get_string(item, "URL"), itemname);
1580 break; 1582 break;
1581 default: 1583 default:
1582 /* I don't know if we really want to do anything here. Most of the desktop item types are crap like 1584 /* I don't know if we really want to do anything here. Most of the desktop item types are crap like
1583 * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really 1585 * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really
1584 * send. The only logical one is "Application," but do we really want to send a binary and nothing else? 1586 * send. The only logical one is "Application," but do we really want to send a binary and nothing else?
1585 * Probably not. I'll just give an error and return. */ 1587 * Probably not. I'll just give an error and return. */
1586 /* The original patch sent the icon used by the launcher. That's probably wrong */ 1588 /* The original patch sent the icon used by the launcher. That's probably wrong */