Mercurial > pidgin
comparison src/gtkconv.c @ 4793:677d3cb193a1
[gaim-migrate @ 5113]
this removes all the remaining deprecated glib, gdk, gdk-pixbuf, and gtk
function calls. Hopefully I didn't break anything.
Most of this is due to the deprecation of g_strcasecmp and g_strncasecmp.
Two functions I never thought would be deprecated, but apparently they're
no good at comparing utf8 text. g_ascii_str{,n}casecmp is OK when you're
sure that it's ASCII. Otherwise, we're supposed to use g_utf8_collate(),
except that it is case sensitive. Since glib doesn't currently have a
case-insensitive one, I wrote one. If you need to compare utf8 text, you
can use gaim_utf8_strcasecmp().
I have to go do dishes now.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 16 Mar 2003 00:01:49 +0000 |
parents | 9212d1c5b7dc |
children | 6f04901ef729 |
comparison
equal
deleted
inserted
replaced
4792:9212d1c5b7dc | 4793:677d3cb193a1 |
---|---|
797 | 797 |
798 if (resp == GTK_RESPONSE_OK) { | 798 if (resp == GTK_RESPONSE_OK) { |
799 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | 799 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); |
800 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | 800 message = gtk_entry_get_text(GTK_ENTRY(info->message)); |
801 | 801 |
802 if (!g_strcasecmp(buddy, "")) { | 802 if (!g_ascii_strcasecmp(buddy, "")) { |
803 g_free(info); | 803 g_free(info); |
804 | 804 |
805 return; | 805 return; |
806 } | 806 } |
807 | 807 |
2083 g_object_unref(G_OBJECT(scale)); | 2083 g_object_unref(G_OBJECT(scale)); |
2084 g_object_unref(G_OBJECT(pixbuf)); | 2084 g_object_unref(G_OBJECT(pixbuf)); |
2085 | 2085 |
2086 /* Make our menu item */ | 2086 /* Make our menu item */ |
2087 menuitem = gtk_radio_menu_item_new_with_label(group, gc->username); | 2087 menuitem = gtk_radio_menu_item_new_with_label(group, gc->username); |
2088 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); | 2088 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2089 | 2089 |
2090 /* Do some evil, see some evil, speak some evil. */ | 2090 /* Do some evil, see some evil, speak some evil. */ |
2091 box = gtk_hbox_new(FALSE, 0); | 2091 box = gtk_hbox_new(FALSE, 0); |
2092 | 2092 |
2093 label = gtk_bin_get_child(GTK_BIN(menuitem)); | 2093 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
2165 if (pixbuf != NULL) g_object_unref(pixbuf); | 2165 if (pixbuf != NULL) g_object_unref(pixbuf); |
2166 | 2166 |
2167 /* Make our menu item */ | 2167 /* Make our menu item */ |
2168 menuitem = gtk_radio_menu_item_new_with_label(group, | 2168 menuitem = gtk_radio_menu_item_new_with_label(group, |
2169 account->username); | 2169 account->username); |
2170 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); | 2170 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2171 | 2171 |
2172 /* Do some evil, see some evil, speak some evil. */ | 2172 /* Do some evil, see some evil, speak some evil. */ |
2173 box = gtk_hbox_new(FALSE, 0); | 2173 box = gtk_hbox_new(FALSE, 0); |
2174 | 2174 |
2175 label = gtk_bin_get_child(GTK_BIN(menuitem)); | 2175 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
2324 nicks != NULL; | 2324 nicks != NULL; |
2325 nicks = nicks->next) { | 2325 nicks = nicks->next) { |
2326 | 2326 |
2327 char *nick = nicks->data; | 2327 char *nick = nicks->data; |
2328 /* this checks to see if the current nick could be a completion */ | 2328 /* this checks to see if the current nick could be a completion */ |
2329 if (g_strncasecmp(nick, entered, strlen(entered))) { | 2329 if (g_ascii_strncasecmp(nick, entered, strlen(entered))) { |
2330 if (*nick != '+' && *nick != '@' && *nick != '%') | 2330 if (*nick != '+' && *nick != '@' && *nick != '%') |
2331 continue; | 2331 continue; |
2332 | 2332 |
2333 if (g_strncasecmp(nick + 1, entered, strlen(entered))) { | 2333 if (g_ascii_strncasecmp(nick + 1, entered, strlen(entered))) { |
2334 if (nick[0] != '@' || nick[1] != '+') | 2334 if (nick[0] != '@' || nick[1] != '+') |
2335 continue; | 2335 continue; |
2336 | 2336 |
2337 if (g_strncasecmp(nick + 2, entered, strlen(entered))) | 2337 if (g_ascii_strncasecmp(nick + 2, entered, strlen(entered))) |
2338 continue; | 2338 continue; |
2339 else | 2339 else |
2340 nick += 2; | 2340 nick += 2; |
2341 } | 2341 } |
2342 else | 2342 else |
2390 */ | 2390 */ |
2391 most_matched = strlen(nick); | 2391 most_matched = strlen(nick); |
2392 partial = g_strdup(nick); | 2392 partial = g_strdup(nick); |
2393 } | 2393 } |
2394 else if (most_matched) { | 2394 else if (most_matched) { |
2395 while (g_strncasecmp(nick, partial, most_matched)) | 2395 while (g_ascii_strncasecmp(nick, partial, most_matched)) |
2396 most_matched--; | 2396 most_matched--; |
2397 | 2397 |
2398 partial[most_matched] = 0; | 2398 partial[most_matched] = 0; |
2399 } | 2399 } |
2400 | 2400 |
2480 else | 2480 else |
2481 break; | 2481 break; |
2482 } | 2482 } |
2483 } | 2483 } |
2484 | 2484 |
2485 if (*c != '\0' && !g_strncasecmp(c, "/me ", 4)) { | 2485 if (*c != '\0' && !g_ascii_strncasecmp(c, "/me ", 4)) { |
2486 memmove(c, c + 4, len - 3); | 2486 memmove(c, c + 4, len - 3); |
2487 | 2487 |
2488 return TRUE; | 2488 return TRUE; |
2489 } | 2489 } |
2490 | 2490 |
3755 | 3755 |
3756 if (gtkconv->u.im->save_icon != NULL) | 3756 if (gtkconv->u.im->save_icon != NULL) |
3757 gtk_widget_destroy(gtkconv->u.im->save_icon); | 3757 gtk_widget_destroy(gtkconv->u.im->save_icon); |
3758 | 3758 |
3759 if (gtkconv->u.im->anim != NULL) | 3759 if (gtkconv->u.im->anim != NULL) |
3760 gdk_pixbuf_animation_unref(gtkconv->u.im->anim); | 3760 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
3761 | 3761 |
3762 g_free(gtkconv->u.im); | 3762 g_free(gtkconv->u.im); |
3763 } | 3763 } |
3764 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | 3764 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
3765 g_free(gtkconv->u.chat); | 3765 g_free(gtkconv->u.chat); |
4140 names != NULL; | 4140 names != NULL; |
4141 names = names->next) { | 4141 names = names->next) { |
4142 | 4142 |
4143 char *u = (char *)names->data; | 4143 char *u = (char *)names->data; |
4144 | 4144 |
4145 if (!g_strcasecmp(u, old_name)) { | 4145 if (!gaim_utf8_strcasecmp(u, old_name)) { |
4146 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | 4146 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4147 | 4147 |
4148 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | 4148 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
4149 break; | 4149 break; |
4150 | 4150 |
4151 while (f != 0) { | 4151 while (f != 0) { |
4152 char *val; | 4152 char *val; |
4153 | 4153 |
4154 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | 4154 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); |
4155 | 4155 |
4156 if (!g_strcasecmp(old_name, val)) { | 4156 if (!gaim_utf8_strcasecmp(old_name, val)) { |
4157 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | 4157 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4158 break; | 4158 break; |
4159 } | 4159 } |
4160 | 4160 |
4161 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | 4161 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); |
4198 names != NULL; | 4198 names != NULL; |
4199 names = names->next) { | 4199 names = names->next) { |
4200 | 4200 |
4201 char *u = (char *)names->data; | 4201 char *u = (char *)names->data; |
4202 | 4202 |
4203 if (!g_strcasecmp(u, user)) { | 4203 if (!gaim_utf8_strcasecmp(u, user)) { |
4204 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | 4204 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4205 | 4205 |
4206 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | 4206 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
4207 break; | 4207 break; |
4208 | 4208 |
4209 while (f != 0) { | 4209 while (f != 0) { |
4210 char *val; | 4210 char *val; |
4211 | 4211 |
4212 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | 4212 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); |
4213 | 4213 |
4214 if (!g_strcasecmp(user, val)) | 4214 if (!gaim_utf8_strcasecmp(user, val)) |
4215 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | 4215 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4216 | 4216 |
4217 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | 4217 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); |
4218 | 4218 |
4219 g_free(val); | 4219 g_free(val); |
4469 if (gtkconv->u.im->icon != NULL) | 4469 if (gtkconv->u.im->icon != NULL) |
4470 gtk_container_remove(GTK_CONTAINER(gtkconv->bbox), | 4470 gtk_container_remove(GTK_CONTAINER(gtkconv->bbox), |
4471 gtkconv->u.im->icon->parent->parent); | 4471 gtkconv->u.im->icon->parent->parent); |
4472 | 4472 |
4473 if (gtkconv->u.im->anim != NULL) | 4473 if (gtkconv->u.im->anim != NULL) |
4474 gdk_pixbuf_animation_unref(gtkconv->u.im->anim); | 4474 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4475 | 4475 |
4476 if (gtkconv->u.im->icon_timer != 0) | 4476 if (gtkconv->u.im->icon_timer != 0) |
4477 g_source_remove(gtkconv->u.im->icon_timer); | 4477 g_source_remove(gtkconv->u.im->icon_timer); |
4478 | 4478 |
4479 if (gtkconv->u.im->iter != NULL) | 4479 if (gtkconv->u.im->iter != NULL) |
4513 MAX(gdk_pixbuf_get_height(buf) * SCALE(gtkconv->u.im->anim) / | 4513 MAX(gdk_pixbuf_get_height(buf) * SCALE(gtkconv->u.im->anim) / |
4514 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), | 4514 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
4515 GDK_INTERP_NEAREST); | 4515 GDK_INTERP_NEAREST); |
4516 | 4516 |
4517 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | 4517 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); |
4518 gdk_pixbuf_unref(scale); | 4518 g_object_unref(G_OBJECT(scale)); |
4519 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | 4519 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); |
4520 gdk_pixmap_unref(pm); | 4520 g_object_unref(G_OBJECT(pm)); |
4521 gtk_widget_queue_draw(gtkconv->u.im->icon); | 4521 gtk_widget_queue_draw(gtkconv->u.im->icon); |
4522 | 4522 |
4523 if (bm) | 4523 if (bm) |
4524 gdk_bitmap_unref(bm); | 4524 g_object_unref(G_OBJECT(bm)); |
4525 | 4525 |
4526 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | 4526 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; |
4527 | 4527 |
4528 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, conv); | 4528 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, conv); |
4529 | 4529 |
4656 return; | 4656 return; |
4657 | 4657 |
4658 if (gaim_conversation_get_gc(conv) == NULL) | 4658 if (gaim_conversation_get_gc(conv) == NULL) |
4659 return; | 4659 return; |
4660 | 4660 |
4661 if(gtkconv->u.im->anim) | |
4662 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
4663 | |
4661 if((buddy = gaim_find_buddy(gaim_conversation_get_account(conv), | 4664 if((buddy = gaim_find_buddy(gaim_conversation_get_account(conv), |
4662 gaim_conversation_get_name(conv))) != NULL) { | 4665 gaim_conversation_get_name(conv))) != NULL) { |
4663 char *file = gaim_buddy_get_setting(buddy, "buddy_icon"); | 4666 char *file = gaim_buddy_get_setting(buddy, "buddy_icon"); |
4664 if(file) { | 4667 if(file) { |
4665 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(file, &err); | 4668 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(file, &err); |
4696 } | 4699 } |
4697 | 4700 |
4698 | 4701 |
4699 if (!gtkconv->u.im->anim) | 4702 if (!gtkconv->u.im->anim) |
4700 return; | 4703 return; |
4704 | |
4705 if(gtkconv->u.im->iter) | |
4706 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4701 | 4707 |
4702 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | 4708 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { |
4703 gtkconv->u.im->iter = NULL; | 4709 gtkconv->u.im->iter = NULL; |
4704 delay = 0; | 4710 delay = 0; |
4705 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | 4711 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
4722 if (delay) | 4728 if (delay) |
4723 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, | 4729 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, |
4724 conv); | 4730 conv); |
4725 | 4731 |
4726 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | 4732 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); |
4727 gdk_pixbuf_unref(scale); | 4733 g_object_unref(G_OBJECT(scale)); |
4728 | 4734 |
4729 frame = gtk_frame_new(NULL); | 4735 frame = gtk_frame_new(NULL); |
4730 gtk_frame_set_shadow_type(GTK_FRAME(frame), | 4736 gtk_frame_set_shadow_type(GTK_FRAME(frame), |
4731 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | 4737 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); |
4732 gtk_box_pack_start(GTK_BOX(gtkconv->bbox), frame, FALSE, FALSE, 5); | 4738 gtk_box_pack_start(GTK_BOX(gtkconv->bbox), frame, FALSE, FALSE, 5); |
4745 gtk_widget_show(gtkconv->u.im->icon); | 4751 gtk_widget_show(gtkconv->u.im->icon); |
4746 | 4752 |
4747 if(im_options & OPT_IM_NO_ANIMATION) | 4753 if(im_options & OPT_IM_NO_ANIMATION) |
4748 stop_anim(NULL, conv); | 4754 stop_anim(NULL, conv); |
4749 | 4755 |
4750 gdk_pixmap_unref(pm); | 4756 g_object_unref(G_OBJECT(pm)); |
4751 | 4757 |
4752 if (bm) | 4758 if (bm) |
4753 gdk_bitmap_unref(bm); | 4759 g_object_unref(G_OBJECT(bm)); |
4754 } | 4760 } |
4755 | 4761 |
4756 void | 4762 void |
4757 gaim_gtkconv_hide_buddy_icons(void) | 4763 gaim_gtkconv_hide_buddy_icons(void) |
4758 { | 4764 { |