comparison src/gtkblist.c @ 13434:ffd724befbf8

[gaim-migrate @ 15809] Cleanup the busy cursor handling code to eliminate a bunch of these loops: while (gtk_events_pending()) gtk_main_iteration(); They seem like a race condition waiting to happen. This code is also simpler, and more generic. This leaves only one such loop, in src/gtkblist.c's gaim_gtk_blist_expand_contact_cb(). committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 07 Mar 2006 05:48:54 +0000
parents a6b846c71358
children 5251e354d213
comparison
equal deleted inserted replaced
13433:7ef6a2d0d9da 13434:ffd724befbf8
385 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); 385 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
386 GaimLogType type; 386 GaimLogType type;
387 GaimAccount *account; 387 GaimAccount *account;
388 char *name = NULL; 388 char *name = NULL;
389 389
390 gdk_window_set_cursor(gtkblist->window->window, cursor); 390 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH);
391 gdk_cursor_unref(cursor);
392 while (gtk_events_pending())
393 gtk_main_iteration();
394 391
395 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { 392 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
396 GaimBuddy *b = (GaimBuddy*) node; 393 GaimBuddy *b = (GaimBuddy*) node;
397 type = GAIM_LOG_IM; 394 type = GAIM_LOG_IM;
398 name = g_strdup(b->name); 395 name = g_strdup(b->name);
406 if (prpl_info && prpl_info->get_chat_name) { 403 if (prpl_info && prpl_info->get_chat_name) {
407 name = prpl_info->get_chat_name(c->components); 404 name = prpl_info->get_chat_name(c->components);
408 } 405 }
409 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) { 406 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
410 gaim_gtk_log_show_contact((GaimContact *)node); 407 gaim_gtk_log_show_contact((GaimContact *)node);
411 gdk_window_set_cursor(gtkblist->window->window, NULL); 408 gaim_gtk_clear_cursor(gtkblist->window);
412 return; 409 return;
413 } else { 410 } else {
414 gdk_window_set_cursor(gtkblist->window->window, NULL); 411 gaim_gtk_clear_cursor(gtkblist->window);
415 412
416 /* This callback should not have been registered for a node 413 /* This callback should not have been registered for a node
417 * that doesn't match the type of one of the blocks above. */ 414 * that doesn't match the type of one of the blocks above. */
418 g_return_if_reached(); 415 g_return_if_reached();
419 } 416 }
420 417
421 if (name && account) { 418 if (name && account) {
422 gaim_gtk_log_show(type, name, account); 419 gaim_gtk_log_show(type, name, account);
423 g_free(name); 420 g_free(name);
424 421
425 gdk_window_set_cursor(gtkblist->window->window, NULL); 422 gaim_gtk_clear_cursor(gtkblist->window);
426 } 423 }
427 } 424 }
428 425
429 static void gtk_blist_show_systemlog_cb() 426 static void gtk_blist_show_systemlog_cb()
430 { 427 {
1328 return handled; 1325 return handled;
1329 } 1326 }
1330 1327
1331 static void gaim_gtk_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item) 1328 static void gaim_gtk_blist_buddy_details_cb(gpointer data, guint action, GtkWidget *item)
1332 { 1329 {
1333 if (gtkblist->window->window) 1330 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH);
1334 {
1335 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
1336 gdk_window_set_cursor(gtkblist->window->window, cursor);
1337 while (gtk_events_pending())
1338 gtk_main_iteration();
1339 gdk_cursor_unref(cursor);
1340 }
1341 1331
1342 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons", 1332 gaim_prefs_set_bool("/gaim/gtk/blist/show_buddy_icons",
1343 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); 1333 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
1344 1334
1345 if (gtkblist->window->window) 1335 gaim_gtk_clear_cursor(gtkblist->window);
1346 gdk_window_set_cursor(gtkblist->window->window, NULL);
1347 } 1336 }
1348 1337
1349 static void gaim_gtk_blist_show_idle_time_cb(gpointer data, guint action, GtkWidget *item) 1338 static void gaim_gtk_blist_show_idle_time_cb(gpointer data, guint action, GtkWidget *item)
1350 { 1339 {
1351 if (gtkblist->window->window) 1340 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH);
1352 {
1353 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
1354 gdk_window_set_cursor(gtkblist->window->window, cursor);
1355 while (gtk_events_pending())
1356 gtk_main_iteration();
1357 gdk_cursor_unref(cursor);
1358 }
1359 1341
1360 gaim_prefs_set_bool("/gaim/gtk/blist/show_idle_time", 1342 gaim_prefs_set_bool("/gaim/gtk/blist/show_idle_time",
1361 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); 1343 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
1362 1344
1363 if (gtkblist->window->window) 1345 gaim_gtk_clear_cursor(gtkblist->window);
1364 gdk_window_set_cursor(gtkblist->window->window, NULL);
1365 } 1346 }
1366 1347
1367 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item) 1348 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item)
1368 { 1349 {
1369 if (gtkblist->window->window) 1350 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH);
1370 {
1371 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
1372 gdk_window_set_cursor(gtkblist->window->window, cursor);
1373 while (gtk_events_pending())
1374 gtk_main_iteration();
1375 gdk_cursor_unref(cursor);
1376 }
1377 1351
1378 gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups", 1352 gaim_prefs_set_bool("/gaim/gtk/blist/show_empty_groups",
1379 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))); 1353 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)));
1380 1354
1381 if (gtkblist->window->window) 1355 gaim_gtk_clear_cursor(gtkblist->window);
1382 gdk_window_set_cursor(gtkblist->window->window, NULL);
1383 } 1356 }
1384 1357
1385 static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action, 1358 static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action,
1386 GtkWidget *checkitem) 1359 GtkWidget *checkitem)
1387 { 1360 {
1388 if (gtkblist->window->window) 1361 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH);
1389 {
1390 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
1391 gdk_window_set_cursor(gtkblist->window->window, cursor);
1392 while (gtk_events_pending())
1393 gtk_main_iteration();
1394 gdk_cursor_unref(cursor);
1395 }
1396 1362
1397 gaim_prefs_set_bool("/gaim/gtk/blist/show_offline_buddies", 1363 gaim_prefs_set_bool("/gaim/gtk/blist/show_offline_buddies",
1398 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem))); 1364 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(checkitem)));
1399 1365
1400 if (gtkblist->window->window) 1366 gaim_gtk_clear_cursor(gtkblist->window);
1401 gdk_window_set_cursor(gtkblist->window->window, NULL);
1402 } 1367 }
1403 1368
1404 static void gaim_gtk_blist_mute_sounds_cb(gpointer data, guint action, GtkWidget *item) 1369 static void gaim_gtk_blist_mute_sounds_cb(gpointer data, guint action, GtkWidget *item)
1405 { 1370 {
1406 gaim_prefs_set_bool("/gaim/gtk/sound/mute", GTK_CHECK_MENU_ITEM(item)->active); 1371 gaim_prefs_set_bool("/gaim/gtk/sound/mute", GTK_CHECK_MENU_ITEM(item)->active);
5764 static void 5729 static void
5765 sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id) 5730 sortmethod_act(GtkCheckMenuItem *checkmenuitem, char *id)
5766 { 5731 {
5767 if (gtk_check_menu_item_get_active(checkmenuitem)) 5732 if (gtk_check_menu_item_get_active(checkmenuitem))
5768 { 5733 {
5769 if (gtkblist->window->window != NULL) 5734 gaim_gtk_set_cursor(gtkblist->window, GDK_WATCH);
5770 {
5771 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
5772 gdk_window_set_cursor(gtkblist->window->window, cursor);
5773 gdk_cursor_unref(cursor);
5774 }
5775
5776 while (gtk_events_pending())
5777 gtk_main_iteration();
5778 5735
5779 gaim_gtk_blist_sort_method_set(id); 5736 gaim_gtk_blist_sort_method_set(id);
5780 gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id); 5737 gaim_prefs_set_string("/gaim/gtk/blist/sort_type", id);
5781 5738
5782 if (gtkblist->window->window != NULL) 5739 gaim_gtk_clear_cursor(gtkblist->window);
5783 gdk_window_set_cursor(gtkblist->window->window, NULL);
5784 } 5740 }
5785 } 5741 }
5786 5742
5787 void 5743 void
5788 gaim_gtk_blist_update_sort_methods(void) 5744 gaim_gtk_blist_update_sort_methods(void)