Prepare switch to ViewFile (unused yet).
[geeqie.git] / src / view_file.c
1 /*
2  * Geeqie
3  * Copyright (C) 2008 The Geeqie Team
4  *
5  * Author: Laurent Monin
6  *
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!
10  */
11
12 #include "main.h"
13 #include "view_file.h"
14
15 #include "debug.h"
16 #include "view_file_list.h"
17 #include "view_file_icon.h"
18
19
20 void vf_thumb_set(ViewFile *vf, gint enable);
21 void vf_marks_set(ViewFile *vf, gint enable);
22 void vf_sort_set(ViewFile *vf, SortType type, gint ascend);
23
24 FileData *vf_index_get_data(ViewFile *vf, gint row);
25 gchar *vf_index_get_path(ViewFile *vf, gint row);
26 gint vf_index_by_path(ViewFile *vf, const gchar *path);
27 gint vf_index_by_fd(ViewFile *vf, FileData *in_fd);
28 gint vf_count(ViewFile *vf, gint64 *bytes);
29 GList *vf_get_list(ViewFile *vf);
30
31 gint vf_index_is_selected(ViewFile *vf, gint row);
32 gint vf_selection_count(ViewFile *vf, gint64 *bytes);
33 GList *vf_selection_get_list(ViewFile *vf);
34 GList *vf_selection_get_list_by_index(ViewFile *vf);
35
36 void vf_select_all(ViewFile *vf);
37 void vf_select_none(ViewFile *vf);
38 void vf_select_by_path(ViewFile *vf, const gchar *path);
39 void vf_select_by_fd(ViewFile *vf, FileData *fd);
40
41 void vf_mark_to_selection(ViewFile *vf, gint mark, MarkToSelectionMode mode);
42 void vf_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode);
43
44 void vf_select_marked(ViewFile *vf, gint mark);
45 void vf_mark_selected(ViewFile *vf, gint mark, gint value);
46
47 gint vf_maint_renamed(ViewFile *vf, FileData *fd);
48 gint vf_maint_removed(ViewFile *vf, FileData *fd, GList *ignore_list);
49 gint vf_maint_moved(ViewFile *vf, FileData *fd, GList *ignore_list);
50
51
52 static gint vf_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
53 {
54         gint ret = FALSE;
55
56         return ret;
57 }
58
59 static gint vf_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
60 {
61         gint ret = FALSE;
62
63         return ret;
64 }
65
66 static gint vf_release_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
67 {
68         gint ret = FALSE;
69
70         return ret;
71 }
72
73 static void vf_dnd_init(ViewFile *vf)
74 {
75 }
76
77 gint vf_refresh(ViewFile *vf)
78 {
79         gint ret = TRUE;
80
81         return ret;
82 }
83
84 gint vf_set_path(ViewFile *vf, const gchar *path)
85 {
86         return FALSE;
87 }
88
89 static void vf_destroy_cb(GtkWidget *widget, gpointer data)
90 {
91         ViewFile *vf = data;
92
93         if (vf->popup)
94                 {
95                 g_signal_handlers_disconnect_matched(G_OBJECT(vf->popup), G_SIGNAL_MATCH_DATA,
96                                                      0, 0, 0, NULL, vf);
97                 gtk_widget_destroy(vf->popup);
98                 }
99
100         g_free(vf->path);
101         g_free(vf);
102 }
103
104 ViewFile *vf_new(FileViewType type, const gchar *path)
105 {
106         ViewFile *vf;
107
108         vf = g_new0(ViewFile, 1);
109
110         vf->path = NULL;
111         vf->list = NULL;
112
113         vf->sort_method = SORT_NAME;
114         vf->sort_ascend = TRUE;
115         
116         vf->thumbs_running = FALSE;
117         vf->thumbs_count = 0;
118         vf->thumbs_loader = NULL;
119         vf->thumbs_filedata = NULL;
120
121         vf->popup = NULL;
122
123         vf->widget = gtk_scrolled_window_new(NULL, NULL);
124         gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vf->widget), GTK_SHADOW_IN);
125         gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vf->widget),
126                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
127
128         vf->listview = NULL; /* FIXME */
129
130         g_signal_connect(G_OBJECT(vf->widget), "destroy",
131                          G_CALLBACK(vf_destroy_cb), vf);
132
133         g_signal_connect(G_OBJECT(vf->listview), "key_press_event",
134                          G_CALLBACK(vf_press_key_cb), vf);
135         g_signal_connect(G_OBJECT(vf->listview), "button_press_event",
136                          G_CALLBACK(vf_press_cb), vf);
137         g_signal_connect(G_OBJECT(vf->listview), "button_release_event",
138                          G_CALLBACK(vf_release_cb), vf);
139
140         gtk_container_add(GTK_CONTAINER(vf->widget), vf->listview);
141         gtk_widget_show(vf->listview);
142
143         vf_dnd_init(vf);
144
145         if (path) vf_set_path(vf, path);
146
147         return vf;
148 }
149
150 void vf_set_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gpointer data), gpointer data)
151 {
152         vf->func_status = func;
153         vf->data_status = data;
154 }
155
156 void vf_set_thumb_status_func(ViewFile *vf, void (*func)(ViewFile *vf, gdouble val, const gchar *text, gpointer data), gpointer data)
157 {
158         vf->func_thumb_status = func;
159         vf->data_thumb_status = data;
160 }
161
162 void vf_set_layout(ViewFile *vf, LayoutWindow *layout)
163 {
164         vf->layout = layout;
165 }