From c94e8e31947d9e8c5dc5ee13abf980cdd0765ddb Mon Sep 17 00:00:00 2001 From: Vedran Ljubovic Date: Fri, 3 Aug 2007 09:59:31 +0000 Subject: [PATCH] - Beginning of ede_ask.h/.cpp - Proper fix for label and text size - no more hacks - Command line parsing, so fltk args can be used (use --help for details) - Autocomplete in location bar and callbacks for shortcut buttons --- efiler/Jamfile | 2 +- efiler/TODO | 4 ++ efiler/ede_ask.cpp | 143 ++++++++++++++++++++++++++++++++++++++++++++ efiler/ede_ask.h | 25 ++++++++ efiler/efiler.cpp | 144 ++++++++++++++++++++++++++++++++++++--------- efiler/fileops.cpp | 66 +++++++++++---------- efiler/fileops.h | 2 +- 7 files changed, 325 insertions(+), 61 deletions(-) create mode 100644 efiler/TODO create mode 100644 efiler/ede_ask.cpp create mode 100644 efiler/ede_ask.h diff --git a/efiler/Jamfile b/efiler/Jamfile index a3fcba0..8ddf9f3 100644 --- a/efiler/Jamfile +++ b/efiler/Jamfile @@ -10,7 +10,7 @@ SubDir TOP efiler ; -SOURCE = Fl_Icon_Browser.cxx EDE_Browser.cpp EDE_DirTree.cpp Util.cpp efiler.cpp fileops.cpp filesystem.cpp ; +SOURCE = Fl_Icon_Browser.cxx EDE_Browser.cpp EDE_DirTree.cpp Util.cpp efiler.cpp fileops.cpp filesystem.cpp ede_ask.cpp ; EdeProgram efiler : $(SOURCE) ; #EdeManual doc/efiler.txt : doc/efiler.jpg ; diff --git a/efiler/TODO b/efiler/TODO new file mode 100644 index 0000000..21a7ca5 --- /dev/null +++ b/efiler/TODO @@ -0,0 +1,4 @@ +- Fix dnd (and if possible copy&paste) with other popular file managers +- Add dnd to directory tree +- Add notify support from edelib +- Add support for fd.o Trash protocol diff --git a/efiler/ede_ask.cpp b/efiler/ede_ask.cpp new file mode 100644 index 0000000..258a31b --- /dev/null +++ b/efiler/ede_ask.cpp @@ -0,0 +1,143 @@ +/* + * $Id$ + * + * EFiler - EDE File Manager + * Part of Equinox Desktop Environment (EDE). + * Copyright (c) 2000-2007 EDE Authors. + * + * This program is licenced under terms of the + * GNU General Public Licence version 2 or newer. + * See COPYING for details. + */ + +// This is a replacement for fl_ask that uses system icons. +// ede_choice_alert() is just ede_choice() that uses alert icon. +// TODO before adding to edelib: +// * return -1 in fl_choice() when user press Escape key or closes the window using [X] +// * un-reverse order of buttons (I know how to order buttons myself thank you :) ) +// * add support for EDE sound events instead of the ugly beep +// * ability to set messagebox title +// * add ede_critical() (ede_alert() with icon messagebox_critical) +// * fix for STR #1745 + + +#include +#include +#include +#include +#include +#include + + +Fl_Image* img; + +void ede_alert(const char*fmt, ...) { + va_list ap; + + img = Fl_Shared_Image::get(edelib::IconTheme::get("messagebox_warning",edelib::ICON_SIZE_MEDIUM).c_str()); + Fl_Widget* w = fl_message_icon(); + w->image(img); + w->label(""); + w->align(FL_ALIGN_TOP| FL_ALIGN_CENTER | FL_ALIGN_INSIDE); + w->box(FL_NO_BOX); + + va_start(ap,fmt); + fl_alert(fmt); + va_end(ap); +} + +void ede_message(const char*fmt, ...) { + va_list ap; + + img = Fl_Shared_Image::get(edelib::IconTheme::get("messagebox_info",edelib::ICON_SIZE_MEDIUM).c_str()); + Fl_Widget* w = fl_message_icon(); + w->image(img); + w->label(""); + w->align(FL_ALIGN_TOP| FL_ALIGN_CENTER | FL_ALIGN_INSIDE); + w->box(FL_NO_BOX); + + va_start(ap,fmt); + fl_message(fmt); + va_end(ap); +} + +int ede_ask(const char*fmt, ...) { + va_list ap; + + img = Fl_Shared_Image::get(edelib::IconTheme::get("help",edelib::ICON_SIZE_MEDIUM).c_str()); + Fl_Widget* w = fl_message_icon(); + w->image(img); + w->label(""); + w->align(FL_ALIGN_TOP| FL_ALIGN_CENTER | FL_ALIGN_INSIDE); + w->box(FL_NO_BOX); + + va_start(ap,fmt); + int c=fl_ask(fmt); + va_end(ap); + return c; +} + +int ede_choice(const char*fmt,const char *b0,const char *b1,const char *b2,...) { + va_list ap; + + img = Fl_Shared_Image::get(edelib::IconTheme::get("help",edelib::ICON_SIZE_MEDIUM).c_str()); + Fl_Widget* w = fl_message_icon(); + w->image(img); + w->label(""); + w->align(FL_ALIGN_TOP| FL_ALIGN_CENTER | FL_ALIGN_INSIDE); + w->box(FL_NO_BOX); + + va_start(ap,b2); + int c=fl_choice(fmt,b0,b1,b2); + va_end(ap); + return c; +} + +int ede_choice_alert(const char*fmt,const char *b0,const char *b1,const char *b2,...) { + va_list ap; + + img = Fl_Shared_Image::get(edelib::IconTheme::get("messagebox_warning",edelib::ICON_SIZE_MEDIUM).c_str()); + Fl_Widget* w = fl_message_icon(); + w->image(img); + w->label(""); + w->align(FL_ALIGN_TOP| FL_ALIGN_CENTER | FL_ALIGN_INSIDE); + w->box(FL_NO_BOX); + + va_start(ap,b2); + int c=fl_choice(fmt,b0,b1,b2); + va_end(ap); + return c; +} + +const char* ede_password(const char*fmt,const char *defstr,...) { + va_list ap; + + img = Fl_Shared_Image::get(edelib::IconTheme::get("password",edelib::ICON_SIZE_MEDIUM).c_str()); + Fl_Widget* w = fl_message_icon(); + w->image(img); + w->label(""); + w->align(FL_ALIGN_TOP| FL_ALIGN_CENTER | FL_ALIGN_INSIDE); + w->box(FL_NO_BOX); + + va_start(ap,defstr); + const char* c = fl_password(fmt,defstr); + va_end(ap); + return c; +} + + +const char* ede_input(const char*fmt,const char *defstr,...) { + va_list ap; + + img = Fl_Shared_Image::get(edelib::IconTheme::get("help",edelib::ICON_SIZE_MEDIUM).c_str()); + Fl_Widget* w = fl_message_icon(); + w->image(img); + w->label(""); + w->align(FL_ALIGN_TOP| FL_ALIGN_CENTER | FL_ALIGN_INSIDE); + w->box(FL_NO_BOX); + + va_start(ap,defstr); + const char* c = fl_input(fmt,defstr); + va_end(ap); + return c; +} diff --git a/efiler/ede_ask.h b/efiler/ede_ask.h new file mode 100644 index 0000000..ba3daad --- /dev/null +++ b/efiler/ede_ask.h @@ -0,0 +1,25 @@ +/* + * $Id$ + * + * EFiler - EDE File Manager + * Part of Equinox Desktop Environment (EDE). + * Copyright (c) 2000-2007 EDE Authors. + * + * This program is licenced under terms of the + * GNU General Public Licence version 2 or newer. + * See COPYING for details. + */ + +// This is a replacement for fl_ask that uses system icons. +// TODO: also add support for EDE sound events instead of the ugly beep +// ede_choice_alert() is just ede_choice() that uses alert icon. + + + +void ede_alert(const char*fmt, ...); +void ede_message(const char*fmt, ...); +int ede_ask(const char*fmt, ...); +int ede_choice(const char*fmt,const char *b0,const char *b1,const char *b2,...); +int ede_choice_alert(const char*fmt,const char *b0,const char *b1,const char *b2,...); +const char* ede_password(const char*fmt,const char *defstr,...); +const char* ede_input(const char*fmt,const char *defstr,...); diff --git a/efiler/efiler.cpp b/efiler/efiler.cpp index 86d569c..22e1187 100644 --- a/efiler/efiler.cpp +++ b/efiler/efiler.cpp @@ -3,7 +3,7 @@ * * EFiler - EDE File Manager * Part of Equinox Desktop Environment (EDE). - * Copyright (c) 2000-2006 EDE Authors. + * Copyright (c) 2000-2007 EDE Authors. * * This program is licenced under terms of the * GNU General Public Licence version 2 or newer. @@ -24,7 +24,6 @@ #include // for fl_dir_chooser, used in "Open location" #include #include -#include #include // location bar #include @@ -36,6 +35,7 @@ #include "EDE_FileView.h" // our file view widget #include "EDE_DirTree.h" // directory tree #include "Util.h" // ex-edelib +#include "ede_ask.h" // replacement for fl_ask #include "fileops.h" // file operations #include "filesystem.h" // filesystem support @@ -51,7 +51,6 @@ Fl_Group* location_bar; Fl_File_Input* location_input; Fl_Menu_Button* context_menu; - char current_dir[FL_PATH_MAX]; bool showhidden; bool semaphore; @@ -74,6 +73,7 @@ const int statusbar_width = 400; int default_tree_width=150; + /*----------------------------------------------------------------- "Simple opener" - keep a list of openers in text file This is just a temporary fix so that efiler works atm. @@ -93,7 +93,7 @@ char *simpleopener(const char* mimetype) { sopeners* p; if (!openers) { FILE* fp = fopen("openers.txt","r"); - if (!fp) { fl_alert(_("File openers.txt not found")); return 0; } + if (!fp) { ede_alert(_("File openers.txt not found")); return 0; } char buf[FL_PATH_MAX*2]; while (!feof(fp)) { fgets((char*)&buf, FL_PATH_MAX*2, fp); @@ -177,13 +177,9 @@ void loaddir(const char *path) { *tmp='\0'; } - // Update directory tree - dirtree->set_current(current_dir); - location_input->value(current_dir); - // variables used later int size=0; - dirent **files; + dirent **files; // List all files in directory if (ignorecase) @@ -192,12 +188,18 @@ void loaddir(const char *path) { size = scandir(current_dir, &files, 0, versionsort); if (size<1) { // there should always be . and .. - fl_alert(_("Permission denied!")); + ede_alert(_("Permission denied!")); strncpy(current_dir,old_dir,strlen(current_dir)); semaphore=false; return; } + // Ok, now we know everything is fine... + + // Update directory tree + dirtree->set_current(current_dir); + location_input->value(current_dir); + // set window label // copy_label() is a method that calls strdup() and later free() win->copy_label(tsprintf(_("%s - File manager"), current_dir)); @@ -310,10 +312,10 @@ fprintf (stderr, "ICON: %s !!!!!\n", icon.c_str()); /*----------------------------------------------------------------- - Main menu callbacks + Main menu and other callbacks -------------------------------------------------------------------*/ -// Open callback +// This callback is called by doubleclicking on file list, by main and context menu void open_cb(Fl_Widget*w, void*data) { fprintf (stderr,"cb\n"); if (Fl::event_clicks() || Fl::event_key() == FL_Enter || w==main_menu || w==context_menu) { @@ -362,6 +364,9 @@ fprintf (stderr,"enter\n"); } } // open_cb + + +// Main menu callbacks void location_cb(Fl_Widget*, void*) { const char *dir = fl_dir_chooser(_("Choose location"),current_dir); if (dir) loaddir(dir); @@ -394,7 +399,6 @@ fprintf(stderr, "Show tree: %d %d\n", currentw, tree_width); void refresh_cb(Fl_Widget*, void*) { loaddir(current_dir); - // TODO: reload directory tree as well- } void locationbar_cb(Fl_Widget*, void*) { @@ -428,7 +432,8 @@ void case_cb(Fl_Widget*, void*) { void dirsfirst_cb(Fl_Widget*, void*) { dirsfirst=!dirsfirst; loaddir(current_dir); } -// dummy callbacks + +// dummy callbacks - TODO 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"); } @@ -446,8 +451,82 @@ void tree_cb(Fl_Widget*, void*) { } } -// User entered a location -void location_input_cb(Fl_Widget*, void*) { loaddir(location_input->value()); } + +// This callback handles location input: changing the directory, autocomplete +// and callbacks for shortcut buttons +// location_input is set to FL_WHEN_CHANGED +void location_input_cb(Fl_Widget*, void*) { +fprintf (stderr, "location_input_cb %d\n",Fl::event()); + if (Fl::event_key() == FL_Enter || Fl::event()==FL_RELEASE) + loaddir(location_input->value()); + + if (Fl::event()==FL_KEYDOWN && Fl::event_key()!=FL_BackSpace) { + // Pressing a key in Fl_Input will automatically replace selection with that key + // So there are really two possibilities: + // 1. Cursor is at the end, we add autocomplete stuff at cursor pos + // 2. Cursor is in the middle, we do nothing + + const char* loc = location_input->value(); // shortcut + if (strlen(loc)<1 || loc[strlen(loc)-1]=='/') return; + int pos = location_input->position(); + if (pos!=strlen(loc)) return; // cursor in the middle + int mark = location_input->mark(); + + // To avoid scandir, we will use view contents + // smart, eh? :) + if ((strlen(loc)>strlen(current_dir)) && (!strchr(loc+strlen(current_dir),'/'))) { + int i; + for (i=1; i<=view->size(); i++) { + const char* p = view->path(i); + if ((p[strlen(p)-1] == '/') && (strncmp(loc, p, strlen(loc))==0)) + break; + } + + if (i<=view->size()) { + location_input->replace(pos, mark, view->path(i)+pos); + location_input->position(pos); + location_input->mark(strlen(view->path(i))); + } + // else beep(); ?? + + } else { + // sigh, we need to scandir.... + char* k; + if (!(k=strrchr(loc,'/'))) return; + char* updir = strdup(loc); + updir[k-loc+1] = '\0'; + + dirent **files; + int size = scandir(updir, &files, 0, versionsort); + if (size<1) { free(updir); return; } + + int i; + char p[FL_PATH_MAX]; + for (i=0; id_name); + + struct stat buf; + if (stat(p,&buf)) continue; // happens when user has traverse but not read privilege + if (S_ISDIR(buf.st_mode)) { + strcat(p,"/"); + if (strncmp(loc, p, strlen(loc))==0) + break; + } + free(files[i]); + } + free(files); free(updir); + if (ireplace(pos, mark, p+pos); + location_input->position(pos); + location_input->mark(strlen(p)); + } + // else beep(); ?? + } + } +} + + + Fl_Menu_Item context_menu_definition[] = { {_("&Open"), 0, open_cb}, @@ -517,24 +596,41 @@ Fl_Menu_Item main_menu_definition[] = { int main (int argc, char **argv) { + // Parse command line - this must come first + int unknown=0; + Fl::args(argc,argv,unknown); + if (unknown==argc) + current_dir[0]='\0'; + else { + if (strcmp(argv[unknown],"--help")==0) { + printf("EFiler - EDE File Manager\nPart of Equinox Desktop Environment (EDE).\nCopyright (c) 2000-2007 EDE Authors.\n\nThis program is licenced under terms of the\nGNU General Public Licence version 2 or newer.\nSee COPYING for details.\n\n"); + printf("Usage:\n\tefiler [OPTIONS] [PATH]\n\n"); + printf("%s\n",Fl::help); + return 1; + } + strncpy(current_dir, argv[unknown], strlen(argv[unknown])+1); + } + + fl_register_images(); edelib::IconTheme::init("crystalsvg"); +FL_NORMAL_SIZE=12; +fl_message_font(FL_HELVETICA, 12); + win = new Fl_Double_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); main_menu->menu(main_menu_definition); - main_menu->textsize(12); // hack for label size location_bar = new Fl_Group(0, menubar_height, default_window_width, location_bar_height); location_bar->begin(); location_input = new Fl_File_Input(70, menubar_height+2, default_window_width-200, location_bar_height-5, _("Location:")); - location_input->labelsize(12); // hack for label size - location_input->textsize(12); // hack for label size location_input->align(FL_ALIGN_LEFT); location_input->callback(location_input_cb); + location_input->when(FL_WHEN_ENTER_KEY_CHANGED); location_bar->end(); location_bar->box(FL_UP_BOX); // hack for label size location_bar->resizable(location_input); @@ -542,7 +638,6 @@ edelib::IconTheme::init("crystalsvg"); tile = new Fl_Tile(0, menubar_height+location_bar_height, default_window_width, default_window_height-menubar_height-location_bar_height-statusbar_height); tile->begin(); dirtree = new DirTree(0, menubar_height+location_bar_height, default_tree_width, default_window_height-menubar_height-location_bar_height-statusbar_height); - dirtree->textsize(12); // hack for label size dirtree->callback(tree_cb); view = new FileDetailsView(150, menubar_height+location_bar_height, default_window_width-default_tree_width, default_window_height-menubar_height-location_bar_height-statusbar_height); @@ -556,7 +651,6 @@ edelib::IconTheme::init("crystalsvg"); Fl_Group *sbgroup = new Fl_Group(0, default_window_height-statusbar_height, default_window_width, statusbar_height); statusbar = new Fl_Box(2, default_window_height-statusbar_height+2, statusbar_width, statusbar_height-4); statusbar->box(FL_DOWN_BOX); - statusbar->labelsize(12); // hack for label size statusbar->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP); statusbar->label(_("Ready.")); @@ -567,7 +661,6 @@ edelib::IconTheme::init("crystalsvg"); context_menu = new Fl_Menu_Button (0,0,0,0); context_menu->type(Fl_Menu_Button::POPUP3); context_menu->menu(context_menu_definition); - context_menu->textsize(12); // hack for label size context_menu->box(FL_NO_BOX); win->end(); @@ -578,17 +671,12 @@ edelib::IconTheme::init("crystalsvg"); view->take_focus(); // Yet another hack for label size.... - fl_message_font(FL_HELVETICA, 12); // TODO remember previous configuration showhidden=false; dirsfirst=true; ignorecase=true; semaphore=false; showtree=true; showlocation=true; tree_width = default_tree_width; dirtree->init(); - if (argc==1) // No params - loaddir (""); - else - loaddir (argv[1]); - + loaddir(current_dir); return Fl::run(); } diff --git a/efiler/fileops.cpp b/efiler/fileops.cpp index 32baa5b..57737bc 100644 --- a/efiler/fileops.cpp +++ b/efiler/fileops.cpp @@ -3,7 +3,7 @@ * * EFiler - EDE File Manager * Part of Equinox Desktop Environment (EDE). - * Copyright (c) 2000-2006 EDE Authors. + * Copyright (c) 2000-2007 EDE Authors. * * This program is licenced under terms of the * GNU General Public Licence version 2 or newer. @@ -35,6 +35,7 @@ #include "EDE_FileView.h" #include "Util.h" +#include "ede_ask.h" // replacement for fl_ask Fl_Progress* cut_copy_progress; @@ -141,8 +142,7 @@ bool my_copy(const char* src, const char* dest) { int c = -1; if (!overwrite_all && !skip_all) { - // here was choice_alert - c = fl_choice(tsprintf(_("File already exists: %s. What to do?"), dest), _("&Overwrite"), _("Over&write all"), _("&Skip"), _("Skip &all"), 0); // asterisk (*) means default + c = ede_choice_alert(tsprintf(_("File already exists: %s. What to do?"), dest), _("&Overwrite"), _("Over&write all"), _("&Skip"), _("Skip &all"), 0); // asterisk (*) means default } if (c==1) overwrite_all=true; if (c==3) skip_all=true; @@ -171,15 +171,19 @@ bool my_copy(const char* src, const char* dest) { if (mkdir (dest, buf.st_mode)==0) return true; // success // here was choice_alert - int q = fl_choice(tsprintf(_("Cannot create directory %s (%d)"),dest,strerror(errno)), _("&Stop"), _("&Continue"), 0); + int q = ede_choice_alert(tsprintf(_("Cannot create directory %s (%d)"),dest,strerror(errno)), _("&Stop"), _("&Continue"), 0); if (q == 0) return false; else return true; } - /* Sorry, edelib funcs just don't cut it.... + /* We don't use edelib funcs because we need to: + * know if file is creatable (e.g. if user has write permissions in target directory), + * detect errors WHILE copying (e.g. disk is full) + * update interface while copying + * set permissions after finish if ( !edelib::file_readable(src) ) { // here was choice_alert - int q = fl_choice(tsprintf(_("Cannot read file %s"),src), _("&Stop"), _("&Continue"), 0); + int q = ede_choice_alert(tsprintf(_("Cannot read file %s"),src), _("&Stop"), _("&Continue"), 0); if (q == 0) return false; else return true; } @@ -187,7 +191,7 @@ bool my_copy(const char* src, const char* dest) { /* if ( !edelib::file_writeable(dest) ) { // here was choice_alert - int q = fl_choice(tsprintf(_("Cannot create file %s"),dest), _("&Stop"), _("&Continue"), 0); + int q = ede_choice_alert(tsprintf(_("Cannot create file %s"),dest), _("&Stop"), _("&Continue"), 0); if (q == 0) return true; else return false; } @@ -196,14 +200,14 @@ bool my_copy(const char* src, const char* dest) { fl_alert(tsprintf(_("Error copying %s to %s"),src,dest)); */ if ( ( fold = fopen( src, "rb" ) ) == NULL ) { - int q = fl_choice(tsprintf(_("Cannot read file\n\t%s\n%s"), src, strerror(errno)), _("&Stop"), _("&Continue"), 0); + int q = ede_choice_alert(tsprintf(_("Cannot read file\n\t%s\n%s"), src, strerror(errno)), _("&Stop"), _("&Continue"), 0); if (q == 0) return false; else return true; } if ( ( fnew = fopen( dest, "wb" ) ) == NULL ) { fclose ( fold ); - int q = fl_choice(tsprintf(_("Cannot create file\n\t%s\n%s"), dest, strerror(errno)), _("&Stop"), _("&Continue"), 0); + int q = ede_choice_alert(tsprintf(_("Cannot create file\n\t%s\n%s"), dest, strerror(errno)), _("&Stop"), _("&Continue"), 0); if (q == 0) return false; else return true; } @@ -222,19 +226,24 @@ bool my_copy(const char* src, const char* dest) { if (ferror(fold)) { fclose(fold); // don't flush error buffer before time fclose(fnew); - int q = fl_choice(tsprintf(_("Error while reading file\n\t%s\n%s"), src, strerror(errno)), _("&Stop"), _("&Continue"), 0); + int q = ede_choice_alert(tsprintf(_("Error while reading file\n\t%s\n%s"), src, strerror(errno)), _("&Stop"), _("&Continue"), 0); if (q == 0) return false; else return true; } if (ferror(fnew)) { fclose(fold); // don't flush error buffer before time fclose(fnew); - int q = fl_choice(tsprintf(_("Error while writing file\n\t%s\n%s"), dest, strerror(errno)), _("&Stop"), _("&Continue"), 0); + int q = ede_choice_alert(tsprintf(_("Error while writing file\n\t%s\n%s"), dest, strerror(errno)), _("&Stop"), _("&Continue"), 0); if (q == 0) return false; else return true; } fclose(fold); fclose(fnew); + // attempt to preserve permissions - if it fails, we don't care + struct stat buf; + stat(src,&buf); + chmod (dest, buf.st_mode); + return true; } @@ -303,18 +312,18 @@ void do_delete() { // here was choice_alert int c; if (list_size==1 && my_isdir(files_list[0])) { - c = fl_choice(tsprintf(_("Are you sure that you want to delete directory\n\t%s\nincluding everything in it?"), files_list[0]), _("Do&n't delete"), _("&Delete"), 0); + c = ede_choice_alert(tsprintf(_("Are you sure that you want to delete directory\n\t%s\nincluding everything in it?"), files_list[0]), _("Do&n't delete"), _("&Delete"), 0); } else if (list_size==1) { - c = fl_choice(tsprintf(_("Are you sure that you want to delete file %s ?"), my_filename_name(files_list[0])), _("Do&n't delete"), _("&Delete"), 0); + c = ede_choice_alert(tsprintf(_("Are you sure that you want to delete file %s ?"), my_filename_name(files_list[0])), _("Do&n't delete"), _("&Delete"), 0); } else - c = fl_choice(tsprintf(_("Are you sure that you want to delete %d files and directories?"), list_size), _("Do&n't delete"), _("&Delete"), 0); + c = ede_choice_alert(tsprintf(_("Are you sure that you want to delete %d files and directories?"), list_size), _("Do&n't delete"), _("&Delete"), 0); if (c==1) { // first remove files... for (int i=0; isize(); i++) @@ -349,10 +358,10 @@ void do_rename(const char* c) { newname += c; if (edelib::file_exists(newname.c_str())) - fl_alert(tsprintf(_("Filename already in use: %s"), newname.c_str())); + ede_alert(tsprintf(_("Filename already in use: %s"), newname.c_str())); // For some reason, edelib::file_rename() always fails and returns false // else if (!edelib::file_rename(oldname.c_str(),newname.c_str())) -// fl_alert(tsprintf(_("Rename %s to %s failed!"), oldname.c_str(), newname.c_str())); +// ede_alert(tsprintf(_("Rename %s to %s failed!"), oldname.c_str(), newname.c_str())); else { rename(oldname.c_str(),newname.c_str()); @@ -421,7 +430,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); // If this window is below others, try to get focus win->take_focus(); if (strcmp(to,from[i])==0) { - //fl_alert(tsprintf(_("Can't copy directory\n\t%s\ninto itself."), to)); + //ede_alert(tsprintf(_("Can't copy directory\n\t%s\ninto itself."), to)); // This happens accidentally, so statusbar is less annoying statusbar->copy_label(tsprintf(_("Can't copy directory %s into itself."), my_filename_name(to))); @@ -430,7 +439,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); if ((strncmp(to,from[i],strlen(to))==0)) { char *k = strchr(from[i]+strlen(to), '/'); if (!k || *(k+1)=='\0') { - //fl_alert(tsprintf(_("File %s is already in directory\n\t%s"), from[i]+strlen(to), to)); + //ede_alert(tsprintf(_("File %s is already in directory\n\t%s"), from[i]+strlen(to), to)); statusbar->copy_label(tsprintf(_("File %s is already in directory %s"), from[i]+strlen(to), to)); goto FINISH; } @@ -445,7 +454,6 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); Fl_Menu_Button* mb = new Fl_Menu_Button (Fl::event_x_root(),Fl::event_y_root(),0,0); mb->box(FL_NO_BOX); mb->type(Fl_Menu_Button::POPUP123); - mb->textsize(12); // hack for label size mb->add(_("&Copy"),0,cb_dnd_copy); mb->add(_("_&Move"),0,cb_dnd_cut); mb->add(_("C&ancel"),0,0); @@ -454,11 +462,11 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); int c; if (count==1 && my_isdir(from[0])) - c = fl_choice(tsprintf(_("Copy or move directory\n\t%s\nto directory\n\t%s ?"), from[0], to), _("C&ancel"), _("&Copy"), _("&Move")); + c = ede_choice_alert(tsprintf(_("Copy or move directory\n\t%s\nto directory\n\t%s ?"), from[0], to), _("C&ancel"), _("&Copy"), _("&Move")); else if (count==1) - c = fl_choice(tsprintf(_("Copy or move file %s to directory\n\t%s ?"), fl_filename_name(from[0]), to), _("C&ancel"), _("&Copy"), _("&Move")); + c = ede_choice_alert(tsprintf(_("Copy or move file %s to directory\n\t%s ?"), fl_filename_name(from[0]), to), _("C&ancel"), _("&Copy"), _("&Move")); else - c = fl_choice(tsprintf(_("Copy or move file these %d files to directory\n\t%s ?"), count, to), _("C&ancel"), _("&Copy"), _("&Move")); + c = ede_choice_alert(tsprintf(_("Copy or move file these %d files to directory\n\t%s ?"), count, to), _("C&ancel"), _("&Copy"), _("&Move")); if (c==0) goto FINISH; if (c==1) operation=COPY; else operation=CUT; @@ -480,7 +488,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); int c = -1; if (!overwrite_all && !skip_all) { // here was choice_alert - c = fl_choice(tsprintf(_("File with name\n\t%s\nalready exists. What to do?"), dest), _("&Overwrite"), _("Over&write all"), _("&Skip"), _("Skip &all")); + c = ede_choice_alert(tsprintf(_("File with name\n\t%s\nalready exists. What to do?"), dest), _("&Overwrite"), _("Over&write all"), _("&Skip"), _("Skip &all")); } if (c==1) overwrite_all=true; if (c==3) skip_all=true; @@ -528,7 +536,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); if (strcmp(srcdir,to)==0) { // This should never happen cause we already checked it... - fl_alert(_("You cannot copy a file onto itself!")); + ede_alert(_("You cannot copy a file onto itself!")); free(srcdir); goto FINISH; } @@ -550,10 +558,6 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); progress_window->end(); progress_window->show(); - caption->labelsize(12); // hack for label size - stop_button->labelsize(12); - - // Set ProgressBar range cut_copy_progress->minimum(0); cut_copy_progress->maximum(count); @@ -599,7 +603,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]); int c = -1; if (!overwrite_all && !skip_all) { // here was choice_alert - c = fl_choice(tsprintf(_("File with name\n\t%s\nalready exists. What to do?"), dest), _("&Overwrite"), _("Over&write all"), _("&Skip"), _("Skip &all")); + c = ede_choice_alert(tsprintf(_("File with name\n\t%s\nalready exists. What to do?"), dest), _("&Overwrite"), _("Over&write all"), _("&Skip"), _("Skip &all")); } if (c==1) overwrite_all=true; if (c==3) skip_all=true; diff --git a/efiler/fileops.h b/efiler/fileops.h index 464a7b6..029446c 100644 --- a/efiler/fileops.h +++ b/efiler/fileops.h @@ -3,7 +3,7 @@ * * EFiler - EDE File Manager * Part of Equinox Desktop Environment (EDE). - * Copyright (c) 2000-2006 EDE Authors. + * Copyright (c) 2000-2007 EDE Authors. * * This program is licenced under terms of the * GNU General Public Licence version 2 or newer.