pidgin/gtkconv.c

changeset 22887
3a03580315c3
parent 22886
3f7532fae33e
child 22895
0851d06eb652
child 22953
ea1dadf8fb40
equal deleted inserted replaced
22886:3f7532fae33e 22887:3a03580315c3
98 98
99 #define DEFAULT_SEND_COLOR "#204a87" 99 #define DEFAULT_SEND_COLOR "#204a87"
100 #define DEFAULT_RECV_COLOR "#cc0000" 100 #define DEFAULT_RECV_COLOR "#cc0000"
101 #define DEFAULT_HIGHLIGHT_COLOR "#AF7F00" 101 #define DEFAULT_HIGHLIGHT_COLOR "#AF7F00"
102 #define DEFAULT_ACTION_COLOR "#062585" 102 #define DEFAULT_ACTION_COLOR "#062585"
103
104 #define BUDDYICON_SIZE_MIN 32
105 #define BUDDYICON_SIZE_MAX 96
103 106
104 /* Undef this to turn off "custom-smiley" debug messages */ 107 /* Undef this to turn off "custom-smiley" debug messages */
105 #define DEBUG_CUSTOM_SMILEY 108 #define DEBUG_CUSTOM_SMILEY
106 109
107 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) 110 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue)))
2559 2562
2560 GdkPixbuf *buf; 2563 GdkPixbuf *buf;
2561 GdkPixbuf *scale; 2564 GdkPixbuf *scale;
2562 gint delay; 2565 gint delay;
2563 int scale_width, scale_height; 2566 int scale_width, scale_height;
2567 int size;
2564 2568
2565 gtkconv = PIDGIN_CONVERSATION(conv); 2569 gtkconv = PIDGIN_CONVERSATION(conv);
2566 account = purple_conversation_get_account(conv); 2570 account = purple_conversation_get_account(conv);
2567 2571
2568 if(account && account->gc) { 2572 if(account && account->gc) {
2573 } 2577 }
2574 2578
2575 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); 2579 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL);
2576 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); 2580 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter);
2577 2581
2578 scale_width = gdk_pixbuf_get_width(buf); 2582 scale_width = gdk_pixbuf_get_width(buf);
2579 scale_height = gdk_pixbuf_get_height(buf); 2583 scale_height = gdk_pixbuf_get_height(buf);
2580 if (scale_width == scale_height) { 2584
2581 scale_width = scale_height = 32; 2585 gtk_widget_get_size_request(gtkconv->infopane_hbox, NULL, &size);
2586 size = MIN(size, MIN(scale_width, scale_height));
2587 size = CLAMP(size, BUDDYICON_SIZE_MIN, BUDDYICON_SIZE_MAX);
2588
2589 if (scale_width == scale_height) {
2590 scale_width = scale_height = size;
2582 } else if (scale_height > scale_width) { 2591 } else if (scale_height > scale_width) {
2583 scale_width = 32 * scale_width / scale_height; 2592 scale_width = size * scale_width / scale_height;
2584 scale_height = 32; 2593 scale_height = size;
2585 } else { 2594 } else {
2586 scale_height = 32 * scale_height / scale_width; 2595 scale_height = size * scale_height / scale_width;
2587 scale_width = 32; 2596 scale_width = size;
2588 } 2597 }
2589 2598
2590 scale = gdk_pixbuf_scale_simple(buf, scale_width, scale_height, 2599 scale = gdk_pixbuf_scale_simple(buf, scale_width, scale_height,
2591 GDK_INTERP_BILINEAR); 2600 GDK_INTERP_BILINEAR);
2592 if (pidgin_gdk_pixbuf_is_opaque(scale)) 2601 if (pidgin_gdk_pixbuf_is_opaque(scale))
2593 pidgin_gdk_pixbuf_make_round(scale); 2602 pidgin_gdk_pixbuf_make_round(scale);
2703 custom_icon_sel_cb, gtkconv); 2712 custom_icon_sel_cb, gtkconv);
2704 gtk_widget_show_all(win); 2713 gtk_widget_show_all(win);
2705 } 2714 }
2706 2715
2707 static void 2716 static void
2717 change_size_cb(GtkWidget *widget, PidginConversation *gtkconv)
2718 {
2719 int size = 0;
2720 PurpleConversation *conv = gtkconv->active_conv;
2721 GSList *buddies;
2722
2723 gtk_widget_get_size_request(gtkconv->infopane_hbox, NULL, &size);
2724
2725 if (size == BUDDYICON_SIZE_MAX) {
2726 size = BUDDYICON_SIZE_MIN;
2727 } else {
2728 size = BUDDYICON_SIZE_MAX;
2729 }
2730
2731 gtk_widget_set_size_request(gtkconv->infopane_hbox, -1, size);
2732 pidgin_conv_update_buddy_icon(conv);
2733
2734 buddies = purple_find_buddies(purple_conversation_get_account(conv),
2735 purple_conversation_get_name(conv));
2736 for (; buddies; buddies = g_slist_delete_link(buddies, buddies)) {
2737 PurpleBuddy *buddy = buddies->data;
2738 PurpleContact *contact = purple_buddy_get_contact(buddy);
2739 purple_blist_node_set_int((PurpleBlistNode*)contact, "pidgin-infopane-iconsize", size);
2740 }
2741 }
2742
2743 static void
2708 remove_custom_icon_cb(GtkWidget *widget, PidginConversation *gtkconv) 2744 remove_custom_icon_cb(GtkWidget *widget, PidginConversation *gtkconv)
2709 { 2745 {
2710 PurpleConversation *conv; 2746 PurpleConversation *conv;
2711 PurpleAccount *account; 2747 PurpleAccount *account;
2712 2748
2763 { 2799 {
2764 static GtkWidget *menu = NULL; 2800 static GtkWidget *menu = NULL;
2765 PurpleConversation *conv; 2801 PurpleConversation *conv;
2766 PurpleBuddy *buddy; 2802 PurpleBuddy *buddy;
2767 2803
2768 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) 2804 if (e->button == 1 && e->type == GDK_BUTTON_PRESS) {
2805 change_size_cb(NULL, gtkconv);
2806 return TRUE;
2807 }
2808
2809 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) {
2769 return FALSE; 2810 return FALSE;
2811 }
2770 2812
2771 /* 2813 /*
2772 * If a menu already exists, destroy it before creating a new one, 2814 * If a menu already exists, destroy it before creating a new one,
2773 * thus freeing-up the memory it occupied. 2815 * thus freeing-up the memory it occupied.
2774 */ 2816 */
2792 G_CALLBACK(icon_menu_save_cb), gtkconv, 2834 G_CALLBACK(icon_menu_save_cb), gtkconv,
2793 0, 0, NULL); 2835 0, 0, NULL);
2794 2836
2795 pidgin_new_item_from_stock(menu, _("Set Custom Icon..."), NULL, 2837 pidgin_new_item_from_stock(menu, _("Set Custom Icon..."), NULL,
2796 G_CALLBACK(set_custom_icon_cb), gtkconv, 2838 G_CALLBACK(set_custom_icon_cb), gtkconv,
2839 0, 0, NULL);
2840
2841 pidgin_new_item_from_stock(menu, _("Change Size"), NULL,
2842 G_CALLBACK(change_size_cb), gtkconv,
2797 0, 0, NULL); 2843 0, 0, NULL);
2798 2844
2799 /* Is there a custom icon for this person? */ 2845 /* Is there a custom icon for this person? */
2800 conv = gtkconv->active_conv; 2846 conv = gtkconv->active_conv;
2801 buddy = purple_find_buddy(purple_conversation_get_account(conv), 2847 buddy = purple_find_buddy(purple_conversation_get_account(conv),
4635 { 4681 {
4636 GtkWidget *vbox, *frame, *imhtml_sw, *event_box; 4682 GtkWidget *vbox, *frame, *imhtml_sw, *event_box;
4637 GtkCellRenderer *rend; 4683 GtkCellRenderer *rend;
4638 GtkTreePath *path; 4684 GtkTreePath *path;
4639 PurpleConversation *conv = gtkconv->active_conv; 4685 PurpleConversation *conv = gtkconv->active_conv;
4686 PurpleBuddy *buddy;
4640 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); 4687 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT);
4641 GtkPolicyType imhtml_sw_hscroll; 4688 GtkPolicyType imhtml_sw_hscroll;
4689 int buddyicon_size = 0;
4642 4690
4643 /* Setup the top part of the pane */ 4691 /* Setup the top part of the pane */
4644 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 4692 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4645 gtk_widget_show(vbox); 4693 gtk_widget_show(vbox);
4646 4694
4670 gtk_list_store_append(gtkconv->infopane_model, &(gtkconv->infopane_iter)); 4718 gtk_list_store_append(gtkconv->infopane_model, &(gtkconv->infopane_iter));
4671 gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox), gtkconv->infopane, TRUE, TRUE, 0); 4719 gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox), gtkconv->infopane, TRUE, TRUE, 0);
4672 path = gtk_tree_path_new_from_string("0"); 4720 path = gtk_tree_path_new_from_string("0");
4673 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(gtkconv->infopane), path); 4721 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(gtkconv->infopane), path);
4674 gtk_tree_path_free(path); 4722 gtk_tree_path_free(path);
4675 gtk_widget_set_size_request(gtkconv->infopane_hbox, -1, 32); 4723
4724 if ((buddy = purple_find_buddy(purple_conversation_get_account(conv),
4725 purple_conversation_get_name(conv))) != NULL) {
4726 PurpleContact *contact = purple_buddy_get_contact(buddy);
4727 if (contact) {
4728 buddyicon_size = purple_blist_node_get_int((PurpleBlistNode*)contact, "pidgin-infopane-iconsize");
4729 }
4730 }
4731 buddyicon_size = CLAMP(buddyicon_size, BUDDYICON_SIZE_MIN, BUDDYICON_SIZE_MAX);
4732 gtk_widget_set_size_request(gtkconv->infopane_hbox, -1, buddyicon_size);
4676 gtk_widget_show(gtkconv->infopane); 4733 gtk_widget_show(gtkconv->infopane);
4677 4734
4678 rend = gtk_cell_renderer_pixbuf_new(); 4735 rend = gtk_cell_renderer_pixbuf_new();
4679 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, FALSE); 4736 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, FALSE);
4680 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "pixbuf", CONV_ICON_COLUMN, NULL); 4737 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "pixbuf", CONV_ICON_COLUMN, NULL);
6781 GdkPixbuf *buf; 6838 GdkPixbuf *buf;
6782 6839
6783 GtkWidget *event; 6840 GtkWidget *event;
6784 GdkPixbuf *scale; 6841 GdkPixbuf *scale;
6785 int scale_width, scale_height; 6842 int scale_width, scale_height;
6843 int size = 0;
6786 6844
6787 PurpleAccount *account; 6845 PurpleAccount *account;
6788 PurplePluginProtocolInfo *prpl_info = NULL; 6846 PurplePluginProtocolInfo *prpl_info = NULL;
6789 6847
6790 PurpleBuddyIcon *icon; 6848 PurpleBuddyIcon *icon;
6893 start_anim(NULL, gtkconv); 6951 start_anim(NULL, gtkconv);
6894 } 6952 }
6895 6953
6896 scale_width = gdk_pixbuf_get_width(buf); 6954 scale_width = gdk_pixbuf_get_width(buf);
6897 scale_height = gdk_pixbuf_get_height(buf); 6955 scale_height = gdk_pixbuf_get_height(buf);
6956
6957 gtk_widget_get_size_request(gtkconv->infopane_hbox, NULL, &size);
6958 size = MIN(size, MIN(scale_width, scale_height));
6959
6960 /* Some sanity checks */
6961 size = CLAMP(size, BUDDYICON_SIZE_MIN, BUDDYICON_SIZE_MAX);
6898 if (scale_width == scale_height) { 6962 if (scale_width == scale_height) {
6899 scale_width = scale_height = 32; 6963 scale_width = scale_height = size;
6900 } else if (scale_height > scale_width) { 6964 } else if (scale_height > scale_width) {
6901 scale_width = 32 * scale_width / scale_height; 6965 scale_width = size * scale_width / scale_height;
6902 scale_height = 32; 6966 scale_height = size;
6903 } else { 6967 } else {
6904 scale_height = 32 * scale_height / scale_width; 6968 scale_height = size * scale_height / scale_width;
6905 scale_width = 32; 6969 scale_width = size;
6906 } 6970 }
6907 scale = gdk_pixbuf_scale_simple(buf, scale_width, scale_height, 6971 scale = gdk_pixbuf_scale_simple(buf, scale_width, scale_height,
6908 GDK_INTERP_BILINEAR); 6972 GDK_INTERP_BILINEAR);
6909 g_object_unref(buf); 6973 g_object_unref(buf);
6910 if (pidgin_gdk_pixbuf_is_opaque(scale)) 6974 if (pidgin_gdk_pixbuf_is_opaque(scale))
8283 to_right = to_right && (win != dest_win); 8347 to_right = to_right && (win != dest_win);
8284 tab = pidgin_conv_window_get_gtkconv_at_index(dest_win, page_num)->tabby; 8348 tab = pidgin_conv_window_get_gtkconv_at_index(dest_win, page_num)->tabby;
8285 } else { 8349 } else {
8286 page_num = 0; 8350 page_num = 0;
8287 to_right = pidgin_conv_xy_to_right_infopane(dest_win, e->x_root, e->y_root); 8351 to_right = pidgin_conv_xy_to_right_infopane(dest_win, e->x_root, e->y_root);
8288 tab = pidgin_conv_window_get_gtkconv_at_index(dest_win, page_num)->infopane; 8352 tab = pidgin_conv_window_get_gtkconv_at_index(dest_win, page_num)->infopane_hbox;
8289 } 8353 }
8290 8354
8291 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || 8355 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP ||
8292 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { 8356 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) {
8293 horiz_tabs = TRUE; 8357 horiz_tabs = TRUE;

mercurial