mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
EFiler v0.2.2:
- Use edelib::Window (fixes problem with titlebar icon and some cruft in main) - Store user preferences in edelib::Resource - Work better with edeneu icon theme, follow fdo icon-naming-spec - Expand . in directory path (e.g. when called from command line), show just last part of path in window title, full width status bar :) - Some fixes to ExpandableGroup usage, use EG by default - In fileops, don't update view manually when notify is available - Improve documentation of EDE_FileView.h - Temporary "Open with" callback for testing
This commit is contained in:
parent
ff505dc732
commit
b7a0958278
@ -56,6 +56,7 @@ void make_end_with_slash(char* path) {
|
||||
|
||||
// Filesystem data
|
||||
// TODO: find better icons for Amiga, Macintosh etc.
|
||||
// TODO: use USB icon for removable media, regardless of filesystem
|
||||
|
||||
static struct {
|
||||
char id[15];
|
||||
@ -80,62 +81,62 @@ static struct {
|
||||
{"usbfs", "", ""},
|
||||
|
||||
// Common filesystems
|
||||
{"ext2", "Linux disk (%s)", "hdd_unmount"},
|
||||
{"ext2fs", "Linux disk (%s)", "hdd_unmount"},
|
||||
{"ext3", "Linux disk (%s)", "hdd_unmount"},
|
||||
{"reiserfs", "Linux disk (%s)", "hdd_unmount"},
|
||||
{"ffs", "BSD disk (%s)", "hdd_unmount"},
|
||||
{"ufs", "Unix disk (%s)", "hdd_unmount"},
|
||||
{"dos", "Windows disk (%s)", "win_mount"},
|
||||
{"fat", "Windows disk (%s)", "win_mount"},
|
||||
{"msdos", "Windows disk (%s)", "win_mount"},
|
||||
{"ntfs", "Windows disk (%s)", "win_mount"},
|
||||
{"pcfs", "Windows disk (%s)", "win_mount"},
|
||||
{"umsdos", "Windows disk (%s)", "win_mount"},
|
||||
{"vfat", "Windows disk (%s)", "win_mount"},
|
||||
{"cd9660", "CD-ROM (%s)", "cdrom_unmount"},
|
||||
{"cdfs", "CD-ROM (%s)", "cdrom_unmount"},
|
||||
{"cdrfs", "CD-ROM (%s)", "cdrom_unmount"},
|
||||
{"hsfs", "CD-ROM (%s)", "cdrom_unmount"},
|
||||
{"iso9660", "CD-ROM (%s)", "cdrom_unmount"},
|
||||
{"isofs", "CD-ROM (%s)", "cdrom_unmount"},
|
||||
{"udf", "DVD-ROM (%s)", "dvd_unmount"},
|
||||
{"cifs", "Shared directory (%s)", "server"},
|
||||
{"nfs", "Shared directory (%s)", "server"},
|
||||
{"nfs4", "Shared directory (%s)", "server"},
|
||||
{"smbfs", "Shared directory (%s)", "server"},
|
||||
{"cramfs", "Virtual (RAM) disk (%s)", "memory"},
|
||||
{"ext2", "Linux legacy (%s)", "drive-harddisk"},
|
||||
{"ext2fs", "Linux legacy (%s)", "drive-harddisk"},
|
||||
{"ext3", "Linux disk (%s)", "drive-harddisk"},
|
||||
{"reiserfs", "Linux alternative (%s)", "drive-harddisk"},
|
||||
{"ffs", "BSD disk (%s)", "drive-harddisk"},
|
||||
{"ufs", "Unix disk (%s)", "drive-harddisk"},
|
||||
{"dos", "Windows disk (%s)", "drive-harddisk"}, // I would prefer a Windows icon
|
||||
{"fat", "Windows disk (%s)", "drive-harddisk"},
|
||||
{"msdos", "Windows disk (%s)", "drive-harddisk"},
|
||||
{"ntfs", "Windows disk (%s)", "drive-harddisk"},
|
||||
{"pcfs", "Windows disk (%s)", "drive-harddisk"},
|
||||
{"umsdos", "Windows disk (%s)", "drive-harddisk"},
|
||||
{"vfat", "Windows disk (%s)", "drive-harddisk"},
|
||||
{"cd9660", "CD-ROM (%s)", "media-cdrom"},
|
||||
{"cdfs", "CD-ROM (%s)", "media-cdrom"},
|
||||
{"cdrfs", "CD-ROM (%s)", "media-cdrom"},
|
||||
{"hsfs", "CD-ROM (%s)", "media-cdrom"},
|
||||
{"iso9660", "CD-ROM (%s)", "media-cdrom"},
|
||||
{"isofs", "CD-ROM (%s)", "media-cdrom"},
|
||||
{"udf", "DVD-ROM (%s)", "media-dvd"},
|
||||
{"cifs", "Shared directory (%s)", "folder-remote"},
|
||||
{"nfs", "Shared directory (%s)", "folder-remote"},
|
||||
{"nfs4", "Shared directory (%s)", "folder-remote"},
|
||||
{"smbfs", "Shared directory (%s)", "folder-remote"},
|
||||
{"cramfs", "Virtual (RAM) disk (%s)", "memory"}, // no icon for ramdisk in fd.o specification or edeneu
|
||||
{"mfs", "Virtual (RAM) disk (%s)", "memory"},
|
||||
{"ramfs", "Virtual (RAM) disk (%s)", "memory"},
|
||||
{"romfs", "Virtual (RAM) disk (%s)", "memory"},
|
||||
{"union", "Virtual (RAM) disk (%s)", "memory"}, // not accurate, but good enough
|
||||
{"unionfs", "Virtual (RAM) disk (%s)", "memory"}, // not accurate, but good enough
|
||||
{"jfs", "IBM AIX disk (%s)", "hdd_unmount"},
|
||||
{"xfs", "SGI IRIX disk (%s)", "hdd_unmount"},
|
||||
{"jfs", "IBM AIX disk (%s)", "drive-harddisk"},
|
||||
{"xfs", "SGI IRIX disk (%s)", "drive-harddisk"},
|
||||
|
||||
|
||||
// Other filesystems
|
||||
{"coherent", "Unix disk (%s)", "hdd_unmount"},
|
||||
{"sysv", "Unix disk (%s)", "hdd_unmount"},
|
||||
{"xenix", "Unix disk (%s)", "hdd_unmount"},
|
||||
{"adfs", "RiscOS disk (%s)", "hdd_unmount"},
|
||||
{"filecore", "RiscOS disk (%s)", "hdd_unmount"},
|
||||
{"ados", "Amiga disk (%s)", "hdd_unmount"},
|
||||
{"affs", "Amiga disk (%s)", "hdd_unmount"},
|
||||
{"afs", "AFS shared directory (%s)", "server"},
|
||||
{"befs", "BeOS disk (%s)", "hdd_unmount"},
|
||||
{"bfs", "UnixWare disk (%s)", "hdd_unmount"},
|
||||
{"efs", "SGI IRIX disk (%s)", "hdd_unmount"},
|
||||
{"ext", "Old Linux disk (%s)", "hdd_unmount"},
|
||||
{"hfs", "Macintosh disk (%s)", "hdd_unmount"}, // Also used for HP-UX filesystem!!
|
||||
{"hpfs", "OS/2 disk (%s)", "hdd_unmount"},
|
||||
// {"lfs", "BSD LFS disk (%s)", "hdd_unmount"}, // This is said to not work
|
||||
{"minix", "Minix disk (%s)", "hdd_unmount"},
|
||||
{"ncpfs", "NetWare shared directory (%s)", "server"},
|
||||
{"nwfs", "NetWare shared directory (%s)", "server"},
|
||||
{"qns", "QNX disk (%s)", "hdd_unmount"},
|
||||
{"supermount", "Removable disk (%s)", "cdrom_umnount"}, // ???
|
||||
{"xiafs", "Old Linux disk (%s)", "hdd_unmount"},
|
||||
{"coherent", "Unix disk (%s)", "drive-harddisk"},
|
||||
{"sysv", "Unix disk (%s)", "drive-harddisk"},
|
||||
{"xenix", "Unix disk (%s)", "drive-harddisk"},
|
||||
{"adfs", "RiscOS disk (%s)", "drive-harddisk"},
|
||||
{"filecore", "RiscOS disk (%s)", "drive-harddisk"},
|
||||
{"ados", "Amiga disk (%s)", "drive-harddisk"},
|
||||
{"affs", "Amiga disk (%s)", "drive-harddisk"},
|
||||
{"afs", "AFS shared directory (%s)", "folder-remote"},
|
||||
{"befs", "BeOS disk (%s)", "drive-harddisk"},
|
||||
{"bfs", "UnixWare disk (%s)", "drive-harddisk"},
|
||||
{"efs", "SGI IRIX disk (%s)", "drive-harddisk"},
|
||||
{"ext", "Old Linux disk (%s)", "drive-harddisk"},
|
||||
{"hfs", "Macintosh disk (%s)", "drive-harddisk"}, // Also used for HP-UX filesystem!!
|
||||
{"hpfs", "OS/2 disk (%s)", "drive-harddisk"},
|
||||
// {"lfs", "BSD LFS disk (%s)", "drive-harddisk"}, // This is said to not work
|
||||
{"minix", "Minix disk (%s)", "drive-harddisk"},
|
||||
{"ncpfs", "NetWare shared directory (%s)", "folder-remote"},
|
||||
{"nwfs", "NetWare shared directory (%s)", "folder-remote"},
|
||||
{"qns", "QNX disk (%s)", "drive-harddisk"},
|
||||
{"supermount", "Removable disk (%s)", "media-cdrom"}, // ???
|
||||
{"xiafs", "Old Linux disk (%s)", "drive-harddisk"},
|
||||
|
||||
// Virtual filesystems (various views of existing files)
|
||||
// How often are these used?
|
||||
@ -168,13 +169,14 @@ void DirTree::init()
|
||||
|
||||
// Top level icon
|
||||
add(_("System"));
|
||||
set_icon(1, Fl_Shared_Image::get(edelib::IconTheme::get("tux",edelib::ICON_SIZE_TINY).c_str()));
|
||||
set_icon(1, Fl_Shared_Image::get(edelib::IconTheme::get("computer",edelib::ICON_SIZE_TINY).c_str()));
|
||||
// TODO: use OS icons: Tux for Linux, devil for FreeBSD...
|
||||
data(1, strdup("about:sysinfo"));
|
||||
|
||||
// Home icon
|
||||
snprintf(buffer,PATH_MAX,_("%s's Home"), getenv("USER"));
|
||||
add(strdup(buffer));
|
||||
set_icon(2, Fl_Shared_Image::get(edelib::IconTheme::get("folder_home",edelib::ICON_SIZE_TINY).c_str()));
|
||||
set_icon(2, Fl_Shared_Image::get(edelib::IconTheme::get("user-home",edelib::ICON_SIZE_TINY).c_str()));
|
||||
strncpy(buffer,getenv("HOME"),PATH_MAX);
|
||||
make_end_with_slash(buffer);
|
||||
data(2, strdup(buffer));
|
||||
@ -182,7 +184,10 @@ void DirTree::init()
|
||||
|
||||
// Root icon
|
||||
add(_("Whole disk"));
|
||||
set_icon(3, Fl_Shared_Image::get(edelib::IconTheme::get("folder_red",edelib::ICON_SIZE_TINY).c_str()));
|
||||
edelib::String root_icon = edelib::IconTheme::get("folder_red",edelib::ICON_SIZE_TINY);
|
||||
if (root_icon=="") // sigh...
|
||||
root_icon = edelib::IconTheme::get("folder",edelib::ICON_SIZE_TINY);
|
||||
set_icon(3, Fl_Shared_Image::get(root_icon.c_str()));
|
||||
data(3,strdup("/"));
|
||||
indent(3,1);
|
||||
|
||||
|
@ -190,7 +190,7 @@ EDEBUG(DBG "value: %s\n", value.c_str());
|
||||
|
||||
// Get icon
|
||||
edelib::String icon = edelib::IconTheme::get(item->icon.c_str(),edelib::ICON_SIZE_TINY);
|
||||
if (icon=="") icon = edelib::IconTheme::get("misc",edelib::ICON_SIZE_TINY,edelib::ICON_CONTEXT_MIMETYPE);
|
||||
if (icon=="") icon = edelib::IconTheme::get("empty",edelib::ICON_SIZE_TINY,edelib::ICON_CONTEXT_MIMETYPE); //in crystalsvg "misc" is better...
|
||||
set_icon(row, Fl_Shared_Image::get(icon.c_str()));
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ EDEBUG(DBG "value: %s\n", value.c_str());
|
||||
|
||||
// Get icon
|
||||
edelib::String icon = edelib::IconTheme::get(item->icon.c_str(),edelib::ICON_SIZE_TINY);
|
||||
if (icon=="") icon = edelib::IconTheme::get("misc",edelib::ICON_SIZE_TINY,edelib::ICON_CONTEXT_MIMETYPE);
|
||||
if (icon=="") icon = edelib::IconTheme::get("empty",edelib::ICON_SIZE_TINY,edelib::ICON_CONTEXT_MIMETYPE); //in crystalsvg "misc" is better...
|
||||
set_icon(row, Fl_Shared_Image::get(icon.c_str()));
|
||||
}
|
||||
|
||||
|
@ -237,13 +237,14 @@ void FileIconView::insert(int row, FileItem *item) {
|
||||
|
||||
// Set icon
|
||||
edelib::String icon = edelib::IconTheme::get(item->icon.c_str(),edelib::ICON_SIZE_MEDIUM);
|
||||
if (icon=="") icon = edelib::IconTheme::get("misc",edelib::ICON_SIZE_MEDIUM,edelib::ICON_CONTEXT_MIMETYPE);
|
||||
if (icon=="") icon = edelib::IconTheme::get("empty",edelib::ICON_SIZE_MEDIUM,edelib::ICON_CONTEXT_MIMETYPE); //in crystalsvg "misc" is better...
|
||||
b->image(Fl_Shared_Image::get(icon.c_str()));
|
||||
|
||||
#ifdef USE_FLU_WRAP_GROUP
|
||||
Flu_Wrap_Group::insert(*b,row);
|
||||
#else
|
||||
edelib::ExpandableGroup::insert(*b,row);
|
||||
edelib::ExpandableGroup::handle(FL_SHOW); // This will force calling reposition_childs()
|
||||
#endif
|
||||
//insert(*b,row); -- why doesn't this work?
|
||||
redraw();
|
||||
@ -285,7 +286,7 @@ void FileIconView::update(FileItem *item) {
|
||||
|
||||
// Set icon
|
||||
edelib::String icon = edelib::IconTheme::get(item->icon.c_str(),edelib::ICON_SIZE_MEDIUM);
|
||||
if (icon=="") icon = edelib::IconTheme::get("misc",edelib::ICON_SIZE_MEDIUM,edelib::ICON_CONTEXT_MIMETYPE);
|
||||
if (icon=="") icon = edelib::IconTheme::get("empty",edelib::ICON_SIZE_MEDIUM,edelib::ICON_CONTEXT_MIMETYPE); //in crystalsvg "misc" is better...
|
||||
w->image(Fl_Shared_Image::get(icon.c_str()));
|
||||
|
||||
w->redraw();
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
// comment this to use edelib::ExpandableGroup
|
||||
#define USE_FLU_WRAP_GROUP
|
||||
//#define USE_FLU_WRAP_GROUP
|
||||
|
||||
#ifdef USE_FLU_WRAP_GROUP
|
||||
#include "Flu_Wrap_Group.h"
|
||||
|
@ -22,7 +22,7 @@
|
||||
* a horizontal scrollbar will be shown)
|
||||
* FILE_DETAILS_VIEW - each file is in a single row, and columns
|
||||
* contain information such as file type, size, date of last change
|
||||
* and permission
|
||||
* and permissions
|
||||
* FILE_ICON_VIEW - large icons are shown, and filenames are
|
||||
* displayed below icons (if necessary, a vertical scrollbar will be
|
||||
* shown), additional data is shown in tooltips
|
||||
@ -36,7 +36,13 @@
|
||||
* such as add(), insert(), remove() and update(). These methods take
|
||||
* values of type struct FileItem, which contains all the data shown
|
||||
* by FileDetailsView. The reason for this is to enable reuse in
|
||||
* programs that don't work with standard filesystem.
|
||||
* programs that don't work with standard filesystem (archivers,
|
||||
* network browsers etc.) These methods work on all views at the same
|
||||
* time, which means that after calling type(), you don't have to
|
||||
* repopulate the view.
|
||||
*
|
||||
* NOTE: for compatibility with Fl_Browser, item indexes are 1 to n
|
||||
* as opposed to the C & C++ usual 0 to n-1
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,7 +57,7 @@ struct FileItem {
|
||||
edelib::String name; // just the name
|
||||
edelib::String icon;
|
||||
edelib::String size;
|
||||
edelib::String realpath; // whatever the caller uses to access the file
|
||||
edelib::String realpath; // whatever the caller uses to access the file - can be VFS
|
||||
edelib::String description;
|
||||
edelib::String date;
|
||||
edelib::String permissions;
|
||||
@ -82,6 +88,9 @@ private:
|
||||
FileIconView* icons;
|
||||
FileViewType m_type;
|
||||
public:
|
||||
/**
|
||||
* Constructor - inherits Fl_Group ctor (with the same behavior)
|
||||
*/
|
||||
FileView(int X, int Y, int W, int H, char*label=0) : Fl_Group(X,Y,W,H,label) {
|
||||
browser = new FileDetailsView(X,Y,W,H,label);
|
||||
browser->end();
|
||||
@ -95,6 +104,10 @@ public:
|
||||
m_type=FILE_DETAILS_VIEW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/set type of view. View contents will be inherited, you don't
|
||||
* have to re-add all items after changing type.
|
||||
*/
|
||||
void type(FileViewType t) {
|
||||
m_type=t;
|
||||
if (t==FILE_DETAILS_VIEW) {
|
||||
@ -120,33 +133,149 @@ public:
|
||||
// Methods that must be implemented by each view
|
||||
|
||||
// Setter methods (forwarded to all views)
|
||||
|
||||
/**
|
||||
* Insert given item after item with index "row". Note that index is 1 to n
|
||||
*/
|
||||
void insert(int row, FileItem *item) { browser->insert(row,item); icons->insert(row,item); }
|
||||
|
||||
/**
|
||||
* Add given item at end of list.
|
||||
*/
|
||||
void add(FileItem *item) { browser->add(item); icons->add(item); }
|
||||
|
||||
/**
|
||||
* Remove given item from list. Item is found according to realpath which is
|
||||
* supposed to be unique.
|
||||
*/
|
||||
void remove(FileItem *item) { browser->remove(item); icons->remove(item); }
|
||||
|
||||
/**
|
||||
* Update given item. Item is matched according to realpath, which means that
|
||||
* this method is not suitable for renaming (but see method update_path). Method
|
||||
* also does redrawing.
|
||||
*/
|
||||
void update(FileItem *item) { browser->update(item); icons->update(item); }
|
||||
|
||||
/**
|
||||
* Update real path of an item in the list. Since update() can't be used for
|
||||
* changing realpath, you can use this method for that part. This will also
|
||||
* update the label (name of file).
|
||||
*/
|
||||
void update_path(const char* oldpath,const char* newpath) { browser->update_path(oldpath,newpath); icons->update_path(oldpath,newpath); }
|
||||
|
||||
/**
|
||||
* Define callback function for view. Callback is called when an item is
|
||||
* doubleclicked or Enter key is pressed. Callback function is standard
|
||||
* Fl_Callback.
|
||||
*/
|
||||
void callback(Fl_Callback*cb) { browser->callback(cb); icons->callback(cb);}
|
||||
|
||||
/**
|
||||
* Define callback function which is called when file renaming is attempted.
|
||||
* Renaming will start when user clicks on an already selected item (see
|
||||
* method start_rename() for other ways). If no rename callback is defined,
|
||||
* then renaming will not be possible, and nothing will happen. This is the
|
||||
* default behavior.
|
||||
*
|
||||
* Rename callback function must be of type void()(const char*) and the
|
||||
* parameter is new file name (old file name can be found using
|
||||
* view->path(view->get_focus()) ).
|
||||
*/
|
||||
void rename_callback(rename_callback_type* cb) { browser->rename_callback(cb); icons->rename_callback(cb); }
|
||||
|
||||
/**
|
||||
* Define callback function which is called when a file is dropped using
|
||||
* mouse into current view (drag&drop). If no paste callback is defined,
|
||||
* widget will refuse dropping and corresponding cursor will be shown
|
||||
* (usually a cross).
|
||||
*
|
||||
* Paste callback function must be of type void()(const char*) and the
|
||||
* parameter is destination / target (usually the current directory).
|
||||
* If the parameter is 0, function must assume current directory, which
|
||||
* is what the parent loaded into view (thus parent application must know
|
||||
* which is the current directory). Source is naturally in
|
||||
* Fl::event_text()
|
||||
*/
|
||||
void paste_callback(paste_callback_type* cb) { browser->paste_callback(cb); icons->paste_callback(cb); }
|
||||
|
||||
/**
|
||||
* Define callback function which is called when right menu button is
|
||||
* clicked. This will usually display a context menu. If no context
|
||||
* callback is defined, nothing will happen (default). Callback
|
||||
* function is standard Fl_Callback.
|
||||
*/
|
||||
void context_callback(Fl_Callback* cb) { browser->context_callback(cb); icons->context_callback(cb); }
|
||||
|
||||
/**
|
||||
* Remove item with index i from view. Note that index is 1 to n
|
||||
*/
|
||||
void remove(int i) { browser->remove(i); icons->remove(i);}
|
||||
|
||||
/**
|
||||
* Remove all items from view and redraw.
|
||||
*/
|
||||
void clear() { browser->clear(); icons->clear();}
|
||||
|
||||
// Methods forwarded to just the active view
|
||||
/**
|
||||
* Gray the item marked with index, marking it for cut operation.
|
||||
*/
|
||||
void gray(int row) { if (m_type==FILE_DETAILS_VIEW) browser->gray(row); else icons->gray(row); }
|
||||
|
||||
/**
|
||||
* Reverse the effect of method gray().
|
||||
*/
|
||||
void ungray(int row) { if (m_type==FILE_DETAILS_VIEW) browser->ungray(row); else icons->ungray(row); }
|
||||
|
||||
const char* path(int i) { if (m_type==FILE_DETAILS_VIEW) return browser->path(i); else return icons->path(i); }
|
||||
int size() { if (m_type==FILE_DETAILS_VIEW) return browser->size(); else return icons->children();}
|
||||
int selected(int i) { if (m_type==FILE_DETAILS_VIEW) return browser->selected(i); else return icons->selected(i); }
|
||||
/**
|
||||
* Return the full path of item with index i.
|
||||
*/
|
||||
const char* path(int i) const { if (m_type==FILE_DETAILS_VIEW) return browser->path(i); else return icons->path(i); }
|
||||
|
||||
/**
|
||||
* Return the total number of items currently in view
|
||||
*/
|
||||
int size() const { if (m_type==FILE_DETAILS_VIEW) return browser->size(); else return icons->children();}
|
||||
|
||||
/**
|
||||
* Return 1 if item with index i is currently selected and 0 if it isn't.
|
||||
* Selection means that item has a darker background and next operation
|
||||
* will be performed on that item.
|
||||
*/
|
||||
int selected(int i) const { if (m_type==FILE_DETAILS_VIEW) return browser->selected(i); else return icons->selected(i); }
|
||||
|
||||
/**
|
||||
* Select (mark) item with index i. If k is 0, then unselect. This also
|
||||
* has the effect that the item is focused.
|
||||
*/
|
||||
void select(int i, int k) { if (m_type==FILE_DETAILS_VIEW) { browser->select(i,k); browser->show_item(i); } else { icons->select(i,k); icons->show_item(i); } }
|
||||
int get_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->get_focus(); else return icons->get_focus(); }
|
||||
|
||||
/**
|
||||
* Return index of item which currently has focus, meaning that focus
|
||||
* box (small dashes) is drawn around it. Focus can be changed with
|
||||
* arrow keys and is useful for keyboard navigation.
|
||||
*/
|
||||
int get_focus() const { if (m_type==FILE_DETAILS_VIEW) return browser->get_focus(); else return icons->get_focus(); }
|
||||
|
||||
/**
|
||||
* Set focus on item that has index i. The view will also be scrolled
|
||||
* to show that item.
|
||||
*/
|
||||
void set_focus(int i) { if (m_type==FILE_DETAILS_VIEW) browser->set_focus(i); else icons->set_focus(i);}
|
||||
|
||||
/**
|
||||
* This standard fltk method is overloaded to enable the currently
|
||||
* visible widget to take focus from other widgets in a window.
|
||||
*/
|
||||
int take_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->take_focus(); else return icons->take_focus(); }
|
||||
|
||||
/**
|
||||
* Start renaming the currently focused file. Since rename box is
|
||||
* implemented inside view widget, this is useful if you want to
|
||||
* enable an alternate method for starting rename operation (e.g.
|
||||
* F2 key).
|
||||
*/
|
||||
void start_rename() { if (m_type==FILE_DETAILS_VIEW) return browser->start_rename(); else return icons->start_rename(); }
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@ Fl_Progress* cut_copy_progress;
|
||||
bool stop_now;
|
||||
bool overwrite_all, skip_all;
|
||||
|
||||
enum OperationType_ { // Stop idiotic warnings from gcc
|
||||
enum OperationType_ { // Stop idiotic warnings from gcc (anonymous enum in global scope)
|
||||
CUT,
|
||||
COPY,
|
||||
ASK
|
||||
@ -118,7 +118,9 @@ const char* my_filename_dir(const char* path) {
|
||||
|
||||
|
||||
|
||||
// Execute cut or copy operation
|
||||
// Execute cut or copy operation from GUI (this actually does nothing
|
||||
// on the filesystem, just store list of files in buffer and mark operation; files
|
||||
// will be copied or moved when do_paste is called)
|
||||
void do_cut_copy(bool m_copy) {
|
||||
int num = view->size();
|
||||
if (m_copy) operation = COPY; else operation = CUT;
|
||||
@ -178,9 +180,9 @@ void do_cut_copy(bool m_copy) {
|
||||
}
|
||||
|
||||
|
||||
// Copy single file. Returns true if operation should continue
|
||||
// Copy single file on filesystem. Returns false if operation failed and process should be stopped
|
||||
|
||||
// Note that at this point directories should be expanded into subdirectories etc.
|
||||
// Note that at this point directories should be expanded into subdirectories and files,
|
||||
// so when "copying" a directory we actually mean creating a new directory with same properties
|
||||
bool my_copy(const char* src, const char* dest) {
|
||||
FILE *fold, *fnew;
|
||||
@ -235,7 +237,7 @@ bool my_copy(const char* src, const char* dest) {
|
||||
fl_alert(tsprintf(_("Error copying %s to %s"),src,dest)); */
|
||||
|
||||
|
||||
// This should already be checked!
|
||||
// This should already be checked by file_readable and file_writeable
|
||||
if ( ( fold = fopen( src, "rb" ) ) == NULL ) {
|
||||
int q = ede_choice_alert(tsprintf(_("Cannot read file\n\t%s\n%s"), src, strerror(errno)), _("&Stop"), _("&Continue"), 0);
|
||||
if (q == 1) return true; else return false;
|
||||
@ -259,7 +261,7 @@ bool my_copy(const char* src, const char* dest) {
|
||||
}
|
||||
|
||||
if (stop_now) {
|
||||
edelib::alert(_("Copying interrupted!\nFile %s is only half-copied and probably broken."), my_filename_name(dest));
|
||||
edelib::alert(_("Copying interrupted!\nFile %s is only half-copied and probably incorrect."), my_filename_name(dest));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -364,10 +366,13 @@ void do_delete() {
|
||||
edelib::alert(_("Couldn't delete directory\n\t%s\n%s"), files_list[i], strerror(errno));
|
||||
|
||||
// refresh directory listing - optimized
|
||||
for (int i=1; i<=view->size(); i++)
|
||||
for (int j=0; j<list_size; j++)
|
||||
if (strcmp(files_list[j],view->path(i))==0)
|
||||
view->remove(i);
|
||||
// if notify is available, it will do it for us
|
||||
if (!notify_available) {
|
||||
for (int i=1; i<=view->size(); i++)
|
||||
for (int j=0; j<list_size; j++)
|
||||
if (strcmp(files_list[j],view->path(i))==0)
|
||||
view->remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup memory
|
||||
@ -390,7 +395,7 @@ void do_rename(const char* newname) {
|
||||
else if (!edelib::file_rename(oldpath,newpath))
|
||||
edelib::alert(_("Rename %s to %s failed!"), oldname, newname);
|
||||
else
|
||||
view->update_path(oldpath,newpath);
|
||||
if (!notify_available) view->update_path(oldpath,newpath);
|
||||
}
|
||||
|
||||
|
||||
@ -506,7 +511,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
|
||||
}
|
||||
|
||||
|
||||
{ // to silence goto
|
||||
{ // to silence warning caused by goto
|
||||
|
||||
overwrite_all=false; skip_all=false;
|
||||
stop_now=false;
|
||||
@ -567,7 +572,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
|
||||
// This list is used for updating mimetypes after the copying is finished
|
||||
FileItem **item_list=0;
|
||||
int item_list_size=0;
|
||||
if (strncmp(to,current_dir,strlen(to))==0)
|
||||
if (!notify_available && strncmp(to,current_dir,strlen(to))==0)
|
||||
// avoid malloc if current dir isn't inside the scope of paste
|
||||
item_list = new FileItem*[list_size];
|
||||
|
||||
@ -624,7 +629,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
|
||||
}
|
||||
|
||||
// Update interface - add file to list (if we are viewing the destination directory)
|
||||
} else if (strcmp(current_dir,my_filename_dir(dest))==0) {
|
||||
} else if (!notify_available && strcmp(current_dir,my_filename_dir(dest))==0) {
|
||||
FileItem *item = new FileItem;
|
||||
item->name = my_filename_name(dest);
|
||||
item->realpath = dest;
|
||||
@ -666,7 +671,8 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
|
||||
goto FINISH;
|
||||
}
|
||||
|
||||
// -- Update interface in a smart way
|
||||
// -- Update interface in a smart way - but only if there is no notify
|
||||
if (!notify_available) {
|
||||
|
||||
// Remove cutted files
|
||||
if (operation == CUT)
|
||||
@ -699,8 +705,11 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
|
||||
}
|
||||
view->update(item);
|
||||
delete item_list[i];
|
||||
}
|
||||
delete[] item_list;
|
||||
} // for...
|
||||
|
||||
delete[] item_list; // this was allocated before
|
||||
|
||||
} // if (!notify_available)...
|
||||
|
||||
// Select the just pasted files (they're at the bottom)
|
||||
if (item_list_size>0) {
|
||||
@ -709,7 +718,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
|
||||
view->select(i,1);
|
||||
}
|
||||
|
||||
} // scoping to silence goto
|
||||
} // scoping to silence goto warning
|
||||
|
||||
// Cleanup memory and exit
|
||||
FINISH:
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "EDE_FileView.h"
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <edelib/Window.h>
|
||||
|
||||
// Execute cut or copy operation when List View is active
|
||||
void do_cut_copy(bool m_copy);
|
||||
@ -31,9 +32,14 @@ void do_delete();
|
||||
// Rename the file that has focus to given name
|
||||
void do_rename(const char*);
|
||||
|
||||
// Show part of path with filename - works for directories too
|
||||
const char* my_filename_name(const char*);
|
||||
|
||||
|
||||
// Stuff declared in global scope in efiler.cpp
|
||||
extern FileView* view;
|
||||
extern Fl_Window* win;
|
||||
extern edelib::Window* win;
|
||||
extern Fl_Box* statusbar;
|
||||
extern char current_dir[];
|
||||
extern void loaddir(const char*);
|
||||
extern bool notify_available;
|
||||
|
Loading…
Reference in New Issue
Block a user