comparison src/collect-table.c @ 1523:24a12aa0cb54

Fix up event source ids type: gint -> guint. Functions like g_timeout_add() or g_idle_add() return a guint greater than 0, but in most places it was wrongly stored as int and initialized to -1. This broke assertions matching in g_source_remove() for example since id was always greater than 0 even when timer was not set (-1 was casted to the biggest guint).
author zas_
date Mon, 06 Apr 2009 22:13:54 +0000
parents c9ed5a43c576
children 760f585d9fa0
comparison
equal deleted inserted replaced
1522:d7206703d90f 1523:24a12aa0cb54
550 550
551 static gboolean tip_schedule_cb(gpointer data) 551 static gboolean tip_schedule_cb(gpointer data)
552 { 552 {
553 CollectTable *ct = data; 553 CollectTable *ct = data;
554 554
555 if (ct->tip_delay_id == -1) return FALSE; 555 if (!ct->tip_delay_id) return FALSE;
556 556
557 tip_show(ct); 557 tip_show(ct);
558 558
559 ct->tip_delay_id = -1; 559 ct->tip_delay_id = 0;
560 return FALSE; 560 return FALSE;
561 } 561 }
562 562
563 static void tip_schedule(CollectTable *ct) 563 static void tip_schedule(CollectTable *ct)
564 { 564 {
565 tip_hide(ct); 565 tip_hide(ct);
566 566
567 if (ct->tip_delay_id != -1) 567 if (ct->tip_delay_id)
568 { 568 {
569 g_source_remove(ct->tip_delay_id); 569 g_source_remove(ct->tip_delay_id);
570 ct->tip_delay_id = -1; 570 ct->tip_delay_id = 0;
571 } 571 }
572 572
573 ct->tip_delay_id = g_timeout_add(ct->show_text ? COLLECT_TABLE_TIP_DELAY_PATH : COLLECT_TABLE_TIP_DELAY, tip_schedule_cb, ct); 573 ct->tip_delay_id = g_timeout_add(ct->show_text ? COLLECT_TABLE_TIP_DELAY_PATH : COLLECT_TABLE_TIP_DELAY, tip_schedule_cb, ct);
574 } 574 }
575 575
576 static void tip_unschedule(CollectTable *ct) 576 static void tip_unschedule(CollectTable *ct)
577 { 577 {
578 tip_hide(ct); 578 tip_hide(ct);
579 579
580 if (ct->tip_delay_id != -1) g_source_remove(ct->tip_delay_id); 580 if (ct->tip_delay_id)
581 ct->tip_delay_id = -1; 581 {
582 g_source_remove(ct->tip_delay_id);
583 ct->tip_delay_id = 0;
584 }
582 } 585 }
583 586
584 static void tip_update(CollectTable *ct, CollectInfo *info) 587 static void tip_update(CollectTable *ct, CollectInfo *info)
585 { 588 {
586 tip_schedule(ct); 589 tip_schedule(ct);
1450 CollectTable *ct = data; 1453 CollectTable *ct = data;
1451 GdkWindow *window; 1454 GdkWindow *window;
1452 gint x, y; 1455 gint x, y;
1453 gint w, h; 1456 gint w, h;
1454 1457
1455 if (ct->drop_idle_id == -1) return FALSE; 1458 if (!ct->drop_idle_id) return FALSE;
1456 1459
1457 window = ct->listview->window; 1460 window = ct->listview->window;
1458 gdk_window_get_pointer(window, &x, &y, NULL); 1461 gdk_window_get_pointer(window, &x, &y, NULL);
1459 gdk_drawable_get_size(window, &w, &h); 1462 gdk_drawable_get_size(window, &w, &h);
1460 if (x >= 0 && x < w && y >= 0 && y < h) 1463 if (x >= 0 && x < w && y >= 0 && y < h)
1461 { 1464 {
1462 collection_table_motion_update(ct, x, y, TRUE); 1465 collection_table_motion_update(ct, x, y, TRUE);
1463 } 1466 }
1464 1467
1465 ct->drop_idle_id = -1; 1468 ct->drop_idle_id = 0;
1466 return FALSE; 1469 return FALSE;
1467 } 1470 }
1468 1471
1469 static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) 1472 static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
1470 { 1473 {
1471 CollectTable *ct = data; 1474 CollectTable *ct = data;
1472 1475
1473 if (ct->drop_idle_id == -1) ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct); 1476 if (!ct->drop_idle_id)
1477 {
1478 ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct);
1479 }
1474 1480
1475 return TRUE; 1481 return TRUE;
1476 } 1482 }
1477 1483
1478 static void collection_table_scroll(CollectTable *ct, gboolean scroll) 1484 static void collection_table_scroll(CollectTable *ct, gboolean scroll)
1479 { 1485 {
1480 if (!scroll) 1486 if (!scroll)
1481 { 1487 {
1482 if (ct->drop_idle_id != -1) 1488 if (ct->drop_idle_id)
1483 { 1489 {
1484 g_source_remove(ct->drop_idle_id); 1490 g_source_remove(ct->drop_idle_id);
1485 ct->drop_idle_id = -1; 1491 ct->drop_idle_id = 0;
1486 } 1492 }
1487 widget_auto_scroll_stop(ct->listview); 1493 widget_auto_scroll_stop(ct->listview);
1488 collection_table_insert_marker(ct, NULL, FALSE); 1494 collection_table_insert_marker(ct, NULL, FALSE);
1489 } 1495 }
1490 else 1496 else
1808 1814
1809 static gboolean collection_table_sync_idle_cb(gpointer data) 1815 static gboolean collection_table_sync_idle_cb(gpointer data)
1810 { 1816 {
1811 CollectTable *ct = data; 1817 CollectTable *ct = data;
1812 1818
1813 if (ct->sync_idle_id == -1) return FALSE; 1819 if (!ct->sync_idle_id) return FALSE;
1814 ct->sync_idle_id = -1; 1820 g_source_remove(ct->sync_idle_id);
1821 ct->sync_idle_id = 0;
1815 1822
1816 collection_table_sync(ct); 1823 collection_table_sync(ct);
1817 return FALSE; 1824 return FALSE;
1818 } 1825 }
1819 1826
1820 static void collection_table_sync_idle(CollectTable *ct) 1827 static void collection_table_sync_idle(CollectTable *ct)
1821 { 1828 {
1822 if (ct->sync_idle_id == -1) 1829 if (!ct->sync_idle_id)
1823 { 1830 {
1824 /* high priority, the view needs to be resynced before a redraw 1831 /* high priority, the view needs to be resynced before a redraw
1825 * may contain invalid pointers at this time 1832 * may contain invalid pointers at this time
1826 */ 1833 */
1827 ct->sync_idle_id = g_idle_add_full(G_PRIORITY_HIGH, collection_table_sync_idle_cb, ct, NULL); 1834 ct->sync_idle_id = g_idle_add_full(G_PRIORITY_HIGH, collection_table_sync_idle_cb, ct, NULL);
2414 g_signal_handlers_disconnect_matched(GTK_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA, 2421 g_signal_handlers_disconnect_matched(GTK_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
2415 0, 0, 0, NULL, ct); 2422 0, 0, 0, NULL, ct);
2416 gtk_widget_destroy(ct->popup); 2423 gtk_widget_destroy(ct->popup);
2417 } 2424 }
2418 2425
2419 if (ct->sync_idle_id != -1) g_source_remove(ct->sync_idle_id); 2426 if (ct->sync_idle_id) g_source_remove(ct->sync_idle_id);
2420 2427
2421 tip_unschedule(ct); 2428 tip_unschedule(ct);
2422 collection_table_scroll(ct, FALSE); 2429 collection_table_scroll(ct, FALSE);
2423 2430
2424 g_free(ct); 2431 g_free(ct);
2439 gint i; 2446 gint i;
2440 2447
2441 ct = g_new0(CollectTable, 1); 2448 ct = g_new0(CollectTable, 1);
2442 2449
2443 ct->cd = cd; 2450 ct->cd = cd;
2444 ct->tip_delay_id = -1;
2445 ct->show_text = options->show_icon_names; 2451 ct->show_text = options->show_icon_names;
2446
2447 ct->sync_idle_id = -1;
2448 ct->drop_idle_id = -1;
2449 2452
2450 ct->scrolled = gtk_scrolled_window_new(NULL, NULL); 2453 ct->scrolled = gtk_scrolled_window_new(NULL, NULL);
2451 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN); 2454 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(ct->scrolled), GTK_SHADOW_IN);
2452 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled), 2455 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ct->scrolled),
2453 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); 2456 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);