[Pkg-wmaker-commits] [wmforecast] 10/63: fixed WMAddPersistentTimerHandler error -- large number of milliseconds (e.g., one hour) failed

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 17 11:20:32 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmforecast.

commit 040867e673c8b3a1984ec49393155860058e1e06
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date:   Sat Apr 19 23:35:06 2014 -0500

    fixed WMAddPersistentTimerHandler error -- large number of milliseconds (e.g., one hour) failed
---
 ChangeLog    | 22 ++++++++++++++--------
 config.h.in  |  3 ---
 wmforecast.c | 19 ++++++++++++++++---
 3 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e90d91c..7f0905e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,20 @@
-2015-04-18  Doug Torrance <dtorrance at monmouthcollege.edu>
-	* wmforecast.c: switched timer handler from pthread to WINGs's native
-	  WMAddPersistentTimerHandler; as a result, ThreadData struct renamed
-	  UpdateData; updateDockapp now takes UpdateData as an argument
+2015-04-19  Doug Torrance <dtorrance at monmouthcollege.edu>
+	* switched timer handler from pthread to WING's native WMAddPersistent-
+	  TimerHandler, resulting in numerous changes:
 	* configure.ac: removed check for pthread
+	* wmforecast.c (UpdateData): struct formerly known as ThreadData, added
+	  long int minutesLeft (keeps track of the number of minutes until the
+	  next refresh)
+	* wmforecast.c (updateDockapp): now takes UpdateData struct as argument
+	  instead of WMScreen, Dockapp, and Preferences (for passing via timer
+	  and event handlers); added "loading" text while downloading new data
+	* wmforecast.c (timerHandler): counts down number of minutes until next
+	  refresh (needed because WMAddPersistentTimerHandler fails when
+	  milliseconds argument too large, e.g., one hour)
 	* wmforecast.c: changed all calls to malloc and realloc to use WINGs's
 	  native wmalloc and wrealloc
-	* wmforecast.c (updateDockapp): added "loading" text while downloading
-	  new weather data
-	* wmforecast.c (refresh, main): new function, refreshes weather data
-	  when icon double clicked
+	* wmforecast.c (refresh): new function, refreshes weather data when icon
+	  double clicked
 
 2015-04-17  Doug Torrance <dtorrance at monmouthcollege.edu>
 	* wmforecast.c: improved error handling -- Weather struct now contains
diff --git a/config.h.in b/config.h.in
index d603f40..56e14e7 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,8 +1,5 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
-/* Define to 1 if you have the `pthread' library (-lpthread). */
-#undef HAVE_LIBPTHREAD
-
 /* Define to 1 if you have the `WINGs' library (-lWINGs). */
 #undef HAVE_LIBWINGS
 
diff --git a/wmforecast.c b/wmforecast.c
index 714b20c..bde3a88 100755
--- a/wmforecast.c
+++ b/wmforecast.c
@@ -67,6 +67,7 @@ typedef struct {
 	WMScreen *screen;
 	Dockapp *dockapp;
 	Preferences *prefs;
+	long int minutesLeft;
 } UpdateData;
 
 Forecast *newForecast()
@@ -607,15 +608,27 @@ UpdateData *newUpdateData(WMScreen *screen, Dockapp *dockapp, Preferences *prefs
 	data->screen = screen;
 	data->dockapp = dockapp;
 	data->prefs = prefs;
+	data->minutesLeft = prefs->interval;
 	return data;
 }
-	
+
 static void refresh(XEvent *event, void *data)
 {
 	if (WMIsDoubleClick(event) && event->xbutton.button == Button1) 
 		updateDockapp(data);
 }
 
+static void timerHandler(void *data)
+{
+	UpdateData *d = (UpdateData *)data;
+	
+	d->minutesLeft--;
+	if (d->minutesLeft == 0) {
+		d->minutesLeft = d->prefs->interval;
+		updateDockapp(data);
+	}
+}
+
 int main(int argc, char **argv)
 {
 	Display *display;
@@ -637,8 +650,8 @@ int main(int argc, char **argv)
 			     refresh, data);
 
 	updateDockapp(data);
-	WMAddPersistentTimerHandler(1000*60*prefs->interval,
-				    updateDockapp, data);
+	WMAddPersistentTimerHandler(60*1000, //one minute
+				    timerHandler, data);
 
 	WMScreenMainLoop(screen);
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmforecast.git



More information about the Pkg-wmaker-commits mailing list