Handle case when icon wasn't selected.

By default, 'empty' icon should be used. It is now shown in preview box and will
be selected when icon wasn't explicitly chosen. Also, redraw full desktop when icon was removed, to
prevent displaying icon which isn't available.

Added small delay when icon was removed so directory watcher skip remove event.
This commit is contained in:
Sanel Zukan 2012-05-15 12:49:16 +00:00
parent eccdcd83ef
commit 1c2cfe3739
2 changed files with 14 additions and 5 deletions

View File

@ -31,13 +31,16 @@
#include <edelib/StrUtil.h> #include <edelib/StrUtil.h>
#include <edelib/Util.h> #include <edelib/Util.h>
#include <edelib/MessageBox.h> #include <edelib/MessageBox.h>
#include <edelib/IconLoader.h>
#include "IconDialog.h" #include "IconDialog.h"
#include "DesktopIcon.h" #include "DesktopIcon.h"
#include "ede-desktop.h" #include "ede-desktop.h"
EDELIB_NS_USING_LIST(9, (str_tolower, icon_chooser, dir_home, build_filename, alert, EDELIB_NS_USING_LIST(10, (str_tolower, icon_chooser, dir_home, build_filename, alert,
ICON_SIZE_HUGE, String, DesktopFile, DESK_FILE_TYPE_APPLICATION)) ICON_SIZE_HUGE, String, IconLoader, DesktopFile, DESK_FILE_TYPE_APPLICATION))
#define DEFAULT_ICON "empty"
/* it is safe to be globals */ /* it is safe to be globals */
static Fl_Window *win; static Fl_Window *win;
@ -100,7 +103,7 @@ static void ok_cb(Fl_Widget*, void*) {
df.set_icon(p); df.set_icon(p);
} }
} else { } else {
df.set_icon("empty"); df.set_icon(DEFAULT_ICON);
} }
df.set_exec(execute->value()); df.set_exec(execute->value());
@ -164,6 +167,7 @@ void icon_dialog_icon_create(void) {
img = new Fl_Button(10, 10, 75, 75); img = new Fl_Button(10, 10, 75, 75);
img->callback(img_browse_cb); img->callback(img_browse_cb);
img->tooltip(_("Click to select icon")); img->tooltip(_("Click to select icon"));
IconLoader::set(img, DEFAULT_ICON, ICON_SIZE_HUGE);
name = new Fl_Input(205, 10, 215, 25, _("Name:")); name = new Fl_Input(205, 10, 215, 25, _("Name:"));
comment = new Fl_Input(205, 40, 215, 25, _("Comment:")); comment = new Fl_Input(205, 40, 215, 25, _("Comment:"));
execute = new Fl_Input(205, 70, 185, 25, _("Execute:")); execute = new Fl_Input(205, 70, 185, 25, _("Execute:"));

View File

@ -575,10 +575,16 @@ DesktopIcon* Desktop::find_icon_by_path(const char* path, DesktopIconListIter* r
bool Desktop::remove_icon(DesktopIcon *d, bool real_delete) { bool Desktop::remove_icon(DesktopIcon *d, bool real_delete) {
bool ret = true; bool ret = true;
if(real_delete) if(real_delete) {
dir_watch_off();
ret = file_remove(d->path().c_str()); ret = file_remove(d->path().c_str());
Fl::wait(1);
dir_watch_on();
}
remove_icon_by_path(d->path().c_str()); remove_icon_by_path(d->path().c_str());
/* TODO: reimplement as 'fast_redraw()' from DesktopIcon */
redraw();
return ret; return ret;
} }
@ -610,7 +616,6 @@ bool Desktop::remove_icon_by_path(const char* path) {
/* Fl_Group::remove() does not delete child, just pops it out */ /* Fl_Group::remove() does not delete child, just pops it out */
remove(ic); remove(ic);
delete ic; delete ic;
return true; return true;
} }