3 * Copyright (C) 2008 The Geeqie Team
5 * Author: Laurent Monin
7 * This software is released under the GNU General Public License (GNU GPL).
8 * Please read the included file COPYING for more information.
9 * This software comes with no warranty of any kind, use at your own risk!
13 #include "view_file.h"
16 #include "view_file_list.h"
17 #include "view_file_icon.h"
21 *-----------------------------------------------------------------------------
23 *-----------------------------------------------------------------------------
26 void vf_sort_set(ViewFile *vf, SortType type, gint ascend)
30 case FILEVIEW_LIST: vflist_sort_set(vf, type, ascend); break;
31 case FILEVIEW_ICON: /*vficon_sort_set(vf, type, ascend);*/; break;
36 *-----------------------------------------------------------------------------
38 *-----------------------------------------------------------------------------
41 FileData *vf_index_get_data(ViewFile *vf, gint row)
47 case FILEVIEW_LIST: fd = vflist_index_get_data(vf, row); break;
48 case FILEVIEW_ICON: /*fd = vficon_index_get_data(vf, row);*/; break;
54 gchar *vf_index_get_path(ViewFile *vf, gint row)
60 case FILEVIEW_LIST: path = vflist_index_get_path(vf, row); break;
61 case FILEVIEW_ICON: /*path = vficon_index_get_path(vf, row);*/; break;
67 gint vf_index_by_path(ViewFile *vf, const gchar *path)
73 case FILEVIEW_LIST: index = vflist_index_by_path(vf, path); break;
74 case FILEVIEW_ICON: /*index = vficon_index_by_path(vf, path);*/; break;
80 gint vf_count(ViewFile *vf, gint64 *bytes)
86 case FILEVIEW_LIST: count = vflist_count(vf, bytes); break;
87 case FILEVIEW_ICON: /*count = vficon_count(vf, bytes);*/; break;
93 GList *vf_get_list(ViewFile *vf)
99 case FILEVIEW_LIST: list = vflist_get_list(vf); break;
100 case FILEVIEW_ICON: /*list = vficon_get_list(vf);*/; break;
108 *-------------------------------------------------------------------
110 *-------------------------------------------------------------------
113 static gint vf_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
120 case FILEVIEW_LIST: ret = vflist_press_key_cb(widget, event, data); break;
121 case FILEVIEW_ICON: /*ret = vficon_press_key_cb(widget, event, data)*/; break;
128 *-------------------------------------------------------------------
130 *-------------------------------------------------------------------
133 static gint vf_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
140 case FILEVIEW_LIST: ret = vflist_press_cb(widget, bevent, data); break;
141 case FILEVIEW_ICON: /*ret = vficon_press_cb(widget, bevent, data)*/; break;
147 static gint vf_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
154 case FILEVIEW_LIST: ret = vflist_release_cb(widget, bevent, data); break;
155 case FILEVIEW_ICON: /*ret = vficon_release_cb(widget, bevent, data)*/; break;
163 *-----------------------------------------------------------------------------
165 *-----------------------------------------------------------------------------
168 gint vf_selection_count(ViewFile *vf, gint64 *bytes)
174 case FILEVIEW_LIST: count = vflist_selection_count(vf, bytes); break;
175 case FILEVIEW_ICON: /*count = vficon_selection_count(vf, bytes)*/; break;
181 GList *vf_selection_get_list(ViewFile *vf)
187 case FILEVIEW_LIST: list = vflist_selection_get_list(vf); break;
188 case FILEVIEW_ICON: /*list = vficon_selection_get_list(vf)*/; break;
194 GList *vf_selection_get_list_by_index(ViewFile *vf)
200 case FILEVIEW_LIST: list = vflist_selection_get_list_by_index(vf); break;
201 case FILEVIEW_ICON: /*list = vficon_selection_get_list_by_index(vf)*/; break;
207 void vf_select_all(ViewFile *vf)
211 case FILEVIEW_LIST: vflist_select_all(vf); break;
212 case FILEVIEW_ICON: /*vficon_select_all(vf);*/; break;
216 void vf_select_none(ViewFile *vf)
220 case FILEVIEW_LIST: vflist_select_none(vf); break;
221 case FILEVIEW_ICON: /*vficon_select_none(vf);*/; break;
225 void vf_select_by_fd(ViewFile *vf, FileData *fd)
229 case FILEVIEW_LIST: vflist_select_by_fd(vf, fd); break;
230 case FILEVIEW_ICON: /*vficon_select_by_fd(vf, fd);*/; break;
234 void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode)
238 case FILEVIEW_LIST: vflist_mark_to_selection(vf, mark, mode); break;
239 case FILEVIEW_ICON: /*vficon_mark_to_selection(vf, mark, mode);*/; break;
243 void vf_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode)
247 case FILEVIEW_LIST: vflist_selection_to_mark(vf, mark, mode); break;
248 case FILEVIEW_ICON: /*vficon_selection_to_mark(vf, mark, mode);*/; break;
253 *-----------------------------------------------------------------------------
255 *-----------------------------------------------------------------------------
259 static void vf_dnd_init(ViewFile *vf)
263 case FILEVIEW_LIST: vflist_dnd_init(vf); break;
264 case FILEVIEW_ICON: /*vficon_dnd_init(vf)*/; break;
268 gint vf_refresh(ViewFile *vf)
274 case FILEVIEW_LIST: ret = vflist_refresh(vf); break;
275 case FILEVIEW_ICON: /*ret = vficon_refresh(vf)*/; break;
281 gint vf_set_path(ViewFile *vf, const gchar *path)
287 case FILEVIEW_LIST: ret = vflist_set_path(vf, path); break;
288 case FILEVIEW_ICON: /*ret = vficon_set_path(vf, path)*/; break;
294 static void vf_destroy_cb(GtkWidget *widget, gpointer data)
300 case FILEVIEW_LIST: vflist_destroy_cb(widget, data); break;
301 case FILEVIEW_ICON: vficon_destroy_cb(widget, data); break;
306 g_signal_handlers_disconnect_matched(G_OBJECT(vf->popup), G_SIGNAL_MATCH_DATA,
308 gtk_widget_destroy(vf->popup);
316 ViewFile *vf_new(FileViewType type, const gchar *path)
320 vf = g_new0(ViewFile, 1);
327 vf->sort_method = SORT_NAME;
328 vf->sort_ascend = TRUE;
330 vf->thumbs_running = FALSE;
331 vf->thumbs_count = 0;
332 vf->thumbs_loader = NULL;
333 vf->thumbs_filedata = NULL;
337 vf->widget = gtk_scrolled_window_new(NULL, NULL);
338 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vf->widget), GTK_SHADOW_IN);
339 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vf->widget),
340 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
342 g_signal_connect(G_OBJECT(vf->widget), "destroy",
343 G_CALLBACK(vf_destroy_cb), vf);
347 case FILEVIEW_LIST: vf = vflist_new(vf, path); break;
348 case FILEVIEW_ICON: /*vf = vftree_new(vf, path);*/ break;
351 g_signal_connect(G_OBJECT(vf->listview), "key_press_event",
352 G_CALLBACK(vf_press_key_cb), vf);
353 g_signal_connect(G_OBJECT(vf->listview), "button_press_event",
354 G_CALLBACK(vf_press_cb), vf);
355 g_signal_connect(G_OBJECT(vf->listview), "button_release_event",
356 G_CALLBACK(vf_release_cb), vf);
358 gtk_container_add(GTK_CONTAINER(vf->widget), vf->listview);
359 gtk_widget_show(vf->listview);
363 if (path) vf_set_path(vf, path);
368 void vf_set_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gpointer data), gpointer data)
370 vf->func_status = func;
371 vf->data_status = data;
374 void vf_set_thumb_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gdouble val, const gchar *text, gpointer data), gpointer data)
376 vf->func_thumb_status = func;
377 vf->data_thumb_status = data;
380 void vf_thumb_set(ViewFile *vf, gint enable)
384 case FILEVIEW_LIST: vflist_thumb_set(vf, enable); break;
385 case FILEVIEW_ICON: /*vficon_thumb_set(vf, enable);*/ break;
389 void vf_marks_set(ViewFile *vf, gint enable)
393 case FILEVIEW_LIST: vflist_marks_set(vf, enable); break;
394 case FILEVIEW_ICON: /*vficon_marks_set(vf, enable);*/ break;
398 void vf_set_layout(ViewFile *vf, LayoutWindow *layout)
404 *-----------------------------------------------------------------------------
405 * maintenance (for rename, move, remove)
406 *-----------------------------------------------------------------------------
409 gint vf_maint_renamed(ViewFile *vf, FileData *fd)
415 case FILEVIEW_LIST: ret = vflist_maint_renamed(vf, fd); break;
416 case FILEVIEW_ICON: /*ret = vficon_maint_renamed(vf, fd);*/ break;
422 gint vf_maint_removed(ViewFile *vf, FileData *fd, GList *ignore_list)
428 case FILEVIEW_LIST: ret = vflist_maint_removed(vf, fd, ignore_list); break;
429 case FILEVIEW_ICON: /*ret = vficon_maint_removed(vf, fd, ignore_list);*/ break;
435 gint vf_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list)
441 case FILEVIEW_LIST: ret = vflist_maint_moved(vf, fd, ignore_list); break;
442 case FILEVIEW_ICON: /*ret = vficon_maint_moved(vf, fd, ignore_list);*/ break;