Enlightenment CVS committal Author : fletch3k Project : misc Module : enotes
Dir : misc/enotes/src Modified Files: config.c config.h controlcentre.c main.c main.h note.c settings.c settings.h storage.c usage.c usage.h Log Message: A Lot of Changes, including some minor bug fixes. Mainly Configuration Based. =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/config.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- config.c 7 Feb 2004 22:14:28 -0000 1.3 +++ config.c 15 Feb 2004 15:13:34 -0000 1.4 @@ -19,12 +19,14 @@ MainConfig *p; p = malloc(sizeof(MainConfig)); - p->note = malloc(sizeof(struct _conf_note)); - p->cc = malloc(sizeof(struct _conf_cc)); p->render_method = NULL; p->theme = NULL; + p->debug = 0; + p->intro = 0; + p->controlcentre = 1; + return (p); } @@ -32,11 +34,6 @@ mainconfig_free(MainConfig * p) { if (!p) { - if (p->note != NULL) - free(p->note); - if (p->cc != NULL) - free(p->cc); - if (p->render_method != NULL) free(p->render_method); if (p->theme != NULL) @@ -98,27 +95,11 @@ free(p->theme); p->theme = strdup(info->value); } else if (!strcmp(info->name, "controlcentre")) { - p->controlcentre=atoi(info->value); + p->controlcentre = atoi(info->value); } else if (!strcmp(info->name, "intro")) { p->intro = atoi(info->value); } else if (!strcmp(info->name, "debug")) { p->debug = atoi(info->value); - } else if (!strcmp(info->name, "cc_x")) { - p->cc->x = atoi(info->value); - } else if (!strcmp(info->name, "cc_y")) { - p->cc->y = atoi(info->value); - } else if (!strcmp(info->name, "cc_w")) { - p->cc->width = atoi(info->value); - } else if (!strcmp(info->name, "cc_h")) { - p->cc->height = atoi(info->value); - } else if (!strcmp(info->name, "note_x")) { - p->note->x = atoi(info->value); - } else if (!strcmp(info->name, "note_y")) { - p->note->y = atoi(info->value); - } else if (!strcmp(info->name, "note_w")) { - p->note->width = atoi(info->value); - } else if (!strcmp(info->name, "note_h")) { - p->note->height = atoi(info->value); } return; } =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/config.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- config.h 7 Feb 2004 22:14:28 -0000 1.3 +++ config.h 15 Feb 2004 15:13:35 -0000 1.4 @@ -32,18 +32,6 @@ int controlcentre; int intro; int debug; - struct _conf_note { - int x; - int y; - int width; - int height; - } *note; - struct _conf_cc { - int x; - int y; - int width; - int height; - } *cc; } MainConfig; #ifndef XMLENTRY_DEF =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/controlcentre.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- controlcentre.c 7 Feb 2004 15:26:54 -0000 1.3 +++ controlcentre.c 15 Feb 2004 15:13:35 -0000 1.4 @@ -22,17 +22,20 @@ ControlCentre *cc = &controlcentre; char *edjefn = malloc(PATH_MAX); char *fontpath = malloc(PATH_MAX); + double edje_w, edje_h; /* Setup the Window */ - cc->win = ecore_evas_software_x11_new(NULL, 0, main_config->cc->x, - main_config->cc->y, - main_config->cc->width, - main_config->cc->height); + cc->win = ecore_evas_software_x11_new(NULL, 0, 0, 0, 250, 250); ecore_evas_title_set(cc->win, "E-Notes Control Centre"); ecore_evas_borderless_set(cc->win, 1); ecore_evas_shaped_set(cc->win, 1); ecore_evas_show(cc->win); + /* Ecore Callbacks */ + ecore_evas_callback_resize_set(cc->win, cc_resize); + ecore_evas_callback_destroy_set(cc->win, cc_close); + ecore_evas_callback_delete_request_set(cc->win, cc_close); + /* Setup the Canvas, Render-Method and Font Path */ cc->evas = ecore_evas_get(cc->win); evas_output_method_set(cc->evas, @@ -46,8 +49,7 @@ cc->dragger = esmart_draggies_new(cc->win); evas_object_name_set(cc->dragger, "dragger"); evas_object_move(cc->dragger, 0, 0); - evas_object_resize(cc->dragger, main_config->cc->width, - main_config->cc->height); + evas_object_resize(cc->dragger, 250, 250); evas_object_layer_set(cc->dragger, 999); evas_object_color_set(cc->dragger, 255, 255, 255, 0); esmart_draggies_button_set(cc->dragger, 1); @@ -60,16 +62,17 @@ edje_object_file_set(cc->edje, edjefn, CC_PART); free(edjefn); evas_object_move(cc->edje, 0, 0); - evas_object_resize(cc->edje, main_config->cc->width, - main_config->cc->height); + evas_object_resize(cc->edje, 250, 250); evas_object_name_set(cc->edje, "edje"); evas_object_pass_events_set(cc->edje, 1); evas_object_show(cc->edje); - /* Ecore Callbacks */ - ecore_evas_callback_resize_set(cc->win, cc_resize); - ecore_evas_callback_destroy_set(cc->win, cc_close); - ecore_evas_callback_delete_request_set(cc->win, cc_close); + /* EDJE and ECORE min, max and resizing */ + edje_object_size_max_get(cc->edje, &edje_w, &edje_h); + ecore_evas_size_max_set(cc->win, edje_w, edje_h); + edje_object_size_min_get(cc->edje, &edje_w, &edje_h); + ecore_evas_size_min_set(cc->win, edje_w, edje_h); + ecore_evas_resize(cc->win, (int) edje_w, (int) edje_h); /* Edje Callbacks */ edje_object_signal_callback_add(cc->edje, =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/main.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- main.c 13 Feb 2004 17:50:48 -0000 1.5 +++ main.c 15 Feb 2004 15:13:35 -0000 1.6 @@ -61,38 +61,44 @@ dml("Efl Successfully Initiated", 1); /* Begin the Control Centre */ - if (main_config->controlcentre==1) { + if (main_config->controlcentre == 1) { setup_cc(); dml("Control Centre Setup", 1); } /* Display the Introduction Note */ if (main_config->intro == 1) { - 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); + FILE *file; + char *tmpstr = malloc(MAX_TEMPLATE_SIZE); + char *template_path = malloc(PATH_MAX); + NoteStor *tmpn = NULL; + + snprintf(template_path, PATH_MAX, TEMPLATE_LOC, + getenv("HOME")); + if ((file = fopen(template_path, "r")) != NULL) { + dml("Using the supplied note template", 2); + 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("Using default note template", 2); + new_note_with_values(0, 0, 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); + 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.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- main.h 13 Feb 2004 17:50:48 -0000 1.3 +++ main.h 15 Feb 2004 15:13:35 -0000 1.4 @@ -33,8 +33,7 @@ #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\nEnjoy!!" - +#define INTRO_CONTENT "Welcome to E-Notes\nBy Thomas Fletcher.\n\nReport bugs to:[EMAIL PROTECTED]" /* The Main Function */ int main(int argc, char *argv[]); =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/note.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- note.c 13 Feb 2004 17:50:48 -0000 1.7 +++ note.c 15 Feb 2004 15:13:35 -0000 1.8 @@ -26,8 +26,7 @@ dml("Creating a Note", 2); new = append_note(); - setup_note(&new, main_config->note->width, - main_config->note->height, DEF_TITLE, DEF_CONTENT); + setup_note(&new, 0, 0, DEF_TITLE, DEF_CONTENT); return; } @@ -77,14 +76,14 @@ char *edjefn = malloc(PATH_MAX); char *datestr; + double edje_w, edje_h; + /* Get the Note from the Evas_List** */ pl = *note; p = evas_list_data(pl); /* Setup the Window */ - p->win = ecore_evas_software_x11_new(NULL, 0, main_config->note->x, - main_config->note->y, width, - height); + p->win = ecore_evas_software_x11_new(NULL, 0, 0, 0, width, height); ecore_evas_title_set(p->win, "An E-Note"); ecore_evas_borderless_set(p->win, 1); ecore_evas_shaped_set(p->win, 1); @@ -102,8 +101,7 @@ 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, width, - 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); @@ -116,8 +114,21 @@ edje_object_file_set(p->edje, edjefn, NOTE_PART); evas_object_name_set(p->edje, "edje"); evas_object_move(p->edje, 0, 0); - evas_object_resize(p->edje, width, height); evas_object_layer_set(p->edje, 0); + + edje_object_size_max_get(p->edje, &edje_w, &edje_h); + ecore_evas_size_max_set(p->win, edje_w, edje_h); + edje_object_size_min_get(p->edje, &edje_w, &edje_h); + ecore_evas_size_min_set(p->win, edje_w, edje_h); + + if (width == 0 && height == 0) { + ecore_evas_resize(p->win, (int) edje_w, (int) edje_h); + evas_object_resize(p->edje, (int) edje_w, (int) edje_h); + } else { + ecore_evas_resize(p->win, width, height); + evas_object_resize(p->edje, width, height); + } + evas_object_show(p->edje); /* Setup the date and user */ =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/settings.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- settings.c 7 Feb 2004 22:14:28 -0000 1.3 +++ settings.c 15 Feb 2004 15:13:35 -0000 1.4 @@ -120,34 +120,10 @@ setup_settings_opt_int(settings->tree, "Intro:", main_config->intro); - settings->note_x = - setup_settings_opt_int(settings->tree, "Note - X:", - main_config->note->x); - settings->note_y = - setup_settings_opt_int(settings->tree, "Note - Y:", - main_config->note->y); - settings->note_w = - setup_settings_opt_int(settings->tree, "Note - Width:", - main_config->note->width); - settings->note_h = - setup_settings_opt_int(settings->tree, "Note - Height:", - main_config->note->height); - - settings->cc = setup_settings_opt_int (settings->tree, "Control Centre [0=No 1=Yes]:", main_config->controlcentre); - settings->cc_x = - setup_settings_opt_int(settings->tree, "Control Centre - X:", - main_config->cc->x); - settings->cc_y = - setup_settings_opt_int(settings->tree, "Control Centre - Y:", - main_config->cc->y); - settings->cc_w = + settings->cc = setup_settings_opt_int(settings->tree, - "Control Centre - Width:", - main_config->cc->width); - settings->cc_h = - setup_settings_opt_int(settings->tree, - "Control Centre - Height:", - main_config->cc->height); + "Control Centre [0=No 1=Yes]:", + main_config->controlcentre); settings->debug = setup_settings_opt_int(settings->tree, "Debugging Level [0-2]:", main_config->debug); @@ -270,30 +246,6 @@ xml_write_append_entry(p, "intro", ewl_entry_get_text((Ewl_Entry *) settings->intro. entry)); - xml_write_append_entry(p, "cc_x", - ewl_entry_get_text((Ewl_Entry *) settings->cc_x. - entry)); - xml_write_append_entry(p, "cc_y", - ewl_entry_get_text((Ewl_Entry *) settings->cc_y. - entry)); - xml_write_append_entry(p, "cc_w", - ewl_entry_get_text((Ewl_Entry *) settings->cc_w. - entry)); - xml_write_append_entry(p, "cc_h", - ewl_entry_get_text((Ewl_Entry *) settings->cc_h. - entry)); - xml_write_append_entry(p, "note_x", - ewl_entry_get_text((Ewl_Entry *) settings-> - note_x.entry)); - xml_write_append_entry(p, "note_y", - ewl_entry_get_text((Ewl_Entry *) settings-> - note_y.entry)); - xml_write_append_entry(p, "note_w", - ewl_entry_get_text((Ewl_Entry *) settings-> - note_w.entry)); - xml_write_append_entry(p, "note_h", - ewl_entry_get_text((Ewl_Entry *) settings-> - note_h.entry)); xml_write_append_entry(p, "debug", ewl_entry_get_text((Ewl_Entry *) settings->debug. entry)); =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/settings.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- settings.h 7 Feb 2004 22:14:28 -0000 1.3 +++ settings.h 15 Feb 2004 15:13:35 -0000 1.4 @@ -47,8 +47,7 @@ Ewl_Widget *savebtn; Ewl_Widget *revertbtn; Ewl_Widget *closebtn; - Settings_Opt render_method, theme, intro, note_x, note_y, note_w, - note_h, cc_x, cc_y, cc_w, cc_h, debug, cc; + Settings_Opt render_method, theme, intro, debug, cc; } Settings; extern MainConfig *main_config; =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/storage.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- storage.c 13 Feb 2004 17:50:48 -0000 1.3 +++ storage.c 15 Feb 2004 15:13:35 -0000 1.4 @@ -17,14 +17,27 @@ void free_note_stor(NoteStor * p) { - if (p->title != NULL) - free(p->title); - if (p->content != NULL) - free(p->content); - free(p); + if (p != NULL) { + if (p->title != NULL) + free(p->title); + if (p->content != NULL) + free(p->content); + free(p); + p = NULL; + } return; } +NoteStor * +alloc_note_stor() +{ + NoteStor *p = malloc(sizeof(NoteStor)); + + p->title = NULL; + p->content = NULL; + return (p); +} + /* One Shot Functions. :-) */ void append_note_stor(NoteStor * p) @@ -205,7 +218,7 @@ NoteStor * get_notestor_from_value(char *e) { - NoteStor *p = malloc(sizeof(NoteStor)); + NoteStor *p = alloc_note_stor(); if (e == NULL) { free(p); @@ -213,26 +226,26 @@ } p->title = strdup(strsep(&e, DEF_VALUE_SEPERATION)); - if (&e==NULL) { - free_note_stor (p); + 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); - } + 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); - } - + 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); - } + if (&e == NULL) { + free_note_stor(p); + return (NULL); + } return (p); } @@ -245,5 +258,6 @@ 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); + return (retval); } =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/usage.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- usage.c 7 Feb 2004 22:14:28 -0000 1.4 +++ usage.c 15 Feb 2004 15:13:35 -0000 1.5 @@ -66,35 +66,11 @@ main_config->theme = strdup(optarg); break; case 'C': - main_config->controlcentre = atoi (optarg); + main_config->controlcentre = atoi(optarg); break; case 'i': main_config->intro = atoi(optarg); break; - case 'X': - main_config->cc->x = atoi(optarg); - break; - case 'Y': - main_config->cc->y = atoi(optarg); - break; - case 'W': - main_config->cc->width = atoi(optarg); - break; - case 'H': - main_config->cc->height = atoi(optarg); - break; - case 'x': - main_config->note->x = atoi(optarg); - break; - case 'y': - main_config->note->y = atoi(optarg); - break; - case 'w': - main_config->note->width = atoi(optarg); - break; - case 'h': - main_config->note->height = atoi(optarg); - break; case 'v': printf(USAGE_VERSION, VERSION); dispusage = 1; =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/usage.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- usage.h 7 Feb 2004 22:14:28 -0000 1.3 +++ usage.h 15 Feb 2004 15:13:35 -0000 1.4 @@ -44,22 +44,12 @@ -C --control-centre INT Enable/Disable the Control\n\ Centre.\n\ -i --intro INT Display the Intro.\n\ -\n\ --X --cc-x INT Control Centre X Positioning.\n\ --Y --cc-y INT Control Centre Y Positioning.\n\ --W --cc-w INT Control Centre Width.\n\ --H --cc-h INT Control Centre Height.\n\ -\n\ --x --note-x INT Note X Positioning.\n\ --y --note-y INT Note Y Positioning.\n\ --w --note-w INT Note Width.\n\ --h --note-h INT Note Height.\n\ \ \n" #define USAGE_VERSION "E-Notes Version:\n%s\n" -#define OPTSTR "v?hc:r:t:i:X:Y:H:W:x:y:w:h:R:d:" +#define OPTSTR "v?hc:r:t:i:R:d:" static struct option long_options[] = { {"help", 0, 0, '?'}, @@ -71,14 +61,6 @@ {"control-centre", 1, 0, 'C'}, {"intro", 1, 0, 'i'}, {"debug", 1, 0, 'd'}, - {"cc-x", 1, 0, 'X'}, - {"cc-y", 1, 0, 'Y'}, - {"cc-w", 1, 0, 'W'}, - {"cc-h", 1, 0, 'H'}, - {"note-x", 1, 0, 'x'}, - {"note-y", 1, 0, 'y'}, - {"note-w", 1, 0, 'w'}, - {"note-h", 1, 0, 'h'}, {NULL, 0, 0, 0} }; ------------------------------------------------------- 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