Enlightenment CVS committal

Author  : fletch3k
Project : misc
Module  : enotes

Dir     : misc/enotes/src


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


Log Message:
Title is gone, x and y added.  Bugs may exist.

===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/ipc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ipc.c       26 Aug 2004 20:50:24 -0000      1.6
+++ ipc.c       9 Sep 2004 10:38:15 -0000       1.7
@@ -114,9 +114,8 @@
                                                                        p->
                                                                        data);
                                        content = fix_newlines(note->content);
-                                       new_note_with_values(note->width,
+                                       
new_note_with_values(note->x,note->y,note->width,
                                                             note->height,
-                                                            note->title,
                                                             content);
                                        free(content);
                                        free_note_stor(note);
@@ -129,16 +128,14 @@
                                        free(controlcentre);
                                        controlcentre = NULL;
                                } else {
-                                       new_note_with_values(325, 0,
-                                                            "No Control Centre to 
Close",
+                                       new_note_with_values(0,0,325, 0,
                                                             "An IPC command was 
recieved which\nwants to close the controlcentre.\n\nSince the control centre isn't 
currently\nopen, it wasn't possible to do so!");
                                }
                        } else if (p->cmd == CONTROLCENTREOPEN) {
                                if (controlcentre == NULL) {
                                        setup_cc();
                                } else {
-                                       new_note_with_values(325, 0,
-                                                            "Control Centre Already 
Open",
+                                       new_note_with_values(0,0,325, 0,
                                                             "An IPC command was 
recieved which\nwants to open the control centre, but the\ncontrol centre is already 
open!");
                                }
                        }
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/main.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- main.c      8 Sep 2004 10:54:02 -0000       1.11
+++ main.c      9 Sep 2004 10:38:15 -0000       1.12
@@ -96,14 +96,13 @@
                                fgets(tmpstr, MAX_TEMPLATE_SIZE, file);
                                if ((tmpn =
                                     get_notestor_from_value(tmpstr)) != NULL)
-                                       new_note_with_values(tmpn->width,
+                                       new_note_with_values(tmpn->x,
+                                                            tmpn->y,tmpn->width,
                                                             tmpn->height,
-                                                            tmpn->title,
                                                             tmpn->content);
                        } else {
                                dml("Using default note template", 2);
-                               new_note_with_values(0, 0, INTRO_TITLE,
-                                                    INTRO_CONTENT);
+                               new_note_with_values(0,0,0, 0, INTRO_CONTENT);
                        }
 
                        dml("Introduction Note Created", 1);
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/main.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- main.h      26 Aug 2004 20:50:24 -0000      1.6
+++ main.h      9 Sep 2004 10:38:15 -0000       1.7
@@ -34,7 +34,6 @@
 #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\nBy Thomas Fletcher.\n\nReport bugs 
to:[EMAIL PROTECTED]"
 
 /* The Main Function */
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/note.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- note.c      5 Sep 2004 15:06:56 -0000       1.21
+++ note.c      9 Sep 2004 10:38:15 -0000       1.22
@@ -30,7 +30,7 @@
        dml("Creating a Note", 2);
 
        new = append_note();
-       setup_note(&new, 0, 0, DEF_TITLE, DEF_CONTENT);
+       setup_note(&new, 0,0,0, 0, DEF_CONTENT);
        return;
 }
 
@@ -42,14 +42,14 @@
  * @brief: Opens a new note.
  */
 void
-new_note_with_values(int width, int height, char *title, char *content)
+new_note_with_values(int x,int y,int width, int height, char *content)
 {
        Evas_List      *new;
 
        dml("Creating a Note", 2);
 
        new = append_note();
-       setup_note(&new, width, height, title, content);
+       setup_note(&new, x,y,width, height, content);
        return;
 }
 
@@ -122,7 +122,7 @@
  * @brief: Sets up the note objects, window, callbacks, etc...
  */
 void
-setup_note(Evas_List ** note, int width, int height, char *title, char *content)
+setup_note(Evas_List ** note, int x,int y,int width, int height, char *content)
 {
        Evas_List      *pl;
        Note           *p;
@@ -141,14 +141,18 @@
        pl = *note;
        p = evas_list_data(pl);
 
+
        /* Setup the Window */
-       p->win = ecore_evas_software_x11_new(NULL, 0, 0, 0, width, height);
+       p->win = ecore_evas_software_x11_new(NULL, 0, x, y, width, height);
        ecore_evas_title_set(p->win, "An E-Note");
        ecore_evas_name_class_set(p->win, "Enotes", "Enotes");
        ecore_evas_borderless_set(p->win, 1);
        ecore_evas_shaped_set(p->win, 1);
        ecore_evas_show(p->win);
 
+       /* Move the damn window  */
+       ecore_x_window_prop_xy_set(ecore_evas_software_x11_window_get(p->win), x, y);
+
        /* Setup the Canvas, fonts, etc... */
        p->evas = ecore_evas_get(p->win);
        evas_output_method_set(p->evas,
@@ -205,28 +209,13 @@
                                   ecore_evas_software_x11_window_get(p->win));
        evas_object_layer_set(p->eo, 2);
        edje_object_part_swallow(p->edje, EDJE_EWL_CONTAINER, p->eo);
-
        evas_object_show(p->eo);
 
-
        evas_object_focus_set(p->eo, TRUE);
        ewl_embed_focus_set((Ewl_Embed *) p->emb, TRUE);
 
-
-       p->vbox = ewl_vbox_new();
-       ewl_object_fill_policy_set((Ewl_Object *) p->vbox, EWL_FLAG_FILL_FILL);
-       ewl_container_child_append((Ewl_Container *) p->emb, p->vbox);
-       ewl_widget_show(p->vbox);
-
-       ewl_callback_append(p->emb, EWL_CALLBACK_CONFIGURE, note_move_embed,
-                           p->vbox);
-
-       p->title = ewl_entry_new(title);
-       ewl_container_child_append((Ewl_Container *) p->vbox, p->title);
-       ewl_widget_show(p->title);
-
        p->content = ewl_text_new(fcontent);
-       ewl_container_child_append((Ewl_Container *) p->vbox, p->content);
+       ewl_container_child_append((Ewl_Container *) p->emb, p->content);
        ewl_widget_show(p->content);
 
        /* Ecore Callbacks */
@@ -397,23 +386,27 @@
 timer_val_compare(void *data)
 {
        Note           *p = (Note *) data;
+       char *tmp;
 
        if (p->timcomp == NULL)
                return (0);
 
        if (p->txt_title != NULL) {
+               tmp=get_title_by_note_struct(p);
                if (strcmp
-                   (p->txt_title,
-                    ewl_entry_text_get((Ewl_Entry *) p->title))) {
+                   (p->txt_title,tmp)) {
                        if (saveload != NULL)
                                ewl_saveload_revert(NULL, NULL, saveload->tree);
 
-                       free(p->txt_title);
+                       if (p->txt_title!=NULL)
+                               free(p->txt_title);
                        p->txt_title =
-                               ewl_entry_text_get((Ewl_Entry *) p->title);
+                               get_title_by_note_struct(p);
                }
+               if(tmp!=NULL)
+                       free(tmp);
        } else {
-               p->txt_title = ewl_entry_text_get((Ewl_Entry *) p->title);
+               p->txt_title = get_title_by_note_struct(p);
        }
        return (1);
 }
@@ -473,9 +466,18 @@
 char           *
 get_title_by_note(Evas_List * note)
 {
-       Note           *p = evas_list_data(note);
+       return (get_title_by_content(get_content_by_note(note)));
+}
 
-       return (ewl_entry_text_get((Ewl_Entry *) p->title));
+/**
+ * @param note: The note to grab the title from (actual).
+ * @return: Returns the title of the supplied note.
+ * @brief: Returns the title text of the supplied note.
+ */
+char           *
+get_title_by_note_struct(Note * note)
+{
+       return (get_title_by_content(get_content_by_note_struct(note)));
 }
 
 /**
@@ -491,6 +493,45 @@
        return ((char *) ewl_text_text_get((Ewl_Text *) p->content));
 }
 
+/**
+ * @param note: The note to grab the content from (actual).
+ * @return: Returns the content of the supplied note.
+ * @brief: Returns the content text of the supplied note.
+ */
+char           *
+get_content_by_note_struct(Note * note)
+{
+       return ((char *) ewl_text_text_get((Ewl_Text *) note->content));
+}
+
+/**
+ * @param content: The content of the note.
+ * @return: The title from the content.
+ * @brief: Takes TITLE_LENGTH worth of characters
+ *         from the front (or newline).
+ */
+char*                   
+get_title_by_content(char *content)
+{
+        char *cont=content;
+        int a=0;        
+        int newlength=0;        
+
+        if (strlen(content)>TITLE_LENGTH)
+                while (a<TITLE_LENGTH&&cont!=NULL){
+                        if (!strncmp(cont,"\n",1)){
+                                newlength=a;
+                                break;
+                        }
+                        a++;
+                        cont++;
+                } a=0;
+
+        if (newlength==0)
+                newlength=TITLE_LENGTH;
+        
+        return((char*)strndup(content,newlength));
+}
 
 /**
  * @return: Returns the beginning node of the note list cycle.
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/note.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- note.h      5 May 2004 18:59:26 -0000       1.6
+++ note.h      9 Sep 2004 10:38:15 -0000       1.7
@@ -34,8 +34,8 @@
 #define EDJE_EWL_CONTAINER "EnotesContainer"
 
 #define COMPARE_INTERVAL 0.01
+#define TITLE_LENGTH 20
 
-#define DEF_TITLE "New Note"
 #define DEF_CONTENT "Edit me. :-)\nYou know you want to!"
 
 typedef struct _note Note;
@@ -48,8 +48,6 @@
 
        Evas_Object    *eo;
        Ewl_Widget     *emb;
-       Ewl_Widget     *vbox;
-       Ewl_Widget     *title;
        Ewl_Widget     *content;
 
        Ewl_Row        *saveload_row;
@@ -63,16 +61,15 @@
 
 /* High Level */
 void            new_note(void);
-void            new_note_with_values(int width, int height, char *title,
-                                    char *content);
+void            new_note_with_values(int x, int y, int width, int height, char 
*content);
 
 /* Lists and Allocation */
 Evas_List      *append_note(void);
 void            remove_note(Evas_List * note);
 
 /* GUI Setup */
-void            setup_note(Evas_List ** note, int width, int height,
-                          char *title, char *content);
+void            setup_note(Evas_List ** note, int x,int y,int width, int height,
+                          char *content);
 
 /* Ecore Callbacks */
 void            note_ecore_close(Ecore_Evas * ee);
@@ -96,7 +93,10 @@
 Evas_List      *get_note_by_content(char *content);
 
 char           *get_title_by_note(Evas_List * note);
+char           *get_title_by_note_struct (Note *note);
 char           *get_content_by_note(Evas_List * note);
+char           *get_content_by_note_struct (Note *note);
+char           *get_title_by_content(char *content);
 
 Evas_List      *get_cycle_begin(void);
 Evas_List      *get_cycle_next_note(Evas_List * note);
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/saveload.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- saveload.c  28 Aug 2004 13:09:08 -0000      1.14
+++ saveload.c  9 Sep 2004 10:38:15 -0000       1.15
@@ -284,7 +284,8 @@
        ecore_evas_geometry_get(note->win, &x, &y, &w, &h);
        n->width = w;
        n->height = h;
-       n->title = strdup(get_title_by_note(p));
+       n->x=x;
+       n->y=y;
        n->content = strdup(get_content_by_note(p));
 
        append_note_stor(n);
@@ -405,7 +406,7 @@
        if (r != NULL) {
                while (r->cur != NULL) {
                        p = stor_cycle_get_notestor(r);
-                       setup_load_opt(load->tree, p->title);
+                       setup_load_opt(load->tree, get_title_by_content(p->content));
                        free_note_stor(p);
                        stor_cycle_next(r);
                }
@@ -480,6 +481,7 @@
 {
        NoteStor       *p;
        XmlReadHandle  *r;
+       char *tmp;
 
        dml("Loading Saved Note", 2);
 
@@ -488,9 +490,11 @@
        if (r != NULL) {
                while (r->cur != NULL) {
                        p = stor_cycle_get_notestor(r);
-                       if (!strcmp(p->title, load_selected))
-                               new_note_with_values(p->width, p->height,
-                                                    p->title, p->content);
+                       tmp=get_title_by_content(p->content);
+                       if (!strcmp(tmp, load_selected))
+                               new_note_with_values(p->x,p->y,p->width, p->height,
+                                                    p->content);
+                       if(tmp!=NULL) free(tmp);
                        free_note_stor(p);
                        stor_cycle_next(r);
                }
@@ -529,6 +533,7 @@
 {
        NoteStor       *p;
        XmlReadHandle  *r;
+       char *tmp=NULL;
 
        dml("Deleting Saved Note", 2);
 
@@ -536,9 +541,12 @@
        if (r != NULL) {
                while (r->cur != NULL) {
                        p = stor_cycle_get_notestor(r);
-                       if (!strcmp(p->title, load_selected)) {
+                       tmp=get_title_by_content(p->content);
+                       if (!strcmp(tmp, load_selected)){
+                               if(tmp!=NULL)free(tmp);
                                break;
                        }
+                       if(tmp!=NULL)free(tmp);
                        free_note_stor(p);
                        stor_cycle_next(r);
                }
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/storage.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- storage.c   8 Sep 2004 10:54:02 -0000       1.7
+++ storage.c   9 Sep 2004 10:38:15 -0000       1.8
@@ -23,8 +23,6 @@
 free_note_stor(NoteStor * p)
 {
        if (p != NULL) {
-               if (p->title != NULL)
-                       free(p->title);
                if (p->content != NULL)
                        free(p->content);
                free(p);
@@ -42,7 +40,6 @@
 {
        NoteStor       *p = malloc(sizeof(NoteStor));
 
-       p->title = NULL;
        p->content = NULL;
        return (p);
 }
@@ -203,7 +200,7 @@
                        tmpstr = strdup(e->value);
                        tmp = get_notestor_from_value(tmpstr);
                        free(tmpstr);
-                       if (strcmp(p->title, tmp->title)) {
+                       if (strcmp(p->content, tmp->content)) {
                                list = evas_list_append(list, strdup(e->value));
                        }
                        free_note_stor(tmp);
@@ -343,8 +340,7 @@
        if (r != NULL) {
                while (r->cur != NULL) {
                        p = stor_cycle_get_notestor(r);
-                       new_note_with_values(p->width, p->height, p->title,
-                                            p->content);
+                       new_note_with_values(p->x,p->y,p->width, p->height, 
p->content);
                        free_note_stor(p);
                        stor_cycle_next(r);
                }
@@ -379,7 +375,8 @@
                n = alloc_note_stor();
                n->width = w;
                n->height = h;
-               n->title = strdup(get_title_by_note(tmp));
+               n->x=x;
+               n->y=y;
                n->content = strdup(get_content_by_note(tmp));
                append_autosave_note_stor(n);
                free_note_stor(n);
@@ -434,23 +431,30 @@
                return (NULL);
        }
 
-       p->title = strdup(strsep(&e, DEF_VALUE_SEPERATION));
+       p->content = strdup(strsep(&e, DEF_VALUE_SEPERATION));
        if (&e == NULL) {
                free_note_stor(p);
                return (NULL);
        }
-       p->content = strdup(strsep(&e, DEF_VALUE_SEPERATION));
+       p->width = atoi(strsep(&e, DEF_VALUE_SEPERATION));
        if (&e == NULL) {
                free_note_stor(p);
                return (NULL);
        }
-       p->width = atoi(strsep(&e, DEF_VALUE_SEPERATION));
+
+       p->height = atoi(strsep(&e, DEF_VALUE_SEPERATION));
        if (&e == NULL) {
                free_note_stor(p);
                return (NULL);
        }
 
-       p->height = atoi(strsep(&e, DEF_VALUE_SEPERATION));
+       p->x = atoi(strsep(&e, DEF_VALUE_SEPERATION));
+       if (&e == NULL) {
+               free_note_stor(p);
+               return (NULL);
+       }
+
+       p->y = atoi(strsep(&e, DEF_VALUE_SEPERATION));
        if (&e == NULL) {
                free_note_stor(p);
                return (NULL);
@@ -470,9 +474,8 @@
 {
        char           *retval = malloc(MAX_VALUE);
 
-       snprintf(retval, MAX_VALUE, "%s%s%s%s%d%s%d", p->title,
-                DEF_VALUE_SEPERATION, p->content, DEF_VALUE_SEPERATION,
-                p->width, DEF_VALUE_SEPERATION, p->height);
+       snprintf(retval, MAX_VALUE, "%s%s%d%s%d%s%d%s%d", p->content, 
DEF_VALUE_SEPERATION,
+                p->width, DEF_VALUE_SEPERATION, 
p->height,DEF_VALUE_SEPERATION,p->x,DEF_VALUE_SEPERATION,p->y);
 
        return (retval);
 }
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/storage.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- storage.h   17 Feb 2004 12:07:29 -0000      1.3
+++ storage.h   9 Sep 2004 10:38:15 -0000       1.4
@@ -31,8 +31,9 @@
 #define MAX_VALUE 2000
 
 typedef struct {
-       char           *title;
        char           *content;
+       int             x;
+       int             y;
        int             width;
        int             height;
 } NoteStor;




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to