2 #include "e_mod_main.h"
4 typedef struct _Instance
9 Evas_Object *o_box, *o_status;
11 Ecore_Event_Handler *fm_op_entry_add_handler, *fm_op_entry_del_handler;
14 /* gadcon requirements */
16 static E_Gadcon_Client *_gc_init (E_Gadcon *gc, const char *name, const char *id, const char *style);
17 static void _gc_shutdown(E_Gadcon_Client *gcc);
18 static void _gc_orient (E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
19 static const char *_gc_label (E_Gadcon_Client_Class *client_class);
20 static Evas_Object *_gc_icon (E_Gadcon_Client_Class *client_class, Evas *evas);
21 static const char *_gc_id_new (E_Gadcon_Client_Class *client_class);
23 static const E_Gadcon_Client_Class _gadcon_class = {
24 GADCON_CLIENT_CLASS_VERSION, "efm_info",
26 _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
27 e_gadcon_site_is_desktop
29 E_GADCON_CLIENT_STYLE_PLAIN
32 /******************** PROTOS *******************************************/
34 static Eina_Bool _opinfo_op_registry_entry_add_cb (void *data, int type, void *event);
35 static Eina_Bool _opinfo_op_registry_entry_del_cb (void *data, int type, void *event);
36 static void _opinfo_op_registry_update_all (Instance *inst);
37 static void _opinfo_op_registry_listener (void *data, const E_Fm2_Op_Registry_Entry *ere);
38 static void _opinfo_op_registry_free_data (void *data);
39 static Eina_Bool _opinfo_op_registry_free_data_delayed(void *data);
40 static void _opinfo_op_registry_abort_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
41 static void _opinfo_op_registry_summary_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
42 static void _opinfo_op_registry_detailed_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
43 static void _opinfo_op_registry_window_jump_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
44 static void _opinfo_op_registry_update_status (Instance *inst);
46 /******************** GLOBALS ******************************************/
48 static E_Module *opinfo_module = NULL;
50 /******************** OP_REGISTRY *************************************/
53 _opinfo_op_registry_listener(void *data, const E_Fm2_Op_Registry_Entry *ere)
55 Evas_Object *o = data;
56 char *total, buf[PATH_MAX];
58 if (!o || !ere) return;
64 edje_object_signal_emit(o, "e,action,icon,copy", "e");
67 edje_object_signal_emit(o, "e,action,icon,move", "e");
70 edje_object_signal_emit(o, "e,action,icon,delete", "e");
73 edje_object_signal_emit(o, "e,action,icon,unknow", "e");
76 // Update has/none linked efm window
77 if (e_win_evas_object_win_get(ere->e_fm))
78 edje_object_signal_emit(o, "state,set,window,exist", "fileman_opinfo");
80 edje_object_signal_emit(o, "state,set,window,absent", "fileman_opinfo");
82 // Update information text
85 case E_FM2_OP_STATUS_ABORTED:
89 snprintf(buf, sizeof(buf), _("Copying is aborted"));
92 snprintf(buf, sizeof(buf), _("Moving is aborted"));
95 snprintf(buf, sizeof(buf), _("Deleting is aborted"));
98 snprintf(buf, sizeof(buf), _("Unknown operation from slave is aborted"));
103 total = e_util_size_string_get(ere->total);
108 snprintf(buf, sizeof(buf), _("Copy of %s done"), total);
110 snprintf(buf, sizeof(buf), _("Copying %s (eta: %d sec)"), total, ere->eta);
114 snprintf(buf, sizeof(buf), _("Move of %s done"), total);
116 snprintf(buf, sizeof(buf), _("Moving %s (eta: %d sec)"), total, ere->eta);
120 snprintf(buf, sizeof(buf), _("Delete done"));
122 snprintf(buf, sizeof(buf), _("Deleting files..."));
125 snprintf(buf, sizeof(buf), _("Unknow operation from slave %d"), ere->id);
129 edje_object_part_text_set(o, "e.text.info", buf);
131 // Update detailed information
133 edje_object_part_text_set(o, "e.text.src", _("(no information)"));
136 if (ere->op == E_FM_OP_REMOVE)
137 snprintf(buf, sizeof(buf), _("File: %s"), ere->src);
139 snprintf(buf, sizeof(buf), _("From: %s"), ere->src);
140 edje_object_part_text_set(o, "e.text.src", buf);
142 if (!ere->dst || ere->op == E_FM_OP_REMOVE)
143 edje_object_part_text_set(o, "e.text.dest", _("(no information)"));
146 snprintf(buf, sizeof(buf), _("To: %s"), ere->dst);
147 edje_object_part_text_set(o, "e.text.dest", buf);
151 edje_object_part_drag_size_set(o, "e.gauge.bar", ere->percent / 100.0, 1.0);
152 snprintf(buf, sizeof(buf), "%3i%%", ere->percent);
153 edje_object_part_text_set(o, "e.text.percent", buf);
156 if (ere->needs_attention)
157 edje_object_signal_emit(o, "e,action,set,need_attention", "e");
159 edje_object_signal_emit(o, "e,action,set,normal", "e");
163 _opinfo_op_registry_free_data(void *data)
165 ecore_timer_add(5.0, _opinfo_op_registry_free_data_delayed, data);
169 _opinfo_op_registry_free_data_delayed(void *data)
171 Evas_Object *o = data;
179 return ECORE_CALLBACK_CANCEL;
183 _opinfo_op_registry_abort_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
190 e_fm2_operation_abort(id);
194 _opinfo_op_registry_summary_cb(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
198 edje_object_signal_emit(obj, "state,set,summary", "fileman_opinfo");
200 edje_object_size_min_get(obj, &mw, &mh);
201 e_box_pack_options_set(obj, 1, 0, 1, 0, 0.0, 0.0, mw, mh, 9999, mh);
205 _opinfo_op_registry_detailed_cb(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
209 edje_object_signal_emit(obj, "state,set,detailed", "fileman_opinfo");
211 edje_object_size_min_calc(obj, &mw, NULL);
212 edje_object_size_max_get(obj, NULL, &xh);
213 e_box_pack_options_set(obj, 1, 0, 1, 0, 0.0, 0.0, mw, xh, 9999, xh);
217 _opinfo_op_registry_window_jump_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
220 E_Fm2_Op_Registry_Entry *ere;
224 ere = e_fm2_op_registry_entry_get(id);
227 // if attention dialog is present then raise it, otherwise raise the efm window
228 win = (ere->needs_attention && ere->dialog) ? ere->dialog->win
229 : e_win_evas_object_win_get(ere->e_fm);
234 if (win->border->iconic)
235 e_border_uniconify(win->border);
236 if (win->border->shaded)
237 e_border_unshade(win->border, win->border->shade.dir);
242 e_desk_show(win->border->desk);
243 e_border_focus_set_with_pointer(win->border);
245 if (ere->needs_attention && e_config->pointer_slide)
246 e_border_pointer_warp_to_center(win->border);
250 _opinfo_op_registry_entry_add_cb(void *data, __UNUSED__ int type, void *event)
252 E_Fm2_Op_Registry_Entry *ere = event;
253 Instance *inst = data;
257 return ECORE_CALLBACK_RENEW;
259 _opinfo_op_registry_update_status(inst);
261 if (!(ere->op == E_FM_OP_COPY || ere->op == E_FM_OP_MOVE || ere->op == E_FM_OP_REMOVE))
262 return ECORE_CALLBACK_RENEW;
264 o = edje_object_add(evas_object_evas_get(inst->o_box));
265 if (!e_theme_edje_object_set(o, "base/theme/modules/fileman_opinfo",
266 "modules/fileman_opinfo/main"))
267 edje_object_file_set(o, inst->theme_file, "modules/fileman_opinfo/main");
268 _opinfo_op_registry_listener(o, ere);
269 e_box_pack_before(inst->o_box, o, inst->o_status);
271 _opinfo_op_registry_summary_cb(inst, o, NULL, NULL);
273 edje_object_signal_callback_add(o, "e,fm,operation,abort", "",
274 _opinfo_op_registry_abort_cb, (void*)(long)ere->id);
275 edje_object_signal_callback_add(o, "state,request,summary", "fileman_opinfo",
276 _opinfo_op_registry_summary_cb, inst);
277 edje_object_signal_callback_add(o, "state,request,detailed", "fileman_opinfo",
278 _opinfo_op_registry_detailed_cb, inst);
279 edje_object_signal_callback_add(o, "e,fm,window,jump", "",
280 _opinfo_op_registry_window_jump_cb, (void*)(long)ere->id);
282 e_fm2_op_registry_entry_listener_add(ere, _opinfo_op_registry_listener,
283 o, _opinfo_op_registry_free_data);
285 return ECORE_CALLBACK_RENEW;
289 _opinfo_op_registry_entry_del_cb(void *data, __UNUSED__ int type, __UNUSED__ void *event)
291 Instance *inst = data;
294 return ECORE_CALLBACK_RENEW;
296 _opinfo_op_registry_update_status(inst);
298 return ECORE_CALLBACK_RENEW;
302 _opinfo_op_registry_update_all(Instance *inst)
305 E_Fm2_Op_Registry_Entry *ere;
307 itr = e_fm2_op_registry_iterator_new();
308 EINA_ITERATOR_FOREACH(itr, ere)
309 _opinfo_op_registry_entry_add_cb(inst, 0, ere);
310 eina_iterator_free(itr);
312 _opinfo_op_registry_update_status(inst);
316 _opinfo_op_registry_update_status(Instance *inst)
321 cnt = e_fm2_op_registry_count();
324 snprintf(buf, sizeof(buf), _("Processing %d operation(s)"), cnt);
325 edje_object_part_text_set(inst->o_status, "e.text.info", buf);
328 edje_object_part_text_set(inst->o_status, "e.text.info", _("Filemanager is idle"));
331 /******************** GADCON *******************************************/
333 static E_Gadcon_Client *
334 _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
336 E_Gadcon_Client *gcc;
341 inst = E_NEW(Instance, 1);
343 r = asprintf(&inst->theme_file, "%s/e-module-fileman_opinfo.edj",
344 e_module_dir_get(opinfo_module));
352 inst->o_box = e_box_add(gc->evas);
353 e_box_homogenous_set(inst->o_box, 0);
354 e_box_orientation_set(inst->o_box, 0);
355 e_box_align_set(inst->o_box, 0, 0);
358 inst->o_status = edje_object_add(evas_object_evas_get(inst->o_box));
359 if (!e_theme_edje_object_set(inst->o_status, "base/theme/modules/fileman_opinfo",
360 "modules/fileman_opinfo/status"))
361 edje_object_file_set(inst->o_status, inst->theme_file, "modules/fileman_opinfo/status");
362 e_box_pack_end(inst->o_box, inst->o_status);
363 evas_object_show(inst->o_status);
364 edje_object_size_min_get(inst->o_status, &mw, &mh);
365 e_box_pack_options_set(inst->o_status, 1, 0, 1, 0, 0.0, 0.0, mw, mh, 9999, mh);
367 _opinfo_op_registry_update_all(inst);
369 gcc = e_gadcon_client_new(gc, name, id, style, inst->o_box);
373 e_gadcon_client_util_menu_attach(gcc);
375 inst->fm_op_entry_add_handler =
376 ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_ADD,
377 _opinfo_op_registry_entry_add_cb, inst);
378 inst->fm_op_entry_del_handler =
379 ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_DEL,
380 _opinfo_op_registry_entry_del_cb, inst);
386 _gc_shutdown(E_Gadcon_Client *gcc)
388 Instance *inst = gcc->data;
390 if (inst->fm_op_entry_add_handler)
391 ecore_event_handler_del(inst->fm_op_entry_add_handler);
392 if (inst->fm_op_entry_del_handler)
393 ecore_event_handler_del(inst->fm_op_entry_del_handler);
394 e_box_unpack(inst->o_status);
395 evas_object_del(inst->o_status);
396 evas_object_del(inst->o_box);
397 free(inst->theme_file);
402 _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
404 Instance *inst = gcc->data;
405 Evas_Coord mw = 200, mh = 100;
407 evas_object_size_hint_min_set(inst->o_box, mw, mh);
408 e_gadcon_client_aspect_set(gcc, mw, mh);
409 e_gadcon_client_min_size_set(gcc, mw, mh);
413 _gc_label(E_Gadcon_Client_Class *client_class __UNUSED__)
415 return _("EFM Operation Info");
419 _gc_icon(E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
424 o = edje_object_add(evas);
425 snprintf(buf, sizeof(buf), "%s/e-module-fileman_opinfo.edj",
426 e_module_dir_get(opinfo_module));
427 edje_object_file_set(o, buf, "icon");
433 _gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__)
435 return _gadcon_class.name;
438 /******************** E MODULE ****************************************/
440 EAPI E_Module_Api e_modapi =
442 E_MODULE_API_VERSION,
447 e_modapi_init(E_Module *m)
450 e_gadcon_provider_register(&_gadcon_class);
455 e_modapi_shutdown(E_Module *m __UNUSED__)
457 opinfo_module = NULL;
458 e_gadcon_provider_unregister(&_gadcon_class);
463 e_modapi_save(E_Module *m __UNUSED__)