comparison src/layout.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 95fe470440ad
children 39369521e263
comparison
equal deleted inserted replaced
379:a430eb2e3c95 380:5afe77bb563a
18 #include "layout_util.h" 18 #include "layout_util.h"
19 #include "menu.h" 19 #include "menu.h"
20 #include "pixbuf-renderer.h" 20 #include "pixbuf-renderer.h"
21 #include "pixbuf_util.h" 21 #include "pixbuf_util.h"
22 #include "utilops.h" 22 #include "utilops.h"
23 #include "view_dir_list.h" 23 #include "view_dir.h"
24 #include "view_dir_tree.h"
25 #include "view_file_list.h" 24 #include "view_file_list.h"
26 #include "view_file_icon.h" 25 #include "view_file_icon.h"
27 #include "ui_bookmark.h" 26 #include "ui_bookmark.h"
28 #include "ui_fileops.h" 27 #include "ui_fileops.h"
29 #include "ui_menu.h" 28 #include "ui_menu.h"
168 layout_set_path(lw, buf); 167 layout_set_path(lw, buf);
169 168
170 g_free(buf); 169 g_free(buf);
171 } 170 }
172 171
173 static void layout_vdlist_select_cb(ViewDirList *vdl, const gchar *path, gpointer data) 172 static void layout_vd_select_cb(ViewDir *vd, const gchar *path, gpointer data)
174 {
175 LayoutWindow *lw = data;
176
177 layout_set_path(lw, path);
178 }
179
180 static void layout_vdtree_select_cb(ViewDirTree *vdt, const gchar *path, gpointer data)
181 { 173 {
182 LayoutWindow *lw = data; 174 LayoutWindow *lw = data;
183 175
184 layout_set_path(lw, path); 176 layout_set_path(lw, path);
185 } 177 }
207 gtk_widget_show(tabcomp); 199 gtk_widget_show(tabcomp);
208 200
209 g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed", 201 g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed",
210 G_CALLBACK(layout_path_entry_changed_cb), lw); 202 G_CALLBACK(layout_path_entry_changed_cb), lw);
211 203
212 if (lw->tree_view) 204 lw->vd = vd_new(lw->dir_view_type, lw->path);
213 { 205 vd_set_layout(lw->vd, lw);
214 lw->vdt = vdtree_new(lw->path, TRUE); 206 vd_set_select_func(lw->vd, layout_vd_select_cb, lw);
215 vdtree_set_layout(lw->vdt, lw); 207
216 vdtree_set_select_func(lw->vdt, layout_vdtree_select_cb, lw); 208 lw->dir_view = lw->vd->widget;
217
218 lw->dir_view = lw->vdt->widget;
219 }
220 else
221 {
222 lw->vdl = vdlist_new(lw->path);
223 vdlist_set_layout(lw->vdl, lw);
224 vdlist_set_select_func(lw->vdl, layout_vdlist_select_cb, lw);
225
226 lw->dir_view = lw->vdl->widget;
227 }
228 209
229 gtk_box_pack_start(GTK_BOX(box), lw->dir_view, TRUE, TRUE, 0); 210 gtk_box_pack_start(GTK_BOX(box), lw->dir_view, TRUE, TRUE, 0);
230 gtk_widget_show(lw->dir_view); 211 gtk_widget_show(lw->dir_view);
231 212
232 gtk_widget_show(box); 213 gtk_widget_show(box);
947 if (!lw->path) return; 928 if (!lw->path) return;
948 929
949 lw->last_time = filetime(lw->path); 930 lw->last_time = filetime(lw->path);
950 931
951 gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path); 932 gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path);
952 if (lw->vdl) vdlist_set_path(lw->vdl, lw->path); 933 vd_set_path(lw->vd, lw->path);
953 if (lw->vdt) vdtree_set_path(lw->vdt, lw->path);
954 934
955 if (lw->vfl) vflist_set_path(lw->vfl, lw->path); 935 if (lw->vfl) vflist_set_path(lw->vfl, lw->path);
956 if (lw->vfi) vficon_set_path(lw->vfi, lw->path); 936 if (lw->vfi) vficon_set_path(lw->vfi, lw->path);
957 } 937 }
958 938
1022 1002
1023 static void layout_refresh_lists(LayoutWindow *lw) 1003 static void layout_refresh_lists(LayoutWindow *lw)
1024 { 1004 {
1025 if (lw->path) lw->last_time = filetime(lw->path); 1005 if (lw->path) lw->last_time = filetime(lw->path);
1026 1006
1027 if (lw->vdl) vdlist_refresh(lw->vdl); 1007 vd_refresh(lw->vd);
1028 if (lw->vdt) vdtree_refresh(lw->vdt);
1029 1008
1030 if (lw->vfl) vflist_refresh(lw->vfl); 1009 if (lw->vfl) vflist_refresh(lw->vfl);
1031 if (lw->vfi) vficon_refresh(lw->vfi); 1010 if (lw->vfi) vficon_refresh(lw->vfi);
1032 } 1011 }
1033 1012
1161 } 1140 }
1162 1141
1163 return TRUE; 1142 return TRUE;
1164 } 1143 }
1165 1144
1166 void layout_views_set(LayoutWindow *lw, gint tree, gint icons) 1145 void layout_views_set(LayoutWindow *lw, DirViewType type, gint icons)
1167 { 1146 {
1168 if (!layout_valid(&lw)) return; 1147 if (!layout_valid(&lw)) return;
1169 1148
1170 if (lw->tree_view == tree && lw->icon_view == icons) return; 1149 if (lw->dir_view_type == type && lw->icon_view == icons) return;
1171 1150
1172 lw->tree_view = tree; 1151 lw->dir_view_type = type;
1173 lw->icon_view = icons; 1152 lw->icon_view = icons;
1174 1153
1175 layout_style_set(lw, -1, NULL); 1154 layout_style_set(lw, -1, NULL);
1176 } 1155 }
1177 1156
1178 gint layout_views_get(LayoutWindow *lw, gint *tree, gint *icons) 1157 gint layout_views_get(LayoutWindow *lw, DirViewType *type, gint *icons)
1179 { 1158 {
1180 if (!layout_valid(&lw)) return FALSE; 1159 if (!layout_valid(&lw)) return FALSE;
1181 1160
1182 *tree = lw->tree_view; 1161 *type = lw->dir_view_type;
1183 *icons = lw->icon_view; 1162 *icons = lw->icon_view;
1184 1163
1185 return TRUE; 1164 return TRUE;
1186 } 1165 }
1187 1166
1661 1640
1662 lw->toolbar = NULL; 1641 lw->toolbar = NULL;
1663 lw->thumb_button = NULL; 1642 lw->thumb_button = NULL;
1664 lw->path_entry = NULL; 1643 lw->path_entry = NULL;
1665 lw->dir_view = NULL; 1644 lw->dir_view = NULL;
1666 lw->vdl = NULL; 1645 lw->vd = NULL;
1667 lw->vdt = NULL;
1668 1646
1669 lw->file_view = NULL; 1647 lw->file_view = NULL;
1670 lw->vfl = NULL; 1648 lw->vfl = NULL;
1671 lw->vfi = NULL; 1649 lw->vfi = NULL;
1672 1650
1917 1895
1918 /* default layout */ 1896 /* default layout */
1919 1897
1920 layout_config_parse(options->layout.style, options->layout.order, 1898 layout_config_parse(options->layout.style, options->layout.order,
1921 &lw->dir_location, &lw->file_location, &lw->image_location); 1899 &lw->dir_location, &lw->file_location, &lw->image_location);
1922 lw->tree_view = options->layout.view_as_tree; 1900 lw->dir_view_type = options->layout.dir_view_type;
1923 lw->icon_view = options->layout.view_as_icons; 1901 lw->icon_view = options->layout.view_as_icons;
1924 1902
1925 /* divider positions */ 1903 /* divider positions */
1926 1904
1927 if (options->layout.save_window_positions) 1905 if (options->layout.save_window_positions)