Remove commented out code.
[geeqie.git] / src / pan-grid.c
1 /*
2  * Geeqie
3  * (C) 2006 John Ellis
4  * Copyright (C) 2008 - 2012 The Geeqie Team
5  *
6  * Author: John Ellis
7  *
8  * This software is released under the GNU General Public License (GNU GPL).
9  * Please read the included file COPYING for more information.
10  * This software comes with no warranty of any kind, use at your own risk!
11  */
12
13
14 #include "main.h"
15 #include "pan-types.h"
16
17 #include <math.h>
18
19
20 void pan_grid_compute(PanWindow *pw, FileData *dir_fd, gint *width, gint *height)
21 {
22         GList *list;
23         GList *work;
24         gint x, y;
25         gint grid_size;
26         gint next_y;
27
28         list = pan_list_tree(dir_fd, SORT_NAME, TRUE, pw->ignore_symlinks);
29
30         grid_size = (gint)sqrt((gdouble)g_list_length(list));
31         if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE)
32                 {
33                 grid_size = grid_size * (512 + PAN_THUMB_GAP) * pw->image_size / 100;
34                 }
35         else
36                 {
37                 grid_size = grid_size * (PAN_THUMB_SIZE + PAN_THUMB_GAP);
38                 }
39
40         next_y = 0;
41
42         *width = PAN_BOX_BORDER * 2;
43         *height = PAN_BOX_BORDER * 2;
44
45         x = PAN_THUMB_GAP;
46         y = PAN_THUMB_GAP;
47         work = list;
48         while (work)
49                 {
50                 FileData *fd;
51                 PanItem *pi;
52
53                 fd = work->data;
54                 work = work->next;
55
56                 if (pw->size > PAN_IMAGE_SIZE_THUMB_LARGE)
57                         {
58                         pi = pan_item_image_new(pw, fd, x, y, 10, 10);
59
60                         x += pi->width + PAN_THUMB_GAP;
61                         if (y + pi->height + PAN_THUMB_GAP > next_y) next_y = y + pi->height + PAN_THUMB_GAP;
62                         if (x > grid_size)
63                                 {
64                                 x = PAN_THUMB_GAP;
65                                 y = next_y;
66                                 }
67                         }
68                 else
69                         {
70                         pi = pan_item_thumb_new(pw, fd, x, y);
71
72                         x += PAN_THUMB_SIZE + PAN_THUMB_GAP;
73                         if (x > grid_size)
74                                 {
75                                 x = PAN_THUMB_GAP;
76                                 y += PAN_THUMB_SIZE + PAN_THUMB_GAP;
77                                 }
78                         }
79                 pan_item_size_coordinates(pi, PAN_THUMB_GAP, width, height);
80                 }
81
82         g_list_free(list);
83 }
84 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */