refactoring for re-use

This commit is contained in:
Andy Williams 2017-04-28 21:16:47 +01:00
parent 64e8a3d703
commit cfe08f0756
2 changed files with 30 additions and 26 deletions

View File

@ -501,34 +501,10 @@ _edi_popup_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_del((Evas_Object *)data);
}
static void
_edi_launcher_run(Edi_Project_Config_Launch *launch)
void
edi_launcher_config_missing()
{
Evas_Object *popup, *button;
char *full_cmd;
int full_len;
if (_edi_project_config->launch.path)
{
if (!_edi_project_config->launch.args)
{
ecore_exe_run(launch->path, NULL);
return;
}
else
{
full_len = strlen(_edi_project_config->launch.path)
+ strlen(_edi_project_config->launch.path);
full_cmd = malloc(sizeof(char) * (full_len + 1));
snprintf(full_cmd, full_len + 2, "%s %s", _edi_project_config->launch.path,
_edi_project_config->launch.args);
ecore_exe_run(full_cmd, NULL);
free(full_cmd);
return;
}
}
popup = elm_popup_add(_edi_main_win);
elm_object_part_text_set(popup, "title,text", "Unable to launch");
@ -542,6 +518,32 @@ _edi_launcher_run(Edi_Project_Config_Launch *launch)
evas_object_show(popup);
}
static void
_edi_launcher_run(Edi_Project_Config_Launch *launch)
{
char *full_cmd;
int full_len;
if (!_edi_project_config->launch.path)
{
edi_launcher_config_missing();
return;
}
if (!_edi_project_config->launch.args)
{
ecore_exe_run(launch->path, NULL);
return;
}
full_len = strlen(_edi_project_config->launch.path) + strlen(_edi_project_config->launch.path);
full_cmd = malloc(sizeof(char) * (full_len + 1));
snprintf(full_cmd, full_len + 2, "%s %s", _edi_project_config->launch.path, _edi_project_config->launch.args);
ecore_exe_run(full_cmd, NULL);
free(full_cmd);
}
static void
_tb_new_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{

View File

@ -43,4 +43,6 @@ void edi_open_url();
Eina_Bool edi_noproject();
void edi_launcher_config_missing();
#endif