Enlightenment CVS committal
Author : sarajervi
Project : misc
Module : erss
Dir : misc/erss/src
Modified Files:
erss.c parse.c parse.h
Log Message:
Added another argument - now possible to specify what theme to use.
Another new feature is the rc file.
===================================================================
RCS file: /cvsroot/enlightenment/misc/erss/src/erss.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- erss.c 25 Dec 2003 20:19:02 -0000 1.4
+++ erss.c 25 Dec 2003 22:06:27 -0000 1.5
@@ -399,8 +399,18 @@
int height;
int width;
int c = 0;
+
+ int got_config_file = FALSE;
+ int got_theme_file = FALSE;
+ int got_rc_file = FALSE;
+ char config_file[PATH_MAX];
+ char theme_file[PATH_MAX];
+
+ struct stat statbuf;
+
+ cfg = NULL;
- while((c = getopt (argc, argv, "cvhl")) != -1)
+ while ((c = getopt (argc, argv, "cvhlt")) != -1)
{
switch (c) {
case 'l':
@@ -413,8 +423,12 @@
fprintf (stderr, "Try `%s -h` for more
information\n", PACKAGE);
exit (-1);
}
- parse_config_file ((char *) argv[optind]);
-
+ got_config_file = TRUE;
+ snprintf (config_file, PATH_MAX, "%s", (char *)
argv[optind]);
+ break;
+ case 't':
+ got_theme_file = TRUE;
+ snprintf (theme_file, PATH_MAX, "%s", (char *)
argv[optind]);
break;
case 'v':
printf ("%s %s\n", PACKAGE, VERSION);
@@ -422,27 +436,48 @@
case 'h':
printf ("Usage: %s [OPTION] ...\n\n", PACKAGE);
- printf (" -c CONFIG \t specify a config file\n");
- printf (" -l \t list avaliable config
files\n");
+ printf (" -c CONFIG \t specify a config file
(required)\n");
+ printf (" -l \t list avaliable config
files\n\n");
+ printf (" -t THEME \t specify an edje theme file
(.eet)\n");
+ printf (" \t else the default will be
used.\n\n");
printf (" -h \t display this help and exit\n");
printf (" -v \t display %s version\n\n",
PACKAGE);
exit (-1);
default:
- fprintf (stderr, "\nUsage: %s [OPTION] ...\n",
PACKAGE);
- fprintf (stderr, "Try `%s -h` for more information\n",
PACKAGE);
- exit (-1);
break;
}
}
- if(optind >= argc) {
- fprintf (stderr, "Usage: %s [OPTION] ...\n", PACKAGE);
- fprintf (stderr, "Try `%s -h` for more information\n", PACKAGE);
+ if (parse_rc_file ())
+ got_rc_file = TRUE;
+
+ if(!got_config_file) {
+ if (!got_rc_file) {
+ fprintf (stderr, "Usage: %s [OPTION] ...\n", PACKAGE);
+ fprintf (stderr, "Try `%s -h` for more information\n",
PACKAGE);
+ exit (-1);
+ } else {
+ parse_config_file (rc->config);
+ }
+ } else {
+ parse_config_file (config_file);
+ }
+
+ if (!got_theme_file)
+ if (!got_rc_file)
+ cfg->theme = strdup (PACKAGE_DATA_DIR"/default.eet");
+ else
+ cfg->theme = strdup (rc->theme);
+ else
+ cfg->theme = strdup (theme_file);
+
+ stat (cfg->theme, &statbuf);
+ if (!S_ISREG(statbuf.st_mode)) {
+ printf ("Erss error: themefile '%s' does not exist!\n");
exit (-1);
}
-
if (!cfg->hostname) {
fprintf (stderr, "Erss error: No hostname defined!\n");
exit (-1);
@@ -555,7 +590,7 @@
if (cfg->header) {
header = edje_object_add (evas);
- edje_object_file_set (header, PACKAGE_DATA_DIR"/default.eet", "erss");
+ edje_object_file_set (header, cfg->theme, "erss");
edje_object_part_text_set (header, "header", cfg->header);
evas_object_show (header);
@@ -564,7 +599,7 @@
if (cfg->clock) {
tid = edje_object_add (evas);
- edje_object_file_set (tid, PACKAGE_DATA_DIR"/default.eet",
"erss_clock");
+ edje_object_file_set (tid, cfg->theme, "erss_clock");
edje_object_part_text_set (tid, "clock", "");
evas_object_show (tid);
===================================================================
RCS file: /cvsroot/enlightenment/misc/erss/src/parse.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- parse.c 25 Dec 2003 20:16:06 -0000 1.3
+++ parse.c 25 Dec 2003 22:06:27 -0000 1.4
@@ -4,6 +4,7 @@
Ewd_List *list = NULL;
Article *item = NULL;
Config *cfg = NULL;
+Rc_Config *rc = NULL;
char *get_element (char **buffer, char *type)
@@ -180,7 +181,7 @@
item->obj = edje_object_add (evas);
edje_object_file_set (item->obj,
- PACKAGE_DATA_DIR"/default.eet", "erss_item");
+ cfg->theme, "erss_item");
if (text)
edje_object_part_text_set (item->obj, "article", text);
@@ -254,6 +255,50 @@
buf = realloc (buf, strlen (buf) ? strlen (buf) : 1);
return buf;
+}
+
+int parse_rc_file ()
+{
+ FILE *fp;
+ char *line;
+ char *c;
+ char file[PATH_MAX];
+
+ snprintf (file, PATH_MAX, "%s/.erssrc", getenv ("HOME"));
+
+ fp = fopen (file, "r");
+ if (!fp)
+ return FALSE;
+
+ rc = malloc (sizeof (Rc_Config));
+
+ while ((line = get_next_line (fp)) != NULL)
+ {
+ if ((c = get_element (&line, "config")) != NULL)
+ {
+ rc->config = strdup (c);
+ continue;
+ }
+
+ if ((c = get_element (&line, "theme")) != NULL)
+ {
+ rc->theme = strdup (c);
+ continue;
+ }
+
+ }
+
+ free (line);
+ fclose (fp);
+
+ if (rc->theme && rc->config)
+ return TRUE;
+ else {
+ fprintf (stderr,
+ "Erss error: you are missing something in your rc
file!\n\n");
+ }
+
+ return FALSE;
}
void parse_config_file (char *file)
===================================================================
RCS file: /cvsroot/enlightenment/misc/erss/src/parse.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- parse.h 22 Dec 2003 21:00:05 -0000 1.2
+++ parse.h 25 Dec 2003 22:06:27 -0000 1.3
@@ -28,11 +28,21 @@
int proxy_port;
char *browser;
char *prefix;
+
+ char *theme;
+ char *config;
} Config;
+typedef struct _rc_config {
+ char *config;
+ char *theme;
+} Rc_Config;
+
+int parse_rc_file ();
void parse_data (char *buf);
void parse_config_file (char *file);
extern int objects_placed;
extern Config *cfg;
extern Article *item;
+extern Rc_Config *rc;
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs