Example #1
0
/* Update the 'connect time' display, if applicable.
 * This should be called at least every second when a call is active.
 * Calling it more often or when a call isn't active won't hurt.
 */
void update_call_timer(void) {
  time_t now, starttime, duration;

  phone_check_ring_timeout();
  
  if (!current_call)
    return;

  /* Measure the time from connect to now or 
   * (if the call has ended) it's end */
  starttime = current_call->begin_time;
  now = time(NULL);
  if (!starttime)
    starttime = now;
  if (current_call->end_time)
    now = current_call->end_time;
  duration = now - starttime;

  /* If there's a call in progress, don't let the power management kick in */
  if (current_call->begin_time && !current_call->end_time)
    pgSetInactivity(0);

  if (old_connect_time != duration) {
    pgReplaceTextFmt(wConnectTime,"%2d:%02d", duration/60,duration%60);
    pgSubUpdate(wConnectTime);
  }

  old_connect_time = duration;
}
Example #2
0
void sysIdle(void) {
  FILE *f;
  char buf[50];
  int bat_raw, bat_percent;
  
  /* Get battery status */
  f = fopen("/proc/r39xxpm","r");
  if (f) {
    /* I don't think the format of /proc/r39xxpm is set in stone, so
     * this might break? Oh well, works for now. */
    fgets(buf,50,f);  /* CPU speed */
    fgets(buf,50,f);  /* Battery voltage */
    fclose(f);
    bat_raw = atoi(buf+9); /* Skip past "Battery: " */
    
    /* Translate to percent, assuming 259 (2.0 volts) is empty
     * and 402 (3.0 volts) is full. */
    bat_percent = ((bat_raw - 259) * 100) / 143;
    if (bat_percent < 0) bat_percent = 0;
    if (bat_percent > 100) bat_percent = 100;
    
    pgSetWidget(wBatt,PG_WP_VALUE,bat_percent,0);
    pgFlushRequests();
    pgSubUpdate(wBatt);  
  }
}
Example #3
0
void sysIdle(void) {
  char *ct;
  char buf[50];
  FILE *f;
  unsigned long cpu_user,cpu_nice,cpu_sys,cpu_idle;
  unsigned long crun,ctotal,wval;
  static unsigned long ocrun = 0,octotal = 1,owval = 0;

  /* Get CPU load */
  f = fopen("/proc/stat","r");
  fgets(buf,50,f);
  fclose(f);
  sscanf(buf,"cpu %lu %lu %lu %lu",&cpu_user,&cpu_nice,&cpu_sys,&cpu_idle);  
  crun = cpu_user + cpu_sys;
  ctotal = crun + cpu_nice + cpu_idle;
  if (crun==ocrun || ctotal==octotal)
    wval = 0;
  else
    wval = (crun-ocrun) * 100 / (ctotal-octotal);

  if (wval!=owval) {
    pgSetWidget(wLoad,PG_WP_VALUE,wval,0);
    pgSubUpdate(wLoad);
  }

  owval = wval;
  ocrun = crun;
  octotal = ctotal;
}
Example #4
0
static void PG_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
{
        int i;
	
	for (i = 0; i < numrects; i++) {
	        if (rects[i].w <= 0 || rects[i].h <= 0)
		  continue;

		/* Schedule an incremental update for this rectangle, using
		 * the canvas gropnodes we've loaded beforehand.
		 */
		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0);
		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, 
			   rects[i].x, rects[i].y,
			   rects[i].w, rects[i].h);
		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1);
		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, 
			   rects[i].x, rects[i].y,
			   rects[i].w, rects[i].h);
		
		/* Go perform the update */
		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0);
		pgSubUpdate(this->hidden->wCanvas);
	}
}
Example #5
0
/* Update the current clock time */
void updateTime(void) {
   time_t now;
   struct tm *ltime;
   char buf[CLKMAX];
   static int blink = 0;

   time(&now);
   ltime = localtime(&now);
   strftime(buf,CLKMAX,blink ? currentClock.fmt1 : currentClock.fmt2,ltime);
   blink = !blink;
   pgReplaceText(currentClock.wClock,buf);
   pgSubUpdate(currentClock.wClock);
}
Example #6
0
/* widget: the parent widget to derive inside
 * directory: the directory into which search for themes */
void themebar(pghandle widget, char* directory, int* themecontext)
{
  struct dirent *dent;
  int i,l;
  DIR *d;
  char buf[80];
  pghandle box;

  THEME_DIRECTORY=directory;
  if (! (d = opendir(THEME_DIRECTORY))) {
      eerror("directory not found");
      exit(1);
  }

  /* simple & dirty */
/*   pageContext = pagecontext; */
/*   themeContext = themecontext; */

  box = pgNewWidget(PG_WIDGET_SCROLLBOX, PG_DERIVE_AFTER, widget);
  pgSetWidget(PGDEFAULT,
	      PG_WP_SIDE, PG_S_ALL,
/*  	      PG_WP_TRANSPARENT, 1, */
	      0);

  /* Make handles */
  rewinddir(d);
  i = 0;
  while ((dent = readdir(d))) {
    l = strlen(dent->d_name);
    if (l<4) continue;
    if (strcmp(dent->d_name+l-3,".th")) continue;

    buf[0] = 0;
/*     dent->d_name[l-3] = 0; */

    if (idx == LENGHT) {
	eerror("max array lenght reached in themebar.c: too many themes.");
	break;
    }

    array[idx].dir = pgNewString(directory);
    array[idx].fname = pgNewString(dent->d_name);
    array[idx].active = 0;

    /* Add item */
    pgNewWidget(PG_WIDGET_BUTTON, PG_DERIVE_INSIDE, box);
    pgSetWidget(PGDEFAULT,
/* 		PG_WP_EXTDEVENTS, pgGetWidget(PGDEFAULT, PG_WP_EXTDEVENTS) & ~PG_EXEV_EXCLUSIVE, */
/* 		PG_WP_EXTDEVENTS, PG_EXEV_TOGGLE, */
		PG_WP_TEXT, array[idx].fname,
		PG_WP_SIDE, PG_S_BOTTOM,
		0);

    pgSetPayload(PGDEFAULT, idx);
    idx++;

    pgBind(PGDEFAULT,PG_WE_ACTIVATE,evtChangeTheme, themecontext);
  }
  closedir(d);

  pgSubUpdate(widget);
  return;
}