comparison src/view_dir_list.c @ 978:9ff64efe11eb

Replace macros VDLIST_INFO() and VDTREE_INFO() by shorter VDLIST() and VDTREE(). VDLIST_INFO(vd, part) becomes VDLIST(vd)->part.
author zas_
date Thu, 21 Aug 2008 22:47:49 +0000
parents ad2ff9608beb
children 8732c06d8aeb
comparison
equal deleted inserted replaced
977:1f634178a14f 978:9ff64efe11eb
26 #include "view_dir.h" 26 #include "view_dir.h"
27 27
28 #include <gdk/gdkkeysyms.h> /* for keyboard values */ 28 #include <gdk/gdkkeysyms.h> /* for keyboard values */
29 29
30 30
31 #define VDLIST_INFO(_vd_, _part_) (((ViewDirInfoList *)(_vd_->info))->_part_) 31 #define VDLIST(_vf_) ((ViewDirInfoList *)(_vf_->info))
32 32
33 33
34 /* 34 /*
35 *----------------------------------------------------------------------------- 35 *-----------------------------------------------------------------------------
36 * misc 36 * misc
69 if (row) *row = -1; 69 if (row) *row = -1;
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 n = 0; 73 n = 0;
74 work = VDLIST_INFO(vd, list); 74 work = VDLIST(vd)->list;
75 while (work) 75 while (work)
76 { 76 {
77 FileData *fd = work->data; 77 FileData *fd = work->data;
78 if (strcmp(fd->path, path) == 0) 78 if (strcmp(fd->path, path) == 0)
79 { 79 {
133 133
134 const gchar *vdlist_row_get_path(ViewDir *vd, gint row) 134 const gchar *vdlist_row_get_path(ViewDir *vd, gint row)
135 { 135 {
136 FileData *fd; 136 FileData *fd;
137 137
138 fd = g_list_nth_data(VDLIST_INFO(vd, list), row); 138 fd = g_list_nth_data(VDLIST(vd)->list, row);
139 139
140 if (fd) return fd->path; 140 if (fd) return fd->path;
141 141
142 return NULL; 142 return NULL;
143 } 143 }
151 gchar *filepath; 151 gchar *filepath;
152 GList *old_list; 152 GList *old_list;
153 gint ret; 153 gint ret;
154 FileData *fd; 154 FileData *fd;
155 155
156 old_list = VDLIST_INFO(vd, list); 156 old_list = VDLIST(vd)->list;
157 157
158 ret = filelist_read(vd->dir_fd, NULL, &VDLIST_INFO(vd, list)); 158 ret = filelist_read(vd->dir_fd, NULL, &VDLIST(vd)->list);
159 VDLIST_INFO(vd, list) = filelist_sort(VDLIST_INFO(vd, list), SORT_NAME, TRUE); 159 VDLIST(vd)->list = filelist_sort(VDLIST(vd)->list, SORT_NAME, TRUE);
160 160
161 /* add . and .. */ 161 /* add . and .. */
162 162
163 if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0) 163 if (strcmp(vd->dir_fd->path, G_DIR_SEPARATOR_S) != 0)
164 { 164 {
165 filepath = g_build_filename(vd->dir_fd->path, "..", NULL); 165 filepath = g_build_filename(vd->dir_fd->path, "..", NULL);
166 fd = file_data_new_simple(filepath); 166 fd = file_data_new_simple(filepath);
167 VDLIST_INFO(vd, list) = g_list_prepend(VDLIST_INFO(vd, list), fd); 167 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
168 g_free(filepath); 168 g_free(filepath);
169 } 169 }
170 170
171 if (options->file_filter.show_dot_directory) 171 if (options->file_filter.show_dot_directory)
172 { 172 {
173 filepath = g_build_filename(vd->dir_fd->path, ".", NULL); 173 filepath = g_build_filename(vd->dir_fd->path, ".", NULL);
174 fd = file_data_new_simple(filepath); 174 fd = file_data_new_simple(filepath);
175 VDLIST_INFO(vd, list) = g_list_prepend(VDLIST_INFO(vd, list), fd); 175 VDLIST(vd)->list = g_list_prepend(VDLIST(vd)->list, fd);
176 g_free(filepath); 176 g_free(filepath);
177 } 177 }
178 178
179 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view))); 179 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view)));
180 if (clear) gtk_list_store_clear(store); 180 if (clear) gtk_list_store_clear(store);
181 181
182 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, NULL); 182 valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, NULL);
183 183
184 work = VDLIST_INFO(vd, list); 184 work = VDLIST(vd)->list;
185 while (work) 185 while (work)
186 { 186 {
187 gint match; 187 gint match;
188 GdkPixbuf *pixbuf; 188 GdkPixbuf *pixbuf;
189 const gchar *date = ""; 189 const gchar *date = "";
326 { 326 {
327 /* scroll to make last path visible */ 327 /* scroll to make last path visible */
328 FileData *found = NULL; 328 FileData *found = NULL;
329 GList *work; 329 GList *work;
330 330
331 work = VDLIST_INFO(vd, list); 331 work = VDLIST(vd)->list;
332 while (work && !found) 332 while (work && !found)
333 { 333 {
334 FileData *fd = work->data; 334 FileData *fd = work->data;
335 if (strcmp(old_path, fd->name) == 0) found = fd; 335 if (strcmp(old_path, fd->name) == 0) found = fd;
336 work = work->next; 336 work = work->next;
425 ViewDir *vd = data; 425 ViewDir *vd = data;
426 426
427 vd_dnd_drop_scroll_cancel(vd); 427 vd_dnd_drop_scroll_cancel(vd);
428 widget_auto_scroll_stop(vd->view); 428 widget_auto_scroll_stop(vd->view);
429 429
430 filelist_free(VDLIST_INFO(vd, list)); 430 filelist_free(VDLIST(vd)->list);
431 } 431 }
432 432
433 ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd) 433 ViewDir *vdlist_new(ViewDir *vd, FileData *dir_fd)
434 { 434 {
435 GtkListStore *store; 435 GtkListStore *store;
438 GtkCellRenderer *renderer; 438 GtkCellRenderer *renderer;
439 439
440 vd->info = g_new0(ViewDirInfoList, 1); 440 vd->info = g_new0(ViewDirInfoList, 1);
441 vd->type = DIRVIEW_LIST; 441 vd->type = DIRVIEW_LIST;
442 442
443 VDLIST_INFO(vd, list) = NULL; 443 VDLIST(vd)->list = NULL;
444 444
445 store = gtk_list_store_new(5, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING); 445 store = gtk_list_store_new(5, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING);
446 vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); 446 vd->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
447 g_object_unref(store); 447 g_object_unref(store);
448 448