From: Enlightenment S. <no-...@en...> - 2010-07-23 21:29:28
|
Log: Better user details window Fix time to use localtime instead Author: rui Date: 2010-07-23 14:29:17 -0700 (Fri, 23 Jul 2010) New Revision: 50462 Modified: trunk/elmdentica/src/elmdentica.c trunk/elmdentica/src/elmdentica.h trunk/elmdentica/src/twitter.c Modified: trunk/elmdentica/src/elmdentica.c =================================================================== --- trunk/elmdentica/src/elmdentica.c 2010-07-23 19:19:08 UTC (rev 50461) +++ trunk/elmdentica/src/elmdentica.c 2010-07-23 21:29:17 UTC (rev 50462) @@ -509,6 +509,8 @@ if(user) { if(user->name) free(user->name); if(user->tmp) free(user->tmp); + if(user->text) free(user->text); + if(user->created_at) free(user->created_at); free(user); } @@ -516,7 +518,7 @@ static void on_handle_user(void *data, Evas_Object *obj, void *event_info) { AnchorData *anchor = (AnchorData*)data; - Evas_Object *icon=NULL, *bg=NULL, *table=NULL, *button=NULL, *buttons=NULL, *label=NULL, *bubble=anchor->bubble; + Evas_Object *icon=NULL, *bg=NULL, *table=NULL, *button=NULL, *buttons=NULL, *label=NULL, *bubble=anchor->bubble, *message=NULL; UserProfile *user; ub_Bubble * ubBubble = eina_hash_find(status2user, &bubble); char *description=NULL,*home, *path=NULL; @@ -618,6 +620,25 @@ elm_table_pack(table, buttons, 1, 1, 1, 1); evas_object_show(buttons); + if(user->text) { + button = elm_bubble_add(url_win); + evas_object_size_hint_weight_set(button, 1, 1); + evas_object_size_hint_align_set(button, -1, 0); + + elm_bubble_label_set(button, user->screen_name); + if(user->created_at) elm_bubble_info_set(button, user->created_at); + + message = elm_anchorblock_add(url_win); + elm_anchorblock_text_set(message, user->text); + evas_object_show(message); + + elm_bubble_content_set(button, message); + + elm_table_pack(table, button, 0, 2, 2, 1); + + evas_object_show(button); + } + evas_object_show(table); evas_object_resize(url_win, 300, 300); @@ -926,7 +947,7 @@ ub_Bubble * ubBubble = calloc(1, sizeof(ub_Bubble)); Evas_Object *message=NULL, *bubble=NULL, *icon=NULL; - struct tm *date_tm; + struct tm date_tm; char *tmp=NULL, datestr[19]; char * file_path=NULL, *home=NULL; @@ -957,9 +978,8 @@ elm_bubble_label_set(bubble, name); - date_tm = gmtime((time_t*)&date); - if(date_tm != NULL) { - strftime(datestr, sizeof(datestr), "%F %R", date_tm); + if(localtime_r((time_t*)&date, &date_tm)) { + strftime(datestr, sizeof(datestr), "%F %R", &date_tm); elm_bubble_info_set(bubble, datestr); } Modified: trunk/elmdentica/src/elmdentica.h =================================================================== --- trunk/elmdentica/src/elmdentica.h 2010-07-23 19:19:08 UTC (rev 50461) +++ trunk/elmdentica/src/elmdentica.h 2010-07-23 21:29:17 UTC (rev 50462) @@ -98,6 +98,8 @@ char *name; char *screen_name; char *description; + char *text; + char *created_at; char *tmp; Eina_Bool protected; int followers_count; Modified: trunk/elmdentica/src/twitter.c =================================================================== --- trunk/elmdentica/src/twitter.c 2010-07-23 19:19:08 UTC (rev 50461) +++ trunk/elmdentica/src/twitter.c 2010-07-23 21:29:17 UTC (rev 50462) @@ -421,7 +421,10 @@ } void json_user_show(UserProfile *user, char *stream) { - json_object *json_stream, *obj, *screen_name_obj; + json_object *json_stream, *obj, *screen_name_obj, *status_obj; + time_t t; + struct tm tm; + char datestr[19]; enum json_type json_stream_type; json_stream = json_tokener_parse(stream); @@ -481,6 +484,27 @@ user->followers_count = (int)json_object_get_int(obj); json_object_put(obj); } + + status_obj = json_object_object_get(json_stream, "status"); + if(status_obj) { + obj = json_object_object_get(status_obj, "text"); + if(obj) { + user->text = strndup(json_object_get_string(obj), PIPE_BUF); + json_object_put(obj); + } + + obj = json_object_object_get(status_obj, "created_at"); + if(obj) { + t = curl_getdate(json_object_get_string(obj), NULL); + + if(localtime_r((time_t*)&t, &tm)) { + strftime(datestr, sizeof(datestr), "%F %R", &tm); + user->created_at = strdup(datestr); + } + json_object_put(obj); + } + json_object_put(status_obj); + } } } json_object_put(json_stream); |