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

git pushed a commit to branch master
in repository enlightenment-module-forecasts.

View the commit online.

commit efb02330296aa7e1f672a92cfaa5dc6aba03477f
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Mon Feb 23 12:26:40 2026 +0000

    add extra 3 days ahead forecast option
    
    from thrice - adding an option for an extra 3 days in a row added to
    the popup for forecasts.
---
 src/e_mod_config.c |  31 +++++++++++++--
 src/e_mod_main.c   | 112 ++++++++++++++++++++++++++++++++++++++++++-----------
 src/e_mod_main.h   |   2 +
 3 files changed, 120 insertions(+), 25 deletions(-)

diff --git a/src/e_mod_config.c b/src/e_mod_config.c
index e810355..0bd66c4 100644
--- a/src/e_mod_config.c
+++ b/src/e_mod_config.c
@@ -7,6 +7,7 @@ struct _E_Config_Dialog_Data
    double           poll_time;
    int              display;
    int              degrees;
+   Eina_Bool        extra_days;
    int              location_id;
    char            *location;
    char            *lat;
@@ -51,6 +52,7 @@ _fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
 {
    cfdata->poll_time = (ci->poll_time / 60.0);
    cfdata->degrees = ci->degrees;
+   cfdata->extra_days = ci->extra_days;
    if (ci->location)
      cfdata->location = strdup(ci->location);
    if (ci->lat)
@@ -228,7 +230,7 @@ static Evas_Object *
 _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
                       E_Config_Dialog_Data *cfdata)
 {
-   Evas_Object *win, *o, *tb, *bx, *fr;
+   Evas_Object *win, *o, *tb, *bx, *fr, *ck;
    Evas_Object *rec, *sl, *rg, *rd, *glist;
    Eina_List *list;
    Elm_Object_Item *it, *sel = NULL;
@@ -268,10 +270,32 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
    fr = elm_frame_add(win);
    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0);
-   elm_object_text_set(fr, D_("Unit Settings"));
+   elm_object_text_set(fr, D_("Extra Days"));
    evas_object_show(fr);
    elm_table_pack(tb, fr, 0, 1, 1, 1);
 
+   bx = elm_box_add(win);
+   evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0);
+   evas_object_show(bx);
+   elm_object_content_set(fr, bx);
+
+   ck = elm_check_add(win);
+   evas_object_size_hint_weight_set(ck, 1.0, 0);
+   evas_object_size_hint_align_set(ck, 0.0, 1.0);
+   elm_object_text_set(ck, D_("Show 3 extra days?"));
+   elm_check_state_pointer_set(ck, &cfdata->extra_days);
+   evas_object_show(ck);
+   evas_object_smart_callback_add(ck, "changed", _radio_changed_cb, cfd);
+   elm_box_pack_end(bx, ck);
+
+   fr = elm_frame_add(win);
+   evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, 0);
+   elm_object_text_set(fr, D_("Unit Settings"));
+   evas_object_show(fr);
+   elm_table_pack(tb, fr, 0, 2, 1, 1);
+
    bx = elm_box_add(win);
    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0); 
@@ -307,7 +331,7 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_object_text_set(fr, D_("Location"));
    evas_object_show(fr);
-   elm_table_pack(tb, fr, 0, 2, 1, 1);
+   elm_table_pack(tb, fr, 0, 3, 1, 1);
 
    tb = elm_table_add(win);
    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
@@ -372,6 +396,7 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
    ci = cfd->data;
 
    ci->degrees = cfdata->degrees;
+   ci->extra_days = cfdata->extra_days;
    ci->poll_time = (cfdata->poll_time * 60.0);
    if (ci->location)
      eina_stringshare_del(ci->location);
diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index 8755f6e..c0f3522 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -353,6 +353,7 @@ _forecasts_config_item_get(const char *id)
    ci->lat = ci->lon = 0;
    ci->show_text = 1;
    ci->popup_on_hover = 1;
+   ci->extra_days = 0;
 
    forecasts_config->items = eina_list_append(forecasts_config->items, ci);
    return ci;
@@ -388,6 +389,7 @@ e_modapi_init(E_Module *m)
    E_CONFIG_VAL(D, T, location, STR);
    E_CONFIG_VAL(D, T, lat, STR);
    E_CONFIG_VAL(D, T, lon, STR);
+   E_CONFIG_VAL(D, T, extra_days, INT);
 
    conf_edd = E_CONFIG_DD_NEW("Forecasts_Config", Config);
 #undef T
@@ -408,6 +410,7 @@ e_modapi_init(E_Module *m)
         ci->id = eina_stringshare_add("0");
         ci->show_text = 1;
         ci->popup_on_hover = 1;
+        ci->extra_days = 0;
 
         forecasts_config->items = eina_list_append(forecasts_config->items, ci);
      }
