@ -4,90 +4,327 @@
# include "e.h"
# include "e_mod_main.h"
typedef struct _Instance Instance ;
struct _Instance
typedef struct _Instance
{
char * theme_file ;
E_Gadcon_Client * gcc ;
Evas_Object * o_btn ;
Ecore_Event_Handler * fm_op_entry_add_handler ;
Ecore_Event_Handler * fm_op_entry_del_handler ;
} ;
Evas_Object * o_box ,
* o_status ;
Ecore_Event_Handler * fm_op_entry_add_handler ,
* fm_op_entry_del_handler ;
} Instance ;
/* gadcon requirements */
static E_Gadcon_Client * _gc_init ( E_Gadcon * gc , const char * name , const char * id , const char * style ) ;
static void _gc_shutdown ( E_Gadcon_Client * gcc ) ;
static void _gc_orient ( E_Gadcon_Client * gcc , E_Gadcon_Orient orient ) ;
static char * _gc_label ( E_Gadcon_Client_Class * client_class ) ;
static Evas_Object * _gc_icon ( E_Gadcon_Client_Class * client_class , Evas * evas ) ;
static const char * _gc_id_new ( E_Gadcon_Client_Class * client_class ) ;
static E_Gadcon_Client * _gc_init ( E_Gadcon * gc , const char * name , const char * id , const char * style ) ;
static void _gc_shutdown ( E_Gadcon_Client * gcc ) ;
static void _gc_orient ( E_Gadcon_Client * gcc , E_Gadcon_Orient orient ) ;
static char * _gc_label ( E_Gadcon_Client_Class * client_class ) ;
static Evas_Object * _gc_icon ( E_Gadcon_Client_Class * client_class , Evas * evas ) ;
static const char * _gc_id_new ( E_Gadcon_Client_Class * client_class ) ;
static const E_Gadcon_Client_Class _gadcon_class = {
GADCON_CLIENT_CLASS_VERSION , " efm_info " , {
_gc_init , _gc_shutdown , _gc_orient , _gc_label , _gc_icon , _gc_id_new , NULL
} , E_GADCON_CLIENT_STYLE_PLAIN
GADCON_CLIENT_CLASS_VERSION , " efm_info " ,
{
_gc_init , _gc_shutdown , _gc_orient , _gc_label , _gc_icon , _gc_id_new , NULL ,
e_gadcon_site_is_desktop
} ,
E_GADCON_CLIENT_STYLE_PLAIN
} ;
/******************** PROTOS *******************************************/
void _opinfo_button_cb ( void * data , void * data2 ) ;
static void _opinfo_update_gadget ( Instance * inst ) ;
static int _opinfo_op_registry_entry_add_cb ( void * data , int type , void * event ) ;
static int _opinfo_op_registry_entry_del_cb ( void * data , int type , void * event ) ;
static void _opinfo_op_registry_update_all ( Instance * inst ) ;
static void _opinfo_op_registry_listener ( void * data , const E_Fm2_Op_Registry_Entry * ere ) ;
static void _opinfo_op_registry_free_data ( void * data ) ;
static int _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_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_update_status ( Instance * inst ) ;
/******************** GLOBALS ******************************************/
static E_Module * opinfo_module = NULL ;
/******************** OP_REGISTRY *************************************/
static void
_opinfo_op_registry_listener ( void * data , const E_Fm2_Op_Registry_Entry * ere )
{
Evas_Object * o = data ;
char * total , buf [ PATH_MAX ] ;
if ( ! o | | ! ere ) return ;
// Update icon
switch ( ere - > op )
{
case E_FM_OP_COPY :
edje_object_signal_emit ( o , " e,action,icon,copy " , " e " ) ;
break ;
case E_FM_OP_MOVE :
edje_object_signal_emit ( o , " e,action,icon,move " , " e " ) ;
break ;
case E_FM_OP_REMOVE :
edje_object_signal_emit ( o , " e,action,icon,delete " , " e " ) ;
break ;
default :
edje_object_signal_emit ( o , " e,action,icon,unknow " , " e " ) ;
}
// Update information text
switch ( ere - > status )
{
case E_FM2_OP_STATUS_ABORTED :
switch ( ere - > op )
{
case E_FM_OP_COPY :
snprintf ( buf , sizeof ( buf ) , _ ( " Copying is aborted " ) ) ;
break ;
case E_FM_OP_MOVE :
snprintf ( buf , sizeof ( buf ) , _ ( " Moving is aborted " ) ) ;
break ;
case E_FM_OP_REMOVE :
snprintf ( buf , sizeof ( buf ) , _ ( " Deleting is aborted " ) ) ;
break ;
default :
snprintf ( buf , sizeof ( buf ) , _ ( " Unknown operation from slave is aborted " ) ) ;
}
break ;
default :
total = e_util_size_string_get ( ere - > total ) ;
switch ( ere - > op )
{
case E_FM_OP_COPY :
if ( ere - > finished )
snprintf ( buf , sizeof ( buf ) , _ ( " Copy of %s done " ) , total ) ;
else
snprintf ( buf , sizeof ( buf ) , _ ( " Copying %s (eta: %d sec) " ) , total , ere - > eta ) ;
break ;
case E_FM_OP_MOVE :
if ( ere - > finished )
snprintf ( buf , sizeof ( buf ) , _ ( " Move of %s done " ) , total ) ;
else
snprintf ( buf , sizeof ( buf ) , _ ( " Moving %s (eta: %d sec) " ) , total , ere - > eta ) ;
break ;
case E_FM_OP_REMOVE :
if ( ere - > finished )
snprintf ( buf , sizeof ( buf ) , _ ( " Delete done " ) ) ;
else
snprintf ( buf , sizeof ( buf ) , _ ( " Deleting files... " ) ) ;
break ;
default :
snprintf ( buf , sizeof ( buf ) , _ ( " Unknow operation from slave %d " ) , ere - > id ) ;
}
E_FREE ( total ) ;
}
edje_object_part_text_set ( o , " e.text.info " , buf ) ;
// Update detailed information
if ( ! ere - > src )
edje_object_part_text_set ( o , " e.text.src " , _ ( " (no information) " ) ) ;
else
{
if ( ere - > op = = E_FM_OP_REMOVE )
snprintf ( buf , sizeof ( buf ) , _ ( " File: %s " ) , ere - > src ) ;
else
snprintf ( buf , sizeof ( buf ) , _ ( " From: %s " ) , ere - > src ) ;
edje_object_part_text_set ( o , " e.text.src " , buf ) ;
}
if ( ! ere - > dst | | ere - > op = = E_FM_OP_REMOVE )
edje_object_part_text_set ( o , " e.text.dest " , _ ( " (no information) " ) ) ;
else
{
snprintf ( buf , sizeof ( buf ) , _ ( " To: %s " ) , ere - > dst ) ;
edje_object_part_text_set ( o , " e.text.dest " , buf ) ;
}
// 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
if ( ere - > needs_attention )
edje_object_signal_emit ( o , " e,action,set,need_attention " , " e " ) ;
else
edje_object_signal_emit ( o , " e,action,set,normal " , " e " ) ;
}
static void
_opinfo_op_registry_free_data ( void * data )
{
ecore_timer_add ( 5.0 , _opinfo_op_registry_free_data_delayed , data ) ;
}
static int
_opinfo_op_registry_free_data_delayed ( void * data )
{
Evas_Object * o = data ;
if ( o )
{
e_box_unpack ( o ) ;
evas_object_del ( o ) ;
}
return ECORE_CALLBACK_CANCEL ;
}
static void
_opinfo_op_registry_abort_cb ( void * data , Evas_Object * obj , const char * emission , const char * source )
{
int id ;
id = ( int ) data ;
if ( ! id ) return ;
e_fm2_operation_abort ( id ) ;
}
static void
_opinfo_op_registry_summary_cb ( void * data , Evas_Object * obj , const char * emission , const char * source )
{
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 , Evas_Object * obj , const char * emission , const char * source )
{
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 int
_opinfo_op_registry_entry_cb ( void * data , int type , void * event )
_opinfo_op_registry_entry_add_ cb ( void * data , int type , void * event )
{
_opinfo_update_gadget ( data ) ;
E_Fm2_Op_Registry_Entry * ere = event ;
Instance * inst = data ;
Evas_Object * o ;
int mw , mh , xh ;
if ( ! inst | | ! ere )
return ECORE_CALLBACK_RENEW ;
_opinfo_op_registry_update_status ( inst ) ;
if ( ! ( ere - > op = = E_FM_OP_COPY | | ere - > op = = E_FM_OP_MOVE | | ere - > op = = E_FM_OP_REMOVE ) )
return ECORE_CALLBACK_RENEW ;
o = edje_object_add ( evas_object_evas_get ( inst - > o_box ) ) ;
if ( ! e_theme_edje_object_set ( o , " base/theme/modules/fileman_opinfo " ,
" 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 " , " " ,
_opinfo_op_registry_abort_cb , ( void * ) ere - > id ) ;
edje_object_signal_callback_add ( o , " state,request,summary " , " fileman_opinfo " ,
_opinfo_op_registry_summary_cb , inst ) ;
edje_object_signal_callback_add ( o , " state,request,detailed " , " fileman_opinfo " ,
_opinfo_op_registry_detailed_cb , inst ) ;
e_fm2_op_registry_entry_listener_add ( ere , _opinfo_op_registry_listener ,
o , _opinfo_op_registry_free_data ) ;
return ECORE_CALLBACK_RENEW ;
}
static void
_opinfo_update_gadget ( Instance * inst )
static int
_opinfo_op_registry_entry_del_cb ( void * data , int type , void * even t )
{
char buf [ 1024 ] ;
int count ;
Instance * inst = data ;
if ( ! inst )
return ECORE_CALLBACK_RENEW ;
count = e_fm2_op_registry_count ( ) ;
if ( count )
snprintf ( buf , sizeof ( buf ) , _ ( " %d operations " ) , count ) ;
else
snprintf ( buf , sizeof ( buf ) , _ ( " idle " ) ) ;
e_widget_button_label_set ( inst - > o_btn , buf ) ;
e_widget_disabled_set ( inst - > o_btn , count ? 0 : 1 ) ;
_opinfo_op_registry_update_status ( inst ) ;
return ECORE_CALLBACK_RENEW ;
}
void
_opinfo_button_cb ( void * data , void * data2 )
static void
_opinfo_op_registry_update_all ( Instance * inst )
{
Ecore_X_Window win ;
Eina_Iterator * itr ;
E_Fm2_Op_Registry_Entry * ere ;
itr = e_fm2_op_registry_iterator_new ( ) ;
EINA_ITERATOR_FOREACH ( itr , ere )
_opinfo_op_registry_entry_add_cb ( inst , 0 , ere ) ;
eina_iterator_free ( itr ) ;
_opinfo_op_registry_update_status ( inst ) ;
}
static void
_opinfo_op_registry_update_status ( Instance * inst )
{
int cnt ;
char buf [ 256 ] ;
cnt = e_fm2_op_registry_count ( ) ;
if ( cnt )
{
win = e_fm2_op_registry_entry_xwin_get ( ere ) ;
e_util_dialog_show ( " TODO " , " What to show here ? " ) ;
//ecore_x_window_show(win);
snprintf ( buf , sizeof ( buf ) , _ ( " Processing %d operation(s) " ) , cnt ) ;
edje_object_part_text_set ( inst - > o_status , " e.text.info " , buf ) ;
}
eina_iterator_free ( itr ) ;
else
edje_object_part_text_set ( inst - > o_status , " e.text.info " , _ ( " Filemanager is idle " ) ) ;