diff --git a/src/bin/e_fm_op_registry.c b/src/bin/e_fm_op_registry.c index fd17d65da..a05fdf9e6 100644 --- a/src/bin/e_fm_op_registry.c +++ b/src/bin/e_fm_op_registry.c @@ -468,6 +468,12 @@ e_fm2_op_registry_is_empty(void) return eina_hash_population(_e_fm2_op_registry) == 0; } +EAPI int +e_fm2_op_registry_count(void) +{ + return eina_hash_population(_e_fm2_op_registry); +} + EAPI unsigned int e_fm2_op_registry_init(void) diff --git a/src/bin/e_fm_op_registry.h b/src/bin/e_fm_op_registry.h index 73cabd0f8..299e1c7cb 100644 --- a/src/bin/e_fm_op_registry.h +++ b/src/bin/e_fm_op_registry.h @@ -53,6 +53,8 @@ EAPI Eina_Iterator *e_fm2_op_registry_iterator_new(void); EAPI Eina_List *e_fm2_op_registry_get_all(void); EAPI void e_fm2_op_registry_get_all_free(Eina_List *list); EAPI Eina_Bool e_fm2_op_registry_is_empty(void); +EAPI int e_fm2_op_registry_count(void); + EAPI unsigned int e_fm2_op_registry_init(void); EAPI unsigned int e_fm2_op_registry_shutdown(void); diff --git a/src/modules/fileman_opinfo/Makefile.am b/src/modules/fileman_opinfo/Makefile.am new file mode 100644 index 000000000..28372fc14 --- /dev/null +++ b/src/modules/fileman_opinfo/Makefile.am @@ -0,0 +1,28 @@ +MAINTAINERCLEANFILES = Makefile.in +MODULE = fileman_opinfo + +# data files for the module +filesdir = $(libdir)/enlightenment/modules/$(MODULE) +files_DATA = \ +e-module-$(MODULE).edj module.desktop + +EXTRA_DIST = $(files_DATA) + +# the module .so file +INCLUDES = -I. \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src/modules/$(MODULE) \ + -I$(top_srcdir)/src/bin \ + -I$(top_srcdir)/src/lib \ + -I$(top_srcdir)/src/modules \ + @e_cflags@ +pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) +pkg_LTLIBRARIES = module.la +module_la_SOURCES = e_mod_main.c \ + e_mod_main.h +module_la_LIBADD = @e_libs@ @dlopen_libs@ +module_la_LDFLAGS = -module -avoid-version +module_la_DEPENDENCIES = $(top_builddir)/config.h + +uninstall: + rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE) diff --git a/src/modules/fileman_opinfo/e-module-fileman_opinfo.edj b/src/modules/fileman_opinfo/e-module-fileman_opinfo.edj new file mode 100644 index 000000000..e7f2d592d Binary files /dev/null and b/src/modules/fileman_opinfo/e-module-fileman_opinfo.edj differ diff --git a/src/modules/fileman_opinfo/e_mod_main.c b/src/modules/fileman_opinfo/e_mod_main.c new file mode 100644 index 000000000..a1caef40e --- /dev/null +++ b/src/modules/fileman_opinfo/e_mod_main.c @@ -0,0 +1,192 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" +#include "e_mod_main.h" + +typedef struct _Instance Instance; + +struct _Instance +{ + E_Gadcon_Client *gcc; + Evas_Object *o_btn; + Ecore_Event_Handler *fm_op_entry_add_handler; + Ecore_Event_Handler *fm_op_entry_del_handler; +}; + +/* 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 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 +}; + +/******************** PROTOS *******************************************/ +void _opinfo_button_cb(void *data, void *data2); +static void _opinfo_update_gadget(Instance *inst); + +/******************** GLOBALS ******************************************/ +static E_Module *opinfo_module = NULL; + +/******************** OP_REGISTRY *************************************/ +static int +_opinfo_op_registry_entry_cb(void *data, int type, void *event) +{ + _opinfo_update_gadget(data); + return ECORE_CALLBACK_RENEW; +} + +static void +_opinfo_update_gadget(Instance *inst) +{ + char buf[1024]; + int count; + + 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); +} + +void +_opinfo_button_cb(void *data, void *data2) +{ + 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) + { + win = e_fm2_op_registry_entry_xwin_get(ere); + e_util_dialog_show("TODO","What to show here ?"); + //ecore_x_window_show(win); + } + eina_iterator_free(itr); +} +/******************** GADCON *******************************************/ +static E_Gadcon_Client * +_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) +{ + Evas_Object *o; + E_Gadcon_Client *gcc; + Instance *inst; + + inst = E_NEW(Instance, 1); + + o = e_widget_button_add(gc->evas, "", NULL, _opinfo_button_cb, NULL, NULL); + inst->o_btn = o; + _opinfo_update_gadget(inst); + + gcc = e_gadcon_client_new(gc, name, id, style, o); + gcc->data = inst; + inst->gcc = gcc; + + e_gadcon_client_util_menu_attach(gcc); + + inst->fm_op_entry_add_handler = + ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_ADD, + _opinfo_op_registry_entry_cb, inst); + inst->fm_op_entry_del_handler = + ecore_event_handler_add(E_EVENT_FM_OP_REGISTRY_DEL, + _opinfo_op_registry_entry_cb, inst); + + return gcc; +} + +static void +_gc_shutdown(E_Gadcon_Client *gcc) +{ + Instance *inst; + + inst = gcc->data; + + if (inst->fm_op_entry_add_handler) + ecore_event_handler_del(inst->fm_op_entry_add_handler); + if (inst->fm_op_entry_del_handler) + ecore_event_handler_del(inst->fm_op_entry_del_handler); + + evas_object_del(inst->o_btn); + free(inst); +} + +static void +_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient) +{ + Instance *inst; + Evas_Coord mw, mh; + + inst = gcc->data; + + mw = 120, mh = 40; + evas_object_size_hint_min_set(inst->o_btn, mw, mh); + e_gadcon_client_aspect_set(gcc, mw, mh); + e_gadcon_client_min_size_set(gcc, mw, mh); +} + +static char * +_gc_label(E_Gadcon_Client_Class *client_class) +{ + return _("EFM Operation Info"); +} + +static Evas_Object * +_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas) +{ + Evas_Object *o; + char buf[4096]; + + o = edje_object_add(evas); + snprintf(buf, sizeof(buf), "%s/e-module-fileman_opinfo.edj", + e_module_dir_get(opinfo_module)); + edje_object_file_set(o, buf, "icon"); + return o; +} + +static const char * +_gc_id_new(E_Gadcon_Client_Class *client_class) +{ + return _gadcon_class.name; +} + +/******************** E MODULE ****************************************/ +EAPI E_Module_Api e_modapi = +{ + E_MODULE_API_VERSION, + "EFM Info" +}; + +EAPI void * +e_modapi_init(E_Module *m) +{ + opinfo_module = m; + + e_gadcon_provider_register(&_gadcon_class); + return m; +} + +EAPI int +e_modapi_shutdown(E_Module *m) +{ + opinfo_module = NULL; + + e_gadcon_provider_unregister(&_gadcon_class); + return 1; +} + +EAPI int +e_modapi_save(E_Module *m) +{ + return 1; +} + +/***************************************************************************/ diff --git a/src/modules/fileman_opinfo/e_mod_main.h b/src/modules/fileman_opinfo/e_mod_main.h new file mode 100644 index 000000000..2eb60362e --- /dev/null +++ b/src/modules/fileman_opinfo/e_mod_main.h @@ -0,0 +1,13 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifndef E_MOD_MAIN_H +#define E_MOD_MAIN_H + +EAPI extern E_Module_Api e_modapi; + +EAPI void *e_modapi_init (E_Module *m); +EAPI int e_modapi_shutdown (E_Module *m); +EAPI int e_modapi_save (E_Module *m); + +#endif diff --git a/src/modules/fileman_opinfo/module.desktop.in b/src/modules/fileman_opinfo/module.desktop.in new file mode 100644 index 000000000..0903f590f --- /dev/null +++ b/src/modules/fileman_opinfo/module.desktop.in @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Link +Name=EFM Operation Info +Name[it]=Informazioni operazioni filemanager +Icon=e-module-fileman_opinfo +Comment=Gadget to show current EFM operations
Can be placed on the desktop or in a shelf. +Comment[it]=Gadget che mostra le operazioni in corso del file manager
Può essere messo sul desktop o su una mensola. +X-Enlightenment-ModuleType=fileman