edi_exe: modify method to allow additional data parameter.
This adds an additional pointer for abritrary data. Have utilised this to make the notidy on build more verbose without code duplication.
This commit is contained in:
parent
7bb4a7cc24
commit
b19befd089
|
@ -701,26 +701,31 @@ _edi_launcher_run(Edi_Project_Config_Launch *launch)
|
|||
}
|
||||
|
||||
static void
|
||||
_edi_build_display_status_cb(int status)
|
||||
_edi_build_display_status_cb(int status, void *data)
|
||||
{
|
||||
Eina_Strbuf *message;
|
||||
Eina_Strbuf *title, *message;
|
||||
const char *name = data;
|
||||
|
||||
title = eina_strbuf_new();
|
||||
message = eina_strbuf_new();
|
||||
|
||||
if (status != 0)
|
||||
eina_strbuf_append_printf(message, "Build of project <b>%s</b> in %s failed with status code %d.", edi_project_name_get(), edi_project_get(), status);
|
||||
eina_strbuf_append_printf(message, "%s of project <b>%s</b> in %s failed with status code %d.\n", name, edi_project_name_get(), edi_project_get(), status);
|
||||
else
|
||||
eina_strbuf_append_printf(message, "Build of project <b>%s</b> in %s was successful.", edi_project_name_get(), edi_project_get());
|
||||
eina_strbuf_append_printf(message, "%s of project <b>%s</b> in %s was successful.\n", name, edi_project_name_get(), edi_project_get());
|
||||
|
||||
edi_screens_desktop_notify("EDI :: Build Status", eina_strbuf_string_get(message));
|
||||
eina_strbuf_append_printf(title, "EDI :: %s Status", name);
|
||||
|
||||
edi_screens_desktop_notify(eina_strbuf_string_get(title), eina_strbuf_string_get(message));
|
||||
|
||||
eina_strbuf_free(title);
|
||||
eina_strbuf_free(message);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_build_project(void)
|
||||
{
|
||||
if (edi_exe_notify_handle("edi_build", _edi_build_display_status_cb))
|
||||
if (edi_exe_notify_handle("edi_build", _edi_build_display_status_cb, "Build"))
|
||||
{
|
||||
edi_consolepanel_show();
|
||||
edi_builder_build();
|
||||
|
@ -730,7 +735,7 @@ _edi_build_project(void)
|
|||
static void
|
||||
_edi_build_clean_project(void)
|
||||
{
|
||||
if (edi_exe_notify_handle("edi_build", _edi_build_display_status_cb))
|
||||
if (edi_exe_notify_handle("edi_build", _edi_build_display_status_cb, "Clean"))
|
||||
{
|
||||
edi_consolepanel_show();
|
||||
edi_builder_clean();
|
||||
|
@ -740,7 +745,7 @@ _edi_build_clean_project(void)
|
|||
static void
|
||||
_edi_build_test_project(void)
|
||||
{
|
||||
if (edi_exe_notify_handle("edi_build", _edi_build_display_status_cb))
|
||||
if (edi_exe_notify_handle("edi_build", _edi_build_display_status_cb, "Test"))
|
||||
{
|
||||
edi_consolepanel_show();
|
||||
edi_builder_test();
|
||||
|
|
|
@ -129,7 +129,7 @@ void edi_screens_desktop_notify(const char *title, const char *message)
|
|||
|
||||
command = eina_strbuf_new();
|
||||
|
||||
eina_strbuf_append_printf(command, "notify-send -t 7000 -i edi '%s' '%s'", title, message);
|
||||
eina_strbuf_append_printf(command, "notify-send -t 10000 -i edi '%s' '%s'", title, message);
|
||||
|
||||
ecore_exe_run(eina_strbuf_string_get(command), NULL);
|
||||
|
||||
|
|
|
@ -13,33 +13,47 @@
|
|||
static Ecore_Event_Handler *_edi_exe_handler = NULL;
|
||||
static Ecore_Event_Handler *_edi_exe_notify_handler = NULL;
|
||||
|
||||
typedef struct _Edi_Exe_Args {
|
||||
void ((*func)(int, void *));
|
||||
void *data;
|
||||
} Edi_Exe_Args;
|
||||
|
||||
static Eina_Bool
|
||||
_edi_exe_notify_data_cb(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
|
||||
{
|
||||
int *status;
|
||||
void *(*func)(int value);
|
||||
Edi_Exe_Args *args;
|
||||
Ecore_Con_Event_Client_Data *ev = event;
|
||||
|
||||
status = ev->data;
|
||||
func = data;
|
||||
|
||||
func(*status);
|
||||
args = data;
|
||||
|
||||
args->func(*status, args->data);
|
||||
|
||||
ecore_event_handler_del(_edi_exe_notify_handler);
|
||||
_edi_exe_notify_handler = NULL;
|
||||
|
||||
free(args);
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
edi_exe_notify_handle(const char *name, void ((*func)(int)))
|
||||
edi_exe_notify_handle(const char *name, void ((*func)(int, void *)), void *data)
|
||||
{
|
||||
Edi_Exe_Args *args;
|
||||
|
||||
if (_edi_exe_notify_handler) return EINA_FALSE;
|
||||
|
||||
/* These are UNIX domain sockets, no need to clean up */
|
||||
ecore_con_server_add(ECORE_CON_LOCAL_USER, name, 0, NULL);
|
||||
|
||||
_edi_exe_notify_handler = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _edi_exe_notify_data_cb, func);
|
||||
args = malloc(sizeof(Edi_Exe_Args));
|
||||
args->func = func;
|
||||
args->data = data;
|
||||
|
||||
_edi_exe_notify_handler = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb) _edi_exe_notify_data_cb, args);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -56,10 +56,11 @@ EAPI void edi_exe_notify(const char *name, const char *command);
|
|||
*
|
||||
* @param name The name of the resource used to identify the notification.
|
||||
* @param func Function that will execute upon receiving exit code of exe.
|
||||
* @param data Additional data to pass to the callback.
|
||||
*
|
||||
* @ingroup Exe
|
||||
*/
|
||||
EAPI Eina_Bool edi_exe_notify_handle(const char *name, void ((*func)(int)));
|
||||
EAPI Eina_Bool edi_exe_notify_handle(const char *name, void ((*func)(int, void *)), void *data);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
Loading…
Reference in New Issue