Enlightenment CVS committal
Author : fletch3k
Project : misc
Module : enotes
Dir : misc/enotes/src
Modified Files:
controlcentre.c controlcentre.h ipc.c main.c note.c note.h
saveload.c storage.c xml.c xml.h
Log Message:
Indentation, Minimize on Controlcentre and Controlcentre position/size saving.
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/controlcentre.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- controlcentre.c 26 Aug 2004 20:50:24 -0000 1.11
+++ controlcentre.c 9 Sep 2004 11:57:30 -0000 1.12
@@ -26,18 +26,29 @@
char *edjefn = malloc(PATH_MAX);
char *fontpath = malloc(PATH_MAX);
Evas_Coord edje_w, edje_h;
+ CCPos *pos;
cc = malloc(sizeof(ControlCentre));
controlcentre = cc;
+ pos = get_cc_pos();
+
/* Setup the Window */
- cc->win = ecore_evas_software_x11_new(NULL, 0, 0, 0, 250, 250);
+ cc->win =
+ ecore_evas_software_x11_new(NULL, 0, pos->x, pos->y, pos->width,
+ pos->height);
ecore_evas_title_set(cc->win, "Enotes");
ecore_evas_name_class_set(cc->win, "Enotes", "Enotes");
ecore_evas_borderless_set(cc->win, 1);
ecore_evas_shaped_set(cc->win, 1);
+ if (pos->x != 0 && pos->y != 0)
+ ecore_evas_resize(cc->win, pos->x, pos->y);
ecore_evas_show(cc->win);
+ /* Moving the damn thing */
+ ecore_x_window_prop_xy_set(ecore_evas_software_x11_window_get(cc->win),
+ pos->x, pos->y);
+
/* Setup the Canvas, Render-Method and Font Path */
cc->evas = ecore_evas_get(cc->win);
evas_output_method_set(cc->evas,
@@ -84,17 +95,111 @@
/* Edje Callbacks */
edje_object_signal_callback_add(cc->edje,
- EDJE_SIGNAL_CC_CLOSE, "",
+ EDJE_SIGNAL_CC_MINIMIZE, "",
+ (void *) cc_minimize, cc->win);
+ edje_object_signal_callback_add(cc->edje, EDJE_SIGNAL_CC_CLOSE, "",
(void *) cc_close, NULL);
- edje_object_signal_callback_add(cc->edje,
- EDJE_SIGNAL_CC_SAVELOAD, "",
+ edje_object_signal_callback_add(cc->edje, EDJE_SIGNAL_CC_SAVELOAD, "",
(void *) cc_saveload, NULL);
- edje_object_signal_callback_add(cc->edje,
- EDJE_SIGNAL_CC_SETTINGS, "",
+ edje_object_signal_callback_add(cc->edje, EDJE_SIGNAL_CC_SETTINGS, "",
(void *) cc_settings, NULL);
edje_object_signal_callback_add(cc->edje, EDJE_SIGNAL_CC_NEW, "",
(void *) cc_newnote, NULL);
+ free(pos);
+ return;
+}
+
+CCPos *
+get_cc_pos()
+{
+ CCPos *p = malloc(sizeof(CCPos));
+ char *locfn = malloc(PATH_MAX);
+ XmlReadHandle *h;
+ XmlEntry *tmp;
+ FILE *fp;
+
+ p->x = -50;
+ p->y = -50;
+ p->width = -50;
+ p->height = -50;
+
+ snprintf(locfn, PATH_MAX, DEF_CC_CONFIG_LOC, getenv("HOME"));
+
+ fp = fopen(locfn, "r");
+ if (fp == NULL) {
+ free(locfn);
+ p->x = 0;
+ p->y = 0;
+ p->width = 250;
+ p->height = 250;
+ return (p);
+ } else {
+ fclose(fp);
+ }
+
+ h = xml_read(locfn);
+ while (h->cur != NULL) {
+ tmp = xml_read_entry_get_entry(h);
+ if (!strcmp(tmp->name, "x")) {
+ if (tmp->value != NULL)
+ p->x = atoi(tmp->value);
+ else
+ p->x = 0;
+ } else if (!strcmp(tmp->name, "y")) {
+ if (tmp->value != NULL)
+ p->y = atoi(tmp->value);
+ else
+ p->y = 0;
+ } else if (!strcmp(tmp->name, "width")) {
+ if (tmp->value != NULL)
+ p->width = atoi(tmp->value);
+ else
+ p->width = 250;
+ } else if (!strcmp(tmp->name, "height")) {
+ if (tmp->value != NULL)
+ p->height = atoi(tmp->value);
+ else
+ p->height = 250;
+ }
+ free_xmlentry(tmp);
+ if (p->x != -50 && p->y != -50 && p->width != -50 &&
+ p->height != -50)
+ break;
+ xml_read_next_entry(h);
+ }
+ xml_read_end(h);
+
+ free(locfn);
+ return (p);
+}
+
+void
+set_cc_pos_by_ccpos(CCPos * p)
+{
+ set_cc_pos(p->x, p->y, p->width, p->height);
+ return;
+}
+
+void
+set_cc_pos()
+{
+ char *locfn = malloc(PATH_MAX);
+ XmlWriteHandle *p;
+ int x, y, width, height;
+
+ ecore_evas_geometry_get(controlcentre->win, &x, &y, &width, &height);
+
+ snprintf(locfn, PATH_MAX, DEF_CC_CONFIG_LOC, getenv("HOME"));
+ p = xml_write(locfn);
+
+ xml_write_append_entry_int(p, "x", x);
+ xml_write_append_entry_int(p, "y", y);
+ xml_write_append_entry_int(p, "width", width);
+ xml_write_append_entry_int(p, "height", height);
+
+ xml_write_end(p);
+ free(locfn);
return;
}
@@ -169,3 +274,15 @@
setup_settings();
return;
}
+
+/**
+ * @param data: This variable isn't used. It is data that could be supplied when
+ * the callback is made.
+ * @brief: Edje signal callback for the clicking or selecting of the minimize button.
+ */
+void
+cc_minimize(void *data)
+{
+ ecore_evas_iconified_set((Ecore_Evas *) data, 1);
+ return;
+}
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/controlcentre.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- controlcentre.h 24 Aug 2004 13:01:33 -0000 1.6
+++ controlcentre.h 9 Sep 2004 11:57:30 -0000 1.7
@@ -42,6 +42,10 @@
#define EDJE_SIGNAL_CC_NEW "ENOTES_NOTE_NEW"
#define EDJE_SIGNAL_CC_SAVELOAD "ENOTES_NOTES_SAVELOAD"
#define EDJE_SIGNAL_CC_SETTINGS "ENOTES_SETTINGS"
+#define EDJE_SIGNAL_CC_MINIMIZE "ENOTES_CONTROL_MINIMIZE"
+
+/* Configuration */
+#define DEF_CC_CONFIG_LOC "%s/.e/notes/cc.xml"
typedef struct {
Ecore_Evas *win;
@@ -50,17 +54,29 @@
Evas_Object *edje;
} ControlCentre;
+typedef struct {
+ int x;
+ int y;
+ int width;
+ int height;
+} CCPos;
+
extern ControlCentre *controlcentre;
extern MainConfig *main_config;
/* Setting the Control Centre up */
void setup_cc(void);
+/* Configuration */
+CCPos *get_cc_pos();
+void set_cc_pos();
+
/* Callbacks */
void cc_resize(Ecore_Evas * ee);
void cc_close(void *data);
void cc_saveload(void *data);
void cc_newnote(void *data);
void cc_settings(void *data);
+void cc_minimize(void *data);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/ipc.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ipc.c 9 Sep 2004 10:38:15 -0000 1.7
+++ ipc.c 9 Sep 2004 11:57:30 -0000 1.8
@@ -114,7 +114,8 @@
p->
data);
content = fix_newlines(note->content);
-
new_note_with_values(note->x,note->y,note->width,
+ new_note_with_values(note->x, note->y,
+ note->width,
note->height,
content);
free(content);
@@ -128,14 +129,14 @@
free(controlcentre);
controlcentre = NULL;
} else {
- new_note_with_values(0,0,325, 0,
+ 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(0,0,325, 0,
+ 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.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- main.c 9 Sep 2004 10:38:15 -0000 1.12
+++ main.c 9 Sep 2004 11:57:30 -0000 1.13
@@ -97,12 +97,13 @@
if ((tmpn =
get_notestor_from_value(tmpstr)) != NULL)
new_note_with_values(tmpn->x,
- tmpn->y,tmpn->width,
+ tmpn->y,
+ tmpn->width,
tmpn->height,
tmpn->content);
} else {
dml("Using default note template", 2);
- new_note_with_values(0,0,0, 0, INTRO_CONTENT);
+ new_note_with_values(0, 0, 0, 0, INTRO_CONTENT);
}
dml("Introduction Note Created", 1);
@@ -126,6 +127,9 @@
dml("Main Loop Ended", 1);
+ /* Save Controlcentre Settings */
+ set_cc_pos();
+
/* Autosaving */
if (main_config->autosave == 1) {
autosave();
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/note.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- note.c 9 Sep 2004 10:38:15 -0000 1.22
+++ note.c 9 Sep 2004 11:57:30 -0000 1.23
@@ -30,7 +30,7 @@
dml("Creating a Note", 2);
new = append_note();
- setup_note(&new, 0,0,0, 0, 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 x,int y,int width, int height, 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, x,y,width, height, content);
+ setup_note(&new, x, y, width, height, content);
return;
}
@@ -122,7 +122,8 @@
* @brief: Sets up the note objects, window, callbacks, etc...
*/
void
-setup_note(Evas_List ** note, int x,int y,int width, int height, char *content)
+setup_note(Evas_List ** note, int x, int y, int width, int height,
+ char *content)
{
Evas_List *pl;
Note *p;
@@ -151,7 +152,8 @@
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);
+ 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);
@@ -386,24 +388,22 @@
timer_val_compare(void *data)
{
Note *p = (Note *) data;
- char *tmp;
+ 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,tmp)) {
+ tmp = get_title_by_note_struct(p);
+ if (strcmp(p->txt_title, tmp)) {
if (saveload != NULL)
ewl_saveload_revert(NULL, NULL, saveload->tree);
- if (p->txt_title!=NULL)
+ if (p->txt_title != NULL)
free(p->txt_title);
- p->txt_title =
- get_title_by_note_struct(p);
+ p->txt_title = get_title_by_note_struct(p);
}
- if(tmp!=NULL)
+ if (tmp != NULL)
free(tmp);
} else {
p->txt_title = get_title_by_note_struct(p);
@@ -510,27 +510,28 @@
* @brief: Takes TITLE_LENGTH worth of characters
* from the front (or newline).
*/
-char*
+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));
+ 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));
}
/**
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/note.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- note.h 9 Sep 2004 10:38:15 -0000 1.7
+++ note.h 9 Sep 2004 11:57:30 -0000 1.8
@@ -61,15 +61,16 @@
/* High Level */
void new_note(void);
-void new_note_with_values(int x, int y, int width, int height, 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 x,int y,int width, int height,
- 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);
@@ -93,9 +94,9 @@
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_title_by_note_struct(Note * note);
char *get_content_by_note(Evas_List * note);
-char *get_content_by_note_struct (Note *note);
+char *get_content_by_note_struct(Note * note);
char *get_title_by_content(char *content);
Evas_List *get_cycle_begin(void);
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/saveload.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -3 -r1.15 -r1.16
--- saveload.c 9 Sep 2004 10:38:15 -0000 1.15
+++ saveload.c 9 Sep 2004 11:57:30 -0000 1.16
@@ -284,8 +284,8 @@
ecore_evas_geometry_get(note->win, &x, &y, &w, &h);
n->width = w;
n->height = h;
- n->x=x;
- n->y=y;
+ n->x = x;
+ n->y = y;
n->content = strdup(get_content_by_note(p));
append_note_stor(n);
@@ -406,7 +406,8 @@
if (r != NULL) {
while (r->cur != NULL) {
p = stor_cycle_get_notestor(r);
- setup_load_opt(load->tree, get_title_by_content(p->content));
+ setup_load_opt(load->tree,
+ get_title_by_content(p->content));
free_note_stor(p);
stor_cycle_next(r);
}
@@ -481,7 +482,7 @@
{
NoteStor *p;
XmlReadHandle *r;
- char *tmp;
+ char *tmp;
dml("Loading Saved Note", 2);
@@ -490,11 +491,12 @@
if (r != NULL) {
while (r->cur != NULL) {
p = stor_cycle_get_notestor(r);
- tmp=get_title_by_content(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);
+ 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);
}
@@ -533,7 +535,7 @@
{
NoteStor *p;
XmlReadHandle *r;
- char *tmp=NULL;
+ char *tmp = NULL;
dml("Deleting Saved Note", 2);
@@ -541,12 +543,14 @@
if (r != NULL) {
while (r->cur != NULL) {
p = stor_cycle_get_notestor(r);
- tmp=get_title_by_content(p->content);
- if (!strcmp(tmp, load_selected)){
- if(tmp!=NULL)free(tmp);
+ tmp = get_title_by_content(p->content);
+ if (!strcmp(tmp, load_selected)) {
+ if (tmp != NULL)
+ free(tmp);
break;
}
- if(tmp!=NULL)free(tmp);
+ 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.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- storage.c 9 Sep 2004 10:38:15 -0000 1.8
+++ storage.c 9 Sep 2004 11:57:30 -0000 1.9
@@ -340,7 +340,8 @@
if (r != NULL) {
while (r->cur != NULL) {
p = stor_cycle_get_notestor(r);
- new_note_with_values(p->x,p->y,p->width, p->height,
p->content);
+ new_note_with_values(p->x, p->y, p->width, p->height,
+ p->content);
free_note_stor(p);
stor_cycle_next(r);
}
@@ -375,8 +376,8 @@
n = alloc_note_stor();
n->width = w;
n->height = h;
- n->x=x;
- n->y=y;
+ n->x = x;
+ n->y = y;
n->content = strdup(get_content_by_note(tmp));
append_autosave_note_stor(n);
free_note_stor(n);
@@ -474,8 +475,10 @@
{
char *retval = malloc(MAX_VALUE);
- 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);
+ 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/xml.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- xml.c 11 Mar 2004 17:28:58 -0000 1.4
+++ xml.c 9 Sep 2004 11:57:30 -0000 1.5
@@ -183,3 +183,21 @@
xmlTextWriterWriteFormatElement(h->writer, BAD_CAST name, "%s", value);
return;
}
+
+/**
+ * @param h: The write handle to add an entry too.
+ * @param name: The xml tag name you want to append to the handle file.
+ * @param value: The value to put inside these tags (int).
+ * @brief: Appends an xml entry into the opened xml file pointed
+ * to by h.
+ */
+void
+xml_write_append_entry_int(XmlWriteHandle * h, char *name, int value)
+{
+ char *tmp = malloc(PATH_MAX);
+
+ snprintf(tmp, PATH_MAX, "%d", value);
+ xml_write_append_entry(h, name, tmp);
+ free(tmp);
+ return;
+}
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/xml.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- xml.h 6 Feb 2004 07:36:31 -0000 1.2
+++ xml.h 9 Sep 2004 11:57:30 -0000 1.3
@@ -65,5 +65,7 @@
void xml_write_append_entry(XmlWriteHandle * h, char *name,
char *value);
+void xml_write_append_entry_int(XmlWriteHandle * h, char *name,
+ int value);
#endif
-------------------------------------------------------
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