@@ -626,8 +629,9 @@ _forecasts_parse(void *data)
 
    for (int i = 0; i < FORECASTS; i++)
      {
-        inst->forecast[i].high = TEMP_MIN_OUT_OF_RANGE;
-        inst->forecast[i].low =  TEMP_MAX_OUT_OF_RANGE;
+        inst->forecast[i].high = (int)TEMP_MIN_OUT_OF_RANGE - 1;  /* -238, safely < MIN */
+        inst->forecast[i].low  = (int)TEMP_MAX_OUT_OF_RANGE + 1;  /* 191, safely > MAX */
+        inst->forecast[i].code[0] = '\0';
      }
    now = time(NULL);
    tm_local = localtime(&now);
@@ -669,13 +673,8 @@ _forecasts_parse(void *data)
         if ((days != days_prev) && days == (days_prev + 1))
           idx++;
 
-        if (idx > 1) break;
-        else if (idx == 0)
-          {
-             strftime(inst->forecast[idx].date, 12, "%d %b %Y", tm_data);
-             strncpy(inst->forecast[idx].day, weekdays[tm_data->tm_wday], 3);
-          }
-        else if (idx == 1)
+        if (idx >= FORECASTS) break;
+        else if (idx < FORECASTS)
           {
              strftime(inst->forecast[idx].date, 12, "%d %b %Y", tm_data);
              strncpy(inst->forecast[idx].day, weekdays[tm_data->tm_wday], 3);
@@ -716,19 +715,53 @@ _forecasts_parse(void *data)
                }
 
              json_object *o_next = json_object_object_get(o_data, "next_1_hours");
-             json_object *o_summary = json_object_object_get(o_next, "summary");
-             code = json_object_get_string(json_object_object_get(o_summary, "symbol_code"));
-             snprintf(inst->condition.code, sizeof(inst->condition.code), "%s", code);
-             snprintf(inst->forecast[idx].code, sizeof(inst->condition.code), "%s", code);
+             if (o_next)
+               {
+                  json_object *o_summary = json_object_object_get(o_next, "summary");
+                  if (o_summary)
+                    {
+                       code = json_object_get_string(json_object_object_get(o_summary, "symbol_code"));
+                       if (code)
+                         {
+                            snprintf(inst->condition.code, sizeof(inst->condition.code), "%s", code);
+                            snprintf(inst->forecast[idx].code, sizeof(inst->forecast[idx].code), "%s", code);
+                         }
+                    }
+               }
           }
 
         if (tm_data->tm_hour == 8)
           {
              // XXX We need TZ data.
              json_object *o_next = json_object_object_get(o_data, "next_12_hours");
-             json_object *o_summary = json_object_object_get(o_next, "summary");
-             code = json_object_get_string(json_object_object_get(o_summary, "symbol_code"));
-             snprintf(inst->forecast[idx].code, sizeof(inst->condition.code), "%s", code);
+             if (o_next)
+               {
+                  json_object *o_summary = json_object_object_get(o_next, "summary");
+                  if (o_summary)
+                    {
+                       code = json_object_get_string(json_object_object_get(o_summary, "symbol_code"));
+                       if (code)
+                         snprintf(inst->forecast[idx].code, sizeof(inst->forecast[idx].code), "%s", code);
+                    }
+               }
+          }
+
+        /* Fallback: if this entry still has no icon, try period sources in order */
+        if (inst->forecast[idx].code[0] == '\0')
+          {
+             json_object *o_next = json_object_object_get(o_data, "next_12_hours");
+             if (!o_next) o_next = json_object_object_get(o_data, "next_6_hours");
+             if (!o_next) o_next = json_object_object_get(o_data, "next_1_hours");
+             if (o_next)
+               {
+                  json_object *o_summary = json_object_object_get(o_next, "summary");
+                  if (o_summary)
+                    {
+                       code = json_object_get_string(json_object_object_get(o_summary, "symbol_code"));
+                       if (code && code[0] != '\0')
+                         snprintf(inst->forecast[idx].code, sizeof(inst->forecast[idx].code), "%s", code);
+                    }
+               }
           }
 
         days_prev = days;
@@ -771,8 +804,12 @@ _forecasts_converter(Instance *inst)
    _forecasts_convert_pressures(&inst->details.atmosphere.pressure, dir);
    for (i = 0; i < FORECASTS; i++)
      {
-        _forecasts_convert_degrees(&inst->forecast[i].low, dir);
-        _forecasts_convert_degrees(&inst->forecast[i].high, dir);
+        if (inst->forecast[i].low > TEMP_MIN_OUT_OF_RANGE &&
+            inst->forecast[i].low < TEMP_MAX_OUT_OF_RANGE)
+          _forecasts_convert_degrees(&inst->forecast[i].low, dir);
+        if (inst->forecast[i].high > TEMP_MIN_OUT_OF_RANGE &&
+            inst->forecast[i].high < TEMP_MAX_OUT_OF_RANGE)
+          _forecasts_convert_degrees(&inst->forecast[i].high, dir);
      }
 }
 
