Revamp the fileman-operation-info desktop gadget using the same theme as efm.

Some feature are lost (window jump and detailed info), hope I can work on that
in the next few days.
Also updated the module icon.



SVN revision: 79728
This commit is contained in:
Davide Andreoli 2012-11-26 23:53:24 +00:00
parent 64396beb84
commit 003fa1bfbd
2 changed files with 109 additions and 110 deletions

View File

@ -38,8 +38,6 @@ static void _opinfo_op_registry_listener (void *data, const E_Fm2_Op_Reg
static void _opinfo_op_registry_free_data (void *data); static void _opinfo_op_registry_free_data (void *data);
static Eina_Bool _opinfo_op_registry_free_data_delayed(void *data); static Eina_Bool _opinfo_op_registry_free_data_delayed(void *data);
static void _opinfo_op_registry_abort_cb (void *data, Evas_Object *obj, const char *emission, const char *source); static void _opinfo_op_registry_abort_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
static void _opinfo_op_registry_summary_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
static void _opinfo_op_registry_detailed_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
static void _opinfo_op_registry_window_jump_cb (void *data, Evas_Object *obj, const char *emission, const char *source); static void _opinfo_op_registry_window_jump_cb (void *data, Evas_Object *obj, const char *emission, const char *source);
static void _opinfo_op_registry_update_status (Instance *inst); static void _opinfo_op_registry_update_status (Instance *inst);
@ -54,23 +52,35 @@ _opinfo_op_registry_listener(void *data, const E_Fm2_Op_Registry_Entry *ere)
{ {
Evas_Object *o = data; Evas_Object *o = data;
char *total, buf[4096]; char *total, buf[4096];
Edje_Message_Float msg;
int mw, mh;
if (!o || !ere) return; if (!o || !ere) return;
// Don't show if the operation keep less than 1 second
if (ere->start_time + 1.0 > ecore_loop_time_get()) return;
// Update icon // Update icon
switch (ere->op) switch (ere->op)
{ {
case E_FM_OP_COPY: case E_FM_OP_COPY:
edje_object_signal_emit(o, "e,action,icon,copy", "e"); edje_object_signal_emit(o, "e,action,icon,copy", "e");
break; break;
case E_FM_OP_MOVE: case E_FM_OP_MOVE:
edje_object_signal_emit(o, "e,action,icon,move", "e"); edje_object_signal_emit(o, "e,action,icon,move", "e");
break; break;
case E_FM_OP_REMOVE: case E_FM_OP_REMOVE:
edje_object_signal_emit(o, "e,action,icon,delete", "e"); edje_object_signal_emit(o, "e,action,icon,delete", "e");
break; break;
case E_FM_OP_SECURE_REMOVE:
edje_object_signal_emit(o, "e,action,icon,secure_delete", "e");
break;
default: default:
edje_object_signal_emit(o, "e,action,icon,unknow", "e"); edje_object_signal_emit(o, "e,action,icon,unknown", "e");
} }
// Update has/none linked efm window // Update has/none linked efm window
@ -81,82 +91,106 @@ _opinfo_op_registry_listener(void *data, const E_Fm2_Op_Registry_Entry *ere)
// Update information text // Update information text
switch (ere->status) switch (ere->status)
{ {
case E_FM2_OP_STATUS_ABORTED: case E_FM2_OP_STATUS_ABORTED:
switch (ere->op) switch (ere->op)
{ {
case E_FM_OP_COPY: case E_FM_OP_COPY:
snprintf(buf, sizeof(buf), _("Copying is aborted")); snprintf(buf, sizeof(buf), _("Copying is aborted"));
break; break;
case E_FM_OP_MOVE:
snprintf(buf, sizeof(buf), _("Moving is aborted")); case E_FM_OP_MOVE:
break; snprintf(buf, sizeof(buf), _("Moving is aborted"));
case E_FM_OP_REMOVE: break;
snprintf(buf, sizeof(buf), _("Deleting is aborted"));
break; case E_FM_OP_REMOVE:
default: snprintf(buf, sizeof(buf), _("Deleting is aborted"));
snprintf(buf, sizeof(buf), _("Unknown operation from slave is aborted")); break;
}
break; case E_FM_OP_SECURE_REMOVE:
snprintf(buf, sizeof(buf), _("Secure deletion is aborted"));
break;
default:
snprintf(buf, sizeof(buf), _("Unknown operation from slave is aborted"));
}
break;
default: default:
total = e_util_size_string_get(ere->total); total = e_util_size_string_get(ere->total);
switch (ere->op) switch (ere->op)
{ {
case E_FM_OP_COPY: case E_FM_OP_COPY:
if (ere->finished) if (ere->finished)
snprintf(buf, sizeof(buf), _("Copy of %s done"), total); snprintf(buf, sizeof(buf), _("Copy of %s done"), total);
else else
snprintf(buf, sizeof(buf), _("Copying %s (eta: %d s)"), total, ere->eta); snprintf(buf, sizeof(buf), _("Copying %s (eta: %s)"),
break; total, e_util_time_str_get(ere->eta));
case E_FM_OP_MOVE: break;
if (ere->finished)
snprintf(buf, sizeof(buf), _("Move of %s done"), total); case E_FM_OP_MOVE:
else if (ere->finished)
snprintf(buf, sizeof(buf), _("Moving %s (eta: %d s)"), total, ere->eta); snprintf(buf, sizeof(buf), _("Move of %s done"), total);
break; else
case E_FM_OP_REMOVE: snprintf(buf, sizeof(buf), _("Moving %s (eta: %s)"),
if (ere->finished) total, e_util_time_str_get(ere->eta));
snprintf(buf, sizeof(buf), _("Delete done")); break;
else
snprintf(buf, sizeof(buf), _("Deleting files...")); case E_FM_OP_REMOVE:
break; if (ere->finished)
default: snprintf(buf, sizeof(buf), _("Delete done"));
snprintf(buf, sizeof(buf), _("Unknown operation from slave %d"), ere->id); else
} snprintf(buf, sizeof(buf), _("Deleting files..."));
E_FREE(total); break;
}
case E_FM_OP_SECURE_REMOVE:
if (ere->finished)
snprintf(buf, sizeof(buf), _("Secure delete done"));
else
snprintf(buf, sizeof(buf), _("Securely deleting files..."));
break;
default:
snprintf(buf, sizeof(buf), _("Unknown operation from slave %d"), ere->id);
}
E_FREE(total);
}
edje_object_part_text_set(o, "e.text.info", buf); edje_object_part_text_set(o, "e.text.info", buf);
// Update detailed information // Update spinner wheel
if (!ere->src) if ((ere->finished) || (ere->status == E_FM2_OP_STATUS_ABORTED))
edje_object_part_text_set(o, "e.text.src", _("(no information)"));
else
{ {
if (ere->op == E_FM_OP_REMOVE) if (!evas_object_data_get(o, "stopped"))
snprintf(buf, sizeof(buf), _("File: %s"), ere->src); {
else evas_object_data_set(o, "stopped", o);
snprintf(buf, sizeof(buf), _("From: %s"), ere->src); edje_object_signal_emit(o, "e,state,busy,stop", "e");
edje_object_part_text_set(o, "e.text.src", buf); }
} }
if (!ere->dst || ere->op == E_FM_OP_REMOVE) if (ere->percent > 0)
edje_object_part_text_set(o, "e.text.dest", _("(no information)"));
else
{ {
snprintf(buf, sizeof(buf), _("To: %s"), ere->dst); if (!evas_object_data_get(o, "started"))
edje_object_part_text_set(o, "e.text.dest", buf); {
evas_object_data_set(o, "started", o);
edje_object_signal_emit(o, "e,state,busy,start", "e");
}
} }
// Update gauge
edje_object_part_drag_size_set(o, "e.gauge.bar", ere->percent / 100.0, 1.0);
snprintf(buf, sizeof(buf), "%3i%%", ere->percent);
edje_object_part_text_set(o, "e.text.percent", buf);
// Update attention // Update attention
if (ere->needs_attention) if (ere->needs_attention)
edje_object_signal_emit(o, "e,action,set,need_attention", "e"); edje_object_signal_emit(o, "e,action,set,need_attention", "e");
else else
edje_object_signal_emit(o, "e,action,set,normal", "e"); edje_object_signal_emit(o, "e,action,set,normal", "e");
// Update gauge
edje_object_part_drag_size_set(o, "e.gauge.bar",
((double)(ere->percent)) / 100.0, 1.0);
msg.val = ((double)(ere->percent)) / 100.0;
edje_object_message_send(o, EDJE_MESSAGE_FLOAT, 1, &msg);
// resize element to fit the box
edje_object_size_min_calc(o, &mw, &mh);
e_box_pack_options_set(o, 1, 0, 1, 0, 0.0, 0.0, mw, mh, 9999, mh);
evas_object_show(o);
} }
static void static void
@ -190,29 +224,6 @@ _opinfo_op_registry_abort_cb(void *data, Evas_Object *obj __UNUSED__, const char
e_fm2_operation_abort(id); e_fm2_operation_abort(id);
} }
static void
_opinfo_op_registry_summary_cb(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
{
int mw, mh;
edje_object_signal_emit(obj, "state,set,summary", "fileman_opinfo");
edje_object_size_min_get(obj, &mw, &mh);
e_box_pack_options_set(obj, 1, 0, 1, 0, 0.0, 0.0, mw, mh, 9999, mh);
}
static void
_opinfo_op_registry_detailed_cb(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
{
int mw, xh;
edje_object_signal_emit(obj, "state,set,detailed", "fileman_opinfo");
edje_object_size_min_calc(obj, &mw, NULL);
edje_object_size_max_get(obj, NULL, &xh);
e_box_pack_options_set(obj, 1, 0, 1, 0, 0.0, 0.0, mw, xh, 9999, xh);
}
static void static void
_opinfo_op_registry_window_jump_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) _opinfo_op_registry_window_jump_cb(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{ {
@ -262,22 +273,10 @@ _opinfo_op_registry_entry_add_cb(void *data, __UNUSED__ int type, void *event)
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
o = edje_object_add(evas_object_evas_get(inst->o_box)); o = edje_object_add(evas_object_evas_get(inst->o_box));
if (!e_theme_edje_object_set(o, "base/theme/modules/fileman_opinfo", e_theme_edje_object_set(o, "base/theme/fileman", "e/fileman/default/progress");
"modules/fileman_opinfo/main"))
edje_object_file_set(o, inst->theme_file, "modules/fileman_opinfo/main");
_opinfo_op_registry_listener(o, ere);
e_box_pack_before(inst->o_box, o, inst->o_status);
evas_object_show(o);
_opinfo_op_registry_summary_cb(inst, o, NULL, NULL);
edje_object_signal_callback_add(o, "e,fm,operation,abort", "", edje_object_signal_callback_add(o, "e,fm,operation,abort", "",
_opinfo_op_registry_abort_cb, (void*)(long)ere->id); _opinfo_op_registry_abort_cb, (void*)(long)ere->id);
edje_object_signal_callback_add(o, "state,request,summary", "fileman_opinfo", e_box_pack_end(inst->o_box, o);
_opinfo_op_registry_summary_cb, inst);
edje_object_signal_callback_add(o, "state,request,detailed", "fileman_opinfo",
_opinfo_op_registry_detailed_cb, inst);
edje_object_signal_callback_add(o, "e,fm,window,jump", "",
_opinfo_op_registry_window_jump_cb, (void*)(long)ere->id);
e_fm2_op_registry_entry_listener_add(ere, _opinfo_op_registry_listener, e_fm2_op_registry_entry_listener_add(ere, _opinfo_op_registry_listener,
o, _opinfo_op_registry_free_data); o, _opinfo_op_registry_free_data);
@ -374,7 +373,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
inst->fm_op_entry_add_handler = inst->fm_op_entry_add_handler =
ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_ADD, ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_ADD,
_opinfo_op_registry_entry_add_cb, inst); _opinfo_op_registry_entry_add_cb, inst);
inst->fm_op_entry_del_handler = inst->fm_op_entry_del_handler =
ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_DEL, ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_DEL,
_opinfo_op_registry_entry_del_cb, inst); _opinfo_op_registry_entry_del_cb, inst);