Enlightenment CVS committal

Author  : handyande
Project : misc
Module  : enotes

Dir     : misc/enotes/src


Modified Files:
        config.c main.c main.h 


Log Message:
add autosave timer and fix some indenting
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/config.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -3 -r1.18 -r1.19
--- config.c    25 Oct 2005 01:07:53 -0000      1.18
+++ config.c    6 Mar 2006 20:53:18 -0000       1.19
@@ -11,7 +11,7 @@
  **************************************************/
 
 
-#include "note.h"
+#include "main.h"
 
 /**
  * @return: Returns an allocated MainConfig variable with some default values
@@ -32,7 +32,8 @@
        p->ontop = 0;
        p->sticky = 0;
 
-       return (p);}
+       return (p);
+}
 
 /**
  * @param p: The MainConfig variable to free.
@@ -42,14 +43,24 @@
        if (p) {
                if (p->render_method)free(p->render_method);
                if (p->theme)free(p->theme);
-               free(p);}}
+               free(p);
+  }
+}
 
 /* LISTENERS */
 
-void theme_listener(const char *key, const Ecore_Config_Type type, const int 
tag,void *data){
+void theme_listener(const char *key, const Ecore_Config_Type type,
+    const int tag,void *data){
        main_config->theme = ecore_config_theme_get(key);
        cc_update_theme();
-       notes_update_themes();}
+       notes_update_themes();
+}
+
+void autosave_listener(const char *key, const Ecore_Config_Type type,
+    const int tag,void *data){
+  main_config->autosave = ecore_config_boolean_get(key);
+  update_autosave();
+}
 
 void remotearg(char *val,void *data){
        remotecmd=val;
@@ -106,5 +117,8 @@
        p->sticky = ecore_config_boolean_get("enotes.sticky");
 
        ecore_config_listen("theme", "enotes.theme", (void*)&theme_listener, 0, 
NULL);
+  ecore_config_listen("autosave", "enotes.autosave", (void*)&autosave_listener,
+      0, NULL);
 
-       return (retv);}
+       return (retv);
+}
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/main.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- main.c      3 Feb 2006 23:02:44 -0000       1.25
+++ main.c      6 Mar 2006 20:53:18 -0000       1.26
@@ -15,6 +15,24 @@
 
 MainConfig     *main_config;
 char *remotecmd;
+Ecore_Timer *autosave_timer = NULL;
+
+static int
+_autosave_timer_tick(void *data) {
+  autosave();
+
+  return 1;
+}
+
+void
+update_autosave(void) {
+  if (main_config->autosave == 1 && autosave_timer == NULL)
+    autosave_timer = ecore_timer_add(30, _autosave_timer_tick, NULL);
+  if (main_config->autosave == 0 && autosave_timer != NULL) {
+    ecore_timer_del(autosave_timer);
+    autosave_timer = NULL;
+  }
+}
 
 /* The Main Function */
 
@@ -25,8 +43,7 @@
  * @brief: The first function once enotes is called.
  */
 int
-main(int argc, char *argv[])
-{
+main(int argc, char *argv[]) {
        int             note_count;
 
        /* IPC Check */
@@ -84,7 +101,10 @@
                dml("Efl Successfully Initiated", 1);
 
                /* Autoloading */
-               if (main_config->autosave == 1)autoload();
+               if (main_config->autosave == 1) {
+      autoload();
+      update_autosave();
+    }
 
                if(remotecmd!=NULL)handle_ipc_message(remotecmd);
 
@@ -114,6 +134,8 @@
                /* Autosaving */
                if (main_config->autosave == 1)
                        autosave();
+    if (autosave_timer)
+      ecore_timer_del(autosave_timer);
 
                /* Shutdown the E-Libs */
                edje_shutdown();
===================================================================
RCS file: /cvsroot/enlightenment/misc/enotes/src/main.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- main.h      6 Apr 2005 11:52:39 -0000       1.11
+++ main.h      6 Mar 2006 20:53:18 -0000       1.12
@@ -37,6 +37,7 @@
 
 extern char *remotecmd;
 
+void            update_autosave(void);
 /* The Main Function */
 int             main(int argc, char *argv[]);
 




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to