Enlightenment CVS committal
Author : devilhorns
Project : e_modules
Module : weather
Dir : e_modules/weather
Modified Files:
e_mod_config.c e_mod_main.c e_mod_main.h weather.edc
Log Message:
Many fixes.
In simple mode, remove the location label.
You may need to remove module.weather.cfg for these to work.
===================================================================
RCS file: /cvs/e/e_modules/weather/e_mod_config.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- e_mod_config.c 20 Mar 2006 20:35:59 -0000 1.3
+++ e_mod_config.c 28 Mar 2006 18:26:32 -0000 1.4
@@ -104,7 +104,7 @@
ob = e_widget_label_add(evas,
D_("http://www.weather.gov/tg/siteloc.shtml"));
e_widget_frametable_object_append(of, ob, 0, 2, 2, 1, 1, 0, 1, 0);
e_widget_list_object_append(o, of, 1, 1, 0.5);
-
+
return o;
}
@@ -112,8 +112,9 @@
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
Weather_Face *wf;
- int i, len;
+ int len;
char tmp[1024];
+ char buf[4096];
if (!cfdata->code)
return 0;
@@ -133,7 +134,16 @@
e_config_save_queue();
if (wf->check_timer)
ecore_timer_interval_set(wf->check_timer, (double)(wf->conf->poll_time));
-
- _weather_display_set(wf, 1);
+
+ if (wf->conf->display == DETAILED_DISPLAY)
+ edje_object_signal_emit(wf->weather_obj, "set_style", "detailed");
+ else
+ edje_object_signal_emit(wf->weather_obj, "set_style", "simple");
+
+ _weather_convert_degrees(wf);
+ snprintf(buf, sizeof(buf), "%d°%c",wf->temp, wf->degrees);
+ edje_object_part_text_set(wf->weather_obj, "temp", buf);
+
+ //_weather_display_set(wf, 1);
return 1;
}
===================================================================
RCS file: /cvs/e/e_modules/weather/e_mod_main.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- e_mod_main.c 21 Mar 2006 04:18:24 -0000 1.12
+++ e_mod_main.c 28 Mar 2006 18:26:32 -0000 1.13
@@ -18,7 +18,9 @@
static int _weather_server_del (void *data, int type,
void *event);
static int _weather_server_data (void *data, int type,
void *event);
static int _weather_parse (Weather_Face * wf);
-static void _weather_convert_degrees (Weather_Face * wf);
+static void _weather_face_menu_cb_face_new (void *data, E_Menu *m,
E_Menu_Item *mi);
+static void _weather_face_menu_cb_face_del (void *data, E_Menu *m,
E_Menu_Item *mi);
+static void _weather_display_set (Weather_Face * wf, int
ok);
static int weather_count;
static E_Config_DD *conf_edd;
@@ -129,7 +131,8 @@
_weather_new(void)
{
Weather *w;
- Evas_List *mans, *l, *l2, *fl;
+ Evas_List *fl;
+ E_Container *con;
char *env;
weather_count = 0;
@@ -147,7 +150,7 @@
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
E_CONFIG_VAL(D, T, display, INT);
E_CONFIG_VAL(D, T, degrees, INT);
- E_CONFIG_VAL(D, T, location, STR);
+ E_CONFIG_VAL(D, T, con, INT);
E_CONFIG_VAL(D, T, host, STR);
E_CONFIG_VAL(D, T, code, STR);
@@ -164,62 +167,83 @@
_weather_config_menu_new(w);
- mans = e_manager_list();
fl = w->conf->faces;
- for (l = mans; l; l = l->next)
+ if (!fl)
{
- E_Manager *man;
+ Weather_Face *wf;
- man = l->data;
- for (l2 = man->containers; l2; l2 = l2->next)
+ con = e_container_current_get(e_manager_current_get());
+ wf = _weather_face_init(w, con);
+ if (wf)
+ {
+ wf->conf = E_NEW(Config_Face, 1);
+ wf->conf->enabled = 1;
+ wf->conf->poll_time = 1800.0;
+ wf->conf->display = DETAILED_DISPLAY;
+ wf->conf->degrees = DEGREES_C;
+ wf->conf->con = con->num;
+ wf->conf->host = evas_stringshare_add("www.rssweather.com");
+ wf->conf->code = evas_stringshare_add("ENKR");
+ E_CONFIG_LIMIT(wf->conf->poll_time, 900.0, 3600.0);
+
+ w->conf->faces = evas_list_append(w->conf->faces, wf->conf);
+ e_config_save_queue();
+
+ wf->degrees = 'C';
+ edje_object_signal_emit(wf->weather_obj, "set_style", "detailed");
+ wf->loc_set = 0;
+ wf->check_timer = ecore_timer_add((double)wf->conf->poll_time,
_weather_face_cb_check, wf->weather);
+
+ if (!wf->conf->enabled)
+ _weather_face_disable(wf);
+ }
+ }
+ else
+ {
+ for (; fl; fl = fl->next)
{
- E_Container *con;
Weather_Face *wf;
+ Config_Face *conf;
- con = l2->data;
+ conf = fl->data;
+ con = e_util_container_number_get(conf->con);
+ if (!con)
+ continue;
wf = _weather_face_init(w, con);
- if (wf)
- {
- if (!fl)
- {
- wf->conf = E_NEW(Config_Face, 1);
- wf->conf->enabled = 1;
- wf->conf->poll_time = 1800.0;
- wf->conf->display = DETAILED_DISPLAY;
- wf->conf->degrees = DEGREES_C;
- wf->conf->host =
evas_stringshare_add("www.rssweather.com");
- wf->conf->location = evas_stringshare_add("Kirkenes
Lufthavn");
- //wf->conf->url =
evas_stringshare_add("/icao/ENKR/rss.php");
- wf->conf->code = evas_stringshare_add("ENKR");
- w->conf->faces = evas_list_append(w->conf->faces,
wf->conf);
- }
- else
- {
- wf->conf = fl->data;
- fl = fl->next;
- }
- E_CONFIG_LIMIT(wf->conf->poll_time, 900.0, 3600.0);
-
- _weather_face_menu_new(wf);
-
- E_Menu_Item *mi;
- mi = e_menu_item_new(w->config_menu);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi,
"enlightenment/configuration");
- e_menu_item_callback_set(mi, _weather_face_cb_menu_configure,
wf);
-
- mi = e_menu_item_new(w->config_menu);
- e_menu_item_label_set(mi, con->name);
- e_menu_item_submenu_set(mi, wf->menu);
-
- wf->check_timer =
ecore_timer_add((double)wf->conf->poll_time, _weather_face_cb_check,
wf->weather);
+ if (!wf)
+ continue;
+ wf->conf = conf;
+ E_CONFIG_LIMIT(wf->conf->poll_time, 900.0, 3600.0);
- if (!wf->conf->enabled)
- _weather_face_disable(wf);
+ switch (wf->conf->degrees)
+ {
+ case 0:
+ wf->degrees = 'F';
+ break;
+ case 1:
+ wf->degrees = 'C';
+ break;
+ }
+ switch (wf->conf->display)
+ {
+ case 0:
+ edje_object_signal_emit(wf->weather_obj, "set_style",
"simple");
+ break;
+ case 1:
+ edje_object_signal_emit(wf->weather_obj, "set_style",
"detailed");
+ break;
}
+
+ edje_object_signal_emit(wf->weather_obj, "set_style", "detailed");
+
+ wf->loc_set = 0;
+ wf->check_timer = ecore_timer_add((double)wf->conf->poll_time,
_weather_face_cb_check, wf->weather);
+
+ if (!wf->conf->enabled)
+ _weather_face_disable(wf);
}
}
-
+
env = getenv("http_proxy");
if (!env)
env = getenv("HTTP_PROXY");
@@ -249,6 +273,7 @@
w->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
_weather_server_add, w);
w->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
_weather_server_del, w);
w->data_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
_weather_server_data, w);
+
_weather_face_cb_check(w);
return w;
}
@@ -338,11 +363,32 @@
static void
_weather_face_menu_new(Weather_Face *wf)
{
- E_Menu *mn;
- E_Menu_Item *mi;
-
+ E_Menu *mn, *sn;
+ E_Menu_Item *mi, *si;
+
mn = e_menu_new();
wf->menu = mn;
+
+ sn = e_menu_new();
+
+ si = e_menu_item_new(sn);
+ e_menu_item_label_set(si, _("Add A Face"));
+ e_menu_item_callback_set(si, _weather_face_menu_cb_face_new, wf->weather);
+
+ if (evas_list_count(wf->weather->conf->faces) > 1)
+ {
+ si = e_menu_item_new(sn);
+ e_menu_item_label_set(si, _("Remove This Face"));
+ e_menu_item_callback_set(si, _weather_face_menu_cb_face_del, wf);
+ }
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Faces"));
+ e_menu_item_icon_file_set(mi, PACKAGE_DATA_DIR"/module_icon.png");
+ e_menu_item_submenu_set(mi, sn);
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_separator_set(mi, 1);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _("Configuration"));
@@ -352,11 +398,11 @@
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _("Edit Mode"));
e_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
- e_menu_item_callback_set(mi, _weather_face_cb_menu_edit, wf);
+ e_menu_item_callback_set(mi, _weather_face_cb_menu_edit, wf);
}
static void
-_weather_face_cb_menu_configure (void *data, E_Menu *mn, E_Menu_Item *mi)
+_weather_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
{
Weather_Face *wf;
@@ -414,8 +460,6 @@
if (wf->conf->host)
evas_stringshare_del(wf->conf->host);
- if (wf->conf->location)
- evas_stringshare_del(wf->conf->location);
if (wf->conf->code)
evas_stringshare_del(wf->conf->code);
@@ -434,6 +478,7 @@
ev = event_info;
if (ev->button == 3)
{
+ _weather_face_menu_new(wf);
e_menu_activate_mouse(wf->menu, e_zone_current_get(wf->con),
ev->output.x, ev->output.y, 1, 1,
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
@@ -520,7 +565,7 @@
if ((!wf) || (ev->server != wf->server))
return 1;
- snprintf(icao, sizeof(icao), "/icao/%s/rss.php", wf->conf->code);
+ snprintf(icao, sizeof(icao), "/icao/%s/rss.php", wf->conf->code);
snprintf(buf, sizeof(buf), "GET http://%s%s HTTP/1.1\r\nHost: %s\r\n\r\n",
wf->conf->host, icao, wf->conf->host);
ecore_con_server_send(wf->server, buf, strlen(buf));
@@ -601,20 +646,22 @@
_weather_parse(Weather_Face *wf)
{
char *needle, *ext;
-
+ char location[256];
+
needle = strstr(wf->buffer, "<title");
- if (needle)
+ if (!needle)
+ goto error;
+
+ needle = strstr(needle, ">");
+ sscanf(needle, ">%[^<]<", location);
+ if (location)
{
- needle = strstr(needle, ">");
- sscanf(needle, ">%[^<]<", wf->location);
- if (wf->location)
+ char *tmp = strdup(location);
+ if (strstr(tmp, ","))
{
- char *tmp = strdup(wf->location);
- if (strstr(tmp, ","))
- {
- tmp = strtok(tmp, ",");
- snprintf(wf->location, sizeof(wf->location), "%s", tmp);
- }
+ tmp = strtok(tmp, ",");
+ wf->location = strdup(tmp);
+ wf->loc_set = 1;
}
}
@@ -663,7 +710,7 @@
return 0;
}
-static void
+void
_weather_convert_degrees(Weather_Face *wf)
{
/* Check if degrees is in C or F */
@@ -679,15 +726,71 @@
}
}
-void
+static void
+_weather_face_menu_cb_face_new(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+ Weather *w;
+ Weather_Face *wf;
+ E_Container *con;
+
+ w = data;
+ if (!w)
+ return;
+
+ con = e_container_current_get(e_manager_current_get());
+ wf = _weather_face_init(w, con);
+ if (!wf)
+ return;
+
+ wf->conf = E_NEW(Config_Face, 1);
+ wf->conf->enabled = 1;
+ wf->conf->poll_time = 1800.0;
+ wf->conf->display = DETAILED_DISPLAY;
+ wf->conf->degrees = DEGREES_C;
+ wf->conf->con = con->num;
+ wf->conf->host = evas_stringshare_add("www.rssweather.com");
+ wf->conf->code = evas_stringshare_add("ENKR");
+ E_CONFIG_LIMIT(wf->conf->poll_time, 900.0, 3600.0);
+
+ w->conf->faces = evas_list_append(w->conf->faces, wf->conf);
+ e_config_save_queue();
+
+ wf->degrees = 'C';
+ wf->loc_set = 0;
+ wf->check_timer = ecore_timer_add((double)wf->conf->poll_time,
_weather_face_cb_check, wf->weather);
+
+ if (!wf->conf->enabled)
+ _weather_face_disable(wf);
+
+ _weather_face_cb_check(wf->weather);
+}
+
+static void
+_weather_face_menu_cb_face_del(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+ Weather *w;
+ Weather_Face *wf;
+
+ wf = data;
+ if (!wf)
+ return;
+
+ w = wf->weather;
+ if (!w)
+ return;
+
+ w->conf->faces = evas_list_remove(w->conf->faces, wf->conf);
+ e_config_save_queue();
+ _weather_face_free(wf);
+}
+
+static void
_weather_display_set(Weather_Face *wf, int ok)
{
char buf[4096];
if (!wf)
return;
-
- edje_object_part_text_set(wf->weather_obj, "location", wf->location);
if (wf->conf->display == DETAILED_DISPLAY)
edje_object_signal_emit(wf->weather_obj, "set_style", "detailed");
@@ -696,8 +799,10 @@
if (!ok)
{
- e_icon_file_set(wf->icon_obj, PACKAGE_DATA_DIR "/images/na.png");
+ snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/images/na.png");
+ e_icon_file_set(wf->icon_obj, buf);
edje_object_part_swallow(wf->weather_obj, "icon", wf->icon_obj);
+ edje_object_part_text_set(wf->weather_obj, "location", "");
edje_object_part_text_set(wf->weather_obj, "temp", "");
edje_object_part_text_set(wf->weather_obj, "conditions", "");
}
@@ -706,6 +811,7 @@
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/images/%s", wf->icon);
e_icon_file_set(wf->icon_obj, buf);
edje_object_part_swallow(wf->weather_obj, "icon", wf->icon_obj);
+ edje_object_part_text_set(wf->weather_obj, "location", wf->location);
snprintf(buf, sizeof(buf), "%d°%c",wf->temp, wf->degrees);
edje_object_part_text_set(wf->weather_obj, "temp", buf);
edje_object_part_text_set(wf->weather_obj, "conditions",
wf->conditions);
===================================================================
RCS file: /cvs/e/e_modules/weather/e_mod_main.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- e_mod_main.h 20 Mar 2006 19:59:56 -0000 1.7
+++ e_mod_main.h 28 Mar 2006 18:26:32 -0000 1.8
@@ -23,11 +23,10 @@
struct _Config_Face
{
double poll_time;
- int display, degrees;
+ int display, degrees, con;
const char *host;
- const char *location;
const char *code;
- unsigned char enabled;
+ unsigned char enabled;
};
struct _Weather
@@ -61,12 +60,12 @@
Ecore_Con_Server *server;
E_Gadman_Client *gmc;
- int temp;
+ int temp, loc_set;
char degrees;
char conditions[256];
char icon[256];
char *buffer;
- char location[256];
+ char *location;
int bufsize;
int cursize;
};
@@ -80,6 +79,6 @@
EAPI int e_modapi_about (E_Module *m);
EAPI int e_modapi_config (E_Module *m);
-void _weather_display_set(Weather_Face * wf, int ok);
+void _weather_convert_degrees(Weather_Face * wf);
#endif
===================================================================
RCS file: /cvs/e/e_modules/weather/weather.edc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- weather.edc 20 Mar 2006 00:54:07 -0000 1.4
+++ weather.edc 28 Mar 2006 18:26:32 -0000 1.5
@@ -78,7 +78,7 @@
font: "Vera Bold";
size: 14;
min: 1 1;
- align: 0.0 0.0;
+ align: 0.5 0.5;
}
}
}
@@ -118,6 +118,7 @@
description
{
state: "simple" 0.0;
+ visible: 0;
rel1
{
relative: 0.0 1.0;
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs