Mercurial > geeqie
comparison src/view_file_icon.c @ 1453:bc3f5c0432f6
gint -> gboolean where applicable. The end (ouf!).
author | zas_ |
---|---|
date | Mon, 16 Mar 2009 20:39:09 +0000 |
parents | a3d3208b0c50 |
children | 331e2d60d447 |
comparison
equal
deleted
inserted
replaced
1452:67b40740122e | 1453:bc3f5c0432f6 |
---|---|
137 IconData *ida = a; | 137 IconData *ida = a; |
138 IconData *idb = b; | 138 IconData *idb = b; |
139 return filelist_sort_compare_filedata(ida->fd, idb->fd); | 139 return filelist_sort_compare_filedata(ida->fd, idb->fd); |
140 } | 140 } |
141 | 141 |
142 GList *iconlist_sort(GList *list, SortType method, gint ascend) | 142 GList *iconlist_sort(GList *list, SortType method, gboolean ascend) |
143 { | 143 { |
144 return filelist_sort_full(list, method, ascend, (GCompareFunc) iconlist_sort_file_cb); | 144 return filelist_sort_full(list, method, ascend, (GCompareFunc) iconlist_sort_file_cb); |
145 } | 145 } |
146 | 146 |
147 GList *iconlist_insert_sort(GList *list, IconData *id, SortType method, gint ascend) | 147 GList *iconlist_insert_sort(GList *list, IconData *id, SortType method, gboolean ascend) |
148 { | 148 { |
149 return filelist_insert_sort_full(list, id, method, ascend, (GCompareFunc) iconlist_sort_file_cb); | 149 return filelist_insert_sort_full(list, id, method, ascend, (GCompareFunc) iconlist_sort_file_cb); |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 static void vficon_toggle_filenames(ViewFile *vf); | 153 static void vficon_toggle_filenames(ViewFile *vf); |
154 static void vficon_selection_remove(ViewFile *vf, IconData *id, SelectionType mask, GtkTreeIter *iter); | 154 static void vficon_selection_remove(ViewFile *vf, IconData *id, SelectionType mask, GtkTreeIter *iter); |
155 static void vficon_move_focus(ViewFile *vf, gint row, gint col, gint relative); | 155 static void vficon_move_focus(ViewFile *vf, gint row, gint col, gboolean relative); |
156 static void vficon_set_focus(ViewFile *vf, IconData *id); | 156 static void vficon_set_focus(ViewFile *vf, IconData *id); |
157 static void vficon_thumb_update(ViewFile *vf); | 157 static void vficon_thumb_update(ViewFile *vf); |
158 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gint force); | 158 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gboolean force); |
159 | 159 |
160 | 160 |
161 /* | 161 /* |
162 *----------------------------------------------------------------------------- | 162 *----------------------------------------------------------------------------- |
163 * pop-up menu | 163 * pop-up menu |
288 *------------------------------------------------------------------- | 288 *------------------------------------------------------------------- |
289 * misc utils | 289 * misc utils |
290 *------------------------------------------------------------------- | 290 *------------------------------------------------------------------- |
291 */ | 291 */ |
292 | 292 |
293 static gint vficon_find_position(ViewFile *vf, IconData *id, gint *row, gint *col) | 293 static gboolean vficon_find_position(ViewFile *vf, IconData *id, gint *row, gint *col) |
294 { | 294 { |
295 gint n; | 295 gint n; |
296 | 296 |
297 n = g_list_index(vf->list, id); | 297 n = g_list_index(vf->list, id); |
298 | 298 |
302 *col = n - (*row * VFICON(vf)->columns); | 302 *col = n - (*row * VFICON(vf)->columns); |
303 | 303 |
304 return TRUE; | 304 return TRUE; |
305 } | 305 } |
306 | 306 |
307 static gint vficon_find_iter(ViewFile *vf, IconData *id, GtkTreeIter *iter, gint *column) | 307 static gboolean vficon_find_iter(ViewFile *vf, IconData *id, GtkTreeIter *iter, gint *column) |
308 { | 308 { |
309 GtkTreeModel *store; | 309 GtkTreeModel *store; |
310 gint row, col; | 310 gint row, col; |
311 | 311 |
312 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); | 312 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
438 { | 438 { |
439 if (VFICON(vf)->tip_window) gtk_widget_destroy(VFICON(vf)->tip_window); | 439 if (VFICON(vf)->tip_window) gtk_widget_destroy(VFICON(vf)->tip_window); |
440 VFICON(vf)->tip_window = NULL; | 440 VFICON(vf)->tip_window = NULL; |
441 } | 441 } |
442 | 442 |
443 static gint tip_schedule_cb(gpointer data) | 443 static gboolean tip_schedule_cb(gpointer data) |
444 { | 444 { |
445 ViewFile *vf = data; | 445 ViewFile *vf = data; |
446 GtkWidget *window; | 446 GtkWidget *window; |
447 | 447 |
448 if (VFICON(vf)->tip_delay_id == -1) return FALSE; | 448 if (VFICON(vf)->tip_delay_id == -1) return FALSE; |
794 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL); | 794 vficon_selection_remove(vf, id, SELECTION_SELECTED, NULL); |
795 | 795 |
796 vf_send_update(vf); | 796 vf_send_update(vf); |
797 } | 797 } |
798 | 798 |
799 static void vficon_select_util(ViewFile *vf, IconData *id, gint select) | 799 static void vficon_select_util(ViewFile *vf, IconData *id, gboolean select) |
800 { | 800 { |
801 if (select) | 801 if (select) |
802 { | 802 { |
803 vficon_select(vf, id); | 803 vficon_select(vf, id); |
804 } | 804 } |
806 { | 806 { |
807 vficon_unselect(vf, id); | 807 vficon_unselect(vf, id); |
808 } | 808 } |
809 } | 809 } |
810 | 810 |
811 static void vficon_select_region_util(ViewFile *vf, IconData *start, IconData *end, gint select) | 811 static void vficon_select_region_util(ViewFile *vf, IconData *start, IconData *end, gboolean select) |
812 { | 812 { |
813 gint row1, col1; | 813 gint row1, col1; |
814 gint row2, col2; | 814 gint row2, col2; |
815 gint t; | 815 gint t; |
816 gint i, j; | 816 gint i, j; |
869 if (id) vficon_select_util(vf, id, select); | 869 if (id) vficon_select_util(vf, id, select); |
870 } | 870 } |
871 } | 871 } |
872 } | 872 } |
873 | 873 |
874 gint vficon_index_is_selected(ViewFile *vf, gint row) | 874 gboolean vficon_index_is_selected(ViewFile *vf, gint row) |
875 { | 875 { |
876 IconData *id = g_list_nth_data(vf->list, row); | 876 IconData *id = g_list_nth_data(vf->list, row); |
877 | 877 |
878 if (!id) return FALSE; | 878 if (!id) return FALSE; |
879 | 879 |
1069 *------------------------------------------------------------------- | 1069 *------------------------------------------------------------------- |
1070 * focus | 1070 * focus |
1071 *------------------------------------------------------------------- | 1071 *------------------------------------------------------------------- |
1072 */ | 1072 */ |
1073 | 1073 |
1074 static void vficon_move_focus(ViewFile *vf, gint row, gint col, gint relative) | 1074 static void vficon_move_focus(ViewFile *vf, gint row, gint col, gboolean relative) |
1075 { | 1075 { |
1076 gint new_row; | 1076 gint new_row; |
1077 gint new_col; | 1077 gint new_col; |
1078 | 1078 |
1079 if (relative) | 1079 if (relative) |
1263 gtk_tree_path_free(tpath); | 1263 gtk_tree_path_free(tpath); |
1264 *y += ch; | 1264 *y += ch; |
1265 popup_menu_position_clamp(menu, x, y, 0); | 1265 popup_menu_position_clamp(menu, x, y, 0); |
1266 } | 1266 } |
1267 | 1267 |
1268 gint vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) | 1268 gboolean vficon_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
1269 { | 1269 { |
1270 ViewFile *vf = data; | 1270 ViewFile *vf = data; |
1271 gint focus_row = 0; | 1271 gint focus_row = 0; |
1272 gint focus_col = 0; | 1272 gint focus_col = 0; |
1273 IconData *id; | 1273 IconData *id; |
1274 gint stop_signal; | 1274 gboolean stop_signal; |
1275 | 1275 |
1276 stop_signal = TRUE; | 1276 stop_signal = TRUE; |
1277 switch (event->keyval) | 1277 switch (event->keyval) |
1278 { | 1278 { |
1279 case GDK_Left: case GDK_KP_Left: | 1279 case GDK_Left: case GDK_KP_Left: |
1398 *------------------------------------------------------------------- | 1398 *------------------------------------------------------------------- |
1399 * mouse | 1399 * mouse |
1400 *------------------------------------------------------------------- | 1400 *------------------------------------------------------------------- |
1401 */ | 1401 */ |
1402 | 1402 |
1403 static gint vficon_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | 1403 static gboolean vficon_motion_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
1404 { | 1404 { |
1405 ViewFile *vf = data; | 1405 ViewFile *vf = data; |
1406 IconData *id; | 1406 IconData *id; |
1407 | 1407 |
1408 id = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, NULL); | 1408 id = vficon_find_data_by_coord(vf, (gint)bevent->x, (gint)bevent->y, NULL); |
1409 tip_update(vf, id); | 1409 tip_update(vf, id); |
1410 | 1410 |
1411 return FALSE; | 1411 return FALSE; |
1412 } | 1412 } |
1413 | 1413 |
1414 gint vficon_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | 1414 gboolean vficon_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
1415 { | 1415 { |
1416 ViewFile *vf = data; | 1416 ViewFile *vf = data; |
1417 GtkTreeIter iter; | 1417 GtkTreeIter iter; |
1418 IconData *id; | 1418 IconData *id; |
1419 | 1419 |
1449 } | 1449 } |
1450 | 1450 |
1451 return FALSE; | 1451 return FALSE; |
1452 } | 1452 } |
1453 | 1453 |
1454 gint vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) | 1454 gboolean vficon_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) |
1455 { | 1455 { |
1456 ViewFile *vf = data; | 1456 ViewFile *vf = data; |
1457 GtkTreeIter iter; | 1457 GtkTreeIter iter; |
1458 IconData *id = NULL; | 1458 IconData *id = NULL; |
1459 gint was_selected; | 1459 gboolean was_selected; |
1460 | 1460 |
1461 tip_schedule(vf); | 1461 tip_schedule(vf); |
1462 | 1462 |
1463 if ((gint)bevent->x != 0 || (gint)bevent->y != 0) | 1463 if ((gint)bevent->x != 0 || (gint)bevent->y != 0) |
1464 { | 1464 { |
1470 vficon_selection_remove(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, NULL); | 1470 vficon_selection_remove(vf, VFICON(vf)->click_id, SELECTION_PRELIGHT, NULL); |
1471 } | 1471 } |
1472 | 1472 |
1473 if (!id || VFICON(vf)->click_id != id) return TRUE; | 1473 if (!id || VFICON(vf)->click_id != id) return TRUE; |
1474 | 1474 |
1475 was_selected = (id->selected & SELECTION_SELECTED); | 1475 was_selected = !!(id->selected & SELECTION_SELECTED); |
1476 | 1476 |
1477 switch (bevent->button) | 1477 switch (bevent->button) |
1478 { | 1478 { |
1479 case MOUSE_BUTTON_LEFT: | 1479 case MOUSE_BUTTON_LEFT: |
1480 { | 1480 { |
1481 vficon_set_focus(vf, id); | 1481 vficon_set_focus(vf, id); |
1482 | 1482 |
1483 if (bevent->state & GDK_CONTROL_MASK) | 1483 if (bevent->state & GDK_CONTROL_MASK) |
1484 { | 1484 { |
1485 gint select; | 1485 gboolean select; |
1486 | 1486 |
1487 select = !(id->selected & SELECTION_SELECTED); | 1487 select = !(id->selected & SELECTION_SELECTED); |
1488 if ((bevent->state & GDK_SHIFT_MASK) && VFICON(vf)->prev_selection) | 1488 if ((bevent->state & GDK_SHIFT_MASK) && VFICON(vf)->prev_selection) |
1489 { | 1489 { |
1490 vficon_select_region_util(vf, VFICON(vf)->prev_selection, id, select); | 1490 vficon_select_region_util(vf, VFICON(vf)->prev_selection, id, select); |
1525 } | 1525 } |
1526 | 1526 |
1527 return TRUE; | 1527 return TRUE; |
1528 } | 1528 } |
1529 | 1529 |
1530 static gint vficon_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data) | 1530 static gboolean vficon_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data) |
1531 { | 1531 { |
1532 ViewFile *vf = data; | 1532 ViewFile *vf = data; |
1533 | 1533 |
1534 tip_unschedule(vf); | 1534 tip_unschedule(vf); |
1535 return FALSE; | 1535 return FALSE; |
1588 gtk_list_store_set(store, iter, FILE_COLUMN_POINTER, list, -1); | 1588 gtk_list_store_set(store, iter, FILE_COLUMN_POINTER, list, -1); |
1589 | 1589 |
1590 return list; | 1590 return list; |
1591 } | 1591 } |
1592 | 1592 |
1593 static void vficon_populate(ViewFile *vf, gint resize, gint keep_position) | 1593 static void vficon_populate(ViewFile *vf, gboolean resize, gboolean keep_position) |
1594 { | 1594 { |
1595 GtkTreeModel *store; | 1595 GtkTreeModel *store; |
1596 GtkTreePath *tpath; | 1596 GtkTreePath *tpath; |
1597 GList *work; | 1597 GList *work; |
1598 IconData *visible_id = NULL; | 1598 IconData *visible_id = NULL; |
1599 gint r, c; | 1599 gint r, c; |
1600 gint valid; | 1600 gboolean valid; |
1601 GtkTreeIter iter; | 1601 GtkTreeIter iter; |
1602 | 1602 |
1603 vficon_verify_selections(vf); | 1603 vficon_verify_selections(vf); |
1604 | 1604 |
1605 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); | 1605 store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); |
1730 | 1730 |
1731 vf_send_update(vf); | 1731 vf_send_update(vf); |
1732 vficon_thumb_update(vf); | 1732 vficon_thumb_update(vf); |
1733 } | 1733 } |
1734 | 1734 |
1735 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gint force) | 1735 static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gboolean force) |
1736 { | 1736 { |
1737 gint new_cols; | 1737 gint new_cols; |
1738 gint thumb_width; | 1738 gint thumb_width; |
1739 | 1739 |
1740 thumb_width = vficon_get_icon_width(vf); | 1740 thumb_width = vficon_get_icon_width(vf); |
1848 *----------------------------------------------------------------------------- | 1848 *----------------------------------------------------------------------------- |
1849 * misc | 1849 * misc |
1850 *----------------------------------------------------------------------------- | 1850 *----------------------------------------------------------------------------- |
1851 */ | 1851 */ |
1852 | 1852 |
1853 void vficon_sort_set(ViewFile *vf, SortType type, gint ascend) | 1853 void vficon_sort_set(ViewFile *vf, SortType type, gboolean ascend) |
1854 { | 1854 { |
1855 if (vf->sort_method == type && vf->sort_ascend == ascend) return; | 1855 if (vf->sort_method == type && vf->sort_ascend == ascend) return; |
1856 | 1856 |
1857 vf->sort_method = type; | 1857 vf->sort_method = type; |
1858 vf->sort_ascend = ascend; | 1858 vf->sort_ascend = ascend; |
1866 *----------------------------------------------------------------------------- | 1866 *----------------------------------------------------------------------------- |
1867 * thumb updates | 1867 * thumb updates |
1868 *----------------------------------------------------------------------------- | 1868 *----------------------------------------------------------------------------- |
1869 */ | 1869 */ |
1870 | 1870 |
1871 static gint vficon_thumb_next(ViewFile *vf); | 1871 static gboolean vficon_thumb_next(ViewFile *vf); |
1872 | 1872 |
1873 static gdouble vficon_thumb_progress(ViewFile *vf) | 1873 static gdouble vficon_thumb_progress(ViewFile *vf) |
1874 { | 1874 { |
1875 gint count = 0; | 1875 gint count = 0; |
1876 gint done = 0; | 1876 gint done = 0; |
1945 } | 1945 } |
1946 | 1946 |
1947 while (vficon_thumb_next(vf)); | 1947 while (vficon_thumb_next(vf)); |
1948 } | 1948 } |
1949 | 1949 |
1950 static gint vficon_thumb_next(ViewFile *vf) | 1950 static gboolean vficon_thumb_next(ViewFile *vf) |
1951 { | 1951 { |
1952 GtkTreePath *tpath; | 1952 GtkTreePath *tpath; |
1953 FileData *fd = NULL; | 1953 FileData *fd = NULL; |
1954 | 1954 |
1955 if (!GTK_WIDGET_REALIZED(vf->listview)) | 1955 if (!GTK_WIDGET_REALIZED(vf->listview)) |
2158 *----------------------------------------------------------------------------- | 2158 *----------------------------------------------------------------------------- |
2159 * | 2159 * |
2160 *----------------------------------------------------------------------------- | 2160 *----------------------------------------------------------------------------- |
2161 */ | 2161 */ |
2162 | 2162 |
2163 static gint vficon_refresh_real(ViewFile *vf, gint keep_position) | 2163 static gboolean vficon_refresh_real(ViewFile *vf, gboolean keep_position) |
2164 { | 2164 { |
2165 gboolean ret = TRUE; | 2165 gboolean ret = TRUE; |
2166 GList *work, *work_fd; | 2166 GList *work, *work_fd; |
2167 IconData *focus_id; | 2167 IconData *focus_id; |
2168 GList *new_filelist = NULL; | 2168 GList *new_filelist = NULL; |
2288 } | 2288 } |
2289 | 2289 |
2290 return ret; | 2290 return ret; |
2291 } | 2291 } |
2292 | 2292 |
2293 gint vficon_refresh(ViewFile *vf) | 2293 gboolean vficon_refresh(ViewFile *vf) |
2294 { | 2294 { |
2295 return vficon_refresh_real(vf, TRUE); | 2295 return vficon_refresh_real(vf, TRUE); |
2296 } | 2296 } |
2297 | 2297 |
2298 /* | 2298 /* |
2424 *----------------------------------------------------------------------------- | 2424 *----------------------------------------------------------------------------- |
2425 * base | 2425 * base |
2426 *----------------------------------------------------------------------------- | 2426 *----------------------------------------------------------------------------- |
2427 */ | 2427 */ |
2428 | 2428 |
2429 gint vficon_set_fd(ViewFile *vf, FileData *dir_fd) | 2429 gboolean vficon_set_fd(ViewFile *vf, FileData *dir_fd) |
2430 { | 2430 { |
2431 gint ret; | 2431 gboolean ret; |
2432 | 2432 |
2433 if (!dir_fd) return FALSE; | 2433 if (!dir_fd) return FALSE; |
2434 if (vf->dir_fd == dir_fd) return TRUE; | 2434 if (vf->dir_fd == dir_fd) return TRUE; |
2435 | 2435 |
2436 file_data_unref(vf->dir_fd); | 2436 file_data_unref(vf->dir_fd); |