[Xfce4-commits] <xfce4-weather-plugin:master> Add parameter to get_timeslice() to store the index.

Harald Judt noreply at xfce.org
Sun Dec 9 23:44:17 CET 2012


Updating branch refs/heads/master
         to 9a6b1f82ebe0152ba6d56222a595d3331269c102 (commit)
       from 2d984af0c2c53a8a55327bd25d771c244f3de758 (commit)

commit 9a6b1f82ebe0152ba6d56222a595d3331269c102
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun Dec 9 19:24:29 2012 +0100

    Add parameter to get_timeslice() to store the index.
    
    If the calling function provides an address, store the index of the timeslice
    found in it so that it can be accessed later. If no timeslice was found,
    this value will be undefined, so the calling function has to check whether
    get_timeslice() returned NULL.

 panel-plugin/weather-data.c    |    8 ++++----
 panel-plugin/weather-parsers.c |   10 +++++++---
 panel-plugin/weather-parsers.h |    3 ++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index 101274d..2d8f797 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -444,10 +444,10 @@ make_combined_timeslice(xml_weather *wd,
     guint i;
 
     /* find point data at start of interval (may not be available) */
-    start = get_timeslice(wd, interval->start, interval->start);
+    start = get_timeslice(wd, interval->start, interval->start, NULL);
 
     /* find point interval at end of interval */
-    end = get_timeslice(wd, interval->end, interval->end);
+    end = get_timeslice(wd, interval->end, interval->end, NULL);
 
     if (start == NULL && end == NULL)
         return NULL;
@@ -597,7 +597,7 @@ find_timeslice(xml_weather *wd,
             start_t = time_calc_hour(start_tm, 0 - hours);
             end_t = time_calc_hour(end_tm, 0 - hours);
 
-            if ((timeslice = get_timeslice(wd, start_t, end_t)))
+            if ((timeslice = get_timeslice(wd, start_t, end_t, NULL)))
                 return timeslice;
         }
 
@@ -606,7 +606,7 @@ find_timeslice(xml_weather *wd,
             start_t = time_calc_hour(start_tm, hours);
             end_t = time_calc_hour(end_tm, hours);
 
-            if ((timeslice = get_timeslice(wd, start_t, end_t)))
+            if ((timeslice = get_timeslice(wd, start_t, end_t, NULL)))
                 return timeslice;
         }
         hours++;
diff --git a/panel-plugin/weather-parsers.c b/panel-plugin/weather-parsers.c
index c48a4c1..0b1cac5 100644
--- a/panel-plugin/weather-parsers.c
+++ b/panel-plugin/weather-parsers.c
@@ -74,7 +74,8 @@ my_timegm(struct tm *tm)
 xml_time *
 get_timeslice(xml_weather *wd,
               const time_t start_t,
-              const time_t end_t)
+              const time_t end_t,
+              guint *index)
 {
     xml_time *timeslice;
     guint i;
@@ -82,8 +83,11 @@ get_timeslice(xml_weather *wd,
     for (i = 0; i < wd->timeslices->len; i++) {
         timeslice = g_array_index(wd->timeslices, xml_time*, i);
         if (timeslice &&
-            timeslice->start == start_t && timeslice->end == end_t)
+            timeslice->start == start_t && timeslice->end == end_t) {
+            if (index != NULL)
+                *index = i;
             return timeslice;
+        }
     }
     return NULL;
 }
@@ -244,7 +248,7 @@ parse_time(xmlNode *cur_node,
         return;
 
     /* look for existing timeslice or add a new one */
-    timeslice = get_timeslice(wd, start_t, end_t);
+    timeslice = get_timeslice(wd, start_t, end_t, NULL);
     if (! timeslice) {
         timeslice = make_timeslice();
         if (G_UNLIKELY(!timeslice))
diff --git a/panel-plugin/weather-parsers.h b/panel-plugin/weather-parsers.h
index 4782aac..53116d8 100644
--- a/panel-plugin/weather-parsers.h
+++ b/panel-plugin/weather-parsers.h
@@ -141,7 +141,8 @@ xml_timezone *parse_timezone(xmlNode *cur_node);
 
 xml_time *get_timeslice(xml_weather *wd,
                         const time_t start_t,
-                        const time_t end_t);
+                        const time_t end_t,
+                        guint *index);
 
 xmlDoc *get_xml_document(SoupMessage *msg);
 


More information about the Xfce4-commits mailing list