FileView::update_path() will now also update the displayed filename - this

will simplify FileIconView implementation
This commit is contained in:
Vedran Ljubovic 2007-08-23 11:09:05 +00:00
parent f56292b6cf
commit 5ebfa5253c
3 changed files with 19 additions and 17 deletions

View File

@ -16,6 +16,7 @@
#include <FL/Fl_Input.H> #include <FL/Fl_Input.H>
#include <FL/Fl_Shared_Image.H> #include <FL/Fl_Shared_Image.H>
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/filename.H> // used in update_path()
#include <edelib/Nls.h> #include <edelib/Nls.h>
#include <edelib/IconTheme.h> #include <edelib/IconTheme.h>
@ -175,9 +176,11 @@ FileDetailsView::FileDetailsView(int X, int Y, int W, int H, char*label) : EDE_B
// struct FileItem (defined in EDE_FileView.h) // struct FileItem (defined in EDE_FileView.h)
void FileDetailsView::insert(int row, FileItem *item) { void FileDetailsView::insert(int row, FileItem *item) {
// edelib::String doesn't support adding plain char
char cc[2]; cc[0]=column_char(); cc[1]='\0';
// Construct browser line // Construct browser line
edelib::String value; edelib::String value = item->name + cc + item->description + cc + item->size + cc + item->date + cc + item->permissions;
value = item->name+"\t"+item->description+"\t"+item->size+"\t"+item->date+"\t"+item->permissions;
char* realpath = strdup(item->realpath.c_str()); char* realpath = strdup(item->realpath.c_str());
EDE_Browser::insert(row, value.c_str(), realpath); // put realpath into data EDE_Browser::insert(row, value.c_str(), realpath); // put realpath into data
bucket.add(realpath); bucket.add(realpath);
@ -200,8 +203,11 @@ void FileDetailsView::update(FileItem *item) {
// c) causes browser to lose focus, making it impossible to click on something while // c) causes browser to lose focus, making it impossible to click on something while
// directory is loading // directory is loading
edelib::String value; // edelib::String doesn't support adding plain char
value = item->name+"\t"+item->description+"\t"+item->size+"\t"+item->date+"\t"+item->permissions; char cc[2]; cc[0]=column_char(); cc[1]='\0';
// Construct browser line
edelib::String value = item->name + cc + item->description + cc + item->size + cc + item->date + cc + item->permissions;
char* realpath = strdup(item->realpath.c_str()); char* realpath = strdup(item->realpath.c_str());
text(row, value.c_str()); text(row, value.c_str());
data(row, realpath); data(row, realpath);
@ -221,6 +227,12 @@ void FileDetailsView::update_path(const char* oldpath,const char* newpath) {
char* c = strdup(newpath); char* c = strdup(newpath);
data(row,c); data(row,c);
bucket.add(c); bucket.add(c);
// Update filename in list
char* oldline = strchr(text(row), column_char());
edelib::String line = fl_filename_name(newpath);
line += oldline;
text(row, line.c_str());
} }

View File

@ -146,11 +146,6 @@ public:
int get_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->get_focus(); else return icons->get_focus(); } int get_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->get_focus(); else return icons->get_focus(); }
void set_focus(int i) { if (m_type==FILE_DETAILS_VIEW) browser->set_focus(i); else icons->set_focus(i);} void set_focus(int i) { if (m_type==FILE_DETAILS_VIEW) browser->set_focus(i); else icons->set_focus(i);}
int take_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->take_focus(); else return icons->take_focus(); } int take_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->take_focus(); else return icons->take_focus(); }
// These methods are used by do_rename() - should become obsoleted
const char* text(int i) { return browser->text(i); }
void text(int i, const char* c) { return browser->text(i,c); }
uchar column_char() { return browser->column_char(); }
}; };

View File

@ -355,15 +355,8 @@ void do_rename(const char* newname) {
ede_alert(tsprintf(_("Filename already in use: %s"), newname)); ede_alert(tsprintf(_("Filename already in use: %s"), newname));
else if (!edelib::file_rename(oldpath,newpath)) else if (!edelib::file_rename(oldpath,newpath))
ede_alert(tsprintf(_("Rename %s to %s failed!"), oldname, newname)); ede_alert(tsprintf(_("Rename %s to %s failed!"), oldname, newname));
else { else
// Insert new name into vline
// FIXME text() methods shouldn't be exported by view!
edelib::String vline = view->text(focus);
vline = newname + vline.substr(vline.find(view->column_char(),0));
view->text(focus,vline.c_str());
view->update_path(oldpath,newpath); view->update_path(oldpath,newpath);
}
} }
@ -393,6 +386,7 @@ void do_paste(const char* t) {
fprintf (stderr, "PASTE from '%s', to '%s', type=%d\n",(char*)Fl::event_text(),to,operation); fprintf (stderr, "PASTE from '%s', to '%s', type=%d\n",(char*)Fl::event_text(),to,operation);
if (!strchr(Fl::event_text(), '/')) if (!strchr(Fl::event_text(), '/'))
return; // User is pasting something that isn't files return; // User is pasting something that isn't files
// TODO: create a text file? // TODO: create a text file?
@ -474,6 +468,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
else else
c = ede_choice_alert(tsprintf(_("Copy or move these %d files to directory\n\t%s ?"), count, to), _("C&ancel"), _("&Copy"), _("&Move")); c = ede_choice_alert(tsprintf(_("Copy or move these %d files to directory\n\t%s ?"), count, to), _("C&ancel"), _("&Copy"), _("&Move"));
fprintf(stderr, "Exited choice_alert\n");
if (c==0) goto FINISH; if (c==0) goto FINISH;
if (c==1) operation=COPY; else operation=CUT; if (c==1) operation=COPY; else operation=CUT;
} }