Enlightenment CVS committal

Author  : devilhorns
Project : e_modules
Module  : uptime

Dir     : e_modules/uptime


Modified Files:
        configure.in e_mod_config.c e_mod_main.c uptime.edc 


Log Message:
Add load average and users for linux :)

Fix edc so that uptime doesn't get clipped at the top and looks better on
Inset style.
   
Changed config dialog to be able to set 1 second check interval:
  -This does not use >80% cpu.
  
Configure.in changes:
  -Check if the system uses sys/time.h or time.h .
  -Check if the getloadavg function is available to use.

===================================================================
RCS file: /cvs/e/e_modules/uptime/configure.in,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- configure.in        10 Jun 2006 02:34:00 -0000      1.10
+++ configure.in        29 Jun 2006 19:56:51 -0000      1.11
@@ -13,10 +13,13 @@
 AC_PROG_CC
 AM_PROG_CC_STDC
 AC_HEADER_STDC
+AC_HEADER_TIME
+AC_CHECK_HEADERS(sys/time.h)
 AC_C_CONST
 AM_ENABLE_SHARED
 AM_PROG_LIBTOOL
 
+AC_CHECK_FUNCS(getloadavg, [], [])
 ALL_LINGUAS="bg eo fi it ja sv"
 AC_SUBST(ALL_LINGUAS)
 
===================================================================
RCS file: /cvs/e/e_modules/uptime/e_mod_config.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- e_mod_config.c      28 Jun 2006 23:48:53 -0000      1.8
+++ e_mod_config.c      29 Jun 2006 19:56:51 -0000      1.9
@@ -104,7 +104,7 @@
    ob = e_widget_label_add(evas, D_("Check Interval:"));
    e_widget_framelist_object_append(of, ob);
 
-   ob = e_widget_slider_add(evas, 1, 0, _("%1.0f seconds"), 15.0, 60.0,
+   ob = e_widget_slider_add(evas, 1, 0, _("%1.0f seconds"), 1.0, 60.0,
                            1.0, 0, &(cfdata->check_interval), NULL, 100);
    e_widget_framelist_object_append(of, ob);
 
===================================================================
RCS file: /cvs/e/e_modules/uptime/e_mod_main.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- e_mod_main.c        29 Jun 2006 17:07:00 -0000      1.12
+++ e_mod_main.c        29 Jun 2006 19:56:51 -0000      1.13
@@ -4,20 +4,30 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <sys/types.h>
-#include <sys/time.h>
+#include <utmp.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
 #include <syslog.h>
 
 #ifdef __linux__
 # include <linux/kernel.h>
+# include <linux/unistd.h>
 #endif
 
 #ifdef __FreeBSD__
-# include <utmp.h>
 # include <paths.h>
 # include <sys/tty.h>
 # include <sys/sysctl.h>
 # include <sys/param.h>
-
 #endif
 
 typedef struct _Instance Instance;
@@ -322,13 +332,12 @@
 EAPI int
 e_modapi_shutdown(E_Module *m)
 {
-
    ut_config->module = NULL;
    e_gadcon_provider_unregister(&_gc_class);
 
    if (ut_config->config_dialog != NULL)
      e_object_del(E_OBJECT(ut_config->config_dialog));
-
+   
    if (ut_config->menu)
      {
        e_menu_post_deactivate_callback_set(ut_config->menu, NULL, NULL);
@@ -413,8 +422,10 @@
 static void
 update_counters(Instance *inst)
 {
+   int ret;
 #ifdef __linux__
    struct sysinfo s_info;
+   struct utmp *utmpstruct;
 #elif defined(__FreeBSD__)
    int mib[2];
    size_t size;
@@ -428,17 +439,29 @@
    struct utmp ut;
    char ttybuf[MAXPATHLEN];
    struct stat st;
-   int ret;      
 #endif
 
-   if (!inst) return;
+   if (!inst) 
+     return;
 
 #ifdef __linux__
    sysinfo(&s_info);
    inst->uptime = s_info.uptime;
-
-   inst->la[0] = -1; /* unsupported */
-   inst->nusers = -1; /* unsupported */
+   inst->la[0] = -1;
+# ifdef HAVE_GETLOADAVG
+   ret = getloadavg(inst->la, sizeof(inst->la)/sizeof(inst->la[0]));
+   if (ret < 0)
+     inst->la[0] = -1;
+# endif
+   inst->nusers = 0;
+   setutent();
+   while ((utmpstruct = getutent())) 
+     {
+       if ((utmpstruct->ut_type == USER_PROCESS) &&
+           (utmpstruct->ut_name[0] != '\0'))
+         inst->nusers++;
+     }
+   endutent();
 #elif defined(__FreeBSD__)
    /* retrive uptime info */
    (void)time(&now);
@@ -453,17 +476,17 @@
        uptime += 30;
       inst->uptime = uptime;
    }
-   else                 
+   else
      inst->uptime = -1;   
    
    /* retrive load averages */
+   inst->la[0] = -1;
+# ifdef HAVE_GETLOADAVG
    ret = getloadavg(inst->la, sizeof(inst->la)/sizeof(inst->la[0]));
    if (ret < 0)
-     {
-       warn("getloadavg()");
-       inst->la[0] = -1;
-     }
-
+     warn("getloadavg()");
+# endif
+   
    /* retrive number of active users */
    utmp = fopen(_PATH_UTMP, "r");
    if (utmp == NULL)
@@ -501,11 +524,11 @@
    time_t uptime;
 
    inst = data;
-   if (inst == 0)
+   if (!inst)
      return 0;
    
    ci = _ut_config_item_get(inst->gcc->id);
-   if (ci == 0)
+   if (!ci)
      return 0;
 
 #ifdef UPTIME_DEBUG
@@ -537,13 +560,15 @@
                 days, hours, minutes, uptime);
      }
 
-   if (inst->la[0] != -1)
+   if (inst->la[0] != -1) 
+     {
      snprintf(load_avg, sizeof(load_avg), 
              D_("la: %.2f %.2f %.2f"), 
              inst->la[0], inst->la[1], inst->la[2]);
-
+     }
+   
    if (inst->nusers != -1)
-     snprintf(users, sizeof(users), D_("users: %d"), inst->nusers);
+     snprintf(users, sizeof(users), D_("user%s: %d"), (inst->nusers != 1) ? 
"s" : "", inst->nusers);
 
    edje_object_part_text_set(inst->ut->ut_obj, "uptime", u_date_time);
    edje_object_part_text_set(inst->ut->ut_obj, "load_average", load_avg);
===================================================================
RCS file: /cvs/e/e_modules/uptime/uptime.edc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- uptime.edc  28 Jun 2006 23:48:53 -0000      1.9
+++ uptime.edc  29 Jun 2006 19:56:51 -0000      1.10
@@ -1,8 +1,3 @@
-images
-{
-   image: "uptime.png" COMP;
-}
-
 fonts
 {
    font: "VeraMono.ttf" "VeraMono";
@@ -27,12 +22,12 @@
                       rel1
                         {
                            relative: 0.0 0.0;
-                           offset: 0 0;
+                           offset: 0 4;
                         }
                       rel2
                         {
                            relative: 1.0 0.33;
-                           offset: 0 0;
+                           offset: 0 -3;
                         }
                       color: 255 255 255 255;
                       color2: 0 0 0 96;
@@ -41,9 +36,10 @@
                         {
                            text: "uptime";
                            font: "VeraMono";
-                           size:  12;
+                           size:  10;
                            min:     1 1;
-                           align: 0.5 0.5;
+                           align: 0.5 1.0;
+                           text_class: "module_large";
                         }
                    }
               }
@@ -58,13 +54,14 @@
                       state: "default" 0.0;
                       rel1
                         {
-                           relative: 0.0 0.33;
-                           offset: 0 0;
+                           relative: 0.0 1.0;
+                           offset: 0 4;
+                           to_y: "uptime";
                         }
                       rel2
                         {
                            relative: 1.0 0.66;
-                           offset: 0 0;
+                           offset: 0 -3;
                         }
                       color: 255 255 255 255;
                       color2: 0 0 0 96;
@@ -73,9 +70,10 @@
                         {
                            text: "load average";
                            font: "VeraMono";
-                           size:  12;
+                           size:  10;
                            min:     1 1;
                            align: 0.5 0.5;
+                           text_class: "module_small";
                         }
                    }
               }
@@ -90,13 +88,14 @@
                       state: "default" 0.0;
                       rel1
                         {
-                           relative: 0.0 0.66;
-                           offset: 0 0;
+                           relative: 0.0 1.0;
+                           offset: 0 4;
+                           to_y: "load_average";
                         }
                       rel2
                         {
                            relative: 1.0 1.0;
-                           offset: 0 0;
+                           offset: 0 -8;
                         }
                       color: 255 255 255 255;
                       color2: 0 0 0 96;
@@ -105,9 +104,10 @@
                         {
                            text: "users";
                            font: "VeraMono";
-                           size:  12;
+                           size:  8;
                            min:     1 1;
-                           align: 0.5 0.5;
+                           align: 0.5 1.0;
+                           text_class: "module_small";
                         }
                    }
               }



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to