enlightenment/src/view.h

249 lines
5.8 KiB
C
Raw Normal View History

#ifndef E_VIEW_H
#define E_VIEW_H
#include "e.h"
#include "background.h"
#include "scrollbar.h"
#include "fs.h"
#include "iconbar.h"
Alright, I spent some time now reading e17's code. Here's what I've changed, this is big, so read this carefully :) * I've added debugging macros for messages and function call tracing. Usage: D("Creating item %i %i %i\n", x, y, z); Define DEBUG to use the D macro. D_ENTER; D_RETURN; D_RETURN_(x); These are for call tracing. Use D_RETURN_(x) when returning something from a function. Define DEBUG_NEST to use this. * added iconbar header file to Makefile.am * added proper new()/cleanup() calls for E_Delayed_Action; * I've completely rewritten the object and observer handling. Bye bye macros, this was nasty. It'll be hard enough to avoid leaks with usecounting in C. We now basically have the same system as gtk. There's a clear separation of observer and object code now. An E_Object by itself has nothing to do with observing or being observed, therefore, there are now E_Observers and E_Observees that are derived from E_Object. IMPORTANT: The cleanup system now reflects the reference count system, therefore, all ..._free() calls are now static, because the destructor should never be called explicitly, but implicitly through e_object_unref(). The object handling now is as follows: - The cleanup functions clean up everything that is contained in a struct, but NOT the struct itself. Instead of the final free() call, they call the destructor of the base class. The calls will walk up the hierarchy and clean up what's contained in every struct, and the final e_object_cleanup() will free the structure itself. E_Delayed_Action is a good example. - The only calls that influence the reference count are e_object_ref() and e_object_unref(). If you need to do things before an object gets destroyed, you can query the use count using e_object_get_usecount() and check if it's equal to 1. So this: OBJ_UNREF(b); OBJ_IF_FREE(b) { ecore_window_reparent(e->win, 0, 0, 0); e_icccm_release(e->win); OBJ_FREE(b); } now is this: if (e_object_get_usecount(E_OBJECT(b)) == 1) { ecore_window_reparent(e->win, 0, 0, 0); e_icccm_release(e->win); } e_object_unref(E_OBJECT(b)); object.h and observer.h are completely commented, it shouldn't be too hard to understand. This'll need to be documented in the manual anyway. * E_Objects are now used in lots of places where void* were used as pointers to objects before, especially in the actions code. This is obviously better, as it will generate compiler warnings when people want to pass things to functions that expect E_Objects. This could probably be more restrictive. * Added typedefs for the function prototypes in E_Action_Impl. Those fat signatures were just painful to read in the function declarations/implementations. * I've also tried to give parameters more useful names. Calling an object "o" is a lot of fun when you want to grep for it. * Included is also Graham's latest menu.c patch. Sorry for the delay, Graham. * I've added checks to the menu code that make sure that menus don't pop up when they're empty (which resulted in a little useless rectangle). I guess that's it for now. Sorry if I broke anything, but this was necessary imho. SVN revision: 5605
2001-11-02 09:07:52 -08:00
#include "object.h"
#include "icons.h"
#ifndef E_VIEW_TYPEDEF
#define E_VIEW_TYPEDEF
typedef struct _E_View E_View;
#endif
#ifndef E_ICON_TYPEDEF
#define E_ICON_TYPEDEF
typedef struct _E_Icon E_Icon;
#endif
#ifndef E_ICONBAR_TYPEDEF
#define E_ICONBAR_TYPEDEF
typedef struct _E_Iconbar E_Iconbar;
#endif
#ifndef E_DND_TYPEDEF
#define E_DND_TYPEDEF
typedef enum {
E_DND_NONE,
E_DND_COPY,
E_DND_MOVE,
E_DND_LINK,
E_DND_ASK
} E_dnd_enum;
#endif
struct _E_View
{
Alright, I spent some time now reading e17's code. Here's what I've changed, this is big, so read this carefully :) * I've added debugging macros for messages and function call tracing. Usage: D("Creating item %i %i %i\n", x, y, z); Define DEBUG to use the D macro. D_ENTER; D_RETURN; D_RETURN_(x); These are for call tracing. Use D_RETURN_(x) when returning something from a function. Define DEBUG_NEST to use this. * added iconbar header file to Makefile.am * added proper new()/cleanup() calls for E_Delayed_Action; * I've completely rewritten the object and observer handling. Bye bye macros, this was nasty. It'll be hard enough to avoid leaks with usecounting in C. We now basically have the same system as gtk. There's a clear separation of observer and object code now. An E_Object by itself has nothing to do with observing or being observed, therefore, there are now E_Observers and E_Observees that are derived from E_Object. IMPORTANT: The cleanup system now reflects the reference count system, therefore, all ..._free() calls are now static, because the destructor should never be called explicitly, but implicitly through e_object_unref(). The object handling now is as follows: - The cleanup functions clean up everything that is contained in a struct, but NOT the struct itself. Instead of the final free() call, they call the destructor of the base class. The calls will walk up the hierarchy and clean up what's contained in every struct, and the final e_object_cleanup() will free the structure itself. E_Delayed_Action is a good example. - The only calls that influence the reference count are e_object_ref() and e_object_unref(). If you need to do things before an object gets destroyed, you can query the use count using e_object_get_usecount() and check if it's equal to 1. So this: OBJ_UNREF(b); OBJ_IF_FREE(b) { ecore_window_reparent(e->win, 0, 0, 0); e_icccm_release(e->win); OBJ_FREE(b); } now is this: if (e_object_get_usecount(E_OBJECT(b)) == 1) { ecore_window_reparent(e->win, 0, 0, 0); e_icccm_release(e->win); } e_object_unref(E_OBJECT(b)); object.h and observer.h are completely commented, it shouldn't be too hard to understand. This'll need to be documented in the manual anyway. * E_Objects are now used in lots of places where void* were used as pointers to objects before, especially in the actions code. This is obviously better, as it will generate compiler warnings when people want to pass things to functions that expect E_Objects. This could probably be more restrictive. * Added typedefs for the function prototypes in E_Action_Impl. Those fat signatures were just painful to read in the function declarations/implementations. * I've also tried to give parameters more useful names. Calling an object "o" is a lot of fun when you want to grep for it. * Included is also Graham's latest menu.c patch. Sorry for the delay, Graham. * I've added checks to the menu code that make sure that menus don't pop up when they're empty (which resulted in a little useless rectangle). I guess that's it for now. Sorry if I broke anything, but this was necessary imho. SVN revision: 5605
2001-11-02 09:07:52 -08:00
E_Object o;
char *dir;
struct {
Evas_Render_Method render_method;
int back_pixmap;
} options;
Evas evas;
struct {
Window base;
Window main;
} win;
Pixmap pmap;
struct {
int w, h;
int force;
} size;
struct {
int x, y;
} scroll;
struct {
int x, y;
} location;
struct {
/* +-----------------+
* | Wt |
* | +-----------+ |
* |Wl| |Wr|
* | | [I] Is | |
* | | Ig | |
* | | [txt] | |
* | | Ib | |
* | +-----------+ |
* | Wb |
* +-----------------+
*/
struct {
int l, r, t, b;
} window;
struct {
int s, g, b;
} icon;
} spacing;
struct {
int on;
/* The number of selected icons. */
int count;
/* The number of icons we selected the last time.
If this is > 0, we don't pop up menus when
the user clicks in a view. */
int last_count;
int x, y, w, h;
struct {
int x, y;
} down;
struct {
struct {
int r, g, b, a;
}
edge_l, edge_r, edge_t, edge_b,
middle,
grad_l, grad_r, grad_t, grad_b;
struct {
int l, r, t, b;
} grad_size;
} config;
struct {
Evas_Object clip;
Evas_Object edge_l;
Evas_Object edge_r;
Evas_Object edge_t;
Evas_Object edge_b;
Evas_Object middle;
Evas_Object grad_l;
Evas_Object grad_r;
Evas_Object grad_t;
Evas_Object grad_b;
} obj;
} select;
struct {
int started;
Window win;
int x, y;
struct {
int x, y;
} offset;
int update;
int drop_mode;
} drag;
struct {
int valid;
double x1, x2, y1, y2;
} extents;
struct {
EfsdCmdId x, y, w, h;
int busy;
} geom_get;
EfsdCmdId getbg;
Evas_Object obj_bg;
char *bg_file;
char *prev_bg_file;
time_t bg_mod;
E_Background *bg;
struct {
E_Scrollbar *h, *v;
} scrollbar;
int is_listing;
int monitor_id;
E_FS_Restarter *restarter;
Evas_List icons;
int is_desktop;
int have_resort_queued;
int changed;
E_Iconbar *iconbar;
};
/**
* e_view_init - View event handlers initialization.
*
* This function registers event handlers for the views.
* Views are the windows in which e as a desktop shell
* displays file icons.
*/
void e_view_init(void);
void e_view_selection_update(E_View *v);
void e_view_deselect_all(void);
void e_view_deselect_all_except(E_Icon *not_ic);
Ecore_Event *e_view_get_current_event(void);
int e_view_filter_file(E_View *v, char *file);
void e_view_icons_get_extents(E_View *v, int *min_x, int *min_y, int *max_x, int *max_y);
void e_view_icons_apply_xy(E_View *v);
void e_view_scroll_to(E_View *v, int sx, int sy);
void e_view_scroll_by(E_View *v, int sx, int sy);
void e_view_scroll_to_percent(E_View *v, double psx, double psy);
void e_view_get_viewable_percentage(E_View *v, double *vw, double *vh);
void e_view_get_position_percentage(E_View *v, double *vx, double *vy);
void e_view_resort_alphabetical(E_View *v);
void e_view_arrange(E_View *v);
void e_view_resort(E_View *v);
void e_view_geometry_record(E_View *v);
void e_view_queue_geometry_record(E_View *v);
void e_view_queue_icon_xy_record(E_View *v);
void e_view_queue_resort(E_View *v);
void e_view_file_added(int id, char *file);
void e_view_file_deleted(int id, char *file);
void e_view_file_changed(int id, char *file);
void e_view_file_moved(int id, char *file);
E_View *e_view_find_by_monitor_id(int id);
/**
* e_view_new - Creates a new view object
*
* This function creates a new view and sets default
* properties on it, such as colors and icon spacings.
*/
E_View *e_view_new(void);
void e_view_set_background(E_View *v);
/**
* e_view_set_dir - Sets view to a given directory
* @v The view for which to set the directory
* @dir The directory to set the view to
*
* This function sets a view to a directory, loading the
* view's metadata (view window coordinates etc) from that
* directory, it also requests monitoring of the files in
* the directory @dir from efsd.
*/
void e_view_set_dir(E_View *v, char *dir);
/**
* e_view_realize - Initializes a view's graphics and content
* @v: The view to initialize
*
* This function initializes a created view by loading
* all the graphics, and sets the view to a given directory
* by calling e_view_set_dir().
*/
void e_view_realize(E_View *v);
void e_view_update(E_View *v);
void e_view_bg_load(E_View *v);
void e_view_bg_change(E_View *v, char *file);
void e_view_bg_add(E_View *v, char *file);
void e_view_bg_del(E_View *v, char *file);
void e_view_close_all(void);
#endif