Mercurial > pidgin.yaz
comparison src/gtkaccount.c @ 9314:74728ac40475
[gaim-migrate @ 10122]
Drag an image file into the modify account dialog and set the buddy icon
for that account.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 19 Jun 2004 15:46:50 +0000 |
parents | 317b5b7af25c |
children | 01c50436203e |
comparison
equal
deleted
inserted
replaced
9313:78ccbda4c916 | 9314:74728ac40475 |
---|---|
390 g_free(dialog->buddy_icon_path); | 390 g_free(dialog->buddy_icon_path); |
391 dialog->buddy_icon_path = NULL; | 391 dialog->buddy_icon_path = NULL; |
392 gtk_widget_hide(dialog->buddy_icon_entry); | 392 gtk_widget_hide(dialog->buddy_icon_entry); |
393 /*gtk_image_set_from_file(GTK_IMAGE(dialog->buddy_icon_entry), "");*/ | 393 /*gtk_image_set_from_file(GTK_IMAGE(dialog->buddy_icon_entry), "");*/ |
394 } | 394 } |
395 | |
396 | |
397 static void | |
398 account_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, | |
399 GtkSelectionData *sd, guint info, guint t, AccountPrefsDialog *dialog) | |
400 { | |
401 gchar *name = sd->data; | |
402 | |
403 if ((sd->length >= 0) && (sd->format == 8)) { | |
404 /* Well, it looks like the drag event was cool. | |
405 * Let's do something with it */ | |
406 if (!g_ascii_strncasecmp(name, "file://", 7)) { | |
407 GError *converr = NULL; | |
408 gchar *tmp, *rtmp; | |
409 /* It looks like we're dealing with a local file. Let's | |
410 * just untar it in the right place */ | |
411 if(!(tmp = g_filename_from_uri(name, NULL, &converr))) { | |
412 gaim_debug(GAIM_DEBUG_ERROR, "buddyicon", "%s\n", | |
413 (converr ? converr->message : | |
414 "g_filename_from_uri error")); | |
415 return; | |
416 } | |
417 if ((rtmp = strchr(tmp, '\r')) || (rtmp = strchr(tmp, '\n'))) | |
418 *rtmp = '\0'; | |
419 if (dialog->buddy_icon_path) | |
420 g_free(dialog->buddy_icon_path); | |
421 printf("Really huh? %s\n", tmp); | |
422 dialog->buddy_icon_path = g_strdup(tmp); | |
423 gtk_image_set_from_file(GTK_IMAGE(dialog->buddy_icon_entry), tmp); | |
424 gtk_widget_show(dialog->buddy_icon_entry); | |
425 g_free(tmp); | |
426 } | |
427 gtk_drag_finish(dc, TRUE, FALSE, t); | |
428 } | |
429 gtk_drag_finish(dc, FALSE, FALSE, t); | |
430 } | |
431 | |
395 | 432 |
396 #if GTK_CHECK_VERSION(2,4,0) | 433 #if GTK_CHECK_VERSION(2,4,0) |
397 gboolean str_array_match(char **a, char **b) | 434 gboolean str_array_match(char **a, char **b) |
398 { | 435 { |
399 int i, j; | 436 int i, j; |
660 | 697 |
661 dialog->buddy_icon_entry = gtk_image_new(); | 698 dialog->buddy_icon_entry = gtk_image_new(); |
662 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_icon_entry, TRUE, TRUE, 0); | 699 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_icon_entry, TRUE, TRUE, 0); |
663 gtk_widget_show(dialog->buddy_icon_entry); | 700 gtk_widget_show(dialog->buddy_icon_entry); |
664 gaim_set_accessible_label (dialog->buddy_icon_entry, label); | 701 gaim_set_accessible_label (dialog->buddy_icon_entry, label); |
665 | 702 dialog->buddy_icon_path = NULL; |
703 | |
666 button = gtk_button_new_with_mnemonic(_("_Browse")); | 704 button = gtk_button_new_with_mnemonic(_("_Browse")); |
667 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | 705 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
668 g_signal_connect(G_OBJECT(button), "clicked", | 706 g_signal_connect(G_OBJECT(button), "clicked", |
669 G_CALLBACK(buddy_icon_select_cb), dialog); | 707 G_CALLBACK(buddy_icon_select_cb), dialog); |
670 gtk_widget_show(button); | 708 gtk_widget_show(button); |
1366 GaimAccount *account = ok_account_prefs_cb(NULL, dialog); | 1404 GaimAccount *account = ok_account_prefs_cb(NULL, dialog); |
1367 | 1405 |
1368 gaim_account_register(account); | 1406 gaim_account_register(account); |
1369 } | 1407 } |
1370 | 1408 |
1409 | |
1410 static const GtkTargetEntry dnd_targets[] = { | |
1411 {"text/plain", 0, 0}, | |
1412 {"text/uri-list", 0, 1}, | |
1413 {"STRING", 0, 2} | |
1414 }; | |
1415 | |
1371 void | 1416 void |
1372 gaim_gtk_account_dialog_show(GaimGtkAccountDialogType type, | 1417 gaim_gtk_account_dialog_show(GaimGtkAccountDialogType type, |
1373 GaimAccount *account) | 1418 GaimAccount *account) |
1374 { | 1419 { |
1375 AccountPrefsDialog *dialog; | 1420 AccountPrefsDialog *dialog; |
1503 gtk_widget_set_sensitive(button, FALSE); | 1548 gtk_widget_set_sensitive(button, FALSE); |
1504 | 1549 |
1505 gtk_widget_show(button); | 1550 gtk_widget_show(button); |
1506 | 1551 |
1507 dialog->ok_button = button; | 1552 dialog->ok_button = button; |
1553 | |
1554 /* Set up DND */ | |
1555 gtk_drag_dest_set(dialog->window, | |
1556 GTK_DEST_DEFAULT_MOTION | | |
1557 GTK_DEST_DEFAULT_DROP, | |
1558 dnd_targets, | |
1559 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
1560 GDK_ACTION_COPY); | |
1561 | |
1562 g_signal_connect(G_OBJECT(dialog->window), "drag_data_received", | |
1563 G_CALLBACK(account_dnd_recv), dialog); | |
1508 | 1564 |
1509 g_signal_connect(G_OBJECT(button), "clicked", | 1565 g_signal_connect(G_OBJECT(button), "clicked", |
1510 G_CALLBACK(ok_account_prefs_cb), dialog); | 1566 G_CALLBACK(ok_account_prefs_cb), dialog); |
1511 | 1567 |
1512 /* Show the window. */ | 1568 /* Show the window. */ |