enlightenment/src/view.h

318 lines
7.2 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 "e_dir.h"
#include "e_file.h"
#include "view_layout.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_VIEW_MODEL_TYPEDEF
#define E_VIEW_MODEL_TYPEDEF
typedef struct _E_Dir E_Dir;
#endif
#ifndef E_VIEW_LAYOUT_TYPEDEF
#define E_VIEW_LAYOUT_TYPEDEF
typedef struct _E_View_Layout E_View_Layout;
typedef struct _E_View_Layout_Element E_View_Layout_Element;
#endif
#ifndef E_SCROLLBAR_TYPEDEF
#define E_SCROLLBAR_TYPEDEF
typedef struct _E_Scrollbar E_Scrollbar;
#endif
typedef enum
{
E_DND_NONE,
E_DND_COPY,
E_DND_MOVE,
E_DND_LINK,
E_DND_ASK,
E_DND_DELETED,
E_DND_COPIED,
E_DND_ICONBAR_ADD
}
E_dnd_enum;
struct _E_View
{
E_Object o;
char *name;
E_Dir *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;
int icon_hide;
int icon_show;
int matching_drop_attempt;
}
drag;
struct
{
int valid;
double x1, x2, y1, y2;
}
extents;
E_Background bg;
E_View_Layout *layout;
struct
{
EfsdCmdId x, y, w, h;
int busy;
}
geom_get;
EfsdCmdId getbg;
struct
{
E_Scrollbar *h, *v;
}
scrollbar;
int is_listing;
E_Iconbar *iconbar;
Evas_List icons;
int have_resort_queued;
int changed;
Evas_List epplet_contexts;
Ebits_Object epplet_layout;
};
/**
* 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(E_View *v);
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_queue_geometry_record(E_View * v);
void e_view_queue_icon_xy_record(E_View * v);
void e_view_queue_resort(E_View * v);
/**
* 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);
/**
* 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
* @is_desktop Inidicates wether the view is a desktop
*
* This function sets a view to a directory, loading the
* view's metadata (view window coordinates etc). If a dir already
* exists for this dir, it is reused, otherwise a new on is created.
*/
void e_view_set_dir(E_View * v, char *dir, int is_desktop);
/**
* e_view_populate - Draws icons for all files in view
* @v The view to populate
*
* Goes through the list of files in the underlying dir and calls
* view_add_file for each one. This results in icons being created for each
* file.
*/
void e_view_populate(E_View * v);
/**
* 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 creating the evas.
*/
void e_view_realize(E_View * v);
/**
* e_view_update - Redraws a view
* @v: The view to redraw
*
* If the contents of the view have changed, this function redraws it.
*/
void e_view_update(E_View * v);
void e_view_bg_reload(E_View * v);
void e_view_ib_reload(E_View * v);
void e_view_file_add(E_View * v, E_File * file);
void e_view_file_changed(E_View * v, E_File * file);
void e_view_file_delete(E_View * v, E_File * file);
void e_view_close_all(void);
#endif