2005-02-07 05:51:09 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2004-11-24 19:37:45 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
|
|
|
typedef struct _E_Util_Fake_Mouse_Up_Info E_Util_Fake_Mouse_Up_Info;
|
|
|
|
|
|
|
|
struct _E_Util_Fake_Mouse_Up_Info
|
|
|
|
{
|
|
|
|
E_Container *con;
|
|
|
|
int button;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
static void _e_util_container_fake_mouse_up_cb(void *data);
|
|
|
|
static int _e_util_wakeup_cb(void *data);
|
|
|
|
|
|
|
|
/* local subsystem globals */
|
|
|
|
static Ecore_Timer *_e_util_dummy_timer = NULL;
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
|
|
|
void
|
|
|
|
e_util_container_fake_mouse_up_later(E_Container *con, int button)
|
|
|
|
{
|
|
|
|
E_Util_Fake_Mouse_Up_Info *info;
|
|
|
|
|
|
|
|
info = calloc(1, sizeof(E_Util_Fake_Mouse_Up_Info));
|
|
|
|
if (info)
|
|
|
|
{
|
|
|
|
info->con = con;
|
|
|
|
info->button = button;
|
|
|
|
e_object_ref(E_OBJECT(info->con));
|
|
|
|
ecore_job_add(_e_util_container_fake_mouse_up_cb, info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_util_container_fake_mouse_up_all_later(E_Container *con)
|
|
|
|
{
|
|
|
|
e_util_container_fake_mouse_up_later(con, 1);
|
|
|
|
e_util_container_fake_mouse_up_later(con, 2);
|
|
|
|
e_util_container_fake_mouse_up_later(con, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_util_wakeup(void)
|
|
|
|
{
|
|
|
|
if (_e_util_dummy_timer) return;
|
|
|
|
_e_util_dummy_timer = ecore_timer_add(0.0, _e_util_wakeup_cb, NULL);
|
|
|
|
}
|
|
|
|
|
2005-04-14 02:09:22 -07:00
|
|
|
void
|
|
|
|
e_util_env_set(const char *var, const char *val)
|
|
|
|
{
|
|
|
|
if (val)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SETENV
|
|
|
|
setenv(var, val, 1);
|
|
|
|
#else
|
|
|
|
char buf[8192];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s=%s", var, val);
|
|
|
|
if (getenv(var))
|
|
|
|
putenv(buf);
|
|
|
|
else
|
|
|
|
putenv(strdup(buf));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
#ifdef HAVE_UNSETENV
|
|
|
|
unsetenv(var);
|
|
|
|
#else
|
|
|
|
if (getenv(var)) putenv(var);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-29 21:21:55 -07:00
|
|
|
E_Zone *
|
|
|
|
e_util_zone_current_get(E_Manager *man)
|
|
|
|
{
|
|
|
|
E_Container *con;
|
|
|
|
|
2005-06-03 12:10:25 -07:00
|
|
|
con = e_container_current_get(man);
|
2005-04-29 21:21:55 -07:00
|
|
|
if (con)
|
|
|
|
{
|
|
|
|
E_Zone *zone;
|
|
|
|
|
|
|
|
zone = e_zone_current_get(con);
|
|
|
|
return zone;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* local subsystem functions */
|
|
|
|
static void
|
|
|
|
_e_util_container_fake_mouse_up_cb(void *data)
|
|
|
|
{
|
|
|
|
E_Util_Fake_Mouse_Up_Info *info;
|
|
|
|
|
|
|
|
info = data;
|
|
|
|
if (info)
|
|
|
|
{
|
2004-12-13 19:32:25 -08:00
|
|
|
evas_event_feed_mouse_up(info->con->bg_evas, info->button, EVAS_BUTTON_NONE, NULL);
|
2004-11-24 19:37:45 -08:00
|
|
|
e_object_unref(E_OBJECT(info->con));
|
|
|
|
free(info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_e_util_wakeup_cb(void *data)
|
|
|
|
{
|
|
|
|
_e_util_dummy_timer = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
2005-06-05 08:02:43 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
e_util_utils_installed(void)
|
|
|
|
{
|
2005-06-11 06:32:29 -07:00
|
|
|
return ecore_file_app_installed("emblem");
|
2005-06-05 08:02:43 -07:00
|
|
|
}
|
|
|
|
|
2005-06-30 21:09:30 -07:00
|
|
|
int
|
|
|
|
e_util_glob_match(char *str, char *glob)
|
|
|
|
{
|
|
|
|
if (glob[0] == 0)
|
|
|
|
{
|
|
|
|
if (str[0] == 0) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!strcmp(glob, "*")) return 1;
|
|
|
|
if (!fnmatch(glob, str, 0)) return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2005-07-02 06:33:53 -07:00
|
|
|
|
|
|
|
E_Container *
|
|
|
|
e_util_container_number_get(int num)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = e_manager_list(); l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Manager *man;
|
|
|
|
E_Container *con;
|
|
|
|
|
|
|
|
man = l->data;
|
|
|
|
con = e_manager_container_number_get(man, num);
|
|
|
|
if (con) return con;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_Zone *
|
|
|
|
e_util_container_zone_number_get(int con_num, int zone_num)
|
|
|
|
{
|
|
|
|
E_Container *con;
|
|
|
|
|
|
|
|
con = e_util_container_number_get(con_num);
|
|
|
|
if (!con) return NULL;
|
|
|
|
return e_container_zone_number_get(con, zone_num);
|
|
|
|
}
|
2005-07-07 02:27:04 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
e_util_head_exec(int head, char *cmd)
|
|
|
|
{
|
|
|
|
char *penv_display;
|
|
|
|
char *p1, *p2;
|
|
|
|
char buf[4096], buf2[32];
|
|
|
|
int ok = 0;
|
|
|
|
Ecore_Exe *exe;
|
|
|
|
|
|
|
|
penv_display = getenv("DISPLAY");
|
|
|
|
if (penv_display) penv_display = strdup(penv_display);
|
|
|
|
/* set env vars */
|
|
|
|
p1 = strrchr(penv_display, ':');
|
|
|
|
p2 = strrchr(penv_display, '.');
|
|
|
|
if ((p1) && (p2) && (p2 > p1)) /* "blah:x.y" */
|
|
|
|
{
|
|
|
|
/* yes it could overflow... but who will voerflow DISPLAY eh? why? to
|
|
|
|
* "exploit" your own applications running as you?
|
|
|
|
*/
|
|
|
|
strcpy(buf, penv_display);
|
|
|
|
buf[p2 - penv_display + 1] = 0;
|
|
|
|
snprintf(buf2, sizeof(buf2), "%i", head);
|
|
|
|
strcat(buf, buf2);
|
|
|
|
}
|
|
|
|
else if (p1) /* "blah:x */
|
|
|
|
{
|
|
|
|
strcpy(buf, penv_display);
|
|
|
|
snprintf(buf2, sizeof(buf2), ".%i", head);
|
|
|
|
strcat(buf, buf2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(buf, penv_display);
|
|
|
|
|
|
|
|
ok = 1;
|
|
|
|
exe = ecore_exe_run(cmd, NULL);
|
|
|
|
if (!exe)
|
|
|
|
{
|
|
|
|
e_error_dialog_show(_("Run Error"),
|
|
|
|
_("Enlightenment was unable fork a child process\n"
|
|
|
|
"to run the execute line:\n"
|
|
|
|
"\n"
|
|
|
|
"%s\n"
|
|
|
|
"\n"),
|
|
|
|
cmd);
|
|
|
|
ok = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset env vars */
|
|
|
|
if (penv_display)
|
|
|
|
{
|
|
|
|
e_util_env_set("DISPLAY", penv_display);
|
|
|
|
free(penv_display);
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|