Enlightenment CVS committal

Author  : devilhorns
Project : e_modules
Module  : cpu

Dir     : e_modules/cpu


Modified Files:
        cpu.edc e_mod_main.c 


Log Message:
Make cpu module work w/ 2.6.24 kernels

===================================================================
RCS file: /cvs/e/e_modules/cpu/cpu.edc,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- cpu.edc     26 Aug 2007 15:10:16 -0000      1.20
+++ cpu.edc     14 Feb 2008 19:23:19 -0000      1.21
@@ -10,11 +10,12 @@
 
 styles
 {
-   style {
-      name: "cpu_style";
-      base: "font=VeraMono font_size=10 text_class=tb_plain align=center 
color=#fff style=outline_soft_shadow shadow_color=#00000032 wrap=word";
-      tag:  "br" "\n";
-   }
+   style
+     {
+        name: "cpu_style";
+        base: "font=VeraMono font_size=12 text_class=tb_plain align=center 
color=#fff style=outline_soft_shadow shadow_color=#00000032 wrap=word";
+        tag:  "br" "\n";
+     }
 }
 
 collections
@@ -45,14 +46,6 @@
                       aspect: 1.0 1.0;
                       aspect_preference: BOTH;
                       align: 0.5 0.5;
-                      rel1
-                        {
-                           relative: 0.0 0.0;
-                        }
-                      rel2
-                        {
-                           relative: 1.0 1.0;
-                        }
                       image
                         {
                            normal: "cpu.png";
@@ -80,11 +73,12 @@
                            relative: 1.0  1.0;
                            to: "cpu";
                         }
-                           text {
-                              style:    "cpu_style";
-                              min:      0 1;
-                           }
-              }
-         }
+                       text
+                         {
+                            style:    "cpu_style";
+                            min:      0 1;
+                         }
+                    }
+               }
+          }
      }
-}
===================================================================
RCS file: /cvs/e/e_modules/cpu/e_mod_main.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -3 -r1.45 -r1.46
--- e_mod_main.c        12 Nov 2007 06:25:59 -0000      1.45
+++ e_mod_main.c        14 Feb 2008 19:23:19 -0000      1.46
@@ -16,9 +16,9 @@
 struct _Instance 
 {
    E_Gadcon_Client *gcc;
-   Cpu             *cpu;
-   Ecore_Timer     *timer;
-   Config_Item     *ci;
+   Cpu *cpu;
+   Ecore_Timer *timer;
+   Config_Item *ci;
 };
 
 struct _Cpu 
@@ -63,13 +63,14 @@
 static E_Gadcon_Client *
 _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) 
 {
-   Cpu             *cpu;
-   Instance        *inst;
+   Cpu *cpu;
+   Instance *inst;
    E_Gadcon_Client *gcc;
-   char             buf[4096];
+   char buf[4096];
 
    cpu_count = _get_cpu_count();
-   
+   printf("Cpus: %d\n", cpu_count);
+
    inst = E_NEW(Instance, 1);   
    inst->ci = _config_item_get(id);
 
@@ -78,13 +79,13 @@
 
    snprintf(buf, sizeof(buf), "%s/cpu.edj", 
            e_module_dir_get(cpu_conf->module));
-   
+
    cpu->o_icon = edje_object_add(gc->evas);
    if (!e_theme_edje_object_set(cpu->o_icon, 
                                "base/theme/modules/cpu", "modules/cpu/main"))
      edje_object_file_set(cpu->o_icon, buf, "modules/cpu/main");
    evas_object_show(cpu->o_icon);
-   
+
    gcc = e_gadcon_client_new(gc, name, id, style, cpu->o_icon);
    gcc->data = inst;
    inst->gcc = gcc;
@@ -103,16 +104,14 @@
 _gc_shutdown(E_Gadcon_Client *gcc) 
 {
    Instance *inst;
-   Cpu      *cpu;
-   
+   Cpu *cpu;
+
    inst = gcc->data;
    cpu = inst->cpu;
 
-   if (inst->timer)
-     ecore_timer_del(inst->timer);
-   if (cpu->o_icon)
-     evas_object_del(cpu->o_icon);
-   
+   if (inst->timer) ecore_timer_del(inst->timer);
+   if (cpu->o_icon) evas_object_del(cpu->o_icon);
+
    cpu_conf->instances = evas_list_remove(cpu_conf->instances, inst);
    E_FREE(cpu);
    E_FREE(inst);
@@ -135,13 +134,13 @@
 _gc_icon(Evas *evas) 
 {
    Evas_Object *o;
-   char         buf[4096];
+   char buf[4096];
 
    if (!cpu_conf->module) return NULL;
-   
+
    snprintf(buf, sizeof(buf), "%s/e-module-cpu.edj", 
            e_module_dir_get(cpu_conf->module));
-   
+
    o = edje_object_add(evas);
    edje_object_file_set(o, buf, "icon");
    return o;
@@ -159,18 +158,17 @@
 static Config_Item *
 _config_item_get(const char *id) 
 {
-   Evas_List   *l;
+   Evas_List *l = NULL;
    Config_Item *ci;
    char buf[128];
+   int num = 0;
+   const char *p;
 
    if (!id)
      {
-       int  num = 0;
-
        /* Create id */
        if (cpu_conf->items)
          {
-            const char *p;
             ci = evas_list_last(cpu_conf->items)->data;
             p = strrchr(ci->id, '.');
             if (p) num = atoi(p + 1) + 1;
@@ -205,17 +203,15 @@
 _set_cpu_load(void *data) 
 {
    Instance *inst;
-   Cpu      *cpu;
-   int       i = 0;
-   char      str[100], str_tmp[100];
+   Cpu *cpu;
+   int i = 0;
+   char str[100], str_tmp[100];
 
    if (cpu_count == -1) return 0;
 
-   inst = data;
-   if (!inst) return 1;
-   cpu = inst->cpu;
-   if (!cpu) return 1;
-   
+   if (!(inst = data)) return 1;
+   if (!(cpu = inst->cpu)) return 1;
+
    _get_cpu_load();
 
    if (cpu_count == 1)
@@ -247,7 +243,7 @@
 
    if (!(f = fopen("/proc/stat", "r"))) return cpu;
 
-   while (fscanf(f, "cp%s %*u %*u %*u %*u %*u %*u %*u %*u\n", (char *) &tmp) 
== 1)
+   while (fscanf(f, "cp%s %*u %*u %*u %*u %*u %*u %*u %*u %*u\n", (char *) 
&tmp) == 1)
      cpu++;
 
    fclose(f);
@@ -267,7 +263,7 @@
 #else
    FILE *stat;
    static unsigned long old_u[4], old_n[4], old_s[4], old_i[4], old_wa[4], 
old_hi[4], old_si[4];
-   unsigned long new_u, new_n, new_s, new_i, new_wa = 0, new_hi = 0, new_si = 
0, dummy2, ticks_past;
+   unsigned long new_u, new_n, new_s, new_i, new_wa = 0, new_hi = 0, new_si = 
0, dummy2, dummy3, ticks_past;
    int tmp_u = 0, tmp_n = 0, tmp_s = 0;
    char dummy[16];
    int i = 0;
@@ -285,12 +281,13 @@
    new_used = cp_time[CP_USER] + cp_time[CP_NICE] + cp_time[CP_SYS];
    new_tot = new_used + cp_time[CP_IDLE];
 
-   cpu_stats[0] = (100 * (float)(new_used - old_used) / (float)(new_tot - 
old_tot)) / update_interval;
+   cpu_stats[0] = 
+     (100 * (float)(new_used - old_used) / (float)(new_tot - old_tot)) / 
update_interval;
 
    old_tot = new_tot;
    old_used = new_used; 
    
-   cpu_stats[0]=(cpu_stats[0]>100?100:cpu_stats[0]);
+   cpu_stats[0] = (cpu_stats[0] > 100 ? 100 : cpu_stats[0]);
 #else
    if (!(stat = fopen("/proc/stat", "r"))) return -1;
 
@@ -301,17 +298,19 @@
        
        In this case the first line is read and forgotten
    */
-   if(cpu_count>1){
-      /* I had to add another %lu (linux 2.6.17) */
-      fscanf(stat, "%s %lu %lu %lu %lu %lu %lu %lu %lu", dummy, &new_u, 
&new_n, &new_s, &new_i, &new_wa, &new_hi, &new_si, &dummy2);
-   }
-   
+
+   if (cpu_count > 1) 
+     {
+        /* I had to add another %lu (linux 2.6.17) */
+        fscanf(stat, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu", dummy, &new_u, 
&new_n, &new_s, &new_i, &new_wa, &new_hi, &new_si, &dummy2, &dummy3);
+     }
+
    while (i < cpu_count)
      {
 
         /* I had to add another %lu (linux 2.6.17) */
-       if (fscanf(stat, "%s %lu %lu %lu %lu %lu %lu %lu %lu", dummy, &new_u, 
&new_n,
-            &new_s, &new_i, &new_wa, &new_hi, &new_si, &dummy2) < 5)
+       if (fscanf(stat, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu", dummy, 
&new_u, &new_n,
+            &new_s, &new_i, &new_wa, &new_hi, &new_si, &dummy2, &dummy3) < 5)
          {
             fclose (stat);
             return -1;
@@ -336,7 +335,7 @@
        old_hi[i] = new_hi;
        old_si[i] = new_si;
        
-       cpu_stats[i]=(cpu_stats[i]>100?100:cpu_stats[i]);
+       cpu_stats[i] = (cpu_stats[i] > 100 ? 100 : cpu_stats[i]);
 
        i++;
      }
@@ -434,7 +433,6 @@
    Instance *inst;
  
    inst = data;
-
    inst->ci->interval = 0.5;
    ecore_timer_del(inst->timer);
    inst->timer = ecore_timer_add(inst->ci->interval, _set_cpu_load, inst);
@@ -447,7 +445,6 @@
    Instance *inst;
  
    inst = data;
-
    inst->ci->interval = 1.0;
    ecore_timer_del(inst->timer);
    inst->timer = ecore_timer_add(inst->ci->interval, _set_cpu_load, inst);
@@ -460,7 +457,6 @@
    Instance *inst;
  
    inst = data;
-
    inst->ci->interval = 2.0;
    ecore_timer_del(inst->timer);
    inst->timer = ecore_timer_add(inst->ci->interval, _set_cpu_load, inst);
@@ -473,7 +469,6 @@
    Instance *inst;
 
    inst = data;
-
    inst->ci->interval = 5.0;
    ecore_timer_del(inst->timer);
    inst->timer = ecore_timer_add(inst->ci->interval, _set_cpu_load, inst);
@@ -486,7 +481,6 @@
    Instance *inst;
 
    inst = data;
-
    inst->ci->interval = 30.0;
    ecore_timer_del(inst->timer);
    inst->timer = ecore_timer_add(inst->ci->interval, _set_cpu_load, inst);
@@ -560,8 +554,7 @@
        Config_Item *ci;
        
        ci = cpu_conf->items->data;
-       if (ci->id)
-         evas_stringshare_del(ci->id);
+       if (ci->id) evas_stringshare_del(ci->id);
        cpu_conf->items = evas_list_remove_list(cpu_conf->items, 
cpu_conf->items);
        E_FREE(ci);
      }



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to