mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
DND stuff (unfinished).
This commit is contained in:
parent
f006fb0d0f
commit
c951b708ce
@ -71,18 +71,21 @@ DesktopIcon::DesktopIcon(GlobalIconSettings* gs, IconSettings* is, int bg) :
|
||||
|
||||
//edelib::String ipath = edelib::IconTheme::get(nn, edelib::ICON_SIZE_MEDIUM);
|
||||
edelib::String ipath = edelib::IconTheme::get(nn, edelib::ICON_SIZE_HUGE);
|
||||
Fl_Image* img = Fl_Shared_Image::get(ipath.c_str());
|
||||
if(img) {
|
||||
int img_w = img->w();
|
||||
int img_h = img->h();
|
||||
if(!ipath.empty()) {
|
||||
Fl_Image* img = Fl_Shared_Image::get(ipath.c_str());
|
||||
if(img) {
|
||||
int img_w = img->w();
|
||||
int img_h = img->h();
|
||||
|
||||
// resize box if icon is larger
|
||||
if(img_w > ICONSIZE || img_h > ICONSIZE)
|
||||
size(img_w + OFFSET_W, img_h + OFFSET_H);
|
||||
// resize box if icon is larger
|
||||
if(img_w > ICONSIZE || img_h > ICONSIZE)
|
||||
size(img_w + OFFSET_W, img_h + OFFSET_H);
|
||||
|
||||
image(img);
|
||||
image(img);
|
||||
} else
|
||||
EDEBUG(ESTRLOC ": Unable to load %s\n", ipath.c_str());
|
||||
} else
|
||||
EDEBUG(ESTRLOC ": Unable to load %s\n", ipath.c_str());
|
||||
EDEBUG(ESTRLOC ": Got empty icon name ?!?\n");
|
||||
}
|
||||
/*
|
||||
EDEBUG(ESTRLOC ": Got label: %s\n", label());
|
||||
|
@ -103,7 +103,7 @@ Pixmap create_xpixmap(Fl_Image* img, XImage* xim, Pixmap pix) {
|
||||
else if(fl_visual->depth > 8)
|
||||
bitmap_pad = 16;
|
||||
else {
|
||||
EWARNING("Visual %i not supported\n", xim->bits_per_pixel);
|
||||
EWARNING(ESTRLOC ": Visual %i not supported\n", xim->bits_per_pixel);
|
||||
|
||||
XDestroyImage(xim);
|
||||
xim = 0;
|
||||
@ -429,3 +429,38 @@ void Wallpaper::draw(void) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <FL/Fl.h>
|
||||
|
||||
int Wallpaper::handle(int event) {
|
||||
switch(event) {
|
||||
/*
|
||||
* Route all DND events to parent (desktop), otherwise
|
||||
* desktop will not get them if Wallpaper is visible
|
||||
*/
|
||||
case FL_DND_ENTER:
|
||||
case FL_DND_DRAG:
|
||||
case FL_DND_LEAVE:
|
||||
case FL_DND_RELEASE:
|
||||
return parent()->handle(event);
|
||||
|
||||
case FL_PASTE:
|
||||
/*
|
||||
* Since some stuff are in fltk unnedededly complicated, like
|
||||
* DND, this is needed to make it correctly work. After we got
|
||||
* FL_PASTE event (drag'n drop content released), that content
|
||||
* is routed to CLIPBOARD buffer of Desktop and in turn will trigger
|
||||
* FL_PASTE on Desktop.
|
||||
*
|
||||
* This is since fltk use XA_PRIMARY as default (or selection clipboard from X11)
|
||||
* not CLIPBOARD (as rest of normal world).
|
||||
*
|
||||
* Also, to make DND workable for Desktop, Wallpaper widget must be
|
||||
* always visible.
|
||||
*/
|
||||
Fl::paste(*parent(), 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Fl_Box::handle(event);
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class Wallpaper : public Fl_Box {
|
||||
bool set(const char* path);
|
||||
bool set_tiled(const char* path);
|
||||
virtual void draw(void);
|
||||
virtual int handle(int event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -121,6 +121,8 @@ Desktop::Desktop() : Fl_Window(0, 0, 100, 100, "") {
|
||||
begin();
|
||||
wallpaper = new Wallpaper(0, 0, w(), h());
|
||||
wallpaper->set("/home/sanel/wallpapers/katebig.jpg");
|
||||
//wallpaper->hide();
|
||||
//wallpaper->set("/home/sanelz/walls/katebig.jpg");
|
||||
//wallpaper->set("/home/sanelz/walls/nin/1024x768-04.jpg");
|
||||
//wallpaper->set("/home/sanelz/walls/nin/1024x768-02.jpg");
|
||||
notify = new NotifyBox(w(), h());
|
||||
@ -168,6 +170,8 @@ void Desktop::show(void) {
|
||||
Fl_X::make_xid(this);
|
||||
net_make_me_desktop(this);
|
||||
}
|
||||
|
||||
//Fl::dnd_text_ops(1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -307,6 +311,7 @@ void Desktop::load_icons(const char* path, edelib::Config& conf) {
|
||||
} else {
|
||||
// then try to figure out it's mime; if fails, ignore it
|
||||
if(mt.set(full_path.c_str())) {
|
||||
EDEBUG(ESTRLOC ": Loading icon as mime-type %s\n", mt.icon_name().c_str());
|
||||
is.icon = mt.icon_name();
|
||||
// icon label is name of file
|
||||
is.name = name;
|
||||
@ -572,6 +577,34 @@ void Desktop::notify_desktop_changed(void) {
|
||||
XFreeStringList(names);
|
||||
}
|
||||
|
||||
void Desktop::drop_source(const char* src, int x, int y) {
|
||||
if(!src)
|
||||
return;
|
||||
IconSettings is;
|
||||
is.x = x;
|
||||
is.y = y;
|
||||
|
||||
// absolute path is (for now) seen as non-url
|
||||
if(src[0] == '/')
|
||||
is.cmd_is_url = false;
|
||||
else
|
||||
is.cmd_is_url = true;
|
||||
|
||||
is.name = get_basename(src);
|
||||
is.cmd = "(none)";
|
||||
is.type = ICON_NORMAL;
|
||||
|
||||
edelib::MimeType mt;
|
||||
if(!mt.set(src)) {
|
||||
EWARNING(ESTRLOC ": MimeType for %s failed, not dropping icon\n", src);
|
||||
return;
|
||||
}
|
||||
|
||||
is.icon = mt.icon_name();
|
||||
DesktopIcon* dic = new DesktopIcon(&gisett, &is, color());
|
||||
add_icon(dic);
|
||||
}
|
||||
|
||||
int Desktop::handle(int event) {
|
||||
switch(event) {
|
||||
case FL_FOCUS:
|
||||
@ -675,6 +708,20 @@ int Desktop::handle(int event) {
|
||||
moving = false;
|
||||
return 1;
|
||||
|
||||
case FL_DND_ENTER:
|
||||
case FL_DND_DRAG:
|
||||
case FL_DND_LEAVE:
|
||||
return 1;
|
||||
|
||||
case FL_DND_RELEASE:
|
||||
EDEBUG(ESTRLOC ": DND on desktop\n");
|
||||
return 1;
|
||||
|
||||
case FL_PASTE:
|
||||
EDEBUG("================> PASTE: %s\n", Fl::event_text());
|
||||
drop_source(Fl::event_text(), Fl::event_x_root(), Fl::event_y_root());
|
||||
return 1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -98,6 +98,8 @@ class Desktop : public Fl_Window {
|
||||
bool in_selection(const DesktopIcon* ic);
|
||||
void move_selection(int x, int y, bool apply);
|
||||
|
||||
void drop_source(const char* src, int x, int y);
|
||||
|
||||
//DesktopIcon* below_mouse(int px, int py);
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user