comparison src/collect-table.c @ 1420:3a9fb1b52559

Use gboolean where applicable, for the sake of consistency.
author zas_
date Thu, 12 Mar 2009 21:06:37 +0000
parents a0bd58a6535f
children c9ed5a43c576
comparison
equal deleted inserted replaced
1419:c520cfd40aef 1420:3a9fb1b52559
63 63
64 64
65 #define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED) 65 #define INFO_SELECTED(x) (x->flag_mask & SELECTION_SELECTED)
66 66
67 67
68 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gint force); 68 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force);
69 69
70 70
71 /* 71 /*
72 *------------------------------------------------------------------- 72 *-------------------------------------------------------------------
73 * more misc 73 * more misc
74 *------------------------------------------------------------------- 74 *-------------------------------------------------------------------
75 */ 75 */
76 76
77 static gint collection_table_find_position(CollectTable *ct, CollectInfo *info, gint *row, gint *col) 77 static gboolean collection_table_find_position(CollectTable *ct, CollectInfo *info, gint *row, gint *col)
78 { 78 {
79 gint n; 79 gint n;
80 80
81 n = g_list_index(ct->cd->list, info); 81 n = g_list_index(ct->cd->list, info);
82 82
86 *col = n - (*row * ct->columns); 86 *col = n - (*row * ct->columns);
87 87
88 return TRUE; 88 return TRUE;
89 } 89 }
90 90
91 static gint collection_table_find_iter(CollectTable *ct, CollectInfo *info, GtkTreeIter *iter, gint *column) 91 static gboolean collection_table_find_iter(CollectTable *ct, CollectInfo *info, GtkTreeIter *iter, gint *column)
92 { 92 {
93 GtkTreeModel *store; 93 GtkTreeModel *store;
94 gint row, col; 94 gint row, col;
95 95
96 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview)); 96 store = gtk_tree_view_get_model(GTK_TREE_VIEW(ct->listview));
225 225
226 gtk_label_set_text(GTK_LABEL(ct->status_label), buf); 226 gtk_label_set_text(GTK_LABEL(ct->status_label), buf);
227 g_free(buf); 227 g_free(buf);
228 } 228 }
229 229
230 static void collection_table_update_extras(CollectTable *ct, gint loading, gdouble value) 230 static void collection_table_update_extras(CollectTable *ct, gboolean loading, gdouble value)
231 { 231 {
232 gchar *text; 232 gchar *text;
233 233
234 if (!ct->extra_label) return; 234 if (!ct->extra_label) return;
235 235
420 collection_table_selection_remove(ct, info, SELECTION_SELECTED, NULL); 420 collection_table_selection_remove(ct, info, SELECTION_SELECTED, NULL);
421 421
422 collection_table_update_status(ct); 422 collection_table_update_status(ct);
423 } 423 }
424 424
425 static void collection_table_select_util(CollectTable *ct, CollectInfo *info, gint select) 425 static void collection_table_select_util(CollectTable *ct, CollectInfo *info, gboolean select)
426 { 426 {
427 if (select) 427 if (select)
428 { 428 {
429 collection_table_select(ct, info); 429 collection_table_select(ct, info);
430 } 430 }
432 { 432 {
433 collection_table_unselect(ct, info); 433 collection_table_unselect(ct, info);
434 } 434 }
435 } 435 }
436 436
437 static void collection_table_select_region_util(CollectTable *ct, CollectInfo *start, CollectInfo *end, gint select) 437 static void collection_table_select_region_util(CollectTable *ct, CollectInfo *start, CollectInfo *end, gboolean select)
438 { 438 {
439 gint row1, col1; 439 gint row1, col1;
440 gint row2, col2; 440 gint row2, col2;
441 gint t; 441 gint t;
442 gint i, j; 442 gint i, j;
546 { 546 {
547 if (ct->tip_window) gtk_widget_destroy(ct->tip_window); 547 if (ct->tip_window) gtk_widget_destroy(ct->tip_window);
548 ct->tip_window = NULL; 548 ct->tip_window = NULL;
549 } 549 }
550 550
551 static gint 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 == -1) return FALSE;
556 556
842 842
843 filelist_free(ct->editmenu_fd_list); 843 filelist_free(ct->editmenu_fd_list);
844 ct->editmenu_fd_list = NULL; 844 ct->editmenu_fd_list = NULL;
845 } 845 }
846 846
847 static GtkWidget *collection_table_popup_menu(CollectTable *ct, gint over_icon) 847 static GtkWidget *collection_table_popup_menu(CollectTable *ct, gboolean over_icon)
848 { 848 {
849 GtkWidget *menu; 849 GtkWidget *menu;
850 GtkWidget *item; 850 GtkWidget *item;
851 GtkWidget *submenu; 851 GtkWidget *submenu;
852 852
967 gtk_tree_view_set_cursor(GTK_TREE_VIEW(ct->listview), tpath, column, FALSE); 967 gtk_tree_view_set_cursor(GTK_TREE_VIEW(ct->listview), tpath, column, FALSE);
968 gtk_tree_path_free(tpath); 968 gtk_tree_path_free(tpath);
969 } 969 }
970 } 970 }
971 971
972 static void collection_table_move_focus(CollectTable *ct, gint row, gint col, gint relative) 972 static void collection_table_move_focus(CollectTable *ct, gint row, gint col, gboolean relative)
973 { 973 {
974 gint new_row; 974 gint new_row;
975 gint new_col; 975 gint new_col;
976 976
977 if (relative) 977 if (relative)
1113 gtk_tree_path_free(tpath); 1113 gtk_tree_path_free(tpath);
1114 *y += ch; 1114 *y += ch;
1115 popup_menu_position_clamp(menu, x, y, 0); 1115 popup_menu_position_clamp(menu, x, y, 0);
1116 } 1116 }
1117 1117
1118 static gint collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) 1118 static gboolean collection_table_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
1119 { 1119 {
1120 CollectTable *ct = data; 1120 CollectTable *ct = data;
1121 gint focus_row = 0; 1121 gint focus_row = 0;
1122 gint focus_col = 0; 1122 gint focus_col = 0;
1123 CollectInfo *info; 1123 CollectInfo *info;
1124 gint stop_signal; 1124 gboolean stop_signal = TRUE;
1125 1125
1126 stop_signal = TRUE;
1127 switch (event->keyval) 1126 switch (event->keyval)
1128 { 1127 {
1129 case GDK_Left: case GDK_KP_Left: 1128 case GDK_Left: case GDK_KP_Left:
1130 focus_col = -1; 1129 focus_col = -1;
1131 break; 1130 break;
1238 *------------------------------------------------------------------- 1237 *-------------------------------------------------------------------
1239 * insert marker 1238 * insert marker
1240 *------------------------------------------------------------------- 1239 *-------------------------------------------------------------------
1241 */ 1240 */
1242 1241
1243 static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo *source, gint *after, GdkRectangle *cell, 1242 static CollectInfo *collection_table_insert_find(CollectTable *ct, CollectInfo *source, gboolean *after, GdkRectangle *cell,
1244 gint use_coord, gint x, gint y) 1243 gboolean use_coord, gint x, gint y)
1245 { 1244 {
1246 CollectInfo *info = NULL; 1245 CollectInfo *info = NULL;
1247 GtkTreeModel *store; 1246 GtkTreeModel *store;
1248 GtkTreeIter iter; 1247 GtkTreeIter iter;
1249 GtkTreePath *tpath; 1248 GtkTreePath *tpath;
1262 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), col); 1261 column = gtk_tree_view_get_column(GTK_TREE_VIEW(ct->listview), col);
1263 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell); 1262 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell);
1264 gtk_tree_path_free(tpath); 1263 gtk_tree_path_free(tpath);
1265 1264
1266 info = source; 1265 info = source;
1267 *after = (x > cell->x + (cell->width / 2)); 1266 *after = !!(x > cell->x + (cell->width / 2));
1268 } 1267 }
1269 return info; 1268 return info;
1270 } 1269 }
1271 1270
1272 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(ct->listview), x, y, 1271 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(ct->listview), x, y,
1282 info = g_list_nth_data(list, n); 1281 info = g_list_nth_data(list, n);
1283 1282
1284 if (info) 1283 if (info)
1285 { 1284 {
1286 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell); 1285 gtk_tree_view_get_background_area(GTK_TREE_VIEW(ct->listview), tpath, column, cell);
1287 *after = (x > cell->x + (cell->width / 2)); 1286 *after = !!(x > cell->x + (cell->width / 2));
1288 } 1287 }
1289 1288
1290 gtk_tree_path_free(tpath); 1289 gtk_tree_path_free(tpath);
1291 } 1290 }
1292 1291
1317 1316
1318 static CollectInfo *collection_table_insert_point(CollectTable *ct, gint x, gint y) 1317 static CollectInfo *collection_table_insert_point(CollectTable *ct, gint x, gint y)
1319 { 1318 {
1320 CollectInfo *info; 1319 CollectInfo *info;
1321 GdkRectangle cell; 1320 GdkRectangle cell;
1322 gint after = FALSE; 1321 gboolean after = FALSE;
1323 1322
1324 info = collection_table_insert_find(ct, NULL, &after, &cell, TRUE, x, y); 1323 info = collection_table_insert_find(ct, NULL, &after, &cell, TRUE, x, y);
1325 1324
1326 if (info && after) 1325 if (info && after)
1327 { 1326 {
1339 } 1338 }
1340 1339
1341 return info; 1340 return info;
1342 } 1341 }
1343 1342
1344 static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, gint enable) 1343 static void collection_table_insert_marker(CollectTable *ct, CollectInfo *info, gboolean enable)
1345 { 1344 {
1346 gint row, col; 1345 gint row, col;
1347 gint after = FALSE; 1346 gboolean after = FALSE;
1348 GdkRectangle cell; 1347 GdkRectangle cell;
1349 1348
1350 if (!enable) 1349 if (!enable)
1351 { 1350 {
1352 if (ct->marker_window) gdk_window_destroy(ct->marker_window); 1351 if (ct->marker_window) gdk_window_destroy(ct->marker_window);
1428 *------------------------------------------------------------------- 1427 *-------------------------------------------------------------------
1429 * mouse drag auto-scroll 1428 * mouse drag auto-scroll
1430 *------------------------------------------------------------------- 1429 *-------------------------------------------------------------------
1431 */ 1430 */
1432 1431
1433 static void collection_table_motion_update(CollectTable *ct, gint x, gint y, gint drop_event) 1432 static void collection_table_motion_update(CollectTable *ct, gint x, gint y, gboolean drop_event)
1434 { 1433 {
1435 CollectInfo *info; 1434 CollectInfo *info;
1436 1435
1437 info = collection_table_find_data_by_coord(ct, x, y, NULL); 1436 info = collection_table_find_data_by_coord(ct, x, y, NULL);
1438 1437
1445 { 1444 {
1446 tip_update(ct, info); 1445 tip_update(ct, info);
1447 } 1446 }
1448 } 1447 }
1449 1448
1450 static gint collection_table_auto_scroll_idle_cb(gpointer data) 1449 static gboolean collection_table_auto_scroll_idle_cb(gpointer data)
1451 { 1450 {
1452 CollectTable *ct = data; 1451 CollectTable *ct = data;
1453 GdkWindow *window; 1452 GdkWindow *window;
1454 gint x, y; 1453 gint x, y;
1455 gint w, h; 1454 gint w, h;
1466 1465
1467 ct->drop_idle_id = -1; 1466 ct->drop_idle_id = -1;
1468 return FALSE; 1467 return FALSE;
1469 } 1468 }
1470 1469
1471 static gint collection_table_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) 1470 static gboolean collection_table_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)
1472 { 1471 {
1473 CollectTable *ct = data; 1472 CollectTable *ct = data;
1474 1473
1475 if (ct->drop_idle_id == -1) ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct); 1474 if (ct->drop_idle_id == -1) ct->drop_idle_id = g_idle_add(collection_table_auto_scroll_idle_cb, ct);
1476 1475
1477 return TRUE; 1476 return TRUE;
1478 } 1477 }
1479 1478
1480 static void collection_table_scroll(CollectTable *ct, gint scroll) 1479 static void collection_table_scroll(CollectTable *ct, gboolean scroll)
1481 { 1480 {
1482 if (!scroll) 1481 if (!scroll)
1483 { 1482 {
1484 if (ct->drop_idle_id != -1) 1483 if (ct->drop_idle_id != -1)
1485 { 1484 {
1501 *------------------------------------------------------------------- 1500 *-------------------------------------------------------------------
1502 * mouse callbacks 1501 * mouse callbacks
1503 *------------------------------------------------------------------- 1502 *-------------------------------------------------------------------
1504 */ 1503 */
1505 1504
1506 static gint collection_table_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) 1505 static gboolean collection_table_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
1507 { 1506 {
1508 CollectTable *ct = data; 1507 CollectTable *ct = data;
1509 1508
1510 collection_table_motion_update(ct, (gint)bevent->x, (gint)bevent->y, FALSE); 1509 collection_table_motion_update(ct, (gint)bevent->x, (gint)bevent->y, FALSE);
1511 1510
1512 return FALSE; 1511 return FALSE;
1513 } 1512 }
1514 1513
1515 static gint collection_table_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) 1514 static gboolean collection_table_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
1516 { 1515 {
1517 CollectTable *ct = data; 1516 CollectTable *ct = data;
1518 GtkTreeIter iter; 1517 GtkTreeIter iter;
1519 CollectInfo *info; 1518 CollectInfo *info;
1520 1519
1549 } 1548 }
1550 1549
1551 return TRUE; 1550 return TRUE;
1552 } 1551 }
1553 1552
1554 static gint collection_table_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) 1553 static gboolean collection_table_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
1555 { 1554 {
1556 CollectTable *ct = data; 1555 CollectTable *ct = data;
1557 GtkTreeIter iter; 1556 GtkTreeIter iter;
1558 CollectInfo *info = NULL; 1557 CollectInfo *info = NULL;
1559 1558
1560 tip_schedule(ct); 1559 tip_schedule(ct);
1561 1560
1562 if ((gint)bevent->x != 0 || (gint) bevent->y != 0) 1561 if ((gint)bevent->x != 0 || (gint)bevent->y != 0)
1563 { 1562 {
1564 info = collection_table_find_data_by_coord(ct, (gint)bevent->x, (gint)bevent->y, &iter); 1563 info = collection_table_find_data_by_coord(ct, (gint)bevent->x, (gint)bevent->y, &iter);
1565 } 1564 }
1566 1565
1567 if (ct->click_info) 1566 if (ct->click_info)
1574 { 1573 {
1575 collection_table_set_focus(ct, info); 1574 collection_table_set_focus(ct, info);
1576 1575
1577 if (bevent->state & GDK_CONTROL_MASK) 1576 if (bevent->state & GDK_CONTROL_MASK)
1578 { 1577 {
1579 gint select; 1578 gboolean select = !INFO_SELECTED(info);
1580 1579
1581 select = !INFO_SELECTED(info);
1582 if ((bevent->state & GDK_SHIFT_MASK) && ct->prev_selection) 1580 if ((bevent->state & GDK_SHIFT_MASK) && ct->prev_selection)
1583 { 1581 {
1584 collection_table_select_region_util(ct, ct->prev_selection, info, select); 1582 collection_table_select_region_util(ct, ct->prev_selection, info, select);
1585 } 1583 }
1586 else 1584 else
1610 } 1608 }
1611 1609
1612 return TRUE; 1610 return TRUE;
1613 } 1611 }
1614 1612
1615 static gint collection_table_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data) 1613 static gboolean collection_table_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
1616 { 1614 {
1617 CollectTable *ct = data; 1615 CollectTable *ct = data;
1618 1616
1619 tip_unschedule(ct); 1617 tip_unschedule(ct);
1620 return FALSE; 1618 return FALSE;
1659 gtk_list_store_set(store, iter, CTABLE_COLUMN_POINTER, list, -1); 1657 gtk_list_store_set(store, iter, CTABLE_COLUMN_POINTER, list, -1);
1660 1658
1661 return list; 1659 return list;
1662 } 1660 }
1663 1661
1664 static void collection_table_populate(CollectTable *ct, gint resize) 1662 static void collection_table_populate(CollectTable *ct, gboolean resize)
1665 { 1663 {
1666 gint row; 1664 gint row;
1667 GList *work; 1665 GList *work;
1668 1666
1669 collection_table_verify_selections(ct); 1667 collection_table_verify_selections(ct);
1723 1721
1724 collection_table_update_focus(ct); 1722 collection_table_update_focus(ct);
1725 collection_table_update_status(ct); 1723 collection_table_update_status(ct);
1726 } 1724 }
1727 1725
1728 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gint force) 1726 static void collection_table_populate_at_new_size(CollectTable *ct, gint w, gint h, gboolean force)
1729 { 1727 {
1730 gint new_cols; 1728 gint new_cols;
1731 gint thumb_width; 1729 gint thumb_width;
1732 1730
1733 thumb_width = collection_table_get_icon_width(ct); 1731 thumb_width = collection_table_get_icon_width(ct);
1807 1805
1808 collection_table_update_focus(ct); 1806 collection_table_update_focus(ct);
1809 collection_table_update_status(ct); 1807 collection_table_update_status(ct);
1810 } 1808 }
1811 1809
1812 static gint collection_table_sync_idle_cb(gpointer data) 1810 static gboolean collection_table_sync_idle_cb(gpointer data)
1813 { 1811 {
1814 CollectTable *ct = data; 1812 CollectTable *ct = data;
1815 1813
1816 if (ct->sync_idle_id == -1) return FALSE; 1814 if (ct->sync_idle_id == -1) return FALSE;
1817 ct->sync_idle_id = -1; 1815 ct->sync_idle_id = -1;
1991 *------------------------------------------------------------------- 1989 *-------------------------------------------------------------------
1992 * dnd 1990 * dnd
1993 *------------------------------------------------------------------- 1991 *-------------------------------------------------------------------
1994 */ 1992 */
1995 1993
1996 static void collection_table_add_dir_recursive(CollectTable *ct, FileData *dir_fd, gint recursive) 1994 static void collection_table_add_dir_recursive(CollectTable *ct, FileData *dir_fd, gboolean recursive)
1997 { 1995 {
1998 GList *d; 1996 GList *d;
1999 GList *f; 1997 GList *f;
2000 GList *work; 1998 GList *work;
2001 1999
2019 2017
2020 filelist_free(f); 2018 filelist_free(f);
2021 filelist_free(d); 2019 filelist_free(d);
2022 } 2020 }
2023 2021
2024 static void confirm_dir_list_do(CollectTable *ct, GList *list, gint recursive) 2022 static void confirm_dir_list_do(CollectTable *ct, GList *list, gboolean recursive)
2025 { 2023 {
2026 GList *work = list; 2024 GList *work = list;
2027 while (work) 2025 while (work)
2028 { 2026 {
2029 FileData *fd = work->data; 2027 FileData *fd = work->data;
2100 static void collection_table_dnd_get(GtkWidget *widget, GdkDragContext *context, 2098 static void collection_table_dnd_get(GtkWidget *widget, GdkDragContext *context,
2101 GtkSelectionData *selection_data, guint info, 2099 GtkSelectionData *selection_data, guint info,
2102 guint time, gpointer data) 2100 guint time, gpointer data)
2103 { 2101 {
2104 CollectTable *ct = data; 2102 CollectTable *ct = data;
2105 gint selected; 2103 gboolean selected;
2106 GList *list = NULL; 2104 GList *list = NULL;
2107 gchar *uri_text = NULL; 2105 gchar *uri_text = NULL;
2108 gint total; 2106 gint total;
2109 2107
2110 if (!ct->click_info) return; 2108 if (!ct->click_info) return;
2511 2509
2512 CollectInfo *collection_table_get_focus_info(CollectTable *ct) 2510 CollectInfo *collection_table_get_focus_info(CollectTable *ct)
2513 { 2511 {
2514 return collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL); 2512 return collection_table_find_data(ct, ct->focus_row, ct->focus_column, NULL);
2515 } 2513 }
2514
2516 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ 2515 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */