Enlightenment CVS committal

Author  : devilhorns
Project : e_modules
Module  : cpu

Dir     : e_modules/cpu


Modified Files:
        e_mod_main.h e_mod_main.c e_mod_config.c cpu.edc 


Log Message:
Fix bug where graph would draw outside the gadget. Added options to show
text and/or graph.

===================================================================
RCS file: /cvsroot/enlightenment/e_modules/cpu/e_mod_main.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- e_mod_main.h        27 Feb 2006 15:11:58 -0000      1.3
+++ e_mod_main.h        27 Feb 2006 20:04:57 -0000      1.4
@@ -9,6 +9,8 @@
 struct _Config 
 {
    int check_interval;
+   int show_text;
+   int show_graph;
 };
 
 struct _Config_Face 
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/cpu/e_mod_main.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- e_mod_main.c        27 Feb 2006 15:11:58 -0000      1.7
+++ e_mod_main.c        27 Feb 2006 20:04:57 -0000      1.8
@@ -129,14 +129,20 @@
    #define T Config
    #define D c->conf_edd
    E_CONFIG_VAL(D, T, check_interval, INT);
+   E_CONFIG_VAL(D, T, show_text, INT);
+   E_CONFIG_VAL(D, T, show_graph, INT);
    
    c->conf = e_config_domain_load("module.cpu", c->conf_edd);
    if (!c->conf) 
      {
        c->conf = E_NEW(Config, 1);
        c->conf->check_interval = 1;
+       c->conf->show_text = 1;
+       c->conf->show_graph = 1;
      }
    E_CONFIG_LIMIT(c->conf->check_interval, 0, 60);
+   E_CONFIG_LIMIT(c->conf->check_interval, 0, 1);
+   E_CONFIG_LIMIT(c->conf->check_interval, 0, 1);
    
    _cpu_config_menu_new(c);
    
@@ -221,17 +227,15 @@
    evas_event_freeze(cf->evas);
    
    o = edje_object_add(cf->evas);
-   cf->cpu_obj = o;
-   
-   if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", 
-                               "modules/cpu/main")) 
+   cf->cpu_obj = o;   
+   if (!e_theme_edje_object_set(o, "base/theme/modules/cpu", 
"modules/cpu/main")) 
      {
        snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/cpu.edj"); 
        edje_object_file_set(o, buf, "modules/cpu/main");
      }   
    evas_object_show(o);
 
-   o = edje_object_add(cf->evas); //evas_object_rectangle_add(cf->evas);
+   o = edje_object_add(cf->evas);
    cf->chart_obj = o;
    evas_object_layer_set(o, 1);
    evas_object_repeat_events_set(o, 0);
@@ -244,8 +248,7 @@
    evas_object_layer_set(o, 2);
    evas_object_repeat_events_set(o, 1);
    evas_object_color_set(o, 0, 0, 0, 0);
-   evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
-                                 _cpu_face_cb_mouse_down, cf);
+   evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, 
_cpu_face_cb_mouse_down, cf);
    evas_object_show(o);
    
    cf->gmc = e_gadman_client_new(cf->con->gadman);
@@ -263,6 +266,7 @@
    e_gadman_client_resize(cf->gmc, 45, 50);
    e_gadman_client_change_func_set(cf->gmc, _cpu_face_cb_gmc_change, cf);
    e_gadman_client_load(cf->gmc);
+   
    evas_event_thaw(cf->evas);
 
    cf->monitor = ecore_timer_add((double)cf->cpu->conf->check_interval, 
_cpu_face_update_values, cf);
@@ -320,10 +324,10 @@
      evas_object_del(cf->event_obj);
    if (cf->cpu_obj)
      evas_object_del(cf->cpu_obj);
-   if (cf->chart_obj)
-     evas_object_del(cf->chart_obj);
    if (cf->old_values)
      _cpu_face_graph_clear(cf);
