comparison gtk/gtkconv.c @ 14700:7fb8a8583c73

[gaim-migrate @ 17452] Depluginize the wingaim conv. flashing. IM window flashing is now always on, chat window flashing is a pref in the wingaim options plugin. Fix some callbacks where 'int' was used instead of 'GaimMessageFlags' committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 09 Oct 2006 03:02:32 +0000
parents 79c1c4fe497d
children f063e0bc1f20
comparison
equal deleted inserted replaced
14699:cd1ddfa8868c 14700:7fb8a8583c73
213 return FALSE; 213 return FALSE;
214 214
215 if (gtkconv->auto_resize) { 215 if (gtkconv->auto_resize) {
216 return FALSE; 216 return FALSE;
217 } 217 }
218 218
219 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the 219 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the
220 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see 220 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see
221 * if there is only one conversation in the window. This way we'll be setting new windows to the 221 * if there is only one conversation in the window. This way we'll be setting new windows to the
222 * size of the last resized new window. */ 222 * size of the last resized new window. */
223 /* I think that the above justification is not the majority, and that the new tab resizing should 223 /* I think that the above justification is not the majority, and that the new tab resizing should
2261 if (status != NULL) 2261 if (status != NULL)
2262 g_object_unref(status); 2262 g_object_unref(status);
2263 } 2263 }
2264 } 2264 }
2265 2265
2266 /* This gets added as an idle handler when doing something that 2266 /* This gets added as an idle handler when doing something that
2267 * redraws the icon. It sets the auto_resize gboolean to TRUE. 2267 * redraws the icon. It sets the auto_resize gboolean to TRUE.
2268 * This way, when the size_allocate callback gets triggered, it notices 2268 * This way, when the size_allocate callback gets triggered, it notices
2269 * that this is an autoresize, and after the main loop iterates, it 2269 * that this is an autoresize, and after the main loop iterates, it
2270 * gets set back to FALSE 2270 * gets set back to FALSE
2271 */ 2271 */
2294 if(account && account->gc) 2294 if(account && account->gc)
2295 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); 2295 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
2296 2296
2297 gtkconv->auto_resize = TRUE; 2297 gtkconv->auto_resize = TRUE;
2298 g_idle_add(reset_auto_resize_cb, gtkconv); 2298 g_idle_add(reset_auto_resize_cb, gtkconv);
2299 2299
2300 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); 2300 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL);
2301 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); 2301 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter);
2302 2302
2303 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : 2303 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec :
2304 NULL, &scale_width, &scale_height); 2304 NULL, &scale_width, &scale_height);
3327 GtkTreeIter iter; 3327 GtkTreeIter iter;
3328 gboolean is_me = FALSE; 3328 gboolean is_me = FALSE;
3329 gboolean is_buddy; 3329 gboolean is_buddy;
3330 gchar *alias_key, *name, *alias; 3330 gchar *alias_key, *name, *alias;
3331 int flags; 3331 int flags;
3332 3332
3333 alias = cb->alias; 3333 alias = cb->alias;
3334 name = cb->name; 3334 name = cb->name;
3335 flags = GPOINTER_TO_INT(cb->flags); 3335 flags = GPOINTER_TO_INT(cb->flags);
3336 3336
3337 chat = GAIM_CONV_CHAT(conv); 3337 chat = GAIM_CONV_CHAT(conv);
3355 3355
3356 if (is_me) 3356 if (is_me)
3357 { 3357 {
3358 GdkColor send_color; 3358 GdkColor send_color;
3359 gdk_color_parse(SEND_COLOR, &send_color); 3359 gdk_color_parse(SEND_COLOR, &send_color);
3360 3360
3361 #if GTK_CHECK_VERSION(2,6,0) 3361 #if GTK_CHECK_VERSION(2,6,0)
3362 gtk_list_store_insert_with_values(ls, &iter, 3362 gtk_list_store_insert_with_values(ls, &iter,
3363 /* 3363 /*
3364 * The GTK docs are mute about the effects of the "row" value for performance. 3364 * The GTK docs are mute about the effects of the "row" value for performance.
3365 * X-Chat hardcodes their value to 0 (prepend) and -1 (append), so we will too. 3365 * X-Chat hardcodes their value to 0 (prepend) and -1 (append), so we will too.
3366 * It *might* be faster to search the gtk_list_store and set row accurately, 3366 * It *might* be faster to search the gtk_list_store and set row accurately,
3367 * but no one in #gtk+ seems to know anything about it either. 3367 * but no one in #gtk+ seems to know anything about it either.
3368 * Inserting in the "wrong" location has no visible ill effects. - F.P. 3368 * Inserting in the "wrong" location has no visible ill effects. - F.P.
3983 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); 3983 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
3984 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); 3984 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0);
3985 gtk_widget_show(sw); 3985 gtk_widget_show(sw);
3986 3986
3987 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, 3987 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING,
3988 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, 3988 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT,
3989 GDK_TYPE_COLOR, G_TYPE_INT); 3989 GDK_TYPE_COLOR, G_TYPE_INT);
3990 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, 3990 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN,
3991 sort_chat_users, NULL, NULL); 3991 sort_chat_users, NULL, NULL);
3992 3992
3993 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); 3993 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls));
3996 3996
3997 col = gtk_tree_view_column_new_with_attributes(NULL, rend, 3997 col = gtk_tree_view_column_new_with_attributes(NULL, rend,
3998 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); 3998 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL);
3999 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); 3999 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
4000 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); 4000 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col);
4001 gtk_widget_set_size_request(lbox, 4001 gtk_widget_set_size_request(lbox,
4002 gaim_prefs_get_int("/gaim/gtk/conversations/chat/userlist_width"), -1); 4002 gaim_prefs_get_int("/gaim/gtk/conversations/chat/userlist_width"), -1);
4003 4003
4004 g_signal_connect(G_OBJECT(list), "button_press_event", 4004 g_signal_connect(G_OBJECT(list), "button_press_event",
4005 G_CALLBACK(right_click_chat_cb), gtkconv); 4005 G_CALLBACK(right_click_chat_cb), gtkconv);
4006 g_signal_connect(G_OBJECT(list), "popup-menu", 4006 g_signal_connect(G_OBJECT(list), "popup-menu",
4007 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); 4007 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv);
4008 g_signal_connect(G_OBJECT(list), "size-allocate", G_CALLBACK(size_allocate_cb), gtkconv); 4008 g_signal_connect(G_OBJECT(list), "size-allocate", G_CALLBACK(size_allocate_cb), gtkconv);
4009 4009
4010 4010
4011 rend = gtk_cell_renderer_text_new(); 4011 rend = gtk_cell_renderer_text_new();
4012 4012
4013 g_object_set(rend, 4013 g_object_set(rend,
4014 "foreground-set", TRUE, 4014 "foreground-set", TRUE,
4015 "weight-set", TRUE, 4015 "weight-set", TRUE,
4476 private_gtkconv_new(conv, FALSE); 4476 private_gtkconv_new(conv, FALSE);
4477 } 4477 }
4478 4478
4479 static void 4479 static void
4480 received_im_msg_cb(GaimAccount *account, char *sender, char *message, 4480 received_im_msg_cb(GaimAccount *account, char *sender, char *message,
4481 GaimConversation *conv, int flags) 4481 GaimConversation *conv, GaimMessageFlags flags)
4482 { 4482 {
4483 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); 4483 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops();
4484 if (conv != NULL) 4484 if (conv != NULL)
4485 return; 4485 return;
4486 4486
5027 5027
5028 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); 5028 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)));
5029 5029
5030 #if GTK_CHECK_VERSION(2,6,0) 5030 #if GTK_CHECK_VERSION(2,6,0)
5031 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 5031 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
5032 GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); 5032 GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID);
5033 #endif 5033 #endif
5034 5034
5035 l = cbuddies; 5035 l = cbuddies;
5036 while (l != NULL) { 5036 while (l != NULL) {
5037 add_chat_buddy_common(conv, (GaimConvChatBuddy *)l->data, NULL); 5037 add_chat_buddy_common(conv, (GaimConvChatBuddy *)l->data, NULL);
5038 l = l->next; 5038 l = l->next;
5039 } 5039 }
5040 5040
5041 /* Currently GTK+ maintains our sorted list after it's in the tree. 5041 /* Currently GTK+ maintains our sorted list after it's in the tree.
5042 * This may change if it turns out we can manage it faster ourselves. 5042 * This may change if it turns out we can manage it faster ourselves.
5043 */ 5043 */
5044 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, 5044 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN,
5045 GTK_SORT_ASCENDING); 5045 GTK_SORT_ASCENDING);
5046 } 5046 }
5319 5319
5320 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); 5320 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley);
5321 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); 5321 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley);
5322 5322
5323 gtk_imhtml_associate_smiley(imhtml, sml, smiley); 5323 gtk_imhtml_associate_smiley(imhtml, sml, smiley);
5324 5324
5325 return TRUE; 5325 return TRUE;
5326 } 5326 }
5327 5327
5328 static gboolean 5328 static gboolean
5329 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile, gboolean remote) 5329 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile, gboolean remote)
5330 { 5330 {
5331 GaimGtkConversation *gtkconv; 5331 GaimGtkConversation *gtkconv;
5332 struct smiley_list *list; 5332 struct smiley_list *list;
5333 const char *sml = NULL, *conv_sml; 5333 const char *sml = NULL, *conv_sml;
5334 5334
5335 if (!conv || !smile || !*smile) { 5335 if (!conv || !smile || !*smile) {
5336 return FALSE; 5336 return FALSE;
5337 } 5337 }
5338 5338
5339 /* If smileys are off, return false */ 5339 /* If smileys are off, return false */
5340 if (gaim_gtkthemes_smileys_disabled()) 5340 if (gaim_gtkthemes_smileys_disabled())
5341 return FALSE; 5341 return FALSE;
5342 5342
5343 /* If possible add this smiley to the current theme. 5343 /* If possible add this smiley to the current theme.
5344 * The addition is only temporary: custom smilies aren't saved to disk. */ 5344 * The addition is only temporary: custom smilies aren't saved to disk. */
5345 conv_sml = gaim_account_get_protocol_name(conv->account); 5345 conv_sml = gaim_account_get_protocol_name(conv->account);
5346 gtkconv = GAIM_GTK_CONVERSATION(conv); 5346 gtkconv = GAIM_GTK_CONVERSATION(conv);
5347 5347
5348 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { 5348 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) {
5349 if (!strcmp(list->sml, conv_sml)) { 5349 if (!strcmp(list->sml, conv_sml)) {
5350 sml = list->sml; 5350 sml = list->sml;
5351 break; 5351 break;
5352 } 5352 }
5353 } 5353 }
5354 5354
5355 if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->imhtml), sml, smile)) 5355 if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->imhtml), sml, smile))
5356 return FALSE; 5356 return FALSE;
5357 5357
5358 if (!remote) /* If it's a local custom smiley, then add it for the entry */ 5358 if (!remote) /* If it's a local custom smiley, then add it for the entry */
5359 if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->entry), sml, smile)) 5359 if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->entry), sml, smile))
5360 return FALSE; 5360 return FALSE;
5361 5361
5362 return TRUE; 5362 return TRUE;
6227 { 6227 {
6228 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); 6228 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement");
6229 } 6229 }
6230 6230
6231 static void 6231 static void
6232 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, 6232 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus,
6233 GaimStatus *newstatus) 6233 GaimStatus *newstatus)
6234 { 6234 {
6235 GList *l; 6235 GList *l;
6236 GaimConversation *conv = NULL; 6236 GaimConversation *conv = NULL;
6237 GaimGtkConversation *gtkconv; 6237 GaimGtkConversation *gtkconv;
6402 6402
6403 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); 6403 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account);
6404 if (conv) 6404 if (conv)
6405 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); 6405 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON);
6406 } 6406 }
6407 6407
6408 static void 6408 static void
6409 update_buddy_icon(GaimBuddy *buddy) 6409 update_buddy_icon(GaimBuddy *buddy)
6410 { 6410 {
6411 GaimConversation *conv; 6411 GaimConversation *conv;
6412 6412
6658 G_CALLBACK(account_signed_off_cb), 6658 G_CALLBACK(account_signed_off_cb),
6659 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); 6659 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE));
6660 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, 6660 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle,
6661 G_CALLBACK(account_signed_off_cb), 6661 G_CALLBACK(account_signed_off_cb),
6662 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); 6662 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE));
6663 6663
6664 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", 6664 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg",
6665 handle, G_CALLBACK(received_im_msg_cb), NULL); 6665 handle, G_CALLBACK(received_im_msg_cb), NULL);
6666 6666
6667 gaim_conversations_set_ui_ops(&conversation_ui_ops); 6667 gaim_conversations_set_ui_ops(&conversation_ui_ops);
6668 6668