| 507 |
509 |
| 508 |
510 |
| 509 /****************************************************************************** |
511 /****************************************************************************** |
| 510 * The Smiley Manager |
512 * The Smiley Manager |
| 511 *****************************************************************************/ |
513 *****************************************************************************/ |
| 512 |
|
| 513 #if 0 |
|
| 514 static void store_smiley_add(PurpleSmiley *smiley) |
|
| 515 { |
|
| 516 GtkTreeIter iter; |
|
| 517 PurpleStoredImage *img; |
|
| 518 GdkPixbuf *sized_smiley = NULL; |
|
| 519 |
|
| 520 if (smiley_manager == NULL) |
|
| 521 return; |
|
| 522 |
|
| 523 img = purple_smiley_get_stored_image(smiley); |
|
| 524 |
|
| 525 if (img != NULL) { |
|
| 526 GdkPixbuf *smiley_image = pidgin_pixbuf_from_imgstore(img); |
|
| 527 purple_imgstore_unref(img); |
|
| 528 |
|
| 529 if (smiley_image != NULL) { |
|
| 530 if (gdk_pixbuf_get_width(smiley_image) > 22 || |
|
| 531 gdk_pixbuf_get_height(smiley_image) > 22) { |
|
| 532 sized_smiley = gdk_pixbuf_scale_simple(smiley_image, |
|
| 533 22, 22, GDK_INTERP_HYPER); |
|
| 534 g_object_unref(G_OBJECT(smiley_image)); |
|
| 535 } else { |
|
| 536 /* don't scale up smaller smileys, avoid blurryness */ |
|
| 537 sized_smiley = smiley_image; |
|
| 538 } |
|
| 539 } |
|
| 540 } |
|
| 541 |
|
| 542 |
|
| 543 gtk_list_store_append(smiley_manager->model, &iter); |
|
| 544 |
|
| 545 gtk_list_store_set(smiley_manager->model, &iter, |
|
| 546 ICON, sized_smiley, |
|
| 547 SHORTCUT, purple_smiley_get_shortcut(smiley), |
|
| 548 SMILEY, smiley, |
|
| 549 -1); |
|
| 550 |
|
| 551 if (sized_smiley != NULL) |
|
| 552 g_object_unref(G_OBJECT(sized_smiley)); |
|
| 553 } |
|
| 554 #endif |
|
| 555 |
|
| 556 #if 0 |
|
| 557 static void populate_smiley_list(SmileyManager *dialog) |
|
| 558 { |
|
| 559 GList *list; |
|
| 560 PurpleSmiley *emoticon; |
|
| 561 |
|
| 562 gtk_list_store_clear(dialog->model); |
|
| 563 |
|
| 564 for(list = purple_smileys_get_all(); list != NULL; |
|
| 565 list = g_list_delete_link(list, list)) { |
|
| 566 emoticon = (PurpleSmiley*)list->data; |
|
| 567 |
|
| 568 store_smiley_add(emoticon); |
|
| 569 } |
|
| 570 } |
|
| 571 #endif |
|
| 572 |
514 |
| 573 #if 0 |
515 #if 0 |
| 574 static void smile_selected_cb(GtkTreeSelection *sel, SmileyManager *dialog) |
516 static void smile_selected_cb(GtkTreeSelection *sel, SmileyManager *dialog) |
| 575 { |
517 { |
| 576 gint selected; |
518 gint selected; |
| 693 |
635 |
| 694 gtk_drag_finish(dc, FALSE, FALSE, t); |
636 gtk_drag_finish(dc, FALSE, FALSE, t); |
| 695 } |
637 } |
| 696 #endif |
638 #endif |
| 697 |
639 |
| 698 static GtkWidget *pidgin_smiley_manager_list_create(SmileyManager *manager) |
640 static void |
| |
641 pidgin_smiley_manager_list_add(SmileyManager *manager, PurpleSmiley *smiley) |
| |
642 { |
| |
643 GdkPixbuf *smiley_image; |
| |
644 GtkTreeIter iter; |
| |
645 |
| |
646 /* TODO: maybe some cache? */ |
| |
647 smiley_image = pidgin_pixbuf_new_from_file_at_scale( |
| |
648 purple_smiley_get_path(smiley), 22, 22, TRUE); |
| |
649 |
| |
650 gtk_list_store_append(manager->model, &iter); |
| |
651 gtk_list_store_set(manager->model, &iter, |
| |
652 SMILEY_LIST_MODEL_ICON, smiley_image, |
| |
653 SMILEY_LIST_MODEL_SHORTCUT, purple_smiley_get_shortcut(smiley), |
| |
654 SMILEY_LIST_MODEL_PURPLESMILEY, smiley, |
| |
655 -1); |
| |
656 |
| |
657 if (smiley_image) |
| |
658 g_object_unref(smiley_image); |
| |
659 } |
| |
660 |
| |
661 static void |
| |
662 pidgin_smiley_manager_list_fill(SmileyManager *manager) |
| |
663 { |
| |
664 GList *custom_smileys, *it; |
| |
665 gtk_list_store_clear(manager->model); |
| |
666 |
| |
667 custom_smileys = purple_smiley_list_get_unique( |
| |
668 purple_smiley_custom_get_list()); |
| |
669 |
| |
670 for (it = custom_smileys; it; it = g_list_next(it)) { |
| |
671 PurpleSmiley *smiley = it->data; |
| |
672 |
| |
673 pidgin_smiley_manager_list_add(manager, smiley); |
| |
674 } |
| |
675 g_list_free(custom_smileys); |
| |
676 } |
| |
677 |
| |
678 static GtkWidget * |
| |
679 pidgin_smiley_manager_list_create(SmileyManager *manager) |
| 699 { |
680 { |
| 700 GtkTreeView *tree; |
681 GtkTreeView *tree; |
| 701 GtkTreeSelection *sel; |
682 GtkTreeSelection *sel; |
| 702 GtkCellRenderer *cellrend; |
683 GtkCellRenderer *cellrend; |
| 703 GtkTreeViewColumn *column; |
684 GtkTreeViewColumn *column; |
| 761 cellrend = gtk_cell_renderer_text_new(); |
742 cellrend = gtk_cell_renderer_text_new(); |
| 762 gtk_tree_view_column_pack_start(column, cellrend, TRUE); |
743 gtk_tree_view_column_pack_start(column, cellrend, TRUE); |
| 763 gtk_tree_view_column_add_attribute(column, cellrend, |
744 gtk_tree_view_column_add_attribute(column, cellrend, |
| 764 "text", SMILEY_LIST_MODEL_SHORTCUT); |
745 "text", SMILEY_LIST_MODEL_SHORTCUT); |
| 765 |
746 |
| 766 // populate_smiley_list(dialog); |
747 pidgin_smiley_manager_list_fill(manager); |
| 767 |
748 |
| 768 return pidgin_make_scrollable(GTK_WIDGET(tree), GTK_POLICY_AUTOMATIC, |
749 return pidgin_make_scrollable(GTK_WIDGET(tree), GTK_POLICY_AUTOMATIC, |
| 769 GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, -1); |
750 GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, -1); |
| 770 } |
751 } |
| 771 |
752 |