mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Small refactoring
This commit is contained in:
parent
865bbca053
commit
8a08b132ad
|
@ -308,6 +308,7 @@ int DesktopIcon::drag_icon_y(void) {
|
||||||
void DesktopIcon::rename(const char* str) {
|
void DesktopIcon::rename(const char* str) {
|
||||||
if(!str)
|
if(!str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(settings->name == str)
|
if(settings->name == str)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -311,3 +311,16 @@ char* get_basename(const char* path) {
|
||||||
|
|
||||||
return (char*)path;
|
return (char*)path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_temp_filename(const char* path) {
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(!path || path[0] == '\0' || path[0] == '.')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
len = strlen(path);
|
||||||
|
if(path[len - 1] == '~')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -41,5 +41,6 @@ void set_xoverlay_drawable(Fl_Window* win);
|
||||||
Pixmap create_mask(Fl_Image* img);
|
Pixmap create_mask(Fl_Image* img);
|
||||||
|
|
||||||
char* get_basename(const char* path);
|
char* get_basename(const char* path);
|
||||||
|
bool is_temp_filename(const char* path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -914,6 +914,10 @@ void Desktop::dir_watch(const char* dir, const char* changed, int flags) {
|
||||||
if(!do_dirwatch || !changed || flags == edelib::DW_REPORT_NONE)
|
if(!do_dirwatch || !changed || flags == edelib::DW_REPORT_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// skip temporary files
|
||||||
|
if(is_temp_filename(changed))
|
||||||
|
return;
|
||||||
|
|
||||||
if(trash_path == dir) {
|
if(trash_path == dir) {
|
||||||
bool is_empty = edelib::dir_empty(trash_path.c_str());
|
bool is_empty = edelib::dir_empty(trash_path.c_str());
|
||||||
|
|
||||||
|
@ -932,17 +936,6 @@ void Desktop::dir_watch(const char* dir, const char* changed, int flags) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Check first we don't get any temporary files (starting with '.'
|
|
||||||
* or ending with '~', like vim does when editing file). For now these
|
|
||||||
* are only conditions, but I will probably add them more when issues occured.
|
|
||||||
*
|
|
||||||
* FIXME: use strcmp() family ?
|
|
||||||
*/
|
|
||||||
edelib::String tmp(changed);
|
|
||||||
if(tmp.empty() || tmp[0] == '.' || tmp[tmp.length()-1] == '~')
|
|
||||||
return;
|
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
if(flags == edelib::DW_REPORT_CREATE) {
|
if(flags == edelib::DW_REPORT_CREATE) {
|
||||||
|
@ -953,15 +946,6 @@ void Desktop::dir_watch(const char* dir, const char* changed, int flags) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Uh; looks like kernel report event faster than file is created
|
|
||||||
* (in some cases). This can be bad for .desktop files when are copied
|
|
||||||
* (eg. on my machine after 'cp Home.desktop foo.desktop', will fail
|
|
||||||
* to load foo.desktop since it's content is not fully copied).
|
|
||||||
* Due that we stop for one sec (use usleep() ???)
|
|
||||||
*/
|
|
||||||
//sleep(1);
|
|
||||||
|
|
||||||
if(add_icon_by_path(changed, 0))
|
if(add_icon_by_path(changed, 0))
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user