2006-08-20 22:43:09 +04:00
|
|
|
/*
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-10-02 13:42:19 +04:00
|
|
|
* ede-desktop, desktop and icon manager
|
2006-08-20 22:43:09 +04:00
|
|
|
* Part of Equinox Desktop Environment (EDE).
|
2009-05-19 15:10:23 +04:00
|
|
|
* Copyright (c) 2006-2009 EDE Authors.
|
2006-08-20 22:43:09 +04:00
|
|
|
*
|
2007-05-22 18:53:17 +04:00
|
|
|
* This program is licensed under terms of the
|
|
|
|
* GNU General Public License version 2 or newer.
|
2006-08-20 22:43:09 +04:00
|
|
|
* See COPYING for details.
|
|
|
|
*/
|
|
|
|
|
2008-10-02 13:42:19 +04:00
|
|
|
#ifndef __EDE_DESKTOP_H__
|
|
|
|
#define __EDE_DESKTOP_H__
|
2006-08-20 22:43:09 +04:00
|
|
|
|
2007-11-06 17:33:19 +03:00
|
|
|
#ifdef USE_EDELIB_WINDOW
|
2011-10-18 12:17:35 +04:00
|
|
|
# include <edelib/Window.h>
|
2011-10-18 12:45:55 +04:00
|
|
|
# define EDE_DESKTOP_WINDOW edelib::Window
|
2007-11-06 17:33:19 +03:00
|
|
|
#else
|
2011-10-18 12:17:35 +04:00
|
|
|
# include <FL/Fl_Window.H>
|
|
|
|
# include <FL/Fl_Double_Window.H>
|
2011-10-18 12:45:55 +04:00
|
|
|
# define EDE_DESKTOP_WINDOW Fl_Window
|
2007-11-06 17:33:19 +03:00
|
|
|
#endif
|
|
|
|
|
2008-09-15 15:00:23 +04:00
|
|
|
#include <FL/Fl_Image.H>
|
2007-06-18 18:18:35 +04:00
|
|
|
|
2007-05-22 18:53:17 +04:00
|
|
|
#include <edelib/String.h>
|
2008-08-07 18:22:05 +04:00
|
|
|
#include <edelib/Resource.h>
|
2007-09-03 16:26:58 +04:00
|
|
|
#include <edelib/List.h>
|
2008-04-07 19:35:02 +04:00
|
|
|
#include <edelib/EdbusConnection.h>
|
2009-07-09 17:26:59 +04:00
|
|
|
#include <edelib/MenuButton.h>
|
2006-08-20 22:43:09 +04:00
|
|
|
|
2007-06-26 20:33:25 +04:00
|
|
|
#define EDAMAGE_CHILD_LABEL 0x10
|
|
|
|
#define EDAMAGE_OVERLAY 0x20
|
2007-06-18 18:18:35 +04:00
|
|
|
|
2009-03-27 12:40:03 +03:00
|
|
|
#define ICON_NORMAL 1 // .desktop file
|
|
|
|
#define ICON_TRASH 2 // trash.desktop (specific since have two icons for empty/full)
|
|
|
|
#define ICON_FILE 3 // real file
|
|
|
|
#define ICON_SYMLINK 4 // symbolic link
|
|
|
|
|
|
|
|
#define ICON_FACE_ONE 1 // use icon
|
|
|
|
#define ICON_FACE_TWO 2 // use icon2
|
|
|
|
|
2007-05-22 18:53:17 +04:00
|
|
|
struct GlobalIconSettings {
|
|
|
|
int label_background;
|
|
|
|
int label_foreground;
|
2011-11-09 18:08:11 +04:00
|
|
|
int label_font;
|
2007-05-22 18:53:17 +04:00
|
|
|
int label_fontsize;
|
|
|
|
int label_maxwidth;
|
|
|
|
bool label_transparent;
|
|
|
|
bool label_draw;
|
|
|
|
bool one_click_exec;
|
2007-06-18 18:18:35 +04:00
|
|
|
bool auto_arrange;
|
2007-05-22 18:53:17 +04:00
|
|
|
bool same_size;
|
2006-08-20 22:43:09 +04:00
|
|
|
};
|
|
|
|
|
2007-05-25 21:45:17 +04:00
|
|
|
/*
|
|
|
|
* Settings representing related to icon on desktop. To complicate our lives
|
|
|
|
* (and to, at least, simplify code) it can be:
|
|
|
|
* - .desktop file content (normal or trash like)
|
|
|
|
* - real file copied/moved inside ~/Desktop directory
|
|
|
|
* - symlink in ~/Desktop directory pointing to the real file
|
|
|
|
*/
|
2007-05-22 18:53:17 +04:00
|
|
|
struct IconSettings {
|
2007-06-18 18:18:35 +04:00
|
|
|
int x, y;
|
|
|
|
int type; // ICON_NORMAL, ICON_TRASH,...
|
2007-05-25 21:45:17 +04:00
|
|
|
bool cmd_is_url; // interpret cmd as url, like system:/,trash:/,$HOME
|
2007-05-22 18:53:17 +04:00
|
|
|
|
|
|
|
edelib::String name;
|
|
|
|
edelib::String cmd;
|
|
|
|
edelib::String icon;
|
2007-05-25 21:45:17 +04:00
|
|
|
edelib::String icon2; // for stateable icons, like trash (empty/full)
|
|
|
|
edelib::String key_name; // name used as key when storing positions
|
2007-07-02 14:28:18 +04:00
|
|
|
edelib::String full_path; // for tracking changes
|
2007-05-22 18:53:17 +04:00
|
|
|
};
|
|
|
|
|
2009-03-27 12:40:03 +03:00
|
|
|
/* selection overlay */
|
2007-06-25 13:20:49 +04:00
|
|
|
struct SelectionOverlay {
|
|
|
|
int x, y, w, h;
|
|
|
|
bool show;
|
|
|
|
};
|
|
|
|
|
2007-06-18 18:18:35 +04:00
|
|
|
class Wallpaper;
|
2007-05-22 18:53:17 +04:00
|
|
|
class DesktopIcon;
|
2007-07-02 14:28:18 +04:00
|
|
|
|
2009-03-27 12:40:03 +03:00
|
|
|
typedef edelib::list<DesktopIcon*> DesktopIconList;
|
2007-09-03 16:26:58 +04:00
|
|
|
typedef edelib::list<DesktopIcon*>::iterator DesktopIconListIter;
|
2009-03-27 12:40:03 +03:00
|
|
|
|
|
|
|
typedef edelib::list<edelib::String> StringList;
|
2007-11-06 17:33:19 +03:00
|
|
|
typedef edelib::list<edelib::String>::iterator StringListIter;
|
2007-05-24 16:53:03 +04:00
|
|
|
|
2011-10-18 12:45:55 +04:00
|
|
|
class Desktop : public EDE_DESKTOP_WINDOW {
|
2009-02-26 14:15:27 +03:00
|
|
|
private:
|
|
|
|
static Desktop* pinstance;
|
2007-05-24 16:53:03 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
int selection_x, selection_y;
|
2012-04-23 16:43:20 +04:00
|
|
|
|
|
|
|
/* last recorded pointer position, so icon can be created at position where menu is clicked */
|
|
|
|
int last_px, last_py;
|
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
bool moving;
|
|
|
|
bool do_dirwatch;
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2012-05-07 12:53:13 +04:00
|
|
|
edelib::String desktop_dir_path;
|
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
SelectionOverlay* selbox;
|
2007-06-25 13:20:49 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
GlobalIconSettings* gisett;
|
2007-05-24 16:53:03 +04:00
|
|
|
|
2012-04-23 16:43:20 +04:00
|
|
|
edelib::MenuButton* dmenu;
|
|
|
|
Wallpaper* wallpaper;
|
2009-02-26 14:15:27 +03:00
|
|
|
edelib::EdbusConnection* dbus;
|
2007-06-18 18:18:35 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
DesktopIconList icons;
|
2009-03-26 21:09:20 +03:00
|
|
|
DesktopIconList selectionbuf;
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void init_internals(void);
|
2007-06-29 15:22:29 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void load_icons(const char* path);
|
|
|
|
void save_icons_positions(void);
|
2009-05-19 15:10:23 +04:00
|
|
|
IconSettings* read_desktop_file(const char* path);
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void add_icon(DesktopIcon* ic);
|
2009-03-27 12:40:03 +03:00
|
|
|
|
|
|
|
DesktopIcon* find_icon_by_path(const char* path, DesktopIconListIter* pos);
|
2009-02-26 14:15:27 +03:00
|
|
|
bool remove_icon_by_path(const char* path);
|
2009-03-27 12:40:03 +03:00
|
|
|
|
2009-10-07 18:38:48 +04:00
|
|
|
void auto_arrange(void);
|
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void unfocus_all(void);
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void select(DesktopIcon* ic, bool do_redraw = true);
|
|
|
|
void select_only(DesktopIcon* ic);
|
|
|
|
bool in_selection(const DesktopIcon* ic);
|
|
|
|
void move_selection(int x, int y, bool apply);
|
2007-05-22 18:53:17 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void select_in_area(void);
|
2007-06-25 13:20:49 +04:00
|
|
|
|
2012-05-07 12:53:13 +04:00
|
|
|
//void dnd_drop_source(const char* src, int src_len, int x, int y);
|
2007-06-23 15:31:36 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
DesktopIcon* below_mouse(int px, int py);
|
2007-05-23 16:43:50 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
public:
|
|
|
|
Desktop();
|
|
|
|
~Desktop();
|
2007-06-18 18:18:35 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
virtual void show(void);
|
|
|
|
virtual void hide(void);
|
|
|
|
virtual void draw(void);
|
|
|
|
virtual int handle(int event);
|
2007-06-18 18:18:35 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
static void init(void);
|
|
|
|
static void shutdown(void);
|
|
|
|
static Desktop* instance(void);
|
2007-05-24 16:53:03 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void read_config(void);
|
2007-05-24 16:53:03 +04:00
|
|
|
|
2012-04-25 20:28:09 +04:00
|
|
|
bool add_icon_by_path(const char* path, edelib::Resource* conf);
|
2012-05-07 12:53:13 +04:00
|
|
|
bool remove_icon(DesktopIcon *d, bool real_delete);
|
2012-05-15 15:10:40 +04:00
|
|
|
bool rename_icon(DesktopIcon *d, const char *n);
|
2012-04-25 20:28:09 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void update_workarea(void);
|
|
|
|
void area(int& X, int& Y, int& W, int& H) { X = x(); Y = y(); W = w(); H = h(); }
|
2007-07-02 14:28:18 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void notify_desktop_changed(void);
|
2007-09-03 16:26:58 +04:00
|
|
|
|
2009-02-26 14:15:27 +03:00
|
|
|
void dir_watch(const char* dir, const char* changed, int flags);
|
|
|
|
void dir_watch_on(void) { do_dirwatch = true; }
|
|
|
|
void dir_watch_off(void) { do_dirwatch = false; }
|
2007-05-22 18:53:17 +04:00
|
|
|
};
|
2006-08-20 22:43:09 +04:00
|
|
|
|
|
|
|
#endif
|