@@ -846,14 +883,14 @@ _forecasts_display_set(Instance *inst, int ok EINA_UNUSED)
              edje_object_part_text_set(inst->forecasts->forecasts_obj, name, inst->forecast[i].desc);
 
              snprintf(name, sizeof(name), "e.text.day%d.high", i);
-             if (inst->forecast[i].high != TEMP_MIN_OUT_OF_RANGE && inst->forecast[i].high != TEMP_MAX_OUT_OF_RANGE)
+             if (inst->forecast[i].high > TEMP_MIN_OUT_OF_RANGE && inst->forecast[i].high < TEMP_MAX_OUT_OF_RANGE)
                snprintf(buf, sizeof(buf), "%d°%c", inst->forecast[i].high, inst->units.temp);
              else
                snprintf(buf, sizeof(buf), "N/A");
              edje_object_part_text_set(inst->forecasts->forecasts_obj, name, buf);
 
              snprintf(name, sizeof(name), "e.text.day%d.low", i);
-             if (inst->forecast[i].low != TEMP_MIN_OUT_OF_RANGE && inst->forecast[i].low != TEMP_MAX_OUT_OF_RANGE)
+             if (inst->forecast[i].low > TEMP_MIN_OUT_OF_RANGE && inst->forecast[i].low < TEMP_MAX_OUT_OF_RANGE)
                snprintf(buf, sizeof(buf), "%d°%c", inst->forecast[i].low, inst->units.temp);
              else
                snprintf(buf, sizeof(buf), "N/A");
@@ -951,7 +988,7 @@ _day_hi_lo_add(Evas_Object *base, const char *day, int lo, int hi, char unit, co
   elm_table_pack(tb, o, 0, 1, 1, 2);
   evas_object_show(o);
 
-  if ((hi != TEMP_MIN_OUT_OF_RANGE) && (hi != TEMP_MAX_OUT_OF_RANGE))
+  if ((hi > TEMP_MIN_OUT_OF_RANGE) && (hi < TEMP_MAX_OUT_OF_RANGE))
     snprintf(buf, sizeof(buf), "%i°%c", hi, unit);
   else
     snprintf(buf, sizeof(buf), D_("N/A"));
@@ -959,7 +996,7 @@ _day_hi_lo_add(Evas_Object *base, const char *day, int lo, int hi, char unit, co
   evas_object_size_hint_align_set(o, 0.0, 0.5);
   elm_table_pack(tb, o, 1, 1, 1, 1);
 
-  if ((lo != TEMP_MIN_OUT_OF_RANGE) && (lo != TEMP_MAX_OUT_OF_RANGE))
+  if ((lo > TEMP_MIN_OUT_OF_RANGE) && (lo < TEMP_MAX_OUT_OF_RANGE))
     snprintf(buf, sizeof(buf), "%i°%c", lo, unit);
   else
     snprintf(buf, sizeof(buf), D_("N/A"));
@@ -1116,6 +1153,37 @@ _forecasts_popup_content_create(Instance *inst)
    elm_box_pack_end(hbx, fr);
    evas_object_show(fr);
 
+   if (inst->ci->extra_days)
+     {
+        int i;
+
+        sp = elm_separator_add(base);
+        elm_separator_horizontal_set(sp, EINA_TRUE);
+        evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
+        evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
+        elm_box_pack_end(bx, sp);
+        evas_object_show(sp);
+
+        hbx = elm_box_add(base);
+        evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+        evas_object_size_hint_align_set(hbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
+        elm_box_horizontal_set(hbx, EINA_TRUE);
+        elm_box_homogeneous_set(hbx, EINA_TRUE);
+        elm_box_pack_end(bx, hbx);
+        evas_object_show(hbx);
+
+        for (i = 2; i < FORECASTS; i++)
+          {
+             fr = _day_hi_lo_add(base, inst->forecast[i].day,
+                                 inst->forecast[i].low,
+                                 inst->forecast[i].high,
+                                 inst->units.temp,
+                                 inst->forecast[i].code);
+             elm_box_pack_end(hbx, fr);
+             evas_object_show(fr);
+          }
+     }
+
    e_gadcon_popup_content_set(inst->popup, bx);
 }
 
diff --git a/src/e_mod_main.h b/src/e_mod_main.h
index e867224..72cc83a 100644
--- a/src/e_mod_main.h
+++ b/src/e_mod_main.h
@@ -40,6 +40,8 @@ struct _Config_Item
    int location_id;
    const char *location;
    const char *lat, *lon;
+
+   int extra_days;
 };
 
 EAPI extern E_Module_Api e_modapi;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to