Icon renaming support.

This commit is contained in:
Sanel Zukan 2012-05-15 11:10:40 +00:00
parent c2366025b5
commit eccdcd83ef
3 changed files with 21 additions and 3 deletions

View File

@ -83,8 +83,11 @@ static void open_cb(Fl_Widget*, void* d) {
static void rename_cb(Fl_Widget*, void* d) {
DesktopIcon* di = (DesktopIcon*)d;
const char* new_name = input(_("New name"), di->label());
const char* new_name = input(_("Change desktop icon name to:"), di->label());
if(new_name) {
di->rename(new_name);
Desktop::instance()->rename_icon(di, new_name);
}
}
static void delete_cb(Fl_Widget*, void* d) {
@ -95,7 +98,7 @@ static void delete_cb(Fl_Widget*, void* d) {
}
static void props_cb(Fl_Widget*, void* d) {
DesktopIcon* di = (DesktopIcon*)d;
//DesktopIcon* di = (DesktopIcon*)d;
}
DesktopIcon::DesktopIcon(GlobalIconSettings* gs, IconSettings* is, int bg) :

View File

@ -582,6 +582,20 @@ bool Desktop::remove_icon(DesktopIcon *d, bool real_delete) {
return ret;
}
bool Desktop::rename_icon(DesktopIcon *d, const char *n) {
DesktopFile f;
const char *p = d->path().c_str();
E_RETURN_VAL_IF_FAIL(f.load(p), false);
dir_watch_off();
f.set_name(n);
bool ret = f.save(p);
dir_watch_on();
return ret;
}
bool Desktop::remove_icon_by_path(const char* path) {
DesktopIconListIter pos;
DesktopIcon* ic = find_icon_by_path(path, &pos);

View File

@ -157,6 +157,7 @@ public:
bool add_icon_by_path(const char* path, edelib::Resource* conf);
bool remove_icon(DesktopIcon *d, bool real_delete);
bool rename_icon(DesktopIcon *d, const char *n);
void update_workarea(void);
void area(int& X, int& Y, int& W, int& H) { X = x(); Y = y(); W = w(); H = h(); }