Mercurial > geeqie.yaz
changeset 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 | a430eb2e3c95 |
children | ff63dcb0425c |
files | src/Makefile.am src/globals.c src/layout.c src/layout.h src/layout_util.c src/main.c src/rcfile.c src/typedefs.h src/view_dir.c src/view_dir.h src/view_dir_list.c src/view_dir_list.h src/view_dir_tree.c src/view_dir_tree.h src/view_file_icon.c src/view_file_list.c |
diffstat | 16 files changed, 467 insertions(+), 401 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Makefile.am Tue Apr 15 21:49:28 2008 +0000 +++ b/src/Makefile.am Wed Apr 16 14:45:22 2008 +0000 @@ -168,6 +168,8 @@ thumb_standard.h \ utilops.c \ utilops.h \ + view_dir.c \ + view_dir.h \ view_dir_list.c \ view_dir_list.h \ view_dir_tree.c \
--- a/src/globals.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/globals.c Wed Apr 16 14:45:22 2008 +0000 @@ -118,7 +118,7 @@ options->layout.style = 0; options->layout.view_as_icons = FALSE; - options->layout.view_as_tree = FALSE; + options->layout.dir_view_type = DIRVIEW_LIST; options->show_icon_names = TRUE;
--- a/src/layout.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/layout.c Wed Apr 16 14:45:22 2008 +0000 @@ -20,8 +20,7 @@ #include "pixbuf-renderer.h" #include "pixbuf_util.h" #include "utilops.h" -#include "view_dir_list.h" -#include "view_dir_tree.h" +#include "view_dir.h" #include "view_file_list.h" #include "view_file_icon.h" #include "ui_bookmark.h" @@ -170,14 +169,7 @@ g_free(buf); } -static void layout_vdlist_select_cb(ViewDirList *vdl, const gchar *path, gpointer data) -{ - LayoutWindow *lw = data; - - layout_set_path(lw, path); -} - -static void layout_vdtree_select_cb(ViewDirTree *vdt, const gchar *path, gpointer data) +static void layout_vd_select_cb(ViewDir *vd, const gchar *path, gpointer data) { LayoutWindow *lw = data; @@ -209,22 +201,11 @@ g_signal_connect(G_OBJECT(lw->path_entry->parent), "changed", G_CALLBACK(layout_path_entry_changed_cb), lw); - if (lw->tree_view) - { - lw->vdt = vdtree_new(lw->path, TRUE); - vdtree_set_layout(lw->vdt, lw); - vdtree_set_select_func(lw->vdt, layout_vdtree_select_cb, lw); + lw->vd = vd_new(lw->dir_view_type, lw->path); + vd_set_layout(lw->vd, lw); + vd_set_select_func(lw->vd, layout_vd_select_cb, lw); - lw->dir_view = lw->vdt->widget; - } - else - { - lw->vdl = vdlist_new(lw->path); - vdlist_set_layout(lw->vdl, lw); - vdlist_set_select_func(lw->vdl, layout_vdlist_select_cb, lw); - - lw->dir_view = lw->vdl->widget; - } + lw->dir_view = lw->vd->widget; gtk_box_pack_start(GTK_BOX(box), lw->dir_view, TRUE, TRUE, 0); gtk_widget_show(lw->dir_view); @@ -949,8 +930,7 @@ lw->last_time = filetime(lw->path); gtk_entry_set_text(GTK_ENTRY(lw->path_entry), lw->path); - if (lw->vdl) vdlist_set_path(lw->vdl, lw->path); - if (lw->vdt) vdtree_set_path(lw->vdt, lw->path); + vd_set_path(lw->vd, lw->path); if (lw->vfl) vflist_set_path(lw->vfl, lw->path); if (lw->vfi) vficon_set_path(lw->vfi, lw->path); @@ -1024,8 +1004,7 @@ { if (lw->path) lw->last_time = filetime(lw->path); - if (lw->vdl) vdlist_refresh(lw->vdl); - if (lw->vdt) vdtree_refresh(lw->vdt); + vd_refresh(lw->vd); if (lw->vfl) vflist_refresh(lw->vfl); if (lw->vfi) vficon_refresh(lw->vfi); @@ -1163,23 +1142,23 @@ return TRUE; } -void layout_views_set(LayoutWindow *lw, gint tree, gint icons) +void layout_views_set(LayoutWindow *lw, DirViewType type, gint icons) { if (!layout_valid(&lw)) return; - if (lw->tree_view == tree && lw->icon_view == icons) return; + if (lw->dir_view_type == type && lw->icon_view == icons) return; - lw->tree_view = tree; + lw->dir_view_type = type; lw->icon_view = icons; layout_style_set(lw, -1, NULL); } -gint layout_views_get(LayoutWindow *lw, gint *tree, gint *icons) +gint layout_views_get(LayoutWindow *lw, DirViewType *type, gint *icons) { if (!layout_valid(&lw)) return FALSE; - *tree = lw->tree_view; + *type = lw->dir_view_type; *icons = lw->icon_view; return TRUE; @@ -1663,8 +1642,7 @@ lw->thumb_button = NULL; lw->path_entry = NULL; lw->dir_view = NULL; - lw->vdl = NULL; - lw->vdt = NULL; + lw->vd = NULL; lw->file_view = NULL; lw->vfl = NULL; @@ -1919,7 +1897,7 @@ layout_config_parse(options->layout.style, options->layout.order, &lw->dir_location, &lw->file_location, &lw->image_location); - lw->tree_view = options->layout.view_as_tree; + lw->dir_view_type = options->layout.dir_view_type; lw->icon_view = options->layout.view_as_icons; /* divider positions */
--- a/src/layout.h Tue Apr 15 21:49:28 2008 +0000 +++ b/src/layout.h Wed Apr 16 14:45:22 2008 +0000 @@ -66,8 +66,8 @@ gint layout_geometry_get(LayoutWindow *lw, gint *x, gint *y, gint *w, gint *h); gint layout_geometry_get_dividers(LayoutWindow *lw, gint *h, gint *v); -void layout_views_set(LayoutWindow *lw, gint tree, gint icons); -gint layout_views_get(LayoutWindow *lw, gint *tree, gint *icons); +void layout_views_set(LayoutWindow *lw, DirViewType type, gint icons); +gint layout_views_get(LayoutWindow *lw, DirViewType *type, gint *icons); void layout_status_update(LayoutWindow *lw, const gchar *text);
--- a/src/layout_util.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/layout_util.c Wed Apr 16 14:45:22 2008 +0000 @@ -37,6 +37,7 @@ #include "ui_menu.h" #include "ui_misc.h" #include "ui_tabcomp.h" +#include "view_dir.h" #include <gdk/gdkkeysyms.h> /* for keyboard values */ @@ -91,9 +92,9 @@ return TRUE; } } - if (lw->vdt && GTK_WIDGET_HAS_FOCUS(lw->vdt->treeview) && + if (lw->vd && lw->dir_view_type == DIRVIEW_TREE && GTK_WIDGET_HAS_FOCUS(lw->vd->view) && !layout_key_match(event->keyval) && - gtk_widget_event(lw->vdt->treeview, (GdkEvent *)event)) + gtk_widget_event(lw->vd->view, (GdkEvent *)event)) { return TRUE; } @@ -562,16 +563,16 @@ if (lw->full_screen) layout_image_full_screen_stop(lw); - layout_views_set(lw, lw->tree_view, (gtk_radio_action_get_current_value(action) == 1)); + layout_views_set(lw, lw->dir_view_type, (gtk_radio_action_get_current_value(action) == 1)); } -static void layout_menu_tree_cb(GtkToggleAction *action, gpointer data) +static void layout_menu_view_dir_as_cb(GtkRadioAction *action, GtkRadioAction *current, gpointer data) { LayoutWindow *lw = data; if (lw->full_screen) layout_image_full_screen_stop(lw); - layout_views_set(lw, gtk_toggle_action_get_active(action), lw->icon_view); + layout_views_set(lw, (DirViewType) gtk_radio_action_get_current_value(action), lw->icon_view); } static void layout_menu_view_in_new_window_cb(GtkAction *action, gpointer data) @@ -1051,6 +1052,7 @@ { "SelectMenu", NULL, N_("_Select") }, { "AdjustMenu", NULL, N_("_Adjust") }, { "ViewMenu", NULL, N_("_View") }, + { "DirMenu", NULL, N_("_View Directory as") }, { "ZoomMenu", NULL, N_("_Zoom") }, { "SplitMenu", NULL, N_("_Split") }, { "HelpMenu", NULL, N_("_Help") }, @@ -1133,7 +1135,6 @@ static GtkToggleActionEntry menu_toggle_entries[] = { { "Thumbnails", NULL, N_("_Thumbnails"), "T", NULL, CB(layout_menu_thumb_cb) }, { "ShowMarks", NULL, N_("Show _Marks"), "M", NULL, CB(layout_menu_marks_cb) }, - { "FolderTree", NULL, N_("Tr_ee"), "<control>T", NULL, CB(layout_menu_tree_cb) }, { "FloatTools", NULL, N_("_Float file list"), "L", NULL, CB(layout_menu_float_cb) }, { "HideToolbar", NULL, N_("Hide tool_bar"), NULL, NULL, CB(layout_menu_toolbar_cb) }, { "SBarKeywords", NULL, N_("_Keywords"), "<control>K", NULL, CB(layout_menu_bar_info_cb) }, @@ -1155,6 +1156,7 @@ { "SplitSingle", NULL, N_("Single"), "Y", NULL, SPLIT_NONE } }; + #undef CB static const char *menu_ui_description = @@ -1252,7 +1254,11 @@ " <menuitem action='ViewList'/>" " <menuitem action='ViewIcons'/>" " <separator/>" -" <menuitem action='FolderTree'/>" +" <menu action='DirMenu'>" +" <menuitem action='FolderList'/>" +" <menuitem action='FolderTree'/>" +" </menu>" +" <separator/>" " <menuitem action='ImageOverlay'/>" " <menuitem action='HistogramChan'/>" " <menuitem action='HistogramLog'/>" @@ -1373,6 +1379,9 @@ gtk_action_group_add_radio_actions(lw->action_group, menu_split_radio_entries, G_N_ELEMENTS(menu_split_radio_entries), 0, G_CALLBACK(layout_menu_split_cb), lw); + gtk_action_group_add_radio_actions(lw->action_group, + menu_view_dir_radio_entries, G_N_ELEMENTS(menu_view_dir_radio_entries), + 0, G_CALLBACK(layout_menu_view_dir_as_cb), lw); lw->ui_manager = gtk_ui_manager_new(); gtk_ui_manager_set_add_tearoffs(lw->ui_manager, TRUE); @@ -1534,7 +1543,7 @@ if (!lw->action_group) return; action = gtk_action_group_get_action(lw->action_group, "FolderTree"); - gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->tree_view); + gtk_radio_action_set_current_value(GTK_RADIO_ACTION(action), lw->dir_view_type); action = gtk_action_group_get_action(lw->action_group, "ViewIcons"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), lw->icon_view);
--- a/src/main.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/main.c Wed Apr 16 14:45:22 2008 +0000 @@ -1237,7 +1237,7 @@ layout_geometry_get_dividers(NULL, &options->layout.main_window.hdivider_pos, &options->layout.main_window.vdivider_pos); - layout_views_get(NULL, &options->layout.view_as_tree, &options->layout.view_as_icons); + layout_views_get(NULL, &options->layout.dir_view_type, &options->layout.view_as_icons); options->layout.show_thumbnails = layout_thumb_get(NULL); layout_sort_get(NULL, &options->file_sort.method, &options->file_sort.ascending);
--- a/src/rcfile.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/rcfile.c Wed Apr 16 14:45:22 2008 +0000 @@ -167,6 +167,11 @@ } } +static void write_uint_option(SecureSaveInfo *ssi, gchar *label, guint n) +{ + secure_fprintf(ssi, "%s: %u\n", label, n); +} + static void read_uint_option(FILE *f, gchar *option, gchar *label, gchar *value, guint *n) { if (n && strcasecmp(option, label) == 0) @@ -280,6 +285,7 @@ #define WRITE_BOOL(_name_) write_bool_option(ssi, #_name_, options->_name_) #define WRITE_INT(_name_) write_int_option(ssi, #_name_, options->_name_) +#define WRITE_UINT(_name_) write_uint_option(ssi, #_name_, options->_name_) #define WRITE_INT_UNIT(_name_, _unit_) write_int_unit_option(ssi, #_name_, options->_name_, _unit_) #define WRITE_CHAR(_name_) write_char_option(ssi, #_name_, options->_name_) #define WRITE_COLOR(_name_) write_color_option(ssi, #_name_, &options->_name_) @@ -335,7 +341,7 @@ WRITE_INT(layout.style); WRITE_CHAR(layout.order); WRITE_BOOL(layout.view_as_icons); - WRITE_BOOL(layout.view_as_tree); + WRITE_UINT(layout.dir_view_type); WRITE_BOOL(layout.show_thumbnails); WRITE_SEPARATOR(); @@ -619,7 +625,7 @@ READ_INT(layout.style); READ_CHAR(layout.order); READ_BOOL(layout.view_as_icons); - READ_BOOL(layout.view_as_tree); + READ_UINT(layout.dir_view_type); READ_BOOL(layout.show_thumbnails); /* window positions */
--- a/src/typedefs.h Tue Apr 15 21:49:28 2008 +0000 +++ b/src/typedefs.h Wed Apr 16 14:45:22 2008 +0000 @@ -14,6 +14,11 @@ #define TYPEDEFS_H typedef enum { + DIRVIEW_LIST, + DIRVIEW_TREE +} DirViewType; + +typedef enum { CMD_COPY = GQ_EDITOR_GENERIC_SLOTS, CMD_MOVE, CMD_RENAME, @@ -128,8 +133,9 @@ typedef struct _FileDataChangeInfo FileDataChangeInfo; typedef struct _LayoutWindow LayoutWindow; -typedef struct _ViewDirList ViewDirList; -typedef struct _ViewDirTree ViewDirTree; +typedef struct _ViewDir ViewDir; +typedef struct _ViewDirInfoList ViewDirInfoList; +typedef struct _ViewDirInfoTree ViewDirInfoTree; typedef struct _ViewFileList ViewFileList; typedef struct _ViewFileIcon ViewFileIcon; @@ -456,11 +462,10 @@ LayoutLocation dir_location; - ViewDirList *vdl; - ViewDirTree *vdt; + ViewDir *vd; GtkWidget *dir_view; - gint tree_view; + DirViewType dir_view_type; /* file view */ @@ -521,36 +526,11 @@ gint bar_exif_advanced; }; -struct _ViewDirList +struct _ViewDir { + DirViewType type; GtkWidget *widget; - GtkWidget *listview; - - gchar *path; - GList *list; - - FileData *click_fd; - - FileData *drop_fd; - GList *drop_list; - - gint drop_scroll_id; - - /* func list */ - void (*select_func)(ViewDirList *vdl, const gchar *path, gpointer data); - gpointer select_data; - - LayoutWindow *layout; - - GtkWidget *popup; - - PixmapFolders *pf; -}; - -struct _ViewDirTree -{ - GtkWidget *widget; - GtkWidget *treeview; + GtkWidget *view; gchar *path; @@ -558,12 +538,10 @@ FileData *drop_fd; GList *drop_list; - gint drop_scroll_id; - gint drop_expand_id; /* func list */ - void (*select_func)(ViewDirTree *vdt, const gchar *path, gpointer data); + void (*select_func)(ViewDir *vd, const gchar *path, gpointer data); gpointer select_data; LayoutWindow *layout; @@ -572,6 +550,17 @@ PixmapFolders *pf; + gpointer info; +}; + +struct _ViewDirInfoList +{ + GList *list; +}; + +struct _ViewDirInfoTree +{ + gint drop_expand_id; gint busy_ref; }; @@ -845,7 +834,7 @@ gint style; gint view_as_icons; - gint view_as_tree; + DirViewType dir_view_type; gint show_thumbnails;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/view_dir.c Wed Apr 16 14:45:22 2008 +0000 @@ -0,0 +1,82 @@ +/* + * Geeqie + * (C) 2008 Vladimir Nadvornik + * + * Author: Laurent Monin + * + * This software is released under the GNU General Public License (GNU GPL). + * Please read the included file COPYING for more information. + * This software comes with no warranty of any kind, use at your own risk! + */ + +#include "main.h" +#include "view_dir.h" + +#include "view_dir_list.h" +#include "view_dir_tree.h" + +GtkRadioActionEntry menu_view_dir_radio_entries[] = { + { "FolderList", NULL, N_("List"), "<meta>L", NULL, DIRVIEW_LIST }, + { "FolderTree", NULL, N_("Tr_ee"), "<control>T", NULL, DIRVIEW_TREE }, +}; + +ViewDir *vd_new(DirViewType type, const gchar *path) +{ + ViewDir *vd = NULL; + + switch(type) + { + case DIRVIEW_LIST: vd = vdlist_new(path); break; + case DIRVIEW_TREE: vd = vdtree_new(path); break; + } + + return vd; +} + +void vd_set_select_func(ViewDir *vd, + void (*func)(ViewDir *vd, const gchar *path, gpointer data), gpointer data) +{ + vd->select_func = func; + vd->select_data = data; +} + +void vd_set_layout(ViewDir *vd, LayoutWindow *layout) +{ + vd->layout = layout; +} + +gint vd_set_path(ViewDir *vd, const gchar *path) +{ + gint ret = FALSE; + + switch(vd->type) + { + case DIRVIEW_LIST: ret = vdlist_set_path(vd, path); break; + case DIRVIEW_TREE: ret = vdtree_set_path(vd, path); break; + } + + return ret; +} + +void vd_refresh(ViewDir *vd) +{ + switch(vd->type) + { + case DIRVIEW_LIST: return vdlist_refresh(vd); + case DIRVIEW_TREE: return vdtree_refresh(vd); + } +} + +const gchar *vd_row_get_path(ViewDir *vd, gint row) +{ + const gchar *ret = NULL; + + switch(vd->type) + { + case DIRVIEW_LIST: ret = vdlist_row_get_path(vd, row); break; + case DIRVIEW_TREE: ret = vdtree_row_get_path(vd, row); break; + } + + return ret; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/view_dir.h Wed Apr 16 14:45:22 2008 +0000 @@ -0,0 +1,39 @@ +/* + * Geeqie + * (C) 2008 Vladimir Nadvornik + * + * Author: Laurent Monin + * + * This software is released under the GNU General Public License (GNU GPL). + * Please read the included file COPYING for more information. + * This software comes with no warranty of any kind, use at your own risk! + */ + +#ifndef VIEW_DIR_H +#define VIEW_DIR_H + +enum { + DIR_COLUMN_POINTER = 0, + DIR_COLUMN_ICON, + DIR_COLUMN_NAME, + DIR_COLUMN_COLOR, + DIR_COLUMN_COUNT +}; + +extern GtkRadioActionEntry menu_view_dir_radio_entries[2]; + +ViewDir *vd_new(DirViewType type, const gchar *path); + +void vd_set_select_func(ViewDir *vdl, void (*func)(ViewDir *vdl, const gchar *path, gpointer data), gpointer data); + +void vd_set_layout(ViewDir *vdl, LayoutWindow *layout); + +gint vd_set_path(ViewDir *vdl, const gchar *path); +void vd_refresh(ViewDir *vdl); + +const gchar *vd_row_get_path(ViewDir *vdl, gint row); + + +#endif + +
--- a/src/view_dir_list.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/view_dir_list.c Wed Apr 16 14:45:22 2008 +0000 @@ -23,20 +23,14 @@ #include "ui_fileops.h" #include "ui_menu.h" #include "ui_tree_edit.h" +#include "view_dir.h" #include <gdk/gdkkeysyms.h> /* for keyboard values */ #define VDLIST_PAD 4 - -enum { - DIR_COLUMN_POINTER = 0, - DIR_COLUMN_ICON, - DIR_COLUMN_NAME, - DIR_COLUMN_COLOR, - DIR_COLUMN_COUNT -}; +#define VDLIST_INFO(_vd_, _part_) (((ViewDirInfoList *)(_vd_->info))->_part_) static void vdlist_popup_destroy_cb(GtkWidget *widget, gpointer data); @@ -48,13 +42,13 @@ *----------------------------------------------------------------------------- */ -static gint vdlist_find_row(ViewDirList *vdl, FileData *fd, GtkTreeIter *iter) +static gint vdlist_find_row(ViewDir *vdl, FileData *fd, GtkTreeIter *iter) { GtkTreeModel *store; gint valid; gint row = 0; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); valid = gtk_tree_model_get_iter_first(store, iter); while (valid) { @@ -71,7 +65,7 @@ static gint vdlist_rename_row_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GtkTreeModel *store; GtkTreeIter iter; FileData *fd; @@ -79,7 +73,7 @@ gchar *new_path; gchar *base; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); if (!gtk_tree_model_get_iter(store, &iter, td->path)) return FALSE; gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); if (!fd) return FALSE; @@ -90,7 +84,7 @@ new_path = concat_dir_and_file(base, new); g_free(base); - if (file_util_rename_dir(fd, new_path, vdl->listview)) + if (file_util_rename_dir(fd, new_path, vdl->view)) { if (vdl->layout && strcmp(vdl->path, old_path) == 0) { @@ -107,22 +101,22 @@ return FALSE; } -static void vdlist_rename_by_row(ViewDirList *vdl, FileData *fd) +static void vdlist_rename_by_row(ViewDir *vdl, FileData *fd) { GtkTreeModel *store; GtkTreePath *tpath; GtkTreeIter iter; if (vdlist_find_row(vdl, fd, &iter) < 0) return; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); tpath = gtk_tree_model_get_path(store, &iter); - tree_edit_by_path(GTK_TREE_VIEW(vdl->listview), tpath, 0, fd->name, + tree_edit_by_path(GTK_TREE_VIEW(vdl->view), tpath, 0, fd->name, vdlist_rename_row_cb, vdl); gtk_tree_path_free(tpath); } -static FileData *vdlist_row_by_path(ViewDirList *vdl, const gchar *path, gint *row) +static FileData *vdlist_row_by_path(ViewDir *vdl, const gchar *path, gint *row) { GList *work; gint n; @@ -134,7 +128,7 @@ } n = 0; - work = vdl->list; + work = VDLIST_INFO(vdl, list); while (work) { FileData *fd = work->data; @@ -151,13 +145,13 @@ return NULL; } -static void vdlist_color_set(ViewDirList *vdl, FileData *fd, gint color_set) +static void vdlist_color_set(ViewDir *vdl, FileData *fd, gint color_set) { GtkTreeModel *store; GtkTreeIter iter; if (vdlist_find_row(vdl, fd, &iter) < 0) return; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); gtk_list_store_set(GTK_LIST_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1); } @@ -169,7 +163,7 @@ static void vdlist_drop_menu_copy_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; const gchar *path; GList *list; @@ -184,7 +178,7 @@ static void vdlist_drop_menu_move_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; const gchar *path; GList *list; @@ -198,7 +192,7 @@ file_util_move_simple(list, path); } -static GtkWidget *vdlist_drop_menu(ViewDirList *vdl, gint active) +static GtkWidget *vdlist_drop_menu(ViewDir *vdl, gint active) { GtkWidget *menu; @@ -224,7 +218,7 @@ static void vdlist_pop_menu_up_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; gchar *path; if (!vdl->path || strcmp(vdl->path, "/") == 0) return; @@ -240,7 +234,7 @@ static void vdlist_pop_menu_slide_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; gchar *path; if (!vdl->layout || !vdl->click_fd) return; @@ -257,7 +251,7 @@ static void vdlist_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; gchar *path; GList *list; @@ -273,7 +267,7 @@ g_free(path); } -static void vdlist_pop_menu_dupe(ViewDirList *vdl, gint recursive) +static void vdlist_pop_menu_dupe(ViewDir *vdl, gint recursive) { DupeWindow *dw; GList *list = NULL; @@ -298,19 +292,19 @@ static void vdlist_pop_menu_dupe_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; vdlist_pop_menu_dupe(vdl, FALSE); } static void vdlist_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; vdlist_pop_menu_dupe(vdl, TRUE); } static void vdlist_pop_menu_new_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; gchar *new_path; gchar *buf; @@ -326,7 +320,7 @@ gchar *text; text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path); - file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vdl->listview); + file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vdl->view); g_free(text); } else @@ -344,42 +338,42 @@ static void vdlist_pop_menu_rename_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; vdlist_rename_by_row(vdl, vdl->click_fd); } static void vdlist_pop_menu_delete_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; if (!vdl->click_fd) return; file_util_delete_dir(vdl->click_fd, vdl->widget); } -static void vdlist_pop_menu_tree_cb(GtkWidget *widget, gpointer data) +static void vdlist_pop_menu_dir_view_as_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; - if (vdl->layout) layout_views_set(vdl->layout, TRUE, vdl->layout->icon_view); + if (vdl->layout) layout_views_set(vdl->layout, DIRVIEW_TREE, vdl->layout->icon_view); } static void vdlist_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; if (vdl->layout) layout_refresh(vdl->layout); } static void vdlist_toggle_show_hidden_files_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; options->file_filter.show_hidden_files = !options->file_filter.show_hidden_files; if (vdl->layout) layout_refresh(vdl->layout); } -static GtkWidget *vdlist_pop_menu(ViewDirList *vdl, FileData *fd) +static GtkWidget *vdlist_pop_menu(ViewDir *vdl, FileData *fd) { GtkWidget *menu; gint active; @@ -425,7 +419,7 @@ menu_item_add_divider(menu); menu_item_add_check(menu, _("View as _tree"), FALSE, - G_CALLBACK(vdlist_pop_menu_tree_cb), vdl); + G_CALLBACK(vdlist_pop_menu_dir_view_as_cb), vdl); menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files, G_CALLBACK(vdlist_toggle_show_hidden_files_cb), vdl); @@ -437,7 +431,7 @@ static void vdlist_popup_destroy_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; vdlist_color_set(vdl, vdl->click_fd, FALSE); vdl->click_fd = NULL; @@ -460,18 +454,18 @@ }; static gint vdlist_dnd_drop_types_count = 1; -static void vdlist_dest_set(ViewDirList *vdl, gint enable) +static void vdlist_dest_set(ViewDir *vdl, gint enable) { if (enable) { - gtk_drag_dest_set(vdl->listview, + gtk_drag_dest_set(vdl->view, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, vdlist_dnd_drop_types, vdlist_dnd_drop_types_count, GDK_ACTION_MOVE | GDK_ACTION_COPY); } else { - gtk_drag_dest_unset(vdl->listview); + gtk_drag_dest_unset(vdl->view); } } @@ -479,7 +473,7 @@ GtkSelectionData *selection_data, guint info, guint time, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GList *list; gchar *text = NULL; gint length = 0; @@ -505,7 +499,7 @@ static void vdlist_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; vdlist_color_set(vdl, vdl->click_fd, TRUE); vdlist_dest_set(vdl, FALSE); @@ -513,7 +507,7 @@ static void vdlist_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; vdlist_color_set(vdl, vdl->click_fd, FALSE); @@ -529,7 +523,7 @@ GtkSelectionData *selection_data, guint info, guint time, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; @@ -569,7 +563,7 @@ } #if 0 -static gint vdlist_get_row_visibility(ViewDirList *vdl, FileData *fd) +static gint vdlist_get_row_visibility(ViewDir *vdl, FileData *fd) { GtkTreeModel *store; GtkTreeViewColumn *column; @@ -581,12 +575,12 @@ if (!fd || vdlist_find_row(vdl, fd, &iter) < 0) return 0; - column = gtk_tree_view_get_column(GTK_TREE_VIEW(vdl->listview), 0); - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + column = gtk_tree_view_get_column(GTK_TREE_VIEW(vdl->view), 0); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); tpath = gtk_tree_model_get_path(store, &iter); - gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(vdl->listview), &vrect); - gtk_tree_view_get_cell_area(GTK_TREE_VIEW(vdl->listview), tpath, column, &crect); + gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(vdl->view), &vrect); + gtk_tree_view_get_cell_area(GTK_TREE_VIEW(vdl->view), tpath, column, &crect); printf("window: %d + %d; cell: %d + %d\n", vrect.y, vrect.height, crect.y, crect.height); gtk_tree_path_free(tpath); @@ -596,38 +590,38 @@ } #endif -static void vdlist_scroll_to_row(ViewDirList *vdl, FileData *fd, gfloat y_align) +static void vdlist_scroll_to_row(ViewDir *vdl, FileData *fd, gfloat y_align) { GtkTreeIter iter; - if (GTK_WIDGET_REALIZED(vdl->listview) && + if (GTK_WIDGET_REALIZED(vdl->view) && vdlist_find_row(vdl, fd, &iter) >= 0) { GtkTreeModel *store; GtkTreePath *tpath; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); tpath = gtk_tree_model_get_path(store, &iter); - gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vdl->listview), tpath, NULL, TRUE, y_align, 0.0); - gtk_tree_view_set_cursor(GTK_TREE_VIEW(vdl->listview), tpath, NULL, FALSE); + gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(vdl->view), tpath, NULL, TRUE, y_align, 0.0); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(vdl->view), tpath, NULL, FALSE); gtk_tree_path_free(tpath); - if (!GTK_WIDGET_HAS_FOCUS(vdl->listview)) gtk_widget_grab_focus(vdl->listview); + if (!GTK_WIDGET_HAS_FOCUS(vdl->view)) gtk_widget_grab_focus(vdl->view); } } -static void vdlist_drop_update(ViewDirList *vdl, gint x, gint y) +static void vdlist_drop_update(ViewDir *vdl, gint x, gint y) { GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; - if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vdl->listview), x, y, + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vdl->view), x, y, &tpath, NULL, NULL, NULL)) { GtkTreeModel *store; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); gtk_tree_model_get_iter(store, &iter, tpath); gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1); gtk_tree_path_free(tpath); @@ -642,7 +636,7 @@ vdl->drop_fd = fd; } -static void vdlist_dnd_drop_scroll_cancel(ViewDirList *vdl) +static void vdlist_dnd_drop_scroll_cancel(ViewDir *vdl) { if (vdl->drop_scroll_id != -1) g_source_remove(vdl->drop_scroll_id); vdl->drop_scroll_id = -1; @@ -650,7 +644,7 @@ static gint vdlist_auto_scroll_idle_cb(gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; if (vdl->drop_fd) { @@ -658,7 +652,7 @@ gint x, y; gint w, h; - window = vdl->listview->window; + window = vdl->view->window; gdk_window_get_pointer(window, &x, &y, NULL); gdk_drawable_get_size(window, &w, &h); if (x >= 0 && x < w && y >= 0 && y < h) @@ -673,7 +667,7 @@ static gint vdlist_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; if (!vdl->drop_fd || vdl->drop_list) return FALSE; @@ -685,11 +679,11 @@ static gint vdlist_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; vdl->click_fd = NULL; - if (gtk_drag_get_source_widget(context) == vdl->listview) + if (gtk_drag_get_source_widget(context) == vdl->view) { /* from same window */ gdk_drag_status(context, 0, time); @@ -704,8 +698,8 @@ if (vdl->drop_fd) { - GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdl->listview)); - widget_auto_scroll_start(vdl->listview, adj, -1, -1, vdlist_auto_scroll_notify_cb, vdl); + GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdl->view)); + widget_auto_scroll_start(vdl->view, adj, -1, -1, vdlist_auto_scroll_notify_cb, vdl); } return FALSE; @@ -713,31 +707,31 @@ static void vdlist_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; if (vdl->drop_fd != vdl->click_fd) vdlist_color_set(vdl, vdl->drop_fd, FALSE); vdl->drop_fd = NULL; } -static void vdlist_dnd_init(ViewDirList *vdl) +static void vdlist_dnd_init(ViewDir *vdl) { - gtk_drag_source_set(vdl->listview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, + gtk_drag_source_set(vdl->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, dnd_file_drag_types, dnd_file_drag_types_count, GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK); - g_signal_connect(G_OBJECT(vdl->listview), "drag_data_get", + g_signal_connect(G_OBJECT(vdl->view), "drag_data_get", G_CALLBACK(vdlist_dnd_get), vdl); - g_signal_connect(G_OBJECT(vdl->listview), "drag_begin", + g_signal_connect(G_OBJECT(vdl->view), "drag_begin", G_CALLBACK(vdlist_dnd_begin), vdl); - g_signal_connect(G_OBJECT(vdl->listview), "drag_end", + g_signal_connect(G_OBJECT(vdl->view), "drag_end", G_CALLBACK(vdlist_dnd_end), vdl); vdlist_dest_set(vdl, TRUE); - g_signal_connect(G_OBJECT(vdl->listview), "drag_data_received", + g_signal_connect(G_OBJECT(vdl->view), "drag_data_received", G_CALLBACK(vdlist_dnd_drop_receive), vdl); - g_signal_connect(G_OBJECT(vdl->listview), "drag_motion", + g_signal_connect(G_OBJECT(vdl->view), "drag_motion", G_CALLBACK(vdlist_dnd_drop_motion), vdl); - g_signal_connect(G_OBJECT(vdl->listview), "drag_leave", + g_signal_connect(G_OBJECT(vdl->view), "drag_leave", G_CALLBACK(vdlist_dnd_drop_leave), vdl); } @@ -747,7 +741,7 @@ *----------------------------------------------------------------------------- */ -static void vdlist_select_row(ViewDirList *vdl, FileData *fd) +static void vdlist_select_row(ViewDir *vdl, FileData *fd) { if (fd && vdl->select_func) { @@ -759,26 +753,26 @@ } } -const gchar *vdlist_row_get_path(ViewDirList *vdl, gint row) +const gchar *vdlist_row_get_path(ViewDir *vdl, gint row) { FileData *fd; - fd = g_list_nth_data(vdl->list, row); + fd = g_list_nth_data(VDLIST_INFO(vdl, list), row); if (fd) return fd->path; return NULL; } -static void vdlist_populate(ViewDirList *vdl) +static void vdlist_populate(ViewDir *vdl) { GtkListStore *store; GList *work; - store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview))); + store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view))); gtk_list_store_clear(store); - work = vdl->list; + work = VDLIST_INFO(vdl, list); while (work) { FileData *fd; @@ -820,7 +814,7 @@ vdl->drop_fd = NULL; } -gint vdlist_set_path(ViewDirList *vdl, const gchar *path) +gint vdlist_set_path(ViewDir *vdl, const gchar *path) { gint ret; FileData *fd; @@ -845,12 +839,12 @@ g_free(vdl->path); vdl->path = g_strdup(path); - filelist_free(vdl->list); - vdl->list = NULL; + filelist_free(VDLIST_INFO(vdl, list)); + VDLIST_INFO(vdl, list) = NULL; - ret = filelist_read(vdl->path, NULL, &vdl->list); + ret = filelist_read(vdl->path, NULL, &VDLIST_INFO(vdl, list)); - vdl->list = filelist_sort(vdl->list, SORT_NAME, TRUE); + VDLIST_INFO(vdl, list) = filelist_sort(VDLIST_INFO(vdl, list), SORT_NAME, TRUE); /* add . and .. */ @@ -858,7 +852,7 @@ { filepath = g_strconcat(vdl->path, "/", "..", NULL); fd = file_data_new_simple(filepath); - vdl->list = g_list_prepend(vdl->list, fd); + VDLIST_INFO(vdl, list) = g_list_prepend(VDLIST_INFO(vdl, list), fd); g_free(filepath); } @@ -866,7 +860,7 @@ { filepath = g_strconcat(vdl->path, "/", ".", NULL); fd = file_data_new_simple(filepath); - vdl->list = g_list_prepend(vdl->list, fd); + VDLIST_INFO(vdl, list) = g_list_prepend(VDLIST_INFO(vdl, list), fd); g_free(filepath); } @@ -878,7 +872,7 @@ FileData *found = NULL; GList *work; - work = vdl->list; + work = VDLIST_INFO(vdl, list); while (work && !found) { FileData *fd = work->data; @@ -892,15 +886,15 @@ return ret; } - if (GTK_WIDGET_REALIZED(vdl->listview)) + if (GTK_WIDGET_REALIZED(vdl->view)) { - gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(vdl->listview), 0, 0); + gtk_tree_view_scroll_to_point(GTK_TREE_VIEW(vdl->view), 0, 0); } return ret; } -void vdlist_refresh(ViewDirList *vdl) +void vdlist_refresh(ViewDir *vdl) { gchar *path; @@ -912,16 +906,16 @@ static void vdlist_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GtkTreeModel *store; GtkTreeIter iter; GtkTreePath *tpath; gint cw, ch; if (vdlist_find_row(vdl, vdl->click_fd, &iter) < 0) return; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->listview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdl->view)); tpath = gtk_tree_model_get_path(store, &iter); - tree_view_get_cell_clamped(GTK_TREE_VIEW(vdl->listview), tpath, 0, TRUE, x, y, &cw, &ch); + tree_view_get_cell_clamped(GTK_TREE_VIEW(vdl->view), tpath, 0, TRUE, x, y, &cw, &ch); gtk_tree_path_free(tpath); *y += ch; popup_menu_position_clamp(menu, x, y, 0); @@ -929,12 +923,12 @@ static gint vdlist_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GtkTreePath *tpath; if (event->keyval != GDK_Menu) return FALSE; - gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdl->listview), &tpath, NULL); + gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdl->view), &tpath, NULL); if (tpath) { GtkTreeModel *store; @@ -962,7 +956,7 @@ static gint vdlist_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; @@ -994,7 +988,7 @@ static gint vdlist_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; @@ -1025,7 +1019,7 @@ static void vdlist_select_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; GtkTreeModel *store; GtkTreeIter iter; FileData *fd; @@ -1058,18 +1052,18 @@ static void vdlist_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; gboolean set; gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1); g_object_set(G_OBJECT(cell), - "cell-background-gdk", vdlist_color_shifted(vdl->listview), + "cell-background-gdk", vdlist_color_shifted(vdl->view), "cell-background-set", set, NULL); } static void vdlist_destroy_cb(GtkWidget *widget, gpointer data) { - ViewDirList *vdl = data; + ViewDir *vdl = data; if (vdl->popup) { @@ -1079,29 +1073,32 @@ } vdlist_dnd_drop_scroll_cancel(vdl); - widget_auto_scroll_stop(vdl->listview); + widget_auto_scroll_stop(vdl->view); filelist_free(vdl->drop_list); folder_icons_free(vdl->pf); g_free(vdl->path); - filelist_free(vdl->list); + filelist_free(VDLIST_INFO(vdl, list)); + g_free(vdl->info); g_free(vdl); } -ViewDirList *vdlist_new(const gchar *path) +ViewDir *vdlist_new(const gchar *path) { - ViewDirList *vdl; + ViewDir *vdl; GtkListStore *store; GtkTreeSelection *selection; GtkTreeViewColumn *column; GtkCellRenderer *renderer; - vdl = g_new0(ViewDirList, 1); + vdl = g_new0(ViewDir, 1); + vdl->info = g_new0(ViewDirInfoList, 1); + vdl->type = DIRVIEW_LIST; vdl->path = NULL; - vdl->list = NULL; + VDLIST_INFO(vdl, list) = NULL; vdl->click_fd = NULL; vdl->drop_fd = NULL; @@ -1119,16 +1116,16 @@ G_CALLBACK(vdlist_destroy_cb), vdl); store = gtk_list_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN); - vdl->listview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); + vdl->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); g_object_unref(store); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdl->listview), FALSE); - gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdl->listview), FALSE); - g_signal_connect(G_OBJECT(vdl->listview), "row_activated", + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdl->view), FALSE); + gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdl->view), FALSE); + g_signal_connect(G_OBJECT(vdl->view), "row_activated", G_CALLBACK(vdlist_select_cb), vdl); - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdl->listview)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdl->view)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE); column = gtk_tree_view_column_new(); @@ -1144,36 +1141,23 @@ gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME); gtk_tree_view_column_set_cell_data_func(column, renderer, vdlist_color_cb, vdl, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(vdl->listview), column); + gtk_tree_view_append_column(GTK_TREE_VIEW(vdl->view), column); - g_signal_connect(G_OBJECT(vdl->listview), "key_press_event", + g_signal_connect(G_OBJECT(vdl->view), "key_press_event", G_CALLBACK(vdlist_press_key_cb), vdl); - gtk_container_add(GTK_CONTAINER(vdl->widget), vdl->listview); - gtk_widget_show(vdl->listview); + gtk_container_add(GTK_CONTAINER(vdl->widget), vdl->view); + gtk_widget_show(vdl->view); vdl->pf = folder_icons_new(); vdlist_dnd_init(vdl); - g_signal_connect(G_OBJECT(vdl->listview), "button_press_event", + g_signal_connect(G_OBJECT(vdl->view), "button_press_event", G_CALLBACK(vdlist_press_cb), vdl); - g_signal_connect(G_OBJECT(vdl->listview), "button_release_event", + g_signal_connect(G_OBJECT(vdl->view), "button_release_event", G_CALLBACK(vdlist_release_cb), vdl); if (path) vdlist_set_path(vdl, path); return vdl; } - -void vdlist_set_select_func(ViewDirList *vdl, - void (*func)(ViewDirList *vdl, const gchar *path, gpointer data), gpointer data) -{ - vdl->select_func = func; - vdl->select_data = data; -} - -void vdlist_set_layout(ViewDirList *vdl, LayoutWindow *layout) -{ - vdl->layout = layout; -} -
--- a/src/view_dir_list.h Tue Apr 15 21:49:28 2008 +0000 +++ b/src/view_dir_list.h Wed Apr 16 14:45:22 2008 +0000 @@ -13,17 +13,12 @@ #define VIEW_DIR_LIST_H -ViewDirList *vdlist_new(const gchar *path); - -void vdlist_set_select_func(ViewDirList *vdl, - void (*func)(ViewDirList *vdl, const gchar *path, gpointer data), gpointer data); +ViewDir *vdlist_new(const gchar *path); -void vdlist_set_layout(ViewDirList *vdl, LayoutWindow *layout); +gint vdlist_set_path(ViewDir *vdl, const gchar *path); +void vdlist_refresh(ViewDir *vdl); -gint vdlist_set_path(ViewDirList *vdl, const gchar *path); -void vdlist_refresh(ViewDirList *vdl); - -const gchar *vdlist_row_get_path(ViewDirList *vdl, gint row); +const gchar *vdlist_row_get_path(ViewDir *vdl, gint row); #endif
--- a/src/view_dir_tree.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/view_dir_tree.c Wed Apr 16 14:45:22 2008 +0000 @@ -24,6 +24,7 @@ #include "ui_fileops.h" #include "ui_menu.h" #include "ui_tree_edit.h" +#include "view_dir.h" #include <gdk/gdkkeysyms.h> /* for keyboard values */ @@ -31,13 +32,7 @@ #define VDTREE_INDENT 14 #define VDTREE_PAD 4 -enum { - DIR_COLUMN_POINTER = 0, - DIR_COLUMN_ICON, - DIR_COLUMN_NAME, - DIR_COLUMN_COLOR, - DIR_COLUMN_COUNT -}; +#define VDTREE_INFO(_vd_, _part_) (((ViewDirInfoTree *)(_vd_->info))->_part_) typedef struct _PathData PathData; @@ -56,8 +51,8 @@ }; -static gint vdtree_populate_path_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, gint force, const gchar *target_path); -static FileData *vdtree_populate_path(ViewDirTree *vdt, const gchar *path, gint expand, gint force); +static gint vdtree_populate_path_by_iter(ViewDir *vdt, GtkTreeIter *iter, gint force, const gchar *target_path); +static FileData *vdtree_populate_path(ViewDir *vdt, const gchar *path, gint expand, gint force); /* @@ -78,24 +73,24 @@ gdk_flush(); } -static void vdtree_busy_push(ViewDirTree *vdt) +static void vdtree_busy_push(ViewDir *vdt) { - if (vdt->busy_ref == 0) set_cursor(vdt->treeview, GDK_WATCH); - vdt->busy_ref++; + if (VDTREE_INFO(vdt, busy_ref) == 0) set_cursor(vdt->view, GDK_WATCH); + VDTREE_INFO(vdt, busy_ref)++; } -static void vdtree_busy_pop(ViewDirTree *vdt) +static void vdtree_busy_pop(ViewDir *vdt) { - if (vdt->busy_ref == 1) set_cursor(vdt->treeview, -1); - if (vdt->busy_ref > 0) vdt->busy_ref--; + if (VDTREE_INFO(vdt, busy_ref) == 1) set_cursor(vdt->view, -1); + if (VDTREE_INFO(vdt, busy_ref) > 0) VDTREE_INFO(vdt, busy_ref)--; } -static gint vdtree_find_row(ViewDirTree *vdt, FileData *fd, GtkTreeIter *iter, GtkTreeIter *parent) +static gint vdtree_find_row(ViewDir *vdt, FileData *fd, GtkTreeIter *iter, GtkTreeIter *parent) { GtkTreeModel *store; gint valid; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); if (parent) { valid = gtk_tree_model_iter_children(store, iter, parent); @@ -124,12 +119,12 @@ return FALSE; } -static void vdtree_icon_set_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, GdkPixbuf *pixbuf) +static void vdtree_icon_set_by_iter(ViewDir *vdt, GtkTreeIter *iter, GdkPixbuf *pixbuf) { GtkTreeModel *store; GdkPixbuf *old; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); gtk_tree_model_get(store, iter, DIR_COLUMN_ICON, &old, -1); if (old != vdt->pf->deny) { @@ -137,26 +132,26 @@ } } -static void vdtree_expand_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, gint expand) +static void vdtree_expand_by_iter(ViewDir *vdt, GtkTreeIter *iter, gint expand) { GtkTreeModel *store; GtkTreePath *tpath; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); tpath = gtk_tree_model_get_path(store, iter); if (expand) { - gtk_tree_view_expand_row(GTK_TREE_VIEW(vdt->treeview), tpath, FALSE); + gtk_tree_view_expand_row(GTK_TREE_VIEW(vdt->view), tpath, FALSE); vdtree_icon_set_by_iter(vdt, iter, vdt->pf->open); } else { - gtk_tree_view_collapse_row(GTK_TREE_VIEW(vdt->treeview), tpath); + gtk_tree_view_collapse_row(GTK_TREE_VIEW(vdt->view), tpath); } gtk_tree_path_free(tpath); } -static void vdtree_expand_by_data(ViewDirTree *vdt, FileData *fd, gint expand) +static void vdtree_expand_by_data(ViewDir *vdt, FileData *fd, gint expand) { GtkTreeIter iter; @@ -166,19 +161,19 @@ } } -static void vdtree_color_set(ViewDirTree *vdt, FileData *fd, gint color_set) +static void vdtree_color_set(ViewDir *vdt, FileData *fd, gint color_set) { GtkTreeModel *store; GtkTreeIter iter; if (!vdtree_find_row(vdt, fd, &iter, NULL)) return; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); gtk_tree_store_set(GTK_TREE_STORE(store), &iter, DIR_COLUMN_COLOR, color_set, -1); } static gint vdtree_rename_row_cb(TreeEditData *td, const gchar *old, const gchar *new, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreeModel *store; GtkTreeIter iter; NodeData *nd; @@ -186,7 +181,7 @@ gchar *new_path; gchar *base; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); if (!gtk_tree_model_get_iter(store, &iter, td->path)) return FALSE; gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); if (!nd) return FALSE; @@ -197,7 +192,7 @@ new_path = concat_dir_and_file(base, new); g_free(base); - if (file_util_rename_dir(nd->fd, new_path, vdt->treeview)) + if (file_util_rename_dir(nd->fd, new_path, vdt->view)) { vdtree_populate_path(vdt, new_path, TRUE, TRUE); @@ -213,7 +208,7 @@ return FALSE; } -static void vdtree_rename_by_data(ViewDirTree *vdt, FileData *fd) +static void vdtree_rename_by_data(ViewDir *vdt, FileData *fd) { GtkTreeModel *store; GtkTreePath *tpath; @@ -222,10 +217,10 @@ if (!fd || !vdtree_find_row(vdt, fd, &iter, NULL)) return; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); tpath = gtk_tree_model_get_path(store, &iter); - tree_edit_by_path(GTK_TREE_VIEW(vdt->treeview), tpath, 0, fd->name, + tree_edit_by_path(GTK_TREE_VIEW(vdt->view), tpath, 0, fd->name, vdtree_rename_row_cb, vdt); gtk_tree_path_free(tpath); } @@ -240,7 +235,7 @@ static void vdtree_popup_destroy_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_color_set(vdt, vdt->click_fd, FALSE); vdt->click_fd = NULL; @@ -260,7 +255,7 @@ static void vdtree_drop_menu_copy_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; const gchar *path; GList *list; @@ -276,7 +271,7 @@ static void vdtree_drop_menu_move_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; const gchar *path; GList *list; @@ -290,7 +285,7 @@ file_util_move_simple(list, path); } -static GtkWidget *vdtree_drop_menu(ViewDirTree *vdt, gint active) +static GtkWidget *vdtree_drop_menu(ViewDir *vdt, gint active) { GtkWidget *menu; @@ -316,7 +311,7 @@ static void vdtree_pop_menu_up_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; gchar *path; if (!vdt->path || strcmp(vdt->path, "/") == 0) return; @@ -332,7 +327,7 @@ static void vdtree_pop_menu_slide_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; gchar *path; if (!vdt->layout) return; @@ -348,7 +343,7 @@ static void vdtree_pop_menu_slide_rec_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; gchar *path; GList *list; @@ -363,7 +358,7 @@ layout_image_slideshow_start_from_list(vdt->layout, list); } -static void vdtree_pop_menu_dupe(ViewDirTree *vdt, gint recursive) +static void vdtree_pop_menu_dupe(ViewDir *vdt, gint recursive) { DupeWindow *dw; GList *list = NULL; @@ -388,19 +383,19 @@ static void vdtree_pop_menu_dupe_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_pop_menu_dupe(vdt, FALSE); } static void vdtree_pop_menu_dupe_rec_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_pop_menu_dupe(vdt, TRUE); } static void vdtree_pop_menu_new_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; const gchar *path; gchar *new_path; gchar *buf; @@ -418,7 +413,7 @@ gchar *text; text = g_strdup_printf(_("Unable to create folder:\n%s"), new_path); - file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vdt->treeview); + file_util_warning_dialog(_("Error creating folder"), text, GTK_STOCK_DIALOG_ERROR, vdt->view); g_free(text); } else @@ -435,42 +430,42 @@ static void vdtree_pop_menu_rename_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_rename_by_data(vdt, vdt->click_fd); } static void vdtree_pop_menu_delete_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; if (!vdt->click_fd) return; file_util_delete_dir(vdt->click_fd, vdt->widget); } -static void vdtree_pop_menu_tree_cb(GtkWidget *widget, gpointer data) +static void vdtree_pop_menu_dir_view_as_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; - if (vdt->layout) layout_views_set(vdt->layout, FALSE, vdt->layout->icon_view); + if (vdt->layout) layout_views_set(vdt->layout, DIRVIEW_LIST, vdt->layout->icon_view); } static void vdtree_pop_menu_refresh_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; if (vdt->layout) layout_refresh(vdt->layout); } static void vdtree_toggle_show_hidden_files_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; options->file_filter.show_hidden_files = !options->file_filter.show_hidden_files; if (vdt->layout) layout_refresh(vdt->layout); } -static GtkWidget *vdtree_pop_menu(ViewDirTree *vdt, FileData *fd) +static GtkWidget *vdtree_pop_menu(ViewDir *vdt, FileData *fd) { GtkWidget *menu; gint active; @@ -520,7 +515,7 @@ menu_item_add_divider(menu); menu_item_add_check(menu, _("View as _tree"), TRUE, - G_CALLBACK(vdtree_pop_menu_tree_cb), vdt); + G_CALLBACK(vdtree_pop_menu_dir_view_as_cb), vdt); menu_item_add_check(menu, _("Show _hidden files"), options->file_filter.show_hidden_files, G_CALLBACK(vdtree_toggle_show_hidden_files_cb), vdt); @@ -542,18 +537,18 @@ static gint vdtree_dnd_drop_types_count = 1; -static void vdtree_dest_set(ViewDirTree *vdt, gint enable) +static void vdtree_dest_set(ViewDir *vdt, gint enable) { if (enable) { - gtk_drag_dest_set(vdt->treeview, + gtk_drag_dest_set(vdt->view, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, vdtree_dnd_drop_types, vdtree_dnd_drop_types_count, GDK_ACTION_MOVE | GDK_ACTION_COPY); } else { - gtk_drag_dest_unset(vdt->treeview); + gtk_drag_dest_unset(vdt->view); } } @@ -561,7 +556,7 @@ GtkSelectionData *selection_data, guint info, guint time, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GList *list; gchar *uri_text = NULL; gint length = 0; @@ -588,7 +583,7 @@ static void vdtree_dnd_begin(GtkWidget *widget, GdkDragContext *context, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_color_set(vdt, vdt->click_fd, TRUE); vdtree_dest_set(vdt, FALSE); @@ -596,7 +591,7 @@ static void vdtree_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_color_set(vdt, vdt->click_fd, FALSE); vdtree_dest_set(vdt, TRUE); @@ -607,7 +602,7 @@ GtkSelectionData *selection_data, guint info, guint time, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; @@ -651,7 +646,7 @@ static gint vdtree_dnd_drop_expand_cb(gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreeIter iter; if (vdt->drop_fd && @@ -661,35 +656,35 @@ vdtree_expand_by_data(vdt, vdt->drop_fd, TRUE); } - vdt->drop_expand_id = -1; + VDTREE_INFO(vdt, drop_expand_id) = -1; return FALSE; } -static void vdtree_dnd_drop_expand_cancel(ViewDirTree *vdt) +static void vdtree_dnd_drop_expand_cancel(ViewDir *vdt) { - if (vdt->drop_expand_id != -1) g_source_remove(vdt->drop_expand_id); - vdt->drop_expand_id = -1; + if (VDTREE_INFO(vdt, drop_expand_id) != -1) g_source_remove(VDTREE_INFO(vdt, drop_expand_id)); + VDTREE_INFO(vdt, drop_expand_id) = -1; } -static void vdtree_dnd_drop_expand(ViewDirTree *vdt) +static void vdtree_dnd_drop_expand(ViewDir *vdt) { vdtree_dnd_drop_expand_cancel(vdt); - vdt->drop_expand_id = g_timeout_add(1000, vdtree_dnd_drop_expand_cb, vdt); + VDTREE_INFO(vdt, drop_expand_id) = g_timeout_add(1000, vdtree_dnd_drop_expand_cb, vdt); } -static void vdtree_drop_update(ViewDirTree *vdt, gint x, gint y) +static void vdtree_drop_update(ViewDir *vdt, gint x, gint y) { GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; - if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vdt->treeview), x, y, + if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(vdt->view), x, y, &tpath, NULL, NULL, NULL)) { GtkTreeModel *store; NodeData *nd; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); gtk_tree_model_get_iter(store, &iter, tpath); gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1); gtk_tree_path_free(tpath); @@ -707,7 +702,7 @@ vdt->drop_fd = fd; } -static void vdtree_dnd_drop_scroll_cancel(ViewDirTree *vdt) +static void vdtree_dnd_drop_scroll_cancel(ViewDir *vdt) { if (vdt->drop_scroll_id != -1) g_source_remove(vdt->drop_scroll_id); vdt->drop_scroll_id = -1; @@ -715,7 +710,7 @@ static gint vdtree_auto_scroll_idle_cb(gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; if (vdt->drop_fd) { @@ -723,7 +718,7 @@ gint x, y; gint w, h; - window = vdt->treeview->window; + window = vdt->view->window; gdk_window_get_pointer(window, &x, &y, NULL); gdk_drawable_get_size(window, &w, &h); if (x >= 0 && x < w && y >= 0 && y < h) @@ -738,7 +733,7 @@ static gint vdtree_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; if (!vdt->drop_fd || vdt->drop_list) return FALSE; @@ -750,11 +745,11 @@ static gint vdtree_dnd_drop_motion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdt->click_fd = NULL; - if (gtk_drag_get_source_widget(context) == vdt->treeview) + if (gtk_drag_get_source_widget(context) == vdt->view) { gdk_drag_status(context, 0, time); return TRUE; @@ -768,8 +763,8 @@ if (vdt->drop_fd) { - GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdt->treeview)); - widget_auto_scroll_start(vdt->treeview, adj, -1, -1, vdtree_auto_scroll_notify_cb, vdt); + GtkAdjustment *adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(vdt->view)); + widget_auto_scroll_start(vdt->view, adj, -1, -1, vdtree_auto_scroll_notify_cb, vdt); } return FALSE; @@ -777,7 +772,7 @@ static void vdtree_dnd_drop_leave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; if (vdt->drop_fd != vdt->click_fd) vdtree_color_set(vdt, vdt->drop_fd, FALSE); @@ -786,24 +781,24 @@ vdtree_dnd_drop_expand_cancel(vdt); } -static void vdtree_dnd_init(ViewDirTree *vdt) +static void vdtree_dnd_init(ViewDir *vdt) { - gtk_drag_source_set(vdt->treeview, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, + gtk_drag_source_set(vdt->view, GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, dnd_file_drag_types, dnd_file_drag_types_count, GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); - g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_get", + g_signal_connect(G_OBJECT(vdt->view), "drag_data_get", G_CALLBACK(vdtree_dnd_get), vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "drag_begin", + g_signal_connect(G_OBJECT(vdt->view), "drag_begin", G_CALLBACK(vdtree_dnd_begin), vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "drag_end", + g_signal_connect(G_OBJECT(vdt->view), "drag_end", G_CALLBACK(vdtree_dnd_end), vdt); vdtree_dest_set(vdt, TRUE); - g_signal_connect(G_OBJECT(vdt->treeview), "drag_data_received", + g_signal_connect(G_OBJECT(vdt->view), "drag_data_received", G_CALLBACK(vdtree_dnd_drop_receive), vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "drag_motion", + g_signal_connect(G_OBJECT(vdt->view), "drag_motion", G_CALLBACK(vdtree_dnd_drop_motion), vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "drag_leave", + g_signal_connect(G_OBJECT(vdt->view), "drag_leave", G_CALLBACK(vdtree_dnd_drop_leave), vdt); } @@ -865,14 +860,14 @@ g_list_free(list); } -static GList *parts_list_add_node_points(ViewDirTree *vdt, GList *list) +static GList *parts_list_add_node_points(ViewDir *vdt, GList *list) { GList *work; GtkTreeModel *store; GtkTreeIter iter; gint valid; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); valid = gtk_tree_model_get_iter_first(store, &iter); work = list; @@ -943,11 +938,11 @@ *---------------------------------------------------------------------------- */ -static gint vdtree_find_iter_by_data(ViewDirTree *vdt, GtkTreeIter *parent, NodeData *nd, GtkTreeIter *iter) +static gint vdtree_find_iter_by_data(ViewDir *vdt, GtkTreeIter *parent, NodeData *nd, GtkTreeIter *iter) { GtkTreeModel *store; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); if (!nd || !gtk_tree_model_iter_children(store, iter, parent)) return -1; do { NodeData *cnd; @@ -959,11 +954,11 @@ return FALSE; } -static NodeData *vdtree_find_iter_by_name(ViewDirTree *vdt, GtkTreeIter *parent, const gchar *name, GtkTreeIter *iter) +static NodeData *vdtree_find_iter_by_name(ViewDir *vdt, GtkTreeIter *parent, const gchar *name, GtkTreeIter *iter) { GtkTreeModel *store; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); if (!name || !gtk_tree_model_iter_children(store, iter, parent)) return NULL; do { NodeData *nd; @@ -975,7 +970,7 @@ return NULL; } -static void vdtree_add_by_data(ViewDirTree *vdt, FileData *fd, GtkTreeIter *parent) +static void vdtree_add_by_data(ViewDir *vdt, FileData *fd, GtkTreeIter *parent) { GtkTreeStore *store; GtkTreeIter child; @@ -1000,7 +995,7 @@ nd->expanded = FALSE; nd->last_update = time(NULL); - store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview))); + store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view))); gtk_tree_store_append(store, &child, parent); gtk_tree_store_set(store, &child, DIR_COLUMN_POINTER, nd, DIR_COLUMN_ICON, pixbuf, @@ -1025,7 +1020,7 @@ gtk_tree_model_get(GTK_TREE_MODEL(store), parent, DIR_COLUMN_POINTER, &pnd, -1); tpath = gtk_tree_model_get_path(GTK_TREE_MODEL(store), parent); if (options->tree_descend_subdirs && - gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath) && + gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->view), tpath) && !nd->expanded) { vdtree_populate_path_by_iter(vdt, &child, FALSE, vdt->path); @@ -1034,7 +1029,7 @@ } } -static gint vdtree_populate_path_by_iter(ViewDirTree *vdt, GtkTreeIter *iter, gint force, const gchar *target_path) +static gint vdtree_populate_path_by_iter(ViewDir *vdt, GtkTreeIter *iter, gint force, const gchar *target_path) { GtkTreeModel *store; GList *list; @@ -1044,7 +1039,7 @@ GtkTreeIter child; NodeData *nd; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); gtk_tree_model_get(store, iter, DIR_COLUMN_POINTER, &nd, -1); if (!nd) return FALSE; @@ -1173,7 +1168,7 @@ return TRUE; } -static FileData *vdtree_populate_path(ViewDirTree *vdt, const gchar *path, gint expand, gint force) +static FileData *vdtree_populate_path(ViewDir *vdt, const gchar *path, gint expand, gint force) { GList *list; GList *work; @@ -1271,13 +1266,13 @@ return selection_is_ok; } -static void vdtree_select_row(ViewDirTree *vdt, FileData *fd) +static void vdtree_select_row(ViewDir *vdt, FileData *fd) { GtkTreeSelection *selection; GtkTreeIter iter; if (!vdtree_find_row(vdt, fd, &iter, NULL)) return; - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->view)); /* hack, such that selection is only allowed to be changed from here */ selection_is_ok = TRUE; @@ -1294,7 +1289,7 @@ } } -gint vdtree_set_path(ViewDirTree *vdt, const gchar *path) +gint vdtree_set_path(ViewDir *vdt, const gchar *path) { FileData *fd; GtkTreeIter iter; @@ -1314,11 +1309,11 @@ GtkTreeModel *store; GtkTreePath *tpath; - tree_view_row_make_visible(GTK_TREE_VIEW(vdt->treeview), &iter, TRUE); + tree_view_row_make_visible(GTK_TREE_VIEW(vdt->view), &iter, TRUE); - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); tpath = gtk_tree_model_get_path(store, &iter); - gtk_tree_view_set_cursor(GTK_TREE_VIEW(vdt->treeview), tpath, NULL, FALSE); + gtk_tree_view_set_cursor(GTK_TREE_VIEW(vdt->view), tpath, NULL, FALSE); gtk_tree_path_free(tpath); vdtree_select_row(vdt, fd); @@ -1328,18 +1323,18 @@ } #if 0 -const gchar *vdtree_get_path(ViewDirTree *vdt) +const gchar *vdtree_get_path(ViewDir *vdt) { return vdt->path; } #endif -void vdtree_refresh(ViewDirTree *vdt) +void vdtree_refresh(ViewDir *vdt) { vdtree_populate_path(vdt, vdt->path, FALSE, TRUE); } -const gchar *vdtree_row_get_path(ViewDirTree *vdt, gint row) +const gchar *vdtree_row_get_path(ViewDir *vdt, gint row) { printf("FIXME: no get row path\n"); return NULL; @@ -1353,16 +1348,16 @@ static void vdtree_menu_position_cb(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreeModel *store; GtkTreeIter iter; GtkTreePath *tpath; gint cw, ch; if (vdtree_find_row(vdt, vdt->click_fd, &iter, NULL) < 0) return; - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); tpath = gtk_tree_model_get_path(store, &iter); - tree_view_get_cell_clamped(GTK_TREE_VIEW(vdt->treeview), tpath, 0, TRUE, x, y, &cw, &ch); + tree_view_get_cell_clamped(GTK_TREE_VIEW(vdt->view), tpath, 0, TRUE, x, y, &cw, &ch); gtk_tree_path_free(tpath); *y += ch; popup_menu_position_clamp(menu, x, y, 0); @@ -1370,12 +1365,12 @@ static gint vdtree_press_key_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreePath *tpath; GtkTreeIter iter; FileData *fd = NULL; - gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdt->treeview), &tpath, NULL); + gtk_tree_view_get_cursor(GTK_TREE_VIEW(vdt->view), &tpath, NULL); if (tpath) { GtkTreeModel *store; @@ -1441,7 +1436,7 @@ static gint vdtree_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreePath *tpath; GtkTreeViewColumn *column; GtkTreeIter iter; @@ -1467,7 +1462,7 @@ */ if (bevent->button == 1 && !left_of_expander && - !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->treeview), tpath)) + !gtk_tree_view_row_expanded(GTK_TREE_VIEW(vdt->view), tpath)) { vdtree_populate_path_by_iter(vdt, &iter, FALSE, vdt->path); vdtree_icon_set_by_iter(vdt, &iter, vdt->pf->open); @@ -1495,7 +1490,7 @@ static gint vdtree_release_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreePath *tpath; GtkTreeIter iter; NodeData *nd = NULL; @@ -1527,7 +1522,7 @@ static void vdtree_row_expanded(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_populate_path_by_iter(vdt, iter, FALSE, NULL); vdtree_icon_set_by_iter(vdt, iter, vdt->pf->open); @@ -1535,7 +1530,7 @@ static void vdtree_row_collapsed(GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *tpath, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; vdtree_icon_set_by_iter(vdt, iter, vdt->pf->close); } @@ -1557,7 +1552,7 @@ *---------------------------------------------------------------------------- */ -static void vdtree_setup_root(ViewDirTree *vdt) +static void vdtree_setup_root(ViewDir *vdt) { const gchar *path = "/"; FileData *fd; @@ -1572,7 +1567,7 @@ static void vdtree_activate_cb(GtkTreeView *tview, GtkTreePath *tpath, GtkTreeViewColumn *column, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreeModel *store; GtkTreeIter iter; NodeData *nd; @@ -1605,12 +1600,12 @@ static void vdtree_color_cb(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; gboolean set; gtk_tree_model_get(tree_model, iter, DIR_COLUMN_COLOR, &set, -1); g_object_set(G_OBJECT(cell), - "cell-background-gdk", vdtree_color_shifted(vdt->treeview), + "cell-background-gdk", vdtree_color_shifted(vdt->view), "cell-background-set", set, NULL); } @@ -1626,7 +1621,7 @@ static void vdtree_destroy_cb(GtkWidget *widget, gpointer data) { - ViewDirTree *vdt = data; + ViewDir *vdt = data; GtkTreeModel *store; if (vdt->popup) @@ -1638,9 +1633,9 @@ vdtree_dnd_drop_expand_cancel(vdt); vdtree_dnd_drop_scroll_cancel(vdt); - widget_auto_scroll_stop(vdt->treeview); + widget_auto_scroll_stop(vdt->view); - store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->treeview)); + store = gtk_tree_view_get_model(GTK_TREE_VIEW(vdt->view)); gtk_tree_model_foreach(store, vdtree_destroy_node_cb, vdt); filelist_free(vdt->drop_list); @@ -1648,18 +1643,21 @@ folder_icons_free(vdt->pf); g_free(vdt->path); + g_free(vdt->info); g_free(vdt); } -ViewDirTree *vdtree_new(const gchar *path, gint expand) +ViewDir *vdtree_new(const gchar *path) { - ViewDirTree *vdt; + ViewDir *vdt; GtkTreeStore *store; GtkTreeSelection *selection; GtkTreeViewColumn *column; GtkCellRenderer *renderer; - vdt = g_new0(ViewDirTree, 1); + vdt = g_new0(ViewDir, 1); + vdt->info = g_new0(ViewDirInfoTree, 1); + vdt->type = DIRVIEW_TREE; vdt->path = NULL; vdt->click_fd = NULL; @@ -1667,11 +1665,11 @@ vdt->drop_fd = NULL; vdt->drop_list = NULL; vdt->drop_scroll_id = -1; - vdt->drop_expand_id = -1; + VDTREE_INFO(vdt, drop_expand_id) = -1; vdt->popup = NULL; - vdt->busy_ref = 0; + VDTREE_INFO(vdt, busy_ref) = 0; vdt->widget = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(vdt->widget), GTK_SHADOW_IN); @@ -1681,27 +1679,27 @@ G_CALLBACK(vdtree_destroy_cb), vdt); store = gtk_tree_store_new(4, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); - vdt->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); + vdt->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); g_object_unref(store); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdt->treeview), FALSE); - gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdt->treeview), FALSE); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(vdt->view), FALSE); + gtk_tree_view_set_enable_search(GTK_TREE_VIEW(vdt->view), FALSE); gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(store), vdtree_sort_cb, vdt, NULL); gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING); - g_signal_connect(G_OBJECT(vdt->treeview), "row_activated", + g_signal_connect(G_OBJECT(vdt->view), "row_activated", G_CALLBACK(vdtree_activate_cb), vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "row_expanded", + g_signal_connect(G_OBJECT(vdt->view), "row_expanded", G_CALLBACK(vdtree_row_expanded), vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "row_collapsed", + g_signal_connect(G_OBJECT(vdt->view), "row_collapsed", G_CALLBACK(vdtree_row_collapsed), vdt); #if 0 g_signal_connect(G_OBJECT(store), "row_deleted", G_CALLBACK(vdtree_row_deleted_cb), vdt); #endif - selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->treeview)); + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vdt->view)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); gtk_tree_selection_set_select_function(selection, vdtree_select_cb, vdt, NULL); @@ -1718,13 +1716,13 @@ gtk_tree_view_column_add_attribute(column, renderer, "text", DIR_COLUMN_NAME); gtk_tree_view_column_set_cell_data_func(column, renderer, vdtree_color_cb, vdt, NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(vdt->treeview), column); + gtk_tree_view_append_column(GTK_TREE_VIEW(vdt->view), column); - g_signal_connect(G_OBJECT(vdt->treeview), "key_press_event", + g_signal_connect(G_OBJECT(vdt->view), "key_press_event", G_CALLBACK(vdtree_press_key_cb), vdt); - gtk_container_add(GTK_CONTAINER(vdt->widget), vdt->treeview); - gtk_widget_show(vdt->treeview); + gtk_container_add(GTK_CONTAINER(vdt->widget), vdt->view); + gtk_widget_show(vdt->view); vdt->pf = folder_icons_new(); @@ -1732,9 +1730,9 @@ vdtree_dnd_init(vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "button_press_event", + g_signal_connect(G_OBJECT(vdt->view), "button_press_event", G_CALLBACK(vdtree_press_cb), vdt); - g_signal_connect(G_OBJECT(vdt->treeview), "button_release_event", + g_signal_connect(G_OBJECT(vdt->view), "button_release_event", G_CALLBACK(vdtree_release_cb), vdt); vdtree_set_path(vdt, path); @@ -1742,16 +1740,9 @@ return vdt; } -void vdtree_set_select_func(ViewDirTree *vdt, - void (*func)(ViewDirTree *vdt, const gchar *path, gpointer data), gpointer data) -{ - vdt->select_func = func; - vdt->select_data = data; -} - #if 0 -void vdtree_set_click_func(ViewDirTree *vdt, - void (*func)(ViewDirTree *vdt, GdkEventButton *event, FileData *fd, gpointer), gpointer data) +void vdtree_set_click_func(ViewDir *vdt, + void (*func)(ViewDir *vdt, GdkEventButton *event, FileData *fd, gpointer), gpointer data) { if (!td) return; vdt->click_func = func; @@ -1759,8 +1750,4 @@ } #endif -void vdtree_set_layout(ViewDirTree *vdt, LayoutWindow *layout) -{ - vdt->layout = layout; -}
--- a/src/view_dir_tree.h Tue Apr 15 21:49:28 2008 +0000 +++ b/src/view_dir_tree.h Wed Apr 16 14:45:22 2008 +0000 @@ -12,17 +12,12 @@ #ifndef VIEW_DIR_TREE_H #define VIEW_DIR_TREE_H -ViewDirTree *vdtree_new(const gchar *path, gint expand); - -void vdtree_set_select_func(ViewDirTree *vdt, - void (*func)(ViewDirTree *vdt, const gchar *path, gpointer data), gpointer data); +ViewDir *vdtree_new(const gchar *path); -void vdtree_set_layout(ViewDirTree *vdt, LayoutWindow *layout); +gint vdtree_set_path(ViewDir *vdt, const gchar *path); +void vdtree_refresh(ViewDir *vdt); -gint vdtree_set_path(ViewDirTree *vdt, const gchar *path); -void vdtree_refresh(ViewDirTree *vdt); - -const gchar *vdtree_row_get_path(ViewDirTree *vdt, gint row); +const gchar *vdtree_row_get_path(ViewDir *vdt, gint row); #endif
--- a/src/view_file_icon.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/view_file_icon.c Wed Apr 16 14:45:22 2008 +0000 @@ -281,7 +281,7 @@ { ViewFileIcon *vfi = data; - if (vfi->layout) layout_views_set(vfi->layout, vfi->layout->tree_view, FALSE); + if (vfi->layout) layout_views_set(vfi->layout, vfi->layout->dir_view_type, FALSE); } static void vficon_pop_menu_show_names_cb(GtkWidget *widget, gpointer data)
--- a/src/view_file_list.c Tue Apr 15 21:49:28 2008 +0000 +++ b/src/view_file_list.c Wed Apr 16 14:45:22 2008 +0000 @@ -428,7 +428,7 @@ { ViewFileList *vfl = data; - if (vfl->layout) layout_views_set(vfl->layout, vfl->layout->tree_view, TRUE); + if (vfl->layout) layout_views_set(vfl->layout, vfl->layout->dir_view_type, TRUE); } static void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data)