Mon Nov 8 14:05:56 PST 1999

(KainX)

Multiple hacks are now supported in E-Xss.  Just edit your config file and
list as many hacks as you want.  The key values are "hack_0", "hack_1", etc.,
on up to however many hacks you want.


SVN revision: 1210
This commit is contained in:
Michael Jennings 1999-11-08 12:14:34 +00:00
parent 6de296475d
commit 3131c6476e
2 changed files with 55 additions and 54 deletions

View File

@ -288,3 +288,12 @@ Sat Nov 6 12:03:16 PST 1999
Well, it seems to work pretty well at this point. Now I just need to figure
out how to support multiple hacks (which is what those previous/next buttons
are for).
-------------------------------------------------------------------------------
Mon Nov 8 14:05:56 PST 1999
(KainX)
Multiple hacks are now supported in E-Xss. Just edit your config file and
list as many hacks as you want. The key values are "hack_0", "hack_1", etc.,
on up to however many hacks you want.

View File

@ -14,19 +14,19 @@
#define BEGMATCH(a, b) (!strncasecmp((a), (b), (sizeof(b) - 1)))
#define NONULL(x) ((x) ? (x) : (""))
#define PREV_HACK() do {if (idx == 1) idx = image_cnt - 1; else if (idx == 0) idx = image_cnt - 2; else idx -= 2;} while (0)
#define CUR_HACK() ((idx == 0) ? (image_cnt - 1) : (idx - 1))
#define PREV_HACK() do {if (idx == 1) idx = hack_cnt - 1; else if (idx == 0) idx = hack_cnt - 2; else idx -= 2;} while (0)
#define CUR_HACK() ((idx == 0) ? (hack_cnt - 1) : (idx - 1))
#define NEXT_HACK() ((void) 0)
#define INC_HACK() do {idx++; if (idx == image_cnt) idx = 0;} while (0)
#define INC_HACK() do {idx++; if (idx == hack_cnt) idx = 0;} while (0)
Epplet_gadget close_button, prev_button, next_button, zoom_button, draw_area;
unsigned long idx = 0, hack_cnt = 0;
double delay = 5.0;
char **hacks = NULL, *hack = NULL;
double delay;
char **hacks = NULL;
unsigned char paused = 0;
pid_t hack_pid = -1;
static void start_hack(void);
static void start_hack(char *hack);
static void stop_hack(void);
static void change_hack(void *data);
static void child_cb(void *data, int pid, int exit_code);
@ -37,7 +37,7 @@ static void in_cb(void *data, Window w);
static void out_cb(void *data, Window w);
static void
start_hack(void) {
start_hack(char *hack) {
char buff[1024];
@ -57,23 +57,11 @@ stop_hack(void) {
static void
change_hack(void *data) {
#if 0
/* Test-load each image to make sure it's a valid image file. */
for (; ((filenames[idx] == NULL) || ((im = Imlib_load_image(Epplet_get_imlib_data(), filenames[idx])) == NULL)); idx++) {
/* It isn't, so NULL out its name. */
filenames[idx] = NULL;
}
Imlib_destroy_image(Epplet_get_imlib_data(), im); /* Destroy the image, but keep it in cache. */
Epplet_change_image(picture, 42, 42, filenames[idx]);
INC_PIC();
Epplet_remove_timer("CHANGE_IMAGE");
if (!paused) {
Epplet_timer(change_image, NULL, delay, "CHANGE_IMAGE");
}
#endif
stop_hack();
start_hack(hacks[idx]);
INC_HACK();
Epplet_timer(change_hack, NULL, delay, "CHANGE_HACK");
return;
data = NULL;
}
@ -83,7 +71,8 @@ child_cb(void *data, int pid, int exit_code) {
if (pid == hack_pid) {
fprintf(stderr, "E-Xss: Child process exited with return code %d\n", exit_code);
exit(0);
Epplet_remove_timer("CHANGE_HACK");
Epplet_timer(change_hack, NULL, 0.1, "CHANGE_HACK");
}
return;
data = NULL;
@ -102,12 +91,8 @@ close_cb(void *data) {
static void
zoom_cb(void *data) {
#if 0
char buff[1024];
Epplet_spawn_command(hacks[CUR_HACK()]);
sprintf(buff, zoom_cmd, filenames[CUR_PIC()]);
Epplet_spawn_command(buff);
#endif
return;
data = NULL;
}
@ -115,38 +100,22 @@ zoom_cb(void *data) {
static void
play_cb(void *data) {
#if 0
int op = (int) data;
switch (op) {
case -1:
/* Previous image */
PREV_PIC();
change_image(NULL);
break;
case 0:
/* Pause */
Epplet_remove_timer("CHANGE_IMAGE");
paused = 1;
Epplet_gadget_hide(pause_button);
Epplet_gadget_show(play_button);
PREV_HACK();
change_hack(NULL);
break;
case 1:
/* Play */
paused = 0;
Epplet_gadget_hide(play_button);
Epplet_gadget_show(pause_button);
change_image(NULL);
break;
case 2:
/* Next image */
NEXT_PIC();
change_image(NULL);
NEXT_HACK();
change_hack(NULL);
break;
default:
break;
}
#endif
return;
data = NULL;
}
@ -180,7 +149,30 @@ out_cb(void *data, Window w) {
static void
parse_config(void) {
hack = Epplet_query_config_def("hack", "kaleidescope");
delay = atof(Epplet_query_config_def("delay", "60.0"));
hacks = (char **) malloc(sizeof(char *) * (hack_cnt + 1));
for (; 1; hack_cnt++) {
char *tmp;
char buff[40];
sprintf(buff, "hack_%lu", hack_cnt);
tmp = Epplet_query_config(buff);
if (!tmp) {
break;
}
hacks = (char **) realloc(hacks, sizeof(char *) * (hack_cnt + 1));
hacks[hack_cnt] = tmp;
}
if (hack_cnt == 0) {
hack_cnt = 3;
hacks = (char **) realloc(hacks, sizeof(char *) * (hack_cnt));
hacks[0] = "kaleidescope";
hacks[1] = "rorschach";
hacks[2] = "qix -solid -delay 0 -segments 100";
Epplet_add_config("hack_0", "kaleidescope");
Epplet_add_config("hack_1", "rorschach");
Epplet_add_config("hack_2", "qix -solid -delay 0 -segments 100");
}
}
int
@ -191,23 +183,23 @@ main(int argc, char **argv) {
prio = getpriority(PRIO_PROCESS, getpid());
setpriority(PRIO_PROCESS, getpid(), prio + 10);
atexit(Epplet_cleanup);
Epplet_Init("E-Xss", "0.1", "Enlightenment Xscreensaver Epplet", 3, 3, argc, argv, 0);
Epplet_Init("E-Xss", "0.2", "Enlightenment Xscreensaver Epplet", 3, 3, argc, argv, 0);
Epplet_load_config();
parse_config();
close_button = Epplet_create_button(NULL, NULL, 3, 3, 0, 0, "CLOSE", 0, NULL, close_cb, NULL);
zoom_button = Epplet_create_button(NULL, NULL, 33, 3, 0, 0, "EJECT", 0, NULL, zoom_cb, NULL);
prev_button = Epplet_create_button(NULL, NULL, 3, 33, 0, 0, "PREVIOUS", 0, NULL, play_cb, (void *) (-1));
next_button = Epplet_create_button(NULL, NULL, 33, 33, 0, 0, "NEXT", 0, NULL, play_cb, (void *) (2));
next_button = Epplet_create_button(NULL, NULL, 33, 33, 0, 0, "NEXT", 0, NULL, play_cb, (void *) (1));
Epplet_gadget_show(prev_button);
Epplet_gadget_show(next_button);
draw_area = Epplet_create_drawingarea(3, 3, 42, 42);
draw_area = Epplet_create_drawingarea(3, 3, 43, 43);
Epplet_gadget_show(draw_area);
Epplet_show();
Epplet_register_focus_in_handler(in_cb, NULL);
Epplet_register_focus_out_handler(out_cb, NULL);
start_hack();
change_hack(NULL);
Epplet_Loop();
return 0;