- F2 to rename

- F8 to switch between active views
- Finally fix dnd in FileIconView
This commit is contained in:
Vedran Ljubovic 2007-08-24 09:19:53 +00:00
parent 7a59ab12a4
commit fdf84c4620
7 changed files with 66 additions and 18 deletions

View File

@ -5,7 +5,4 @@ will be assumed.
- Callback for tree view widget is erratic - it usually doesn't work on Enter
key and sometimes it is sufficient to press arrow up or down to enter a
directory.
- Pressing F2 doesn't start renaming the file
- In icon view, holding shift while clicking has the same effect as ctrl (i.e.
adds just the focused widget to selection, not the ones in between)
- Icon view: sometimes files with @ in name aren't properly aligned

View File

@ -399,9 +399,9 @@ int FileDetailsView::handle(int e) {
selected_items += "\r\n";
}
EDEBUG(DBG "DnD buffer: '%s'\n", selected_items.c_str());
dragx = Fl::event_x(); dragy = Fl::event_y();
Fl::copy(selected_items.c_str(),selected_items.length(),0);
Fl::dnd();
dragx = Fl::event_x(); dragy = Fl::event_y();
return 1; // don't do the multiple selection thing from Fl_Browser
}

View File

@ -156,6 +156,8 @@ public:
// Aliases for better compatibility with other views
const char*path(int row) { return (const char*)data(row); }
void show_item(int row) { middleline(row); }
void start_rename() { show_editbox(get_focus()); }
};

View File

@ -69,7 +69,8 @@ EDEBUG(DBG " Editbox handle(%d)\n", e);
} else if (k==FL_Up || k==FL_Down || k==FL_Page_Up || k==FL_Page_Down) {
view->hide_editbox();
return 0; // let the view scroll
} else if (k==FL_F+2 || k==FL_Escape)
} else if (e==FL_KEYBOARD && (k==FL_F+2 || k==FL_Escape))
// FL_KEYUP will happen immediately after showing editbox
view->hide_editbox();
else
Fl_Input::handle(e);
@ -703,9 +704,11 @@ EDEBUG(DBG"FL_DRAG! ");
// If paste_callback_ isn't set, that means we don't support dnd
if (paste_callback_) {
EDEBUG(DBG"- dnd.\n");
dragx=ex; dragy=ey; // to test the min. distance
Fl::belowmouse(this); // without this, we will never get FL_DND_RELEASE!!!
Fl::copy(selected_items.c_str(),selected_items.length(),0);
Fl::dnd();
dragx=ex; dragy=ey; // to test if its close
}
return 1;
@ -842,7 +845,7 @@ if (e==FL_DND_ENTER) { EDEBUG(DBG"FL_DND_ENTER\n"); }
if (e==FL_DND_DRAG) { EDEBUG(DBG"FL_DND_DRAG\n"); }
if (e==FL_DND_RELEASE) { EDEBUG(DBG"FL_DND_RELEASE\n"); }
// Let the window manager know that we accept dnd
if (e==FL_DND_ENTER||e==FL_DND_DRAG) return 1;
if (e==FL_DND_ENTER||e==FL_DND_DRAG||e==FL_DND_LEAVE) return 1;
/* // Scroll the view by dragging to border
if (e==FL_DND_LEAVE) {

View File

@ -195,6 +195,10 @@ public:
edelib::ExpandableGroup::clear();
#endif
}
void start_rename() {
show_editbox(get_focus());
}
};

View File

@ -146,6 +146,8 @@ public:
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);}
int take_focus() { if (m_type==FILE_DETAILS_VIEW) return browser->take_focus(); else return icons->take_focus(); }
void start_rename() { if (m_type==FILE_DETAILS_VIEW) return browser->start_rename(); else return icons->start_rename(); }
};

View File

@ -80,6 +80,39 @@ const int statusbar_width = 400;
int default_tree_width=150;
// Subclassed Fl_Window for switching views
class EFiler_Window : public Fl_Double_Window {
public:
EFiler_Window (int W, int H, const char* title=0) : Fl_Double_Window(W,H,title) {}
EFiler_Window (int X, int Y, int W, int H, const char* title=0) :
Fl_Double_Window(X,Y,W,H,title) {}
int handle(int e) {
// Have F8 function as switch between active views
if (e == FL_KEYBOARD && Fl::event_key()==FL_F+8) {
if (view->type() == FILE_DETAILS_VIEW) {
view->type(FILE_ICON_VIEW);
// We do this juggling with tsprintf to avoid duplicate strings for localization
Fl_Menu_Item* i = (Fl_Menu_Item*) main_menu->find_item(tsprintf("%s/%s", _("&View"), _("&Icons")));
i->set();
} else {
view->type(FILE_DETAILS_VIEW);
Fl_Menu_Item* i = (Fl_Menu_Item*) main_menu->find_item(tsprintf("%s/%s", _("&View"), _("&Detailed list")));
i->set();
}
loaddir(current_dir);
return 1;
}
return Fl_Double_Window::handle(e);
}
};
/*-----------------------------------------------------------------
Some improvements to Fl_File_Input, that should be added
upstream:
@ -525,6 +558,9 @@ void copy_cb(Fl_Widget*, void*) { do_cut_copy(true); }
void paste_cb(Fl_Widget*, void*) { Fl::paste(*view,1); } // view->handle() will call do_paste()
void delete_cb(Fl_Widget*, void*) { do_delete(); }
// Call view's rename functionality
void viewrename_cb(Fl_Widget*, void*) { view->start_rename(); }
void showtree_cb(Fl_Widget*, void*) {
showtree = !showtree;
@ -585,15 +621,19 @@ void dirsfirst_cb(Fl_Widget*, void*) {
void ow_cb(Fl_Widget*, void*) { fprintf(stderr, "callback\n"); } // make a list of openers
void pref_cb(Fl_Widget*, void*) { fprintf(stderr, "callback\n"); }
void iconsview_cb(Fl_Widget*, void*) {
//fprintf(stderr, "callback\n");
view->type(FILE_ICON_VIEW);
loaddir(current_dir);
if (view->type() != FILE_ICON_VIEW) {
view->type(FILE_ICON_VIEW);
loaddir(current_dir);
}
}
void listview_cb(Fl_Widget*, void*) {
//fprintf(stderr, "callback\n");
view->type(FILE_DETAILS_VIEW);
loaddir(current_dir);
if (view->type() != FILE_DETAILS_VIEW) {
view->type(FILE_DETAILS_VIEW);
loaddir(current_dir);
}
}
void about_cb(Fl_Widget*, void*) { fprintf(stderr, "callback\n"); }
void aboutede_cb(Fl_Widget*, void*) { fprintf(stderr, "callback\n"); }
@ -721,13 +761,13 @@ Fl_Menu_Item main_menu_definition[] = {
{_("&Cut"), FL_CTRL+'x', cut_cb},
{_("C&opy"), FL_CTRL+'c', copy_cb},
{_("&Paste"), FL_CTRL+'v', paste_cb},
{_("&Rename"), FL_F+2, 0}, // no callback - view handles this
{_("&Rename"), FL_F+2, viewrename_cb},
{_("&Delete"), FL_Delete, delete_cb, 0, FL_MENU_DIVIDER},
{_("Pre&ferences"), FL_CTRL+'p', pref_cb},
{0},
{_("&View"), 0, 0, 0, FL_SUBMENU},
{_("&Icons"), FL_F+8, iconsview_cb, 0, FL_MENU_RADIO}, // coming soon
{_("&Icons"), 0, iconsview_cb, 0, FL_MENU_RADIO},
{_("&Detailed list"), 0, listview_cb, 0, FL_MENU_RADIO|FL_MENU_VALUE|FL_MENU_DIVIDER},
{_("Directory &tree"), FL_F+9, showtree_cb, 0, FL_MENU_TOGGLE|FL_MENU_VALUE},
{_("&Location bar"), FL_F+10, locationbar_cb, 0, FL_MENU_TOGGLE|FL_MENU_VALUE},
@ -776,8 +816,7 @@ fl_message_font(FL_HELVETICA, 12);
// Main GUI design
win = new Fl_Double_Window(default_window_width, default_window_height);
win = new EFiler_Window(default_window_width, default_window_height);
// win->color(FL_WHITE);
win->begin();
main_menu = new Fl_Menu_Bar(0,0,default_window_width,menubar_height);
@ -838,6 +877,7 @@ fl_message_font(FL_HELVETICA, 12);
showhidden=false; dirsfirst=true; ignorecase=true; semaphore=false; showtree=true; showlocation=true;
tree_width = default_tree_width;
Fl::visual(FL_DOUBLE|FL_INDEX); // see Fl_Window docs
win->show(argc,argv);
view->take_focus();
dirtree->init();