Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/modules/clock


Modified Files:
        e_mod_main.c e_mod_main.h 


Log Message:


fix up config code so i can do lists and structs etc.

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/modules/clock/e_mod_main.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- e_mod_main.c        27 Nov 2004 18:17:21 -0000      1.4
+++ e_mod_main.c        5 Dec 2004 07:43:51 -0000       1.5
@@ -3,7 +3,7 @@
 
 /* TODO List:
  *
- * fix up a better default x and y
+ * should support proepr resize and move handles in the edje.
  * 
  */
 
@@ -19,8 +19,6 @@
 static void    _clock_cb_face_up(void *data, Evas *e, Evas_Object *obj, void 
*event_info);
 static void    _clock_cb_face_move(void *data, Evas *e, Evas_Object *obj, void 
*event_info);
 
-char          *_clock_module_dir;
-
 /* public module routines. all modules must have these */
 void *
 init(E_Module *m)
@@ -69,10 +67,7 @@
    Clock *e;
 
    e = m->data;
-   ecore_config_int_set("e.module.clock.x", e->face->fx);
-   ecore_config_int_set("e.module.clock.y", e->face->fy);
-   ecore_config_int_set("e.module.clock.width", e->face->fw);
-   e_config_save_queue();
+   e_config_domain_save("module.clock", e->conf_edd, e->conf);
    return 1;
 }
 
@@ -96,32 +91,35 @@
 }
 
 /* module private routines */
