Mercurial > geeqie.yaz
annotate src/view_dir.c @ 380:5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
data.
Specific data is now in ViewDirInfoList and ViewDirInfoTree.
Type of directory view can be specified with enum DirViewType.
This is saved to rc file as layout.dir_view_type, which replace
layout.view_as_tree.
Code was modified to reflect these changes.
This is a first to move to merge common code of view_dir_list.c
and view_dir_tree.c and ease the introduction of new types
of directory view.
author | zas_ |
---|---|
date | Wed, 16 Apr 2008 14:45:22 +0000 |
parents | |
children | 499d7ba62261 |
rev | line source |
---|---|
380
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
1 /* |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
2 * Geeqie |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
3 * (C) 2008 Vladimir Nadvornik |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
4 * |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
5 * Author: Laurent Monin |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
6 * |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
7 * This software is released under the GNU General Public License (GNU GPL). |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
8 * Please read the included file COPYING for more information. |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
9 * This software comes with no warranty of any kind, use at your own risk! |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
10 */ |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
11 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
12 #include "main.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
13 #include "view_dir.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
14 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
15 #include "view_dir_list.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
16 #include "view_dir_tree.h" |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
17 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
18 GtkRadioActionEntry menu_view_dir_radio_entries[] = { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
19 { "FolderList", NULL, N_("List"), "<meta>L", NULL, DIRVIEW_LIST }, |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
20 { "FolderTree", NULL, N_("Tr_ee"), "<control>T", NULL, DIRVIEW_TREE }, |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
21 }; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
22 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
23 ViewDir *vd_new(DirViewType type, const gchar *path) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
24 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
25 ViewDir *vd = NULL; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
26 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
27 switch(type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
28 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
29 case DIRVIEW_LIST: vd = vdlist_new(path); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
30 case DIRVIEW_TREE: vd = vdtree_new(path); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
31 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
32 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
33 return vd; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
34 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
35 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
36 void vd_set_select_func(ViewDir *vd, |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
37 void (*func)(ViewDir *vd, const gchar *path, gpointer data), gpointer data) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
38 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
39 vd->select_func = func; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
40 vd->select_data = data; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
41 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
42 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
43 void vd_set_layout(ViewDir *vd, LayoutWindow *layout) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
44 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
45 vd->layout = layout; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
46 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
47 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
48 gint vd_set_path(ViewDir *vd, const gchar *path) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
49 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
50 gint ret = FALSE; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
51 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
52 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
53 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
54 case DIRVIEW_LIST: ret = vdlist_set_path(vd, path); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
55 case DIRVIEW_TREE: ret = vdtree_set_path(vd, path); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
56 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
57 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
58 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
59 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
60 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
61 void vd_refresh(ViewDir *vd) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
62 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
63 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
64 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
65 case DIRVIEW_LIST: return vdlist_refresh(vd); |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
66 case DIRVIEW_TREE: return vdtree_refresh(vd); |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
67 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
68 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
69 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
70 const gchar *vd_row_get_path(ViewDir *vd, gint row) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
71 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
72 const gchar *ret = NULL; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
73 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
74 switch(vd->type) |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
75 { |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
76 case DIRVIEW_LIST: ret = vdlist_row_get_path(vd, row); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
77 case DIRVIEW_TREE: ret = vdtree_row_get_path(vd, row); break; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
78 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
79 |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
80 return ret; |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
81 } |
5afe77bb563a
Introduce a new struct ViewDir to handle directory views common
zas_
parents:
diff
changeset
|
82 |