Chandra
view release on metacpan or search on metacpan
include/chandra/chandra_splash.h view on Meta::CPAN
static int
csplash_create(const char *title, int width, int height, int frameless)
{
/* -1/-1 â center on screen */
return cwin_create(title ? title : "", width, height, -1, -1, 0, frameless);
}
/*
* csplash_show_html â set HTML content and make the window visible.
*/
static void
csplash_show_html(int wid, const char *html)
{
cwin_set_html(wid, html);
cwin_show(wid);
}
/*
* csplash_update_status â update the status text line via JS eval.
* text is escaped to prevent JS injection.
*/
static void
csplash_update_status(int wid, const char *text)
{
char *escaped = csplash_js_escape(text);
if (!escaped) return;
/* JS_STATUS expects a %s that is already a quoted JS string literal */
size_t js_len = strlen(CHANDRA_SPLASH_JS_STATUS) + strlen(escaped) + 1;
char *js = (char *)malloc(js_len);
if (js) {
snprintf(js, js_len, CHANDRA_SPLASH_JS_STATUS, escaped);
cwin_eval_js(wid, js);
free(js);
}
free(escaped);
}
/*
* csplash_update_progress â update progress bar width (0â100).
*/
static void
csplash_update_progress(int wid, int percent)
{
char js[256];
if (percent < 0) percent = 0;
if (percent > 100) percent = 100;
snprintf(js, sizeof(js), CHANDRA_SPLASH_JS_PROGRESS, percent);
cwin_eval_js(wid, js);
}
/*
* csplash_close â destroy the splash window.
*/
static void
csplash_close(int wid)
{
cwin_destroy(wid);
}
/*
* csplash_is_open â 1 if the window is still alive, 0 otherwise.
*/
static int
csplash_is_open(int wid)
{
return (wid > 0) ? cwin_exists(wid) : 0;
}
#endif /* CHANDRA_XS_IMPLEMENTATION */
#endif /* CHANDRA_SPLASH_H */
( run in 2.608 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )