Enlightenment CVS committal

Author  : fletch3k
Project : misc
Module  : enotes

Dir     : misc/enotes/src


Modified Files:
        main.c main.h note.c storage.c 


Log Message:
Initial Note Template Support.

===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/main.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- main.c      7 Feb 2004 22:14:28 -0000       1.4
+++ main.c      13 Feb 2004 17:50:48 -0000      1.5
@@ -68,10 +68,31 @@
 
                /* Display the Introduction Note */
                if (main_config->intro == 1) {
-                       new_note_with_values(main_config->note->width,
-                                            main_config->note->height,
-                                            INTRO_TITLE, INTRO_CONTENT);
+                       FILE *file;
+                       char *tmpstr=malloc(MAX_TEMPLATE_SIZE);
+                       char *template_path=malloc(PATH_MAX);
+                       NoteStor *tmpn;
+                       snprintf (template_path, PATH_MAX, TEMPLATE_LOC, getenv 
("HOME"));
+                       if ((file=fopen(template_path, "r"))!=NULL) {
+                               fgets (tmpstr, MAX_TEMPLATE_SIZE, file);
+                               if ((tmpn=get_notestor_from_value (tmpstr))!=NULL)
+                                       new_note_with_values(tmpn->width, tmpn->height,
+                                                            tmpn->title, 
tmpn->content);
+                       } else {
+                               new_note_with_values(main_config->note->width,
+                                                    main_config->note->height,
+                                                    INTRO_TITLE, INTRO_CONTENT);
+                       }
+                       
                        dml("Introduction Note Created", 1);
+                       if (file!=NULL)
+                               fclose (file);
+                       if (tmpstr!=NULL)
+                               free (tmpstr);
+                       if (template_path!=NULL)
+                               free (template_path);
+                       if (tmpn!=NULL)
+                               free_note_stor (tmpn);
                }
 
                /* Begin the main loop */
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/main.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- main.h      6 Feb 2004 07:36:30 -0000       1.2
+++ main.h      13 Feb 2004 17:50:48 -0000      1.3
@@ -24,19 +24,17 @@
 #include <Edje.h>
 
 #include "config.h"
+#include "note.h"
 #include "usage.h"
 #include "debug.h"
 
 
+#define MAX_TEMPLATE_SIZE 999
+#define TEMPLATE_LOC "%s/.e/notes/defnote"
+
 #define INTRO_TITLE "Welcome to E-Notes"
-#define INTRO_CONTENT "\
-Welcome to E-Notes, by\n\
-Thomas Fletcher.\n\n\
-Please E-Mail any bugs you\n\
-encounter to:\n\
[EMAIL PROTECTED]
-ENJOY! :-)\n\
-"
+#define INTRO_CONTENT "Welcome to E-Notes\nBy Thomas Fletcher.\n\nEnjoy!!"
+
 
 /* The Main Function */
 int             main(int argc, char *argv[]);
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/note.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- note.c      7 Feb 2004 22:01:56 -0000       1.6
+++ note.c      13 Feb 2004 17:50:48 -0000      1.7
@@ -102,8 +102,8 @@
        p->dragger = (Evas_Object *) esmart_draggies_new(p->win);
        evas_object_name_set(p->dragger, "dragger");
        evas_object_move(p->dragger, 0, 0);
-       evas_object_resize(p->dragger, main_config->cc->width,
-                          main_config->cc->height);
+       evas_object_resize(p->dragger, width,
+                          height);
        evas_object_layer_set(p->dragger, 999);
        evas_object_color_set(p->dragger, 255, 255, 255, 0);
        esmart_draggies_button_set(p->dragger, 1);
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/storage.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- storage.c   6 Feb 2004 07:36:30 -0000       1.2
+++ storage.c   13 Feb 2004 17:50:48 -0000      1.3
@@ -213,9 +213,26 @@
        }
 
        p->title = strdup(strsep(&e, DEF_VALUE_SEPERATION));
+       if (&e==NULL) {
+               free_note_stor (p);
+               return (NULL);
+       }
        p->content = strdup(strsep(&e, DEF_VALUE_SEPERATION));
+       if (&e==NULL) {
+                free_note_stor (p);
+                return (NULL);
+        }
        p->width = atoi(strsep(&e, DEF_VALUE_SEPERATION));
+       if (&e==NULL) {
+                free_note_stor (p);
+                return (NULL);
+        }
+       
        p->height = atoi(strsep(&e, DEF_VALUE_SEPERATION));
+       if (&e==NULL) {
+                free_note_stor (p);
+                return (NULL);
+        }
 
        return (p);
 }




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to