-static
-Clock *_clock_init(E_Module *m)
+static Clock *
+_clock_init(E_Module *m)
 {
    Clock *e;
-   char buf[4096];
    Evas_List *managers, *l, *l2;
    
    e = calloc(1, sizeof(Clock));
    if (!e) return NULL;
    
-   ecore_config_int_create
-       ("e.module.clock.x", 50, 0, "",
-         "Clock module: X start position");
-   ecore_config_int_create
-       ("e.module.clock.y", 50, 0, "",
-         "Clock module: Y start position");
-   ecore_config_int_create
-        ("e.module.clock.width", 64, 0, "",
-         "Clock module: Start width");
-
-   ecore_config_load();
-
-   e->conf.width = ecore_config_int_get("e.module.clock.width");
-   e->conf.x = ecore_config_int_get("e.module.clock.x");
-   e->conf.y = ecore_config_int_get("e.module.clock.y");
-   _clock_module_dir = e_module_dir_get(m);
+   e->conf_edd = E_CONFIG_DD_NEW("Clock_Config", Config);
+#undef T
+#undef D
+#define T Config
+#define D e->conf_edd   
+   E_CONFIG_VAL(D, T, width, INT);
+   E_CONFIG_VAL(D, T, x, DOUBLE);
+   E_CONFIG_VAL(D, T, y, DOUBLE);
+
+   e->conf = e_config_domain_load("module.clock", e->conf_edd);
+   if (!e->conf)
+     {
+       e->conf = E_NEW(Config, 1);
+       e->conf->width = 64;
+       e->conf->x = 0.0;
+       e->conf->y = 1.0;
+     }
+   E_CONFIG_LIMIT(e->conf->width, 2, 256);
+   E_CONFIG_LIMIT(e->conf->x, 0.0, 1.0);
+   E_CONFIG_LIMIT(e->conf->y, 0.0, 1.0);
    
    managers = e_manager_list();
    for (l = managers; l; l = l->next)
@@ -152,6 +150,9 @@
 static void
 _clock_shutdown(Clock *e)
 {
+   free(e->conf);
+   E_CONFIG_DD_FREE(e->conf_edd);
+   
    _clock_face_free(e->face);
    free(e);
 }
@@ -190,16 +191,15 @@
    Evas_List *l;
    Evas_Coord ww, hh, bw, bh;
    Evas_Object *o;
-   char buf[4096];
    
-   ef->fx = ef->clock->conf.x;
-   ef->fy = ef->clock->conf.y;
+   evas_output_viewport_get(ef->evas, NULL, NULL, &ww, &hh);
+   ef->fx = ef->clock->conf->x * (ww - ef->clock->conf->width);
+   ef->fy = ef->clock->conf->y * (hh - ef->clock->conf->width);
       
    evas_event_freeze(ef->evas);
    o = edje_object_add(ef->evas);
    ef->clock_object = o;
 
-   snprintf(buf, sizeof(buf), "%s/default.eet", _clock_module_dir);
    edje_object_file_set(o,
                        /* FIXME: "default.eet" needs to come from conf */
                        e_path_find(path_themes, "default.eet"),
@@ -237,20 +237,21 @@
 static void
 _clock_face_reconfigure(Clock_Face *ef)
 {
-   Evas_Coord minw, minh, maxw, maxh;
+   Evas_Coord minw, minh, maxw, maxh, ww, hh;
 
    edje_object_size_min_calc(ef->clock_object, &minw, &maxh);
    edje_object_size_max_get(ef->clock_object, &maxw, &minh);
-   ef->fx = ef->clock->conf.x;
-   ef->fy = ef->clock->conf.y;
-   ef->fw = ef->clock->conf.width;
+   evas_output_viewport_get(ef->evas, NULL, NULL, &ww, &hh);
+   ef->fx = ef->clock->conf->x * (ww - ef->clock->conf->width);
+   ef->fy = ef->clock->conf->y * (hh - ef->clock->conf->width);
+   ef->fw = ef->clock->conf->width;
    ef->minsize = minw;
    ef->maxsize = maxw;
 
-   evas_object_move(ef->clock_object, ef->clock->conf.x, ef->clock->conf.y);
-   evas_object_resize(ef->clock_object, ef->clock->conf.width, 
ef->clock->conf.width);
-   evas_object_move(ef->event_object, ef->clock->conf.x, ef->clock->conf.y);
-   evas_object_resize(ef->event_object, ef->clock->conf.width, 
ef->clock->conf.width);
+   evas_object_move(ef->clock_object, ef->fx, ef->fy);
+   evas_object_resize(ef->clock_object, ef->clock->conf->width, 
ef->clock->conf->width);
+   evas_object_move(ef->event_object, ef->fx, ef->fy);
+   evas_object_resize(ef->event_object, ef->clock->conf->width, 
ef->clock->conf->width);
 }
 
 static void
@@ -284,11 +285,16 @@
 {
    Evas_Event_Mouse_Up *ev;
    Clock_Face *ef;
+   Evas_Coord ww, hh;
    
    ev = event_info;
    ef = data;
    ef->move = 0;
    ef->resize = 0;
+   evas_output_viewport_get(ef->evas, NULL, NULL, &ww, &hh);
+   ef->clock->conf->x = (double)ef->fx / (double)(ww - ef->clock->conf->width);
+   ef->clock->conf->y = (double)ef->fy / (double)(hh - ef->clock->conf->width);
+   e_config_save_queue();
 }
 
 static void
@@ -297,6 +303,7 @@
    Evas_Event_Mouse_Move *ev;
    Clock_Face *ef;
    Evas_Coord x, y, w, h, cx, cy, sw, sh;
+   
    evas_pointer_canvas_xy_get(e, &cx, &cy);
    evas_output_viewport_get(e, NULL, NULL, &sw, &sh);
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/modules/clock/e_mod_main.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_mod_main.h        26 Nov 2004 10:53:38 -0000      1.1
+++ e_mod_main.h        5 Dec 2004 07:43:51 -0000       1.2
@@ -1,17 +1,23 @@
 #ifndef E_MOD_MAIN_H
 #define E_MOD_MAIN_H
 
+typedef struct _Config     Config;
 typedef struct _Clock      Clock;
 typedef struct _Clock_Face Clock_Face;
 
+struct _Config
+{
+   int width;
+   double x, y;
+};
+
 struct _Clock
 {
    E_Menu      *config_menu;
    Clock_Face *face;
-   struct {
-      int       width;
-      int       x, y;
-   } conf;
+   
+   E_Config_DD *conf_edd;
+   Config      *conf;
 };
 
 struct _Clock_Face




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to