1 #ifdef E_TYPEDEFS 2 3 #define E_GADCON_CLIENT(x) ((E_Gadcon_Client *)(x)) 4 5 /* different layout policies - only 1 supported for now */ 6 typedef enum _E_Gadcon_Layout_Policy 7 { 8 E_GADCON_LAYOUT_POLICY_PANEL 9 } E_Gadcon_Layout_Policy; 10 11 typedef enum _E_Gadcon_Orient 12 { 13 /* generic orientations */ 14 E_GADCON_ORIENT_FLOAT = 0, 15 E_GADCON_ORIENT_HORIZ, 16 E_GADCON_ORIENT_VERT, 17 E_GADCON_ORIENT_LEFT, 18 E_GADCON_ORIENT_RIGHT, 19 E_GADCON_ORIENT_TOP, 20 E_GADCON_ORIENT_BOTTOM, 21 E_GADCON_ORIENT_CORNER_TL, 22 E_GADCON_ORIENT_CORNER_TR, 23 E_GADCON_ORIENT_CORNER_BL, 24 E_GADCON_ORIENT_CORNER_BR, 25 E_GADCON_ORIENT_CORNER_LT, 26 E_GADCON_ORIENT_CORNER_RT, 27 E_GADCON_ORIENT_CORNER_LB, 28 E_GADCON_ORIENT_CORNER_RB, 29 E_GADCON_ORIENT_LAST 30 } E_Gadcon_Orient; 31 32 typedef enum _E_Gadcon_Site 33 { 34 E_GADCON_SITE_UNKNOWN = 0, // when target site is unknown 35 /* generic sities */ 36 E_GADCON_SITE_SHELF, 37 E_GADCON_SITE_DESKTOP, 38 E_GADCON_SITE_TOOLBAR, // generic toolbar 39 E_GADCON_SITE_EFM_TOOLBAR // filemanager window toolbar 40 } E_Gadcon_Site; 41 42 #define E_GADCON_CLIENT_STYLE_PLAIN "plain" 43 #define E_GADCON_CLIENT_STYLE_INSET "inset" 44 45 typedef struct _E_Gadcon E_Gadcon; 46 typedef struct _E_Gadcon_Client E_Gadcon_Client; 47 typedef struct _E_Event_Gadcon_Client E_Event_Gadcon_Client_Add; 48 typedef struct _E_Event_Gadcon_Client E_Event_Gadcon_Client_Del; 49 typedef struct _E_Gadcon_Client_Class E_Gadcon_Client_Class; 50 typedef struct _E_Event_Gadcon_Client_Class E_Event_Gadcon_Client_Class_Add; 51 typedef struct _E_Event_Gadcon_Client_Class E_Event_Gadcon_Client_Class_Del; 52 typedef struct _E_Gadcon_Location E_Gadcon_Location; 53 typedef struct _E_Event_Gadcon_Populate E_Event_Gadcon_Populate; 54 typedef void (*E_Gadcon_DND_Cb)(E_Gadcon*, E_Gadcon_Client*); 55 56 #else 57 #ifndef E_GADCON_H 58 #define E_GADCON_H 59 60 #define E_GADCON_TYPE 0xE0b01006 61 #define E_GADCON_DUMMY_TYPE 0xE0b01016 62 #define E_GADCON_CLIENT_TYPE 0xE0b01007 63 64 E_API extern int E_EVENT_GADCON_CLIENT_ADD; 65 E_API extern int E_EVENT_GADCON_CLIENT_DEL; 66 E_API extern int E_EVENT_GADCON_CLIENT_CLASS_ADD; 67 E_API extern int E_EVENT_GADCON_CLIENT_CLASS_DEL; 68 E_API extern int E_EVENT_GADCON_POPULATE; 69 70 struct _E_Gadcon 71 { 72 E_Object e_obj_inherit; 73 74 const char *name; 75 int id; 76 77 E_Gadcon_Layout_Policy layout_policy; 78 79 struct 80 { 81 Evas_Object *o_parent; 82 const char *swallow_name; 83 } edje; 84 Ecore_Evas *ecore_evas; 85 E_Zone *zone; 86 87 E_Gadcon_Orient orient; 88 89 Evas *evas; 90 Evas_Object *o_container; 91 Eina_List *clients; 92 Eina_List *populate_requests; 93 Eina_List *populated_classes; 94 Eina_Hash *awaiting_classes; /* E_Config_Gadcon_Client */ 95 96 struct 97 { 98 void (*func)(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h); 99 void *data; 100 } resize_request, min_size_request; 101 struct 102 { 103 Evas_Object *(*func)(void *data, E_Gadcon_Client * gcc, const char *style); 104 void *data; 105 } frame_request; 106 struct 107 { 108 void (*func)(void *data, E_Gadcon_Client *gcc, E_Menu *menu); 109 void *data; 110 } menu_attach; 111 struct 112 { 113 void (*func)(void *data, E_Gadcon *gc, const E_Gadcon_Client_Class *cc); 114 void *data; 115 } populate_class; 116 struct 117 { 118 void (*func)(void *data, int lock); 119 void *data; 120 } locked_set; 121 struct 122 { 123 void (*func)(void *data); 124 void *data; 125 } urgent_show; 126 127 E_Config_Dialog *config_dialog; 128 unsigned char editing E_BITFIELD; 129 Ecore_X_Window dnd_win, xdnd_win; 130 E_Shelf *shelf; 131 E_Toolbar *toolbar; 132 E_Gadcon_Location *location; 133 134 E_Drop_Handler *drop_handler; 135 E_Gadcon_Client *drag_gcc, *new_gcc; 136 E_Gadcon_DND_Cb dnd_enter_cb, dnd_leave_cb, dnd_move_cb, dnd_drop_cb; 137 138 E_Config_Gadcon *cf; 139 140 unsigned char instant_edit E_BITFIELD; 141 unsigned char dummy E_BITFIELD; 142 Eina_Bool custom E_BITFIELD; 143 Eina_Bool cfg_delete E_BITFIELD; 144 }; 145 146 #define GADCON_CLIENT_CLASS_VERSION 3 147 /* Version 3 add the *client_class param to icon(),label(),id_new(), id_del() */ 148 /* and the *orient param to orient() */ 149 struct _E_Gadcon_Client_Class 150 { 151 int version; 152 /* All members below are part of version 1 */ 153 const char *name; 154 struct 155 { 156 E_Gadcon_Client *(*init)(E_Gadcon * gc, const char *name, const char *id, const char *style); 157 void (*shutdown)(E_Gadcon_Client *gcc); 158 void (*orient)(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); 159 const char *(*label)(const E_Gadcon_Client_Class *client_class); 160 Evas_Object *(*icon)(const E_Gadcon_Client_Class *client_class, Evas * evas); 161 /* All members below are part of version 2 */ 162 /* Create new id, so that the gadcon client can refer to a config set inside the module */ 163 const char *(*id_new)(const E_Gadcon_Client_Class *client_class); 164 /* Del an id when a gadcon client is removed from the system */ 165 void (*id_del)(const E_Gadcon_Client_Class *client_class, const char *id); 166 /* All members below are part of version 3 */ 167 Eina_Bool (*is_site)(E_Gadcon_Site site); 168 } func; 169 const char *default_style; 170 }; 171 172 struct _E_Gadcon_Client 173 { 174 E_Object e_obj_inherit; 175 E_Gadcon *gadcon; 176 const char *name; 177 int id; 178 Evas_Object *o_base; 179 Evas_Object *o_box; 180 Evas_Object *o_frame; 181 Evas_Object *o_control; 182 Evas_Object *o_event; 183 const E_Gadcon_Client_Class *client_class; 184 void *data; 185 186 struct 187 { 188 int pos, size, res; //gadcon 189 double pos_x, pos_y, size_w, size_h; //gadman 190 } config; 191 192 struct 193 { 194 int seq, flags; /* goes to save */ 195 int state, resist; 196 int prev_pos, prev_size; 197 Eina_Bool want_save E_BITFIELD; 198 } state_info; 199 200 struct 201 { 202 int w, h; 203 } pad, min, max, aspect; 204 205 Ecore_Timer *scroll_timer; 206 Ecore_Timer *instant_edit_timer; 207 Ecore_Animator *scroll_animator; 208 double scroll_pos, scroll_wanted; 209 210 struct 211 { 212 void *data; 213 void (*func)(void *data); 214 } scroll_cb; 215 216 E_Menu *menu; 217 const char *style; 218 unsigned char autoscroll E_BITFIELD; 219 unsigned char resizable E_BITFIELD; 220 unsigned char moving E_BITFIELD; 221 unsigned char resizing E_BITFIELD; 222 unsigned char autoscroll_set E_BITFIELD; 223 unsigned char autoscroll_disabled E_BITFIELD; 224 Evas_Coord dx, dy; 225 226 struct 227 { 228 int x, y; 229 E_Drag *drag; 230 } drag; 231 232 unsigned char hidden E_BITFIELD; 233 234 E_Config_Gadcon_Client *cf; 235 char pscrollstate; 236 }; 237 238 struct _E_Event_Gadcon_Client_Class 239 { 240 const E_Gadcon_Client_Class *cc; 241 }; 242 243 struct _E_Event_Gadcon_Client 244 { 245 E_Gadcon_Client *gcc; 246 }; 247 248 struct _E_Event_Gadcon_Populate 249 { 250 E_Gadcon *gc; 251 }; 252 253 /* defines usable gadget placements such as Desktop, Shelf #, etc */ 254 /* next fields are mandatory (not NULL): name, add_gadget.func, remove_gadget.func */ 255 struct _E_Gadcon_Location 256 { 257 /* location name */ 258 const char *name; 259 /* icon related to location, such as "preferences-desktop-shelf" for shelves, "preferences-desktop" for menus */ 260 const char *icon_name; 261 E_Gadcon_Site site; 262 /* adds gadcon client to location. Returns nonzero on success */ 263 struct 264 { 265 int (*func)(void *data, E_Gadcon_Client *gcc, const E_Gadcon_Client_Class *cc); 266 void *data; 267 } gadget_add; 268 /* removes existing gadcon client from location */ 269 struct 270 { 271 void (*func)(void *data, E_Gadcon_Client *gcc); 272 void *data; 273 } gadget_remove; 274 }; 275 276 EINTERN int e_gadcon_init(void); 277 EINTERN int e_gadcon_shutdown(void); 278 E_API void e_gadcon_provider_register(const E_Gadcon_Client_Class *cc); 279 E_API void e_gadcon_provider_unregister(const E_Gadcon_Client_Class *cc); 280 E_API Eina_List *e_gadcon_provider_list(void); 281 E_API E_Gadcon *e_gadcon_dummy_new(int id); 282 E_API void e_gadcon_drop_handler_add(E_Gadcon *gc, E_Gadcon_DND_Cb enter, E_Gadcon_DND_Cb leave, E_Gadcon_DND_Cb move, E_Gadcon_DND_Cb drop, int x, int y, int w, int h); 283 E_API void e_gadcon_config_del(E_Gadcon *gc); 284 E_API E_Gadcon *e_gadcon_swallowed_new(const char *name, int id, Evas_Object *obj, const char *swallow_name); 285 E_API void e_gadcon_custom_new(E_Gadcon *gc); 286 E_API void e_gadcon_custom_del(E_Gadcon *gc); 287 E_API void e_gadcon_custom_populate_request(E_Gadcon *gc); 288 E_API void e_gadcon_swallowed_min_size_set(E_Gadcon *gc, Evas_Coord w, Evas_Coord h); 289 E_API void e_gadcon_min_size_request_callback_set(E_Gadcon *gc, void (*func)(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data); 290 E_API void e_gadcon_size_request_callback_set(E_Gadcon *gc, void (*func)(void *data, E_Gadcon *gc, Evas_Coord w, Evas_Coord h), void *data); 291 E_API void e_gadcon_frame_request_callback_set(E_Gadcon * gc, Evas_Object * (*func)(void *data, E_Gadcon_Client * gcc, const char *style), void *data); 292 E_API void e_gadcon_populate_callback_set(E_Gadcon *gc, void (*func)(void *data, E_Gadcon *gc, const E_Gadcon_Client_Class *cc), void *data); 293 E_API void e_gadcon_layout_policy_set(E_Gadcon *gc, E_Gadcon_Layout_Policy layout_policy); 294 E_API Eina_Bool e_gadcon_populate(E_Gadcon *gc); 295 E_API void e_gadcon_unpopulate(E_Gadcon *gc); 296 E_API void e_gadcon_repopulate(E_Gadcon *gc); 297 E_API void e_gadcon_populate_class(E_Gadcon *gc, const E_Gadcon_Client_Class *cc); 298 E_API void e_gadcon_orient(E_Gadcon *gc, E_Gadcon_Orient orient); 299 E_API void e_gadcon_edit_begin(E_Gadcon *gc); 300 E_API void e_gadcon_edit_end(E_Gadcon *gc); 301 E_API void e_gadcon_all_edit_begin(void); 302 E_API void e_gadcon_all_edit_end(void); 303 E_API void e_gadcon_zone_set(E_Gadcon *gc, E_Zone *zone); 304 E_API E_Zone *e_gadcon_zone_get(E_Gadcon *gc); 305 E_API void e_gadcon_ecore_evas_set(E_Gadcon *gc, Ecore_Evas *ee); 306 E_API int e_gadcon_canvas_zone_geometry_get(E_Gadcon *gc, int *x, int *y, int *w, int *h); 307 E_API void e_gadcon_util_menu_attach_func_set(E_Gadcon *gc, void (*func)(void *data, E_Gadcon_Client *gcc, E_Menu *menu), void *data); 308 E_API void e_gadcon_util_lock_func_set(E_Gadcon *gc, void (*func)(void *data, int lock), void *data); 309 E_API void e_gadcon_util_urgent_show_func_set(E_Gadcon *gc, void (*func)(void *data), void *data); 310 E_API void e_gadcon_dnd_window_set(E_Gadcon *gc, Ecore_X_Window win); 311 E_API Ecore_X_Window e_gadcon_dnd_window_get(E_Gadcon *gc); 312 E_API void e_gadcon_xdnd_window_set(E_Gadcon *gc, Ecore_X_Window win); 313 E_API Ecore_X_Window e_gadcon_xdnd_window_get(E_Gadcon *gc); 314 E_API void e_gadcon_shelf_set(E_Gadcon *gc, E_Shelf *shelf); 315 E_API E_Shelf *e_gadcon_shelf_get(E_Gadcon *gc); 316 E_API void e_gadcon_toolbar_set(E_Gadcon *gc, E_Toolbar *toolbar); 317 E_API E_Toolbar *e_gadcon_toolbar_get(E_Gadcon *gc); 318 E_API E_Gadcon_Client *e_gadcon_client_find(E_Gadcon *gc, E_Config_Gadcon_Client *cf_gcc); 319 E_API E_Config_Gadcon_Client *e_gadcon_client_config_new(E_Gadcon *gc, const char *name); 320 E_API void e_gadcon_client_config_del(E_Config_Gadcon *cf_gc, E_Config_Gadcon_Client *cf_gcc); 321 E_API E_Gadcon_Client *e_gadcon_client_new(E_Gadcon *gc, const char *name, const char *id, const char *style, Evas_Object *base_obj); 322 E_API void e_gadcon_client_edit_begin(E_Gadcon_Client *gcc); 323 E_API void e_gadcon_client_edit_end(E_Gadcon_Client *gcc); 324 E_API void e_gadcon_client_queue(E_Gadcon *gc, E_Config_Gadcon_Client *cf_gcc); 325 E_API void e_gadcon_client_show(E_Gadcon_Client *gcc); 326 E_API void e_gadcon_client_hide(E_Gadcon_Client *gcc); 327 E_API void e_gadcon_client_size_request(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h); 328 E_API void e_gadcon_client_min_size_set(E_Gadcon_Client *gcc, Evas_Coord w, Evas_Coord h); 329 E_API void e_gadcon_client_aspect_set(E_Gadcon_Client *gcc, int w, int h); 330 E_API void e_gadcon_client_autoscroll_toggle_disabled_set(E_Gadcon_Client *gcc, Eina_Bool disable); 331 E_API void e_gadcon_client_autoscroll_set(E_Gadcon_Client *gcc, int autoscroll); 332 E_API void e_gadcon_client_autoscroll_update(E_Gadcon_Client *gcc, int mx, int my); 333 E_API void e_gadcon_client_autoscroll_cb_set(E_Gadcon_Client *gcc, void (*func)(void *data), void *data); 334 E_API void e_gadcon_client_resizable_set(E_Gadcon_Client *gcc, int resizable); 335 E_API int e_gadcon_client_geometry_get(E_Gadcon_Client *gcc, int *x, int *y, int *w, int *h); 336 E_API int e_gadcon_client_viewport_geometry_get(E_Gadcon_Client *gcc, int *x, int *y, int *w, int *h); 337 E_API E_Zone *e_gadcon_client_zone_get(E_Gadcon_Client *gcc); 338 E_API E_Menu *e_gadcon_client_menu_set(E_Gadcon_Client *gcc, E_Menu *m); 339 E_API E_Menu *e_gadcon_client_util_menu_items_append(E_Gadcon_Client *gcc, E_Menu *menu_gadget, int flags); 340 E_API void e_gadcon_client_util_menu_attach(E_Gadcon_Client *gcc); 341 E_API void e_gadcon_locked_set(E_Gadcon *gc, int lock); 342 E_API void e_gadcon_urgent_show(E_Gadcon *gc); 343 E_API void e_gadcon_name_set(E_Gadcon *gc, const char *name); 344 345 /* site helpers */ 346 347 E_API Eina_Bool e_gadcon_site_is_shelf(E_Gadcon_Site site); 348 E_API Eina_Bool e_gadcon_site_is_desktop(E_Gadcon_Site site); 349 E_API Eina_Bool e_gadcon_site_is_efm_toolbar(E_Gadcon_Site site); 350 351 E_API Eina_Bool e_gadcon_site_is_any_toolbar(E_Gadcon_Site site); // all toolbar sities 352 E_API Eina_Bool e_gadcon_site_is_not_toolbar(E_Gadcon_Site site); // all non-toolbar sities 353 354 /* location helpers */ 355 356 E_API E_Gadcon_Location * 357 e_gadcon_location_new(const char *name, E_Gadcon_Site site, 358 int (*add_func)(void *data, E_Gadcon_Client *, const E_Gadcon_Client_Class *cc), 359 void *add_data, 360 void (*remove_func)(void *data, E_Gadcon_Client *cc), 361 void *remove_data); 362 E_API void e_gadcon_location_free(E_Gadcon_Location *loc); 363 E_API void e_gadcon_location_register(E_Gadcon_Location *loc); 364 E_API void e_gadcon_location_unregister(E_Gadcon_Location *loc); 365 E_API void e_gadcon_location_set_icon_name(E_Gadcon_Location *loc, const char *name); 366 E_API void e_gadcon_client_add_location_menu(E_Gadcon_Client *gcc, E_Menu *menu); 367 E_API void e_gadcon_drag_finished_cb(E_Drag *drag, int dropped); 368 E_API void e_gadcon_client_drag_set(E_Gadcon_Client *gcc); 369 370 E_API Eina_Bool e_gadcon_client_visible_get(const E_Gadcon_Client *gcc, const E_Desk *desk); 371 372 #define GADCON_CLIENT_CONFIG_GET(_type, _items, _gc_class, _id) \ 373 if (!_id) \ 374 { \ 375 char *_buf; \ 376 int _num = 0; \ 377 _type *_ci; \ 378 if (_items) \ 379 { \ 380 const char *_p; \ 381 _ci = eina_list_last(_items)->data; \ 382 _p = strrchr(_ci->id, '.'); \ 383 if (_p) _num = atoi(_p + 1) + 1; \ 384 } \ 385 _buf = alloca(((_gc_class.name ? strlen(_gc_class.name) : 0) + 40)); \ 386 sprintf(_buf, "%s.%d", _gc_class.name, _num); \ 387 _id = _buf; \ 388 } \ 389 else \ 390 { \ 391 Eina_List *l; \ 392 _type *_ci; \ 393 EINA_LIST_FOREACH(_items, l, _ci) \ 394 if ((_ci->id) && (!strcmp(_ci->id, _id))) return _ci; \ 395 } 396 397 #endif 398 #endif 399