+   if (cf->chart_obj)
+     evas_object_del(cf->chart_obj);
    
    if (cf->gmc) 
      {
@@ -346,8 +350,6 @@
    switch (change) 
      {
       case E_GADMAN_CHANGE_MOVE_RESIZE:
-       if (cf->monitor)
-         ecore_timer_del(cf->monitor);
        e_gadman_client_geometry_get(cf->gmc, &x, &y, &w, &h);
        evas_object_move(cf->chart_obj, x, y);
        evas_object_move(cf->event_obj, x, y);
@@ -355,8 +357,12 @@
        evas_object_resize(cf->chart_obj, w, h);
        evas_object_resize(cf->event_obj, w, h);
        evas_object_resize(cf->cpu_obj, w, h);
-       _cpu_face_graph_clear(cf);      
+       _cpu_face_graph_clear(cf);
+       /*
+       if (cf->monitor)
+         ecore_timer_del(cf->monitor);
        cf->monitor = ecore_timer_add((double)cf->cpu->conf->check_interval, 
_cpu_face_update_values, cf);
+        */
        break;
       case E_GADMAN_CHANGE_RAISE:
        evas_object_raise(cf->cpu_obj);
@@ -416,10 +422,17 @@
    if (val == -1)
      return 1;
 
-   snprintf(str, sizeof(str), "%d %%", val);
-   edje_object_part_text_set(cf->cpu_obj, "in-text", str);   
+   if (cf->cpu->conf->show_text) 
+     {
+       snprintf(str, sizeof(str), "%d %%", val);
+       edje_object_part_text_set(cf->cpu_obj, "in-text", str);   
+     }
    
-   _cpu_face_graph_values(cf, val);
+   if (cf->cpu->conf->show_graph) 
+     _cpu_face_graph_values(cf, val);
+   else 
+     _cpu_face_graph_clear(cf);
+
    return 1;
 }
 
@@ -509,9 +522,11 @@
    Evas_Object *last = NULL;
    Evas_List *l;
    int i, j = 0;
+   int v;
    
    evas_object_geometry_get(cf->chart_obj, &x, &y, &w, &h);
-   
+
+   v = (int)((double)val * ((double)h / (double)100));      
    o = evas_object_line_add(cf->evas);
    edje_object_part_swallow(cf->chart_obj, "lines", o);
    evas_object_layer_set(o, 1);
@@ -519,7 +534,7 @@
      evas_object_hide(o);
    else 
      {
-       evas_object_line_xy_set(o, (x + w), (y + h), (x + w), ((y + h) - val));
+       evas_object_line_xy_set(o, (x + w), (y + h), (x + w), ((y + h) - v));
        evas_object_color_set(o, 255, 0, 0, 150);
        evas_object_pass_events_set(o, 1);
        evas_object_show(o);
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/cpu/e_mod_config.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_mod_config.c      20 Feb 2006 12:02:22 -0000      1.1
+++ e_mod_config.c      27 Feb 2006 20:04:57 -0000      1.2
@@ -6,6 +6,8 @@
 struct _E_Config_Dialog_Data
 {
    int check_interval;
+   int show_text;
+   int show_graph;
 };
 
 /* Protos */
@@ -37,6 +39,8 @@
 _fill_data(Cpu *c, E_Config_Dialog_Data *cfdata)
 {
    cfdata->check_interval = c->conf->check_interval;   
+   cfdata->show_text = c->conf->show_text;
+   cfdata->show_graph = c->conf->show_graph;
 }
 
 static void *
@@ -71,6 +75,11 @@
    
    o = e_widget_list_add(evas, 0, 0);
    of = e_widget_framelist_add(evas, _("Cpu Settings"), 0);
+   ob = e_widget_check_add(evas, _("Show Text"), (&(cfdata->show_text)));
+   e_widget_framelist_object_append(of, ob);
+   ob = e_widget_check_add(evas, _("Show Graph"), (&(cfdata->show_graph)));   
+   e_widget_framelist_object_append(of, ob);
+
    ob = e_widget_label_add(evas, _("Check Interval:"));
    e_widget_framelist_object_append(of, ob);
    ob = e_widget_slider_add(evas, 1, 0, _("%1.0f seconds"), 1, 60, 1, 0, NULL, 
&(cfdata->check_interval), 150);
@@ -87,7 +96,9 @@
    Cpu *c;
 
    c = cfd->data;
-   c->conf->check_interval = cfdata->check_interval;
+   c->conf->check_interval = cfdata->check_interval;   
+   c->conf->show_text = cfdata->show_text;   
+   c->conf->show_graph = cfdata->show_graph;   
    e_config_save_queue ();
    if (c->face->monitor)
      ecore_timer_interval_set(c->face->monitor, 
(double)cfdata->check_interval);
===================================================================
RCS file: /cvsroot/enlightenment/e_modules/cpu/cpu.edc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- cpu.edc     27 Feb 2006 15:11:58 -0000      1.6
+++ cpu.edc     27 Feb 2006 20:04:57 -0000      1.7
@@ -53,7 +53,7 @@
              color: 255 255 255 255;
              color3: 0 0 0 100;
              text {
-                  text: "%"; 
+                  text: ""; 
                   font: "VeraMono";
                   size:  8;     
                   min:     1 1;




-------------------------------------------------------
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