mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Port efiler to new MessageBox class, remove some debugging msg
This commit is contained in:
parent
d30d6f1776
commit
165449fe85
@ -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 ede_ask.cpp Flu_Wrap_Group.cpp EDE_FileIconView.cpp EDE_FileDetailsView.cpp ;
|
||||
SOURCE = Fl_Icon_Browser.cxx EDE_Browser.cpp EDE_DirTree.cpp Util.cpp efiler.cpp fileops.cpp filesystem.cpp Flu_Wrap_Group.cpp EDE_FileIconView.cpp EDE_FileDetailsView.cpp ;
|
||||
|
||||
LinkAgainst efiler : -lXpm ;
|
||||
|
||||
|
@ -1,143 +0,0 @@
|
||||
/*
|
||||
* $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 <FL/Fl.H>
|
||||
#include <FL/fl_ask.H>
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <FL/Fl_Widget.H>
|
||||
#include <edelib/IconTheme.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
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_choice(fmt, fl_yes, fl_no, 0);
|
||||
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;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* $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,...);
|
@ -38,12 +38,11 @@
|
||||
#include <edelib/StrUtil.h>
|
||||
#include <edelib/Run.h>
|
||||
#include <edelib/IconTheme.h> // for setting the icon theme
|
||||
#include <edelib/MessageBox.h>
|
||||
|
||||
#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 "Ask.h"
|
||||
|
||||
#include "fileops.h" // file operations
|
||||
#include "filesystem.h" // filesystem support
|
||||
@ -190,7 +189,7 @@ char *simpleopener(const char* mimetype) {
|
||||
sopeners* p;
|
||||
if (!openers) {
|
||||
FILE* fp = fopen("openers.txt","r");
|
||||
if (!fp) { ede_alert(_("File openers.txt not found")); return 0; }
|
||||
if (!fp) { edelib::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);
|
||||
@ -334,7 +333,7 @@ void loaddir(const char *path) {
|
||||
if (path!=current_dir) strncpy(current_dir,tmpath,strlen(tmpath)+1);
|
||||
}
|
||||
} else {
|
||||
ede_alert(tsprintf(_("Directory not found: %s"),path));
|
||||
edelib::alert(tsprintf(_("Directory not found: %s"),path));
|
||||
free(tmpath);
|
||||
semaphore=false;
|
||||
return;
|
||||
@ -364,7 +363,7 @@ void loaddir(const char *path) {
|
||||
size = scandir(current_dir, &files, 0, versionsort);
|
||||
|
||||
if (size<1) { // there should always be . and ..
|
||||
ede_alert(_("Permission denied!"));
|
||||
edelib::alert(_("Permission denied!"));
|
||||
// edelib::fl_alert(_("Permission denied!"));
|
||||
strncpy(current_dir,old_dir,strlen(current_dir));
|
||||
semaphore=false;
|
||||
@ -384,7 +383,6 @@ void loaddir(const char *path) {
|
||||
|
||||
view->clear();
|
||||
|
||||
fprintf(stderr, "Size: %d\n", size);
|
||||
FileItem **item_list = new FileItem*[size];
|
||||
int fsize=0;
|
||||
|
||||
@ -463,7 +461,6 @@ fprintf(stderr, "Size: %d\n", size);
|
||||
if (desc!="" || icon!="") {
|
||||
if (desc != "") item_list[i]->description = desc;
|
||||
if (icon != "") item_list[i]->icon = icon;
|
||||
fprintf (stderr, "ICON: %s !!!!!\n", icon.c_str());
|
||||
view->update(item_list[i]);
|
||||
}
|
||||
Fl::check();
|
||||
@ -494,11 +491,9 @@ fprintf (stderr, "ICON: %s !!!!!\n", icon.c_str());
|
||||
|
||||
// This callback is called by doubleclicking on file list, by main menu 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) {
|
||||
|
||||
fprintf (stderr,"enter\n");
|
||||
//if (Fl::event_clicks()) fprintf(stderr, "clicks\n");
|
||||
//if (Fl::event_key()==FL_Enter) fprintf(stderr, "ekey\n");
|
||||
static timeval tm = {0,0};
|
||||
@ -509,7 +504,6 @@ fprintf (stderr,"enter\n");
|
||||
if (view->get_focus()==0) return; // This can happen while efiler is loading
|
||||
|
||||
char* path = (char*)view->path(view->get_focus());
|
||||
fprintf(stderr, "Path: %s (ev %d)\n",path,Fl::event());
|
||||
|
||||
if (stat(path,&stat_buffer)) return; // error
|
||||
if (S_ISDIR(stat_buffer.st_mode)) { // directory
|
||||
@ -567,11 +561,9 @@ void showtree_cb(Fl_Widget*, void*) {
|
||||
if (!showtree) {
|
||||
tree_width = dirtree->w();
|
||||
tile->position(default_tree_width, 1, 1, 1); // NOTE this doesn't always work!
|
||||
fprintf(stderr, "Hide tree: %d\n", tree_width);
|
||||
} else {
|
||||
int currentw = dirtree->w();
|
||||
tile->position(currentw, 1, tree_width, 1);
|
||||
fprintf(stderr, "Show tree: %d %d\n", currentw, tree_width);
|
||||
}
|
||||
}
|
||||
|
||||
@ -814,6 +806,9 @@ edelib::IconTheme::init("crystalsvg");
|
||||
FL_NORMAL_SIZE=12;
|
||||
fl_message_font(FL_HELVETICA, 12);
|
||||
|
||||
// Required by the new edelib::MessageBox class
|
||||
edelib::themed_dialog_icons(MSGBOX_ICON_INFO, MSGBOX_ICON_WARNING, MSGBOX_ICON_QUESTION, MSGBOX_ICON_QUESTION, MSGBOX_ICON_PASSWORD);
|
||||
|
||||
|
||||
// Main GUI design
|
||||
win = new EFiler_Window(default_window_width, default_window_height);
|
||||
@ -877,7 +872,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
|
||||
Fl::visual(FL_DOUBLE|FL_INDEX); // see Fl_Double_Window docs
|
||||
win->show(argc,argv);
|
||||
view->take_focus();
|
||||
dirtree->init();
|
||||
|
@ -31,11 +31,11 @@
|
||||
#include <edelib/String.h>
|
||||
#include <edelib/StrUtil.h>
|
||||
#include <edelib/MimeType.h>
|
||||
#include <edelib/MessageBox.h>
|
||||
|
||||
|
||||
#include "EDE_FileView.h"
|
||||
#include "Util.h"
|
||||
#include "ede_ask.h" // replacement for fl_ask
|
||||
#include "filesystem.h" // is_on_same_fs()
|
||||
|
||||
|
||||
@ -50,6 +50,36 @@ enum OperationType_ { // Stop idiotic warnings from gcc
|
||||
} operation = ASK;
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
// Our choice alert (fl_choice with alert icon)
|
||||
// based on edelib::MessageBox
|
||||
// ----------------------------------------------
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int ede_choice_alert(const char*fmt,const char *b0,const char *b1,const char *b2,...) {
|
||||
static char internal_buff[1024];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, b2);
|
||||
vsnprintf(internal_buff, 1024, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
edelib::MessageBox mb;
|
||||
mb.set_text(internal_buff);
|
||||
mb.add_button(b0);
|
||||
mb.add_button(b1);
|
||||
mb.add_button(b2);
|
||||
|
||||
mb.set_theme_icon(MSGBOX_ICON_WARNING); // specified in edelib/MessageBox.h
|
||||
|
||||
mb.set_modal();
|
||||
return mb.run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
// Some helper functions
|
||||
// ----------------------------------------------
|
||||
@ -225,7 +255,7 @@ bool my_copy(const char* src, const char* dest) {
|
||||
}
|
||||
|
||||
if (stop_now) {
|
||||
ede_alert(tsprintf(_("Copying interrupted!\nFile %s is only half-copied and probably broken."), my_filename_name(dest)));
|
||||
edelib::alert(tsprintf(_("Copying interrupted!\nFile %s is only half-copied and probably broken."), my_filename_name(dest)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -320,14 +350,14 @@ void do_delete() {
|
||||
for (int i=0; i<list_size; i++)
|
||||
if (!my_isdir(files_list[i]))
|
||||
if (!edelib::file_remove(files_list[i]))
|
||||
ede_alert(tsprintf(_("Couldn't delete file\n\t%s\n%s"), files_list[i], strerror(errno)));
|
||||
edelib::alert(tsprintf(_("Couldn't delete file\n\t%s\n%s"), files_list[i], strerror(errno)));
|
||||
|
||||
// ...then directories
|
||||
// since expand_dirs() returns first dirs then files, we should go in oposite direction
|
||||
for (int i=list_size-1; i>=0; i--)
|
||||
if (my_isdir(files_list[i]))
|
||||
if (!edelib::dir_remove(files_list[i]))
|
||||
ede_alert(tsprintf(_("Couldn't delete directory\n\t%s\n%s"), files_list[i], strerror(errno)));
|
||||
edelib::alert(tsprintf(_("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++)
|
||||
@ -352,9 +382,9 @@ void do_rename(const char* newname) {
|
||||
snprintf(newpath, FL_PATH_MAX-1, "%s%s", current_dir, newname);
|
||||
|
||||
if (edelib::file_exists(newpath))
|
||||
ede_alert(tsprintf(_("Filename already in use: %s"), newname));
|
||||
edelib::alert(tsprintf(_("Filename already in use: %s"), newname));
|
||||
else if (!edelib::file_rename(oldpath,newpath))
|
||||
ede_alert(tsprintf(_("Rename %s to %s failed!"), oldname, newname));
|
||||
edelib::alert(tsprintf(_("Rename %s to %s failed!"), oldname, newname));
|
||||
else
|
||||
view->update_path(oldpath,newpath);
|
||||
}
|
||||
@ -481,7 +511,7 @@ fprintf (stderr, "from[%d]='%s'\n", k, from[k]);
|
||||
char *srcdir = strdup(my_filename_dir(from[0]));
|
||||
if (strcmp(srcdir,to)==0) {
|
||||
// This should never happen cause we already checked it...
|
||||
ede_alert(_("You cannot copy a file onto itself!"));
|
||||
edelib::alert(_("You cannot copy a file onto itself!"));
|
||||
free(srcdir);
|
||||
goto FINISH;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user