Mon Nov 29 14:08:10 GMT 1999

(gilbertt)

Tidied up E-UrlWatch lots. Its pretty lean now.


SVN revision: 1451
This commit is contained in:
Tom Gilbert 1999-11-29 10:29:22 +00:00
parent 10af2854ff
commit 6680bc8f5d
4 changed files with 43 additions and 409 deletions

View File

@ -966,3 +966,10 @@ Sun Nov 28 21:33:53 EST 1999
More fun with focus...
-------------------------------------------------------------------------------
Mon Nov 29 14:08:10 GMT 1999
(gilbertt)
Tidied up E-UrlWatch lots. Its pretty lean now.

View File

@ -26,62 +26,33 @@
#include "epplet.h"
#include "utils.h"
#include "cloak.h"
#include "E-UrlWatch.h"
#if 0
#define D(a) { printf("%s +%u : ",__FILE__,__LINE__); \
printf a; fflush(stdout); }
#else
#define D(a) { /* No debug */; }
#endif
static void display_string (char *string);
static void handle_url (char *url, char *type);
static void add_url_to_popup (char *url);
static int url_in_popup (char *url);
static char *validate_url (char *url);
static void
choose_random_cloak (void *data)
{
static int last_anim = 0;
do
{
opt.cloak_anim = (int) (15 * ((float) rand ()) / (RAND_MAX + 1.0)) + 1;
}
while (opt.cloak_anim == last_anim); /* Don't pick the same one twice in a row. */
last_anim = opt.cloak_anim;
Epplet_timer (choose_random_cloak, NULL, opt.rand_delay, "RAND_TIMER");
return;
data = NULL;
}
static void
save_config (void)
{
char buf[10];
Esnprintf (buf, sizeof (buf), "%.2f", opt.cloak_delay);
Epplet_modify_config ("CLOAK_DELAY", buf);
Esnprintf (buf, sizeof (buf), "%.2f", opt.draw_interval);
Epplet_modify_config ("DRAW_INTERVAL", buf);
Esnprintf (buf, sizeof (buf), "%.2f", opt.rand_delay);
Epplet_modify_config ("RAND_DELAY", buf);
Esnprintf (buf, sizeof (buf), "%d", opt.always_show_file_urls);
Epplet_modify_config ("ALWAYS_SHOW_FILE_URLS", buf);
/*
* Esnprintf (buf, sizeof (buf), "%d", opt.do_cloak);
* Epplet_modify_config ("DO_CLOAK", buf);
*/
Esnprintf (buf, sizeof (buf), "%d", opt.save_urls);
Epplet_modify_config ("SAVE_URLS", buf);
Esnprintf (buf, sizeof (buf), "%d", opt.check_url_file);
Epplet_modify_config ("CHECK_URL_FILE", buf);
Esnprintf (buf, sizeof (buf), "%d", opt.do_new_url_command);
Epplet_modify_config ("RUN_COMMAND_ON_NEW_URL", buf);
if (opt.rand_cloak)
{
strcpy (buf, "16");
}
else
{
Esnprintf (buf, sizeof (buf), "%d", opt.cloak_anim);
}
Epplet_modify_config ("CLOAK_ANIM", buf);
Epplet_modify_config ("WWW_COMMAND", opt.www_command);
Epplet_modify_config ("FTP_COMMAND", opt.ftp_command);
Epplet_modify_config ("GET_COMMAND", opt.get_command);
@ -95,26 +66,12 @@ load_config (void)
{
char *home = getenv ("HOME");
char buf[256];
opt.do_cloak = atoi (Epplet_query_config_def ("DO_CLOAK", "0"));
opt.cloak_anim = atoi (Epplet_query_config_def ("CLOAK_ANIM", "8"));
opt.save_urls = atoi (Epplet_query_config_def ("SAVE_URLS", "1"));
opt.check_url_file = atoi (Epplet_query_config_def ("CHECK_URL_FILE", "1"));
opt.always_show_file_urls =
atoi (Epplet_query_config_def ("ALWAYS_SHOW_FILE_URLS", "0"));
opt.do_new_url_command =
atoi (Epplet_query_config_def ("RUN_COMMAND_ON_NEW_URL", "1"));
if (opt.cloak_anim == 16)
{
opt.rand_cloak = 1;
choose_random_cloak (NULL);
}
else
{
opt.rand_cloak = 0;
}
opt.cloak_delay = atof (Epplet_query_config_def ("CLOAK_DELAY", "4"));
opt.rand_delay = atof (Epplet_query_config_def ("RAND_DELAY", "60"));
opt.draw_interval = atof (Epplet_query_config_def ("DRAW_INTERVAL", "0.1"));
if (opt.www_command)
free (opt.www_command);
opt.www_command =
@ -164,211 +121,6 @@ cb_help (void *data)
data = NULL;
}
static void
cloak_draw (void *data)
{
switch (opt.cloak_anim)
{
case 0:
{
blank_buf ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 1:
{
load_val = (opt.quality / 2);
draw_flame ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 2:
{
draw_radar ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 3:
{
draw_aa_radar ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 4:
{
draw_aa_triangle ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 5:
{
draw_aa_star ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 6:
{
draw_starfield ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 7:
{
draw_aa_starfield ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 8:
{
draw_rotator ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 9:
{
draw_scanner ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 10:
{
draw_colorwarp ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 11:
{
draw_ball ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 12:
{
draw_atoms ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 13:
{
draw_text ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 14:
{
draw_sine ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
case 15:
{
draw_funky_rotator ();
Epplet_timer (cloak_draw, NULL, opt.draw_interval, "DRAW_TIMER");
break;
}
default:
{
blank_buf ();
break;
}
}
Epplet_paste_buf (buf, win, 0, 0);
return;
data = NULL;
}
static void
cloak_epplet (void *data)
{
if (!cloaked)
{
Epplet_gadget_hide (btn_close);
Epplet_gadget_hide (btn_conf);
Epplet_gadget_hide (btn_help);
Epplet_gadget_hide (btn_www);
Epplet_gadget_hide (btn_ctimer);
Epplet_gadget_show (da);
cloak_draw (NULL);
cloaked = 1;
}
return;
data = NULL;
}
static void
cb_cloak_anim (void *data)
{
cb_in (NULL, 0);
opt.do_cloak = 1;
opt.cloak_anim = *((int *) data);
if (opt.cloak_anim == 16)
{
opt.rand_cloak = 1;
choose_random_cloak (NULL);
}
else
{
if (opt.rand_cloak)
{
Epplet_remove_timer ("RAND_TIMER");
}
opt.rand_cloak = 0;
}
Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER");
return;
data = NULL;
}
static void
cb_cloak_delay (void *data)
{
Epplet_remove_timer ("CLOAK_TIMER");
opt.cloak_delay = *(int *) data;
Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER");
return;
data = NULL;
}
static void
cb_dont_cloak (void *data)
{
opt.do_cloak = 0;
Epplet_remove_timer ("CLOAK_TIMER");
return;
data = NULL;
}
static void
cb_in (void *data, Window w)
{
if (cloaked)
{
Epplet_gadget_hide (da);
cloaked = 0;
Epplet_gadget_show (btn_close);
Epplet_gadget_show (btn_conf);
Epplet_gadget_show (btn_help);
Epplet_gadget_show (btn_www);
Epplet_gadget_show (btn_ctimer);
}
Epplet_remove_timer ("CLOAK_TIMER");
Epplet_remove_timer ("DRAW_TIMER");
return;
data = NULL;
w = (Window) 0;
}
static void
cb_out (void *data, Window w)
{
Epplet_remove_timer ("CLOAK_TIMER");
if ((!cloaked) && (opt.do_cloak))
Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER");
return;
data = NULL;
w = (Window) 0;
}
static void
cb_url_listp (void *data)
{
@ -471,16 +223,26 @@ get_url_from_file_list (char *file, int position)
if (position == -1)
{
while (!feof (fp))
fgets (buf, sizeof (buf), fp);
D (("In get_url_from_file_list: buf is -->%s<--\n", buf));
{
j++;
fgets (buf, sizeof (buf), fp);
}
D (("In get_url_from_file_list: There are %d urls in the file\n", j));
}
else
{
while (!feof (fp) && j++ < position)
fgets (buf, sizeof (buf), fp);
D (("In get_url_from_file_list: buf is -->%s<--\n", buf));
while (!feof (fp) && j < position)
{
j++;
fgets (buf, sizeof (buf), fp);
}
D (
("In get_url_from_file_list: Asked for url %d returning url %d\n",
position, j));
}
D (("In get_url_from_file_list: buf is -->%s<--\n", buf));
fclose (fp);
return buf;
@ -510,6 +272,7 @@ display_url_from_file (char *url)
add_url_to_popup (validurl);
}
/* Examine the file for changes */
static void
check_url_file (void *data)
{
@ -583,7 +346,7 @@ validate_url (char *url)
if (p != NULL)
*p = '\0';
/* If just www.blah, add the http:// */
/* If just www.blah, add the http:// to avoid confusing nutscrape */
if (*ret == 'w' && *(ret + 1) == 'w' && *(ret + 2) == 'w')
{
char *temp = _Strjoin (NULL, "http://", ret, NULL);
@ -608,12 +371,7 @@ save_url (char *url)
{
FILE *fp;
char *home = getenv ("HOME");
char filename[256];
Esnprintf (filename, sizeof (filename), "%s/%s", home, ".Urls");
if ((fp = fopen (filename, "a")) != NULL)
if ((fp = fopen (opt.url_save_file, "a")) != NULL)
{
fprintf (fp, "%s\n", url);
fclose (fp);
@ -660,9 +418,7 @@ scroll_string (void *data)
Epplet_change_label (lbl_url, buf);
}
else
{
Epplet_change_label (lbl_url, dtext.str);
}
Epplet_change_label (lbl_url, dtext.str);
if (pause)
{
@ -778,6 +534,7 @@ cb_shoot (void *data)
return;
}
static void
cb_btn_file_url (void *data)
{
@ -789,16 +546,6 @@ cb_btn_file_url (void *data)
data = NULL;
}
static void
cb_color (void *data)
{
int *d;
d = (int *) data;
flame_col (d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8]);
Epplet_gadget_hide (col_p);
}
static void
create_epplet_layout (void)
{
@ -828,92 +575,12 @@ create_epplet_layout (void)
btn_file_url = Epplet_create_button ("New Url!", NULL,
32, 2, 48, 12,
0, 0, NULL, cb_btn_file_url, NULL);
p = Epplet_create_popup ();
Epplet_add_popup_entry (p, "Don't Cloak", NULL, cb_dont_cloak, NULL);
Epplet_add_popup_entry (p, "Blank Epplet", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[0])));
Epplet_add_popup_entry (p, "RasterFire", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[1])));
Epplet_add_popup_entry (p, "Radar", NULL, cb_cloak_anim,
(void *) (&(cloak_anims[2])));
Epplet_add_popup_entry (p, "AA Radar", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[3])));
Epplet_add_popup_entry (p, "AA Triangle", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[4])));
Epplet_add_popup_entry (p, "AA Star", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[5])));
Epplet_add_popup_entry (p, "Starfield", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[6])));
Epplet_add_popup_entry (p, "AA Starfield", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[7])));
Epplet_add_popup_entry (p, "Mesh", NULL, cb_cloak_anim,
(void *) (&(cloak_anims[8])));
Epplet_add_popup_entry (p, "Funky Mesh", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[15])));
Epplet_add_popup_entry (p, "Scanner", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[9])));
Epplet_add_popup_entry (p, "ColorShift", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[10])));
Epplet_add_popup_entry (p, "Bouncy Ball", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[11])));
Epplet_add_popup_entry (p, "Atoms", NULL, cb_cloak_anim,
(void *) (&(cloak_anims[12])));
Epplet_add_popup_entry (p, "Banner", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[13])));
Epplet_add_popup_entry (p, "SineWave", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[14])));
Epplet_add_popup_entry (p, "Random", NULL,
cb_cloak_anim, (void *) (&(cloak_anims[16])));
ctimer_p = Epplet_create_popup ();
Epplet_add_popup_entry (ctimer_p, "Cloak Delay", NULL, NULL, NULL);
Epplet_add_popup_entry (ctimer_p, "1 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[0])));
Epplet_add_popup_entry (ctimer_p, "2 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[1])));
Epplet_add_popup_entry (ctimer_p, "3 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[2])));
Epplet_add_popup_entry (ctimer_p, "4 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[3])));
Epplet_add_popup_entry (ctimer_p, "5 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[4])));
Epplet_add_popup_entry (ctimer_p, "10 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[5])));
Epplet_add_popup_entry (ctimer_p, "15 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[6])));
Epplet_add_popup_entry (ctimer_p, "20 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[7])));
Epplet_add_popup_entry (ctimer_p, "30 Sec", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[8])));
Epplet_add_popup_entry (ctimer_p, "1 min", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[9])));
Epplet_add_popup_entry (ctimer_p, "2 mins", NULL,
cb_cloak_delay, (void *) (&(cloak_delays[10])));
/* Epplet_gadget_show (btn_conf =
Epplet_create_popupbutton (NULL,
NULL, 34,
2, 12, 12, "CONFIGURE", p));
Epplet_gadget_show (btn_ctimer =
Epplet_create_popupbutton (NULL,
EROOT
"/epplet_data/E-ScreenShoot/E-ScreenShoot_minitime.png",
50, 2,
12, 12, NULL, ctimer_p));
*/
url_p = Epplet_create_popup ();
Epplet_add_popup_entry (url_p, "Url List", NULL, NULL, NULL);
Epplet_gadget_show (btn_urllist = Epplet_create_popupbutton (NULL, NULL, 16,
2, 12, 12,
"ARROW_DOWN",
url_p));
da = Epplet_create_drawingarea (2, 2, 44, 44);
win = Epplet_get_drawingarea_window (da);
buf = Epplet_make_rgb_buf (40, 40);
cloaked = 0;
set_flame_col (0);
if (opt.do_cloak)
Epplet_timer (cloak_epplet, NULL, opt.cloak_delay, "CLOAK_TIMER");
Epplet_register_mouse_enter_handler (cb_in, (void *) win);
Epplet_register_mouse_leave_handler (cb_out, NULL);
Epplet_add_popup_entry (url_p, "Url List is currently empty", NULL, NULL,
NULL);
Epplet_gadget_show (btn_urllist =
Epplet_create_popupbutton (NULL, NULL, 16, 2, 12, 12,
"ARROW_DOWN", url_p));
if (opt.check_url_file)
Epplet_timer (check_url_file, NULL, 1, "URLCHECK_TIMER");
display_string ("Welcome to E-UrlWatch ;-)");
@ -933,8 +600,6 @@ main (int argc, char **argv)
prio = getpriority (PRIO_PROCESS, getpid ());
setpriority (PRIO_PROCESS, getpid (), prio + 10);
atexit (clean_exit);
/* Initialise random numbers */
srand (time (0));
Epplet_Init ("E-UrlWatch", "0.1",
"Enlightenment Url Watcher Epplet", 6, 3, argc, argv, 0);
Epplet_load_config ();

View File

@ -1,40 +1,10 @@
#if 0
#define D(a) { \
printf("%s +%u : ",__FILE__,__LINE__); \
printf a; \
fflush(stdout); \
}
#else
#define D(a) { \
/* No debug */; \
}
#endif
Epplet_gadget btn_conf, btn_close, btn_help, btn_ctimer, btn_www, btn_ftp, btn_wget;
Epplet_gadget btn_col, lbl_url, btn_file_url, btn_urllist;
Epplet_gadget p, col_p, ctimer_p, stimer_p, url_p;
Window win;
RGB_buf buf;
Epplet_gadget da;
int cloaked = 0;
extern int load_val;
extern int colors[];
static void cb_in (void *data, Window w);
Epplet_gadget btn_conf, btn_close, btn_help, btn_www, btn_ftp, btn_wget;
Epplet_gadget lbl_url, btn_file_url, btn_urllist;
Epplet_gadget p, url_p;
char *urllist[10]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
int num_urls = 0;
int cloak_anims[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
};
int cloak_delays[] = {
1, 2, 3, 4, 5, 10, 15, 20, 30, 60, 120
};
int rand_delays[] = {
0, 30, 60, 90, 120, 180, 240, 300, 600, 900, 1200
};
struct
{
char *str;
@ -44,18 +14,11 @@ struct
struct
{
int quality;
int win;
int cloak_anim;
int do_cloak;
int rand_cloak;
int save_urls;
int check_url_file;
int do_new_url_command;
int always_show_file_urls;
double cloak_delay;
double rand_delay;
double draw_interval;
char *new_url_command;
char *url_save_file;
char *url_file;

View File

@ -116,8 +116,7 @@ E-ScreenSave.c E-ScreenSave.h cloak.c utils.c utils.h cloak.h
E_ScreenSave_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la
E_ScreenSave_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir)
E_UrlWatch_epplet_SOURCES = \
E-UrlWatch.c E-UrlWatch.h cloak.c utils.c utils.h cloak.h
E_UrlWatch_epplet_SOURCES = E-UrlWatch.c E-UrlWatch.h utils.c utils.h
E_UrlWatch_epplet_DEPENDENCIES = $(top_srcdir)/api/libepplet.la
E_UrlWatch_epplet_LDFLAGS = -rpath $(libdir):$(pkglibdir) $(X_LIBS)
E_UrlWatch_epplet_LDADD = $(top_builddir)/api/libepplet.la -L$(libdir) -L$(prefix)/lib $(LIBS) $(X_LIBS)