2007-05-22 18:53:17 +04:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2013-05-30 17:07:49 +04:00
|
|
|
* Copyright (C) 2006-2013 Sanel Zukan
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-05-22 18:53:17 +04:00
|
|
|
*/
|
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2011-08-03 16:20:37 +04:00
|
|
|
#define FL_LIBRARY 1
|
|
|
|
|
2008-09-15 15:00:23 +04:00
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/fl_draw.H>
|
2007-05-22 18:53:17 +04:00
|
|
|
#include <edelib/Debug.h>
|
2009-03-25 14:13:12 +03:00
|
|
|
#include <edelib/IconLoader.h>
|
2013-05-30 17:07:49 +04:00
|
|
|
#include <edelib/MenuItem.h>
|
2007-09-03 16:26:58 +04:00
|
|
|
#include <edelib/MessageBox.h>
|
2007-07-02 14:28:18 +04:00
|
|
|
#include <edelib/Nls.h>
|
2009-03-03 14:47:30 +03:00
|
|
|
#include <edelib/Run.h>
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2008-08-07 18:22:05 +04:00
|
|
|
#include "DesktopIcon.h"
|
2011-10-18 12:17:35 +04:00
|
|
|
#include "MovableIcon.h"
|
2013-05-30 17:07:49 +04:00
|
|
|
#include "Desktop.h"
|
|
|
|
|
|
|
|
/* label offset from icon y() + h(), so selection box can be drawn nicely */
|
|
|
|
#define LABEL_OFFSET 2
|
2008-08-07 18:22:05 +04:00
|
|
|
|
2009-07-09 17:44:16 +04:00
|
|
|
/* minimal icon sizes */
|
2008-08-10 21:49:38 +04:00
|
|
|
#define ICON_SIZE_MIN_W 48
|
|
|
|
#define ICON_SIZE_MIN_H 48
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2009-07-09 17:44:16 +04:00
|
|
|
/* spaces around box in case of large/small icons */
|
2007-05-22 18:53:17 +04:00
|
|
|
#define OFFSET_W 16
|
|
|
|
#define OFFSET_H 16
|
|
|
|
|
2009-07-09 17:44:16 +04:00
|
|
|
EDELIB_NS_USING(IconLoader)
|
2013-05-30 17:07:49 +04:00
|
|
|
EDELIB_NS_USING(String)
|
2009-07-09 17:44:16 +04:00
|
|
|
EDELIB_NS_USING(MenuButton)
|
2013-05-30 17:07:49 +04:00
|
|
|
EDELIB_NS_USING(MenuItem)
|
2009-07-09 17:44:16 +04:00
|
|
|
EDELIB_NS_USING(run_async)
|
2013-05-30 17:07:49 +04:00
|
|
|
EDELIB_NS_USING(ask)
|
|
|
|
EDELIB_NS_USING(alert)
|
|
|
|
EDELIB_NS_USING(input)
|
|
|
|
EDELIB_NS_USING(ICON_SIZE_TINY)
|
|
|
|
EDELIB_NS_USING(ICON_SIZE_HUGE)
|
2009-07-09 17:44:16 +04:00
|
|
|
|
2009-07-09 17:59:51 +04:00
|
|
|
static void open_cb(Fl_Widget*, void* d);
|
2008-08-07 18:22:05 +04:00
|
|
|
static void rename_cb(Fl_Widget*, void* d);
|
2012-05-07 12:53:13 +04:00
|
|
|
static void delete_cb(Fl_Widget*, void* d);
|
2007-07-02 14:28:18 +04:00
|
|
|
|
2009-07-09 17:44:16 +04:00
|
|
|
static MenuItem icon_menu[] = {
|
2009-07-09 17:59:51 +04:00
|
|
|
{_("&Open"), 0, open_cb, 0},
|
2009-07-09 17:44:16 +04:00
|
|
|
{_("&Rename"), 0, rename_cb, 0},
|
2012-05-18 16:06:32 +04:00
|
|
|
{_("&Delete"), 0, delete_cb, 0},
|
2007-07-02 14:28:18 +04:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
#if 0
|
2009-07-09 17:44:16 +04:00
|
|
|
static MenuItem icon_trash_menu[] = {
|
|
|
|
{_("&Open"), 0, 0},
|
|
|
|
{_("&Properties"), 0, 0, 0, FL_MENU_DIVIDER},
|
|
|
|
{_("&Empty"), 0, 0},
|
2007-07-02 14:28:18 +04:00
|
|
|
{0}
|
|
|
|
};
|
2013-05-30 17:07:49 +04:00
|
|
|
#endif
|
2007-07-02 14:28:18 +04:00
|
|
|
|
2009-07-09 17:59:51 +04:00
|
|
|
static void open_cb(Fl_Widget*, void* d) {
|
2013-05-30 17:07:49 +04:00
|
|
|
DesktopIcon* o = (DesktopIcon*)d;
|
|
|
|
run_async("ede-launch %s", o->get_cmd());
|
2009-07-09 17:59:51 +04:00
|
|
|
}
|
|
|
|
|
2008-08-07 18:22:05 +04:00
|
|
|
static void rename_cb(Fl_Widget*, void* d) {
|
2007-07-02 14:28:18 +04:00
|
|
|
DesktopIcon* di = (DesktopIcon*)d;
|
|
|
|
|
2012-05-15 15:10:40 +04:00
|
|
|
const char* new_name = input(_("Change desktop icon name to:"), di->label());
|
|
|
|
if(new_name) {
|
2013-05-30 17:07:49 +04:00
|
|
|
bool saved = ((Desktop*)di->parent())->rename_icon(di, new_name);
|
|
|
|
if(!saved)
|
|
|
|
alert(_("Unable to rename this icon. Please check if you have enough permissions to do so"));
|
2012-05-15 15:10:40 +04:00
|
|
|
}
|
2007-07-02 14:28:18 +04:00
|
|
|
}
|
|
|
|
|
2012-05-07 12:53:13 +04:00
|
|
|
static void delete_cb(Fl_Widget*, void* d) {
|
|
|
|
DesktopIcon* di = (DesktopIcon*)d;
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
if(ask(_("This icon will be permanently deleted. Are you sure?")))
|
|
|
|
((Desktop*)di->parent())->remove_icon(di, true);
|
2012-05-07 12:53:13 +04:00
|
|
|
}
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
DesktopIcon::DesktopIcon(const char *l, int W, int H) : Fl_Widget(1, 1, W, H, l) {
|
|
|
|
box(FL_FLAT_BOX);
|
|
|
|
color(FL_RED);
|
|
|
|
label(l);
|
|
|
|
align(FL_ALIGN_WRAP);
|
|
|
|
|
|
|
|
/* default values unless given explicitly */
|
|
|
|
labelfont(FL_HELVETICA);
|
|
|
|
labelsize(12);
|
|
|
|
|
|
|
|
darker_img = 0;
|
|
|
|
micon = 0;
|
2007-05-22 18:53:17 +04:00
|
|
|
lwidth = lheight = 0;
|
2013-05-30 17:07:49 +04:00
|
|
|
focused = false;
|
|
|
|
imenu = 0;
|
2009-05-19 15:10:23 +04:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
icon_menu[2].image((Fl_Image*)IconLoader::get("edit-delete", ICON_SIZE_TINY));
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
DesktopIcon::~DesktopIcon() {
|
2008-10-03 15:29:56 +04:00
|
|
|
delete darker_img;
|
2013-05-30 17:07:49 +04:00
|
|
|
delete micon;
|
2007-07-02 14:28:18 +04:00
|
|
|
delete imenu;
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
void DesktopIcon::set_image(const char *name) {
|
|
|
|
E_RETURN_IF_FAIL(IconLoader::inited());
|
2007-11-28 15:42:52 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
/* if not name give, use false name to trick IconLoader to use fallback icons */
|
|
|
|
if(!name) name = "THIS-ICON-DOES-NOT-EXISTS";
|
|
|
|
E_RETURN_IF_FAIL(IconLoader::set(this, name, ICON_SIZE_HUGE));
|
2009-03-25 14:13:12 +03:00
|
|
|
|
|
|
|
/* fetch image object for sizes */
|
|
|
|
Fl_Image* img = image();
|
2007-11-28 15:42:52 +03:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
int img_w = img->w(),
|
|
|
|
img_h = img->h();
|
2007-11-28 15:42:52 +03:00
|
|
|
|
2009-03-25 14:13:12 +03:00
|
|
|
/* resize box if icon is larger */
|
2008-08-10 21:49:38 +04:00
|
|
|
if(img_w > ICON_SIZE_MIN_W || img_h > ICON_SIZE_MIN_H)
|
2007-11-28 15:42:52 +03:00
|
|
|
size(img_w + OFFSET_W, img_h + OFFSET_H);
|
|
|
|
}
|
|
|
|
|
2011-11-09 18:08:11 +04:00
|
|
|
void DesktopIcon::update_label_font_and_size(void) {
|
2013-05-30 17:07:49 +04:00
|
|
|
E_RETURN_IF_FAIL(opts != 0);
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
labelfont(opts->label_font);
|
|
|
|
labelsize(opts->label_fontsize);
|
|
|
|
lwidth = opts->label_maxwidth;
|
|
|
|
lheight = 0;
|
|
|
|
|
2007-06-18 18:18:35 +04:00
|
|
|
/*
|
|
|
|
* make sure current font size/type is set (internaly to fltk)
|
|
|
|
* so fl_measure() can correctly calculate label width and height
|
|
|
|
*/
|
2013-05-30 17:07:49 +04:00
|
|
|
int old = fl_font(), old_sz = fl_size();
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
fl_font(labelfont(), labelsize());
|
2007-06-18 18:18:35 +04:00
|
|
|
fl_measure(label(), lwidth, lheight, align());
|
2007-07-02 14:28:18 +04:00
|
|
|
fl_font(old, old_sz);
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
lwidth += 12;
|
2007-06-28 18:31:14 +04:00
|
|
|
lheight += 5;
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
|
|
|
|
2007-07-02 14:28:18 +04:00
|
|
|
void DesktopIcon::fix_position(int X, int Y) {
|
2013-05-30 17:07:49 +04:00
|
|
|
int dx = parent()->x(),
|
|
|
|
dy = parent()->y(),
|
|
|
|
dw = parent()->w(),
|
|
|
|
dh = parent()->h();
|
|
|
|
|
|
|
|
if(X < dx) X = dx;
|
|
|
|
if(Y < dy) Y = dy;
|
|
|
|
if(X + w() > dw) X = (dx + dw) - w();
|
|
|
|
if(Y + h() > dh) Y = (dy + dh) - h();
|
2007-07-02 14:28:18 +04:00
|
|
|
|
|
|
|
position(X, Y);
|
|
|
|
}
|
|
|
|
|
2007-05-22 18:53:17 +04:00
|
|
|
void DesktopIcon::drag(int x, int y, bool apply) {
|
|
|
|
if(!micon) {
|
|
|
|
micon = new MovableIcon(this);
|
2009-03-26 21:09:20 +03:00
|
|
|
#if HAVE_SHAPE
|
2007-06-22 13:43:15 +04:00
|
|
|
/*
|
|
|
|
* This is used to calculate correct window startup/ending
|
|
|
|
* position since icon is placed in the middle of the box.
|
|
|
|
*/
|
2009-07-09 17:44:16 +04:00
|
|
|
int ix = 0, iy = 0;
|
2007-06-22 13:43:15 +04:00
|
|
|
if(image()) {
|
|
|
|
ix = (w()/2) - (image()->w()/2);
|
|
|
|
iy = (h()/2) - (image()->h()/2);
|
2013-05-30 17:07:49 +04:00
|
|
|
|
|
|
|
/* include parent offset since x/y are absolute locations */
|
|
|
|
if(parent()) {
|
|
|
|
ix += parent()->x();
|
|
|
|
iy += parent()->y();
|
|
|
|
}
|
2007-06-22 13:43:15 +04:00
|
|
|
}
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2007-06-22 13:43:15 +04:00
|
|
|
micon->position(micon->x() + ix, micon->y() + iy);
|
|
|
|
#endif
|
|
|
|
micon->show();
|
|
|
|
} else {
|
2008-08-07 18:22:05 +04:00
|
|
|
E_ASSERT(micon != NULL);
|
2007-06-22 13:43:15 +04:00
|
|
|
micon->position(x, y);
|
|
|
|
}
|
2007-05-22 18:53:17 +04:00
|
|
|
|
|
|
|
if(apply) {
|
2009-03-26 21:09:20 +03:00
|
|
|
#if HAVE_SHAPE
|
2009-07-09 17:44:16 +04:00
|
|
|
int ix = 0, iy = 0;
|
2007-06-22 13:43:15 +04:00
|
|
|
if(image()) {
|
|
|
|
ix = (w()/2) - (image()->w()/2);
|
|
|
|
iy = (h()/2) - (image()->h()/2);
|
2013-05-30 17:07:49 +04:00
|
|
|
|
|
|
|
/* also take into account offsets, as below we subtract it */
|
|
|
|
if(parent()) {
|
|
|
|
ix += parent()->x();
|
|
|
|
iy += parent()->y();
|
|
|
|
}
|
2007-06-22 13:43:15 +04:00
|
|
|
}
|
2013-05-30 17:07:49 +04:00
|
|
|
|
2007-07-02 14:28:18 +04:00
|
|
|
fix_position(micon->x() - ix, micon->y() - iy);
|
2007-06-22 13:43:15 +04:00
|
|
|
#else
|
2007-07-02 14:28:18 +04:00
|
|
|
fix_position(micon->x(), micon->y());
|
2007-06-22 13:43:15 +04:00
|
|
|
#endif
|
2007-05-22 18:53:17 +04:00
|
|
|
delete micon;
|
2007-06-18 18:18:35 +04:00
|
|
|
micon = NULL;
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* used only in Desktop::move_selection */
|
2007-05-22 18:53:17 +04:00
|
|
|
int DesktopIcon::drag_icon_x(void) {
|
|
|
|
if(!micon)
|
|
|
|
return x();
|
2007-06-18 18:18:35 +04:00
|
|
|
else
|
2007-05-22 18:53:17 +04:00
|
|
|
return micon->x();
|
|
|
|
}
|
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* used only in Desktop::move_selection */
|
2007-05-22 18:53:17 +04:00
|
|
|
int DesktopIcon::drag_icon_y(void) {
|
|
|
|
if(!micon)
|
|
|
|
return y();
|
|
|
|
else
|
|
|
|
return micon->y();
|
|
|
|
}
|
2013-05-30 17:07:49 +04:00
|
|
|
|
2007-06-18 18:18:35 +04:00
|
|
|
void DesktopIcon::fast_redraw(void) {
|
2007-07-02 14:28:18 +04:00
|
|
|
int wsz = w();
|
|
|
|
int xpos = x();
|
|
|
|
|
|
|
|
if(lwidth > w()) {
|
|
|
|
wsz = lwidth + 4;
|
|
|
|
xpos = x() - 4;
|
|
|
|
}
|
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* LABEL_OFFSET + 2 include selection box line height too; same for xpos */
|
2007-07-02 14:28:18 +04:00
|
|
|
parent()->damage(FL_DAMAGE_ALL, xpos, y(), wsz, h() + lheight + LABEL_OFFSET + 2);
|
2007-06-18 18:18:35 +04:00
|
|
|
}
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
void DesktopIcon::draw(void) {
|
2007-06-18 18:18:35 +04:00
|
|
|
if(image() && (damage() & FL_DAMAGE_ALL)) {
|
2013-05-30 17:07:49 +04:00
|
|
|
Fl_Image *im = image();
|
2007-06-18 18:18:35 +04:00
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* center image in the box */
|
2007-06-18 18:18:35 +04:00
|
|
|
int ix = (w()/2) - (im->w()/2);
|
|
|
|
int iy = (h()/2) - (im->h()/2);
|
|
|
|
ix += x();
|
|
|
|
iy += y();
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
if(is_focused()) {
|
|
|
|
/* create darker image only when needed */
|
|
|
|
if(!darker_img) {
|
|
|
|
darker_img = im->copy(im->w(), im->h());
|
|
|
|
darker_img->color_average(FL_BLUE, 0.6);
|
|
|
|
}
|
|
|
|
|
2008-10-03 15:29:56 +04:00
|
|
|
darker_img->draw(ix, iy);
|
2013-05-30 17:07:49 +04:00
|
|
|
} else {
|
2008-10-03 15:29:56 +04:00
|
|
|
im->draw(ix, iy);
|
2013-05-30 17:07:49 +04:00
|
|
|
}
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
2013-05-30 17:07:49 +04:00
|
|
|
|
|
|
|
if(opts && opts->label_visible && (damage() & (FL_DAMAGE_ALL | EDE_DESKTOP_DAMAGE_CHILD_LABEL))) {
|
2007-06-18 18:18:35 +04:00
|
|
|
int X = x() + w()-(w()/2)-(lwidth/2);
|
|
|
|
int Y = y() + h() + LABEL_OFFSET;
|
|
|
|
|
|
|
|
Fl_Color old = fl_color();
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
if(!opts->label_transparent) {
|
|
|
|
fl_color(opts->label_background);
|
2007-06-18 18:18:35 +04:00
|
|
|
fl_rectf(X, Y, lwidth, lheight);
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
|
|
|
|
2007-07-02 14:28:18 +04:00
|
|
|
int old_font = fl_font();
|
|
|
|
int old_font_sz = fl_size();
|
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* draw with icon's font */
|
2007-07-02 14:28:18 +04:00
|
|
|
fl_font(labelfont(), labelsize());
|
2013-05-30 17:07:49 +04:00
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* pseudo-shadow */
|
2007-06-28 18:31:14 +04:00
|
|
|
fl_color(FL_BLACK);
|
|
|
|
fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0);
|
|
|
|
|
2013-05-30 17:07:49 +04:00
|
|
|
fl_color(opts->label_foreground);
|
2007-06-18 18:18:35 +04:00
|
|
|
fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0);
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* restore old font */
|
2007-07-02 14:28:18 +04:00
|
|
|
fl_font(old_font, old_font_sz);
|
|
|
|
|
2007-05-22 18:53:17 +04:00
|
|
|
if(is_focused()) {
|
2009-03-26 21:09:20 +03:00
|
|
|
/* draw focused box on our way so later this can be used to draw customised boxes */
|
2013-05-30 17:07:49 +04:00
|
|
|
fl_color(opts->label_foreground);
|
2007-06-28 18:31:14 +04:00
|
|
|
fl_line_style(FL_DOT);
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2007-06-18 18:18:35 +04:00
|
|
|
fl_push_matrix();
|
|
|
|
fl_begin_loop();
|
2009-03-26 21:09:20 +03:00
|
|
|
fl_vertex(X, Y);
|
|
|
|
fl_vertex(X + lwidth, Y);
|
|
|
|
fl_vertex(X + lwidth, Y + lheight);
|
|
|
|
fl_vertex(X, Y + lheight);
|
|
|
|
fl_vertex(X, Y);
|
2007-06-18 18:18:35 +04:00
|
|
|
fl_end_loop();
|
|
|
|
fl_pop_matrix();
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* revert to default line style */
|
2007-06-18 18:18:35 +04:00
|
|
|
fl_line_style(0);
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
2007-05-23 16:43:50 +04:00
|
|
|
|
2009-03-26 21:09:20 +03:00
|
|
|
/* revert to old color whatever that be */
|
2007-06-18 18:18:35 +04:00
|
|
|
fl_color(old);
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int DesktopIcon::handle(int event) {
|
2007-06-20 14:58:07 +04:00
|
|
|
switch(event) {
|
|
|
|
case FL_FOCUS:
|
|
|
|
case FL_UNFOCUS:
|
|
|
|
case FL_ENTER:
|
|
|
|
case FL_LEAVE:
|
2009-03-26 21:09:20 +03:00
|
|
|
/* We have to handle FL_MOVE too, if want to get only once FL_ENTER when entered or FL_LEAVE when leaved */
|
2007-06-20 14:58:07 +04:00
|
|
|
case FL_MOVE:
|
|
|
|
return 1;
|
2013-05-30 17:07:49 +04:00
|
|
|
|
2007-06-20 14:58:07 +04:00
|
|
|
case FL_PUSH:
|
2007-07-02 14:28:18 +04:00
|
|
|
if(Fl::event_button() == 3) {
|
2013-05-30 17:07:49 +04:00
|
|
|
/*
|
|
|
|
* init icon specific menu only when needed
|
|
|
|
* TODO: since menu for all icons is mostly the same, it can be shared; Desktop can
|
|
|
|
* have menu instance seeded to all icons
|
|
|
|
*/
|
|
|
|
if(!imenu) {
|
|
|
|
imenu = new MenuButton(0, 0, 0, 0);
|
|
|
|
imenu->menu(icon_menu);
|
|
|
|
}
|
|
|
|
|
2009-07-09 17:44:16 +04:00
|
|
|
/* MenuItem::popup() by default does not call callbacks */
|
2013-05-30 17:07:49 +04:00
|
|
|
const MenuItem *m = imenu->menu()->popup(Fl::event_x(), Fl::event_y());
|
2009-03-26 21:09:20 +03:00
|
|
|
|
2007-07-02 14:28:18 +04:00
|
|
|
if(m && m->callback())
|
|
|
|
m->do_callback(0, this);
|
|
|
|
}
|
2007-06-20 14:58:07 +04:00
|
|
|
return 1;
|
2013-05-30 17:07:49 +04:00
|
|
|
|
2007-06-20 14:58:07 +04:00
|
|
|
case FL_RELEASE:
|
2013-05-30 17:07:49 +04:00
|
|
|
if(Fl::event_clicks() > 0 && !cmd.empty())
|
|
|
|
run_async("ede-launch %s", cmd.c_str());
|
2007-06-20 14:58:07 +04:00
|
|
|
return 1;
|
2007-07-02 14:28:18 +04:00
|
|
|
|
|
|
|
case FL_DND_ENTER:
|
|
|
|
case FL_DND_DRAG:
|
|
|
|
case FL_DND_LEAVE:
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case FL_DND_RELEASE:
|
2008-08-07 18:22:05 +04:00
|
|
|
E_DEBUG(E_STRLOC ": FL_DND_RELEASE on icon\n");
|
2007-07-02 14:28:18 +04:00
|
|
|
return 1;
|
|
|
|
case FL_PASTE:
|
2008-08-07 18:22:05 +04:00
|
|
|
E_DEBUG(E_STRLOC ": FL_PASTE on icon with %s\n", Fl::event_text());
|
2007-07-02 14:28:18 +04:00
|
|
|
return 1;
|
2007-06-20 14:58:07 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-07-02 14:28:18 +04:00
|
|
|
return 0;
|
2007-05-22 18:53:17 +04:00
|
|
|
}
|