Table of Contents
Examples of Codes for EFL
This page includes some Tips and Tricks for EFL, you can found here a lot of chunks of examples of nice and useful things
You can consider this page as a kind of fast reference
Chunks of codes
Exe Handler
Run an external command and set a handler (listener) to run a function when it has finished (exited), it also can know the exit code value of the command launched
#include <stdio.h> #include <Ecore.h> typedef struct _Handy Handy; struct _Handy { Ecore_Exe *gen_exe; Ecore_Event_Handler *handler; }; static int _run_cb(){ // Run this just in order to demonstrate that we are not catching the events anymore (handlers deleted previously) ecore_exe_run("echo 'running something extra (_run_cb) for check handler' ; sleep 1 ; false", NULL); } static int _del_cb(void *data, int type, void *event) { Ecore_Exe_Event_Del *ev; Handy *hand = NULL; ev = event; hand = data; if (hand) { ecore_event_handler_del(hand->handler); hand->handler = NULL; hand->gen_exe = NULL; printf("handlers deleted\n"); } if (ev->exit_code == 1) // this is the return exit code by the job run before { printf("exit code (1) returned from command\n"); _run_cb(); // This is not needed, is just a checker of that the handler has really finished (deleted) } if(hand) { printf("hand freed\n"); free(hand); } return ECORE_CALLBACK_CANCEL; // 0 } int main (int argc, char **argv) { ecore_init(); Handy *hand = NULL; hand = calloc(1, sizeof(Handy)); // Add event handler to call _del_cb when the job is finished (deleted), also pass the structure hand hand->handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _del_cb, hand); // run something, and return false in order to catch the 'error' exit code (1) hand->gen_exe = ecore_exe_run("echo running command ; sleep 1 ; echo command finished ; false", hand); ecore_main_loop_begin(); ecore_shutdown(); return(0); }
Last modified
5 years ago
Last modified on Sep 16, 2019, 5:25:19 AM
Note:
See TracWiki
for help on using the wiki.