Update to yahoo new xml format and add option to allow popup on mouse click

SVN revision: 33192
This commit is contained in:
Eric Schuele 2007-12-21 18:39:19 +00:00
parent d91348748c
commit 8deda34e2a
3 changed files with 29 additions and 10 deletions

View File

@ -8,6 +8,7 @@ struct _E_Config_Dialog_Data
int degrees;
char *code;
int show_text;
int popup_on_hover;
};
static void *_create_data(E_Config_Dialog * cfd);
@ -50,6 +51,7 @@ _fill_data(Config_Item * ci, E_Config_Dialog_Data * cfdata)
if (ci->code)
cfdata->code = strdup(ci->code);
cfdata->show_text = ci->show_text;
cfdata->popup_on_hover = ci->popup_on_hover;
}
static void *
@ -94,6 +96,8 @@ _basic_create_widgets(E_Config_Dialog * cfd, Evas * evas,
e_widget_framelist_object_append(of, ob);
ob = e_widget_check_add(evas, D_("Show Description"), &(cfdata->show_text));
e_widget_framelist_object_append(of, ob);
ob = e_widget_check_add(evas, _("Popup on mouse over"), &(cfdata->popup_on_hover));
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, D_("Unit Settings"), 0);
@ -142,6 +146,7 @@ _basic_apply_data(E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
*t = toupper(*t);
ci->code = evas_stringshare_add(t);
ci->show_text = cfdata->show_text;
ci->popup_on_hover = cfdata->popup_on_hover;
e_config_save_queue();
_forecasts_config_updated(ci);

View File

@ -362,7 +362,8 @@ _forecasts_config_item_get(const char *id)
ci->host = evas_stringshare_add("xml.weather.yahoo.com");
ci->code = evas_stringshare_add("BUXX0005");
ci->show_text = 1;
ci->popup_on_hover = 1;
forecasts_config->items = evas_list_append(forecasts_config->items, ci);
return ci;
}
@ -393,6 +394,7 @@ e_modapi_init(E_Module * m)
E_CONFIG_VAL(D, T, host, STR);
E_CONFIG_VAL(D, T, code, STR);
E_CONFIG_VAL(D, T, show_text, INT);
E_CONFIG_VAL(D, T, popup_on_hover, INT);
conf_edd = E_CONFIG_DD_NEW("Forecasts_Config", Config);
#undef T
@ -415,6 +417,7 @@ e_modapi_init(E_Module * m)
ci->code = evas_stringshare_add("BUXX0005");
ci->id = evas_stringshare_add("0");
ci->show_text = 1;
ci->popup_on_hover = 1;
forecasts_config->items = evas_list_append(forecasts_config->items, ci);
}
@ -646,7 +649,7 @@ _forecasts_parse(void *data)
char city[256];
char region[256];
char location[512];
int visibility;
float visibility;
int i;
inst = data;
@ -694,7 +697,7 @@ _forecasts_parse(void *data)
sscanf(needle, "\"%3[^\"]\"", inst->units.speed);
/* Current conditions */
needle = strstr(inst->buffer, "<yweather:condition text=");
needle = strstr(inst->buffer, "<yweather:condition text=");
if (!needle) goto error;
needle = strstr(needle, "\"");
sscanf(needle, "\"%255[^\"]\"", inst->condition.desc);
@ -734,8 +737,8 @@ _forecasts_parse(void *data)
needle = strstr(needle, "visibility=\"");
if (!needle) goto error;
needle = strstr(needle, "\"");
sscanf(needle, "\"%d\"", &visibility);
inst->details.atmosphere.visibility = (float) visibility / 100;
sscanf(needle, "\"%f\"", &visibility);
inst->details.atmosphere.visibility = visibility;
needle = strstr(needle, "pressure=\"");
if (!needle) goto error;
needle = strstr(needle, "\"");
@ -1068,13 +1071,19 @@ _forecasts_popup_destroy(Instance *inst)
e_object_del(E_OBJECT(inst->popup));
}
static void
static void
_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Instance *inst;
Evas_Event_Mouse_Down *ev;
inst = data;
if (!(inst = data)) return;
if (!inst->ci->popup_on_hover)
{
e_gadcon_popup_show(inst->popup);
return;
}
ev = event_info;
if (ev->button == 1)
{
@ -1086,17 +1095,21 @@ static void
_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Instance *inst;
if (!(inst = data)) return;
if (!inst->ci->popup_on_hover) return;
e_gadcon_popup_show(inst->popup);
}
static void
static void
_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Instance *inst;
if (!(inst = data)) return;
if (inst->popup->pinned) return;
e_gadcon_popup_hide(inst->popup);
}

View File

@ -27,6 +27,7 @@ struct _Config_Item
int degrees;
const char *host, *code;
int show_text;
int popup_on_hover;
};
EAPI extern E_Module_Api e_modapi;