2013-07-20 01:51:56 -07:00
# include <Elementary.h>
# include "common.h"
struct statusbar_s
{
Evas_Object * layout ;
2013-09-18 09:43:10 -07:00
Eina_Stringshare * group_name ;
2013-08-24 10:41:53 -07:00
config_data * cd ;
2013-07-20 01:51:56 -07:00
} ;
void
stats_line_num_update ( stats_data * sd , int cur_line , int max_line )
{
char buf [ 128 ] ;
2013-09-20 04:20:26 -07:00
if ( DARK_THEME )
snprintf ( buf , sizeof ( buf ) ,
2013-09-20 05:43:22 -07:00
" <align=right>Line [<style=glow><color=#3399ff>%d</color></style>:<style=glow><color=#3399ff>%d</color></style>]</align> " , cur_line , max_line ) ;
2013-09-20 04:20:26 -07:00
else
snprintf ( buf , sizeof ( buf ) ,
" <align=right>Line [<color=#000000>%d</color>:<color=#000000>%d</color>]</align> " , cur_line , max_line ) ;
2013-07-20 01:51:56 -07:00
elm_object_part_text_set ( sd - > layout , " elm.text.line " , buf ) ;
}
void
2013-09-18 09:43:10 -07:00
stats_edc_file_set ( stats_data * sd , Eina_Stringshare * group_name )
2013-07-20 01:51:56 -07:00
{
char buf [ PATH_MAX ] ;
2013-08-24 10:41:53 -07:00
const char * filename = ecore_file_file_get ( config_edc_path_get ( sd - > cd ) ) ;
2013-09-20 04:20:26 -07:00
if ( DARK_THEME )
2013-09-20 05:43:22 -07:00
snprintf ( buf , sizeof ( buf ) , " <align=right>File [<style=glow><color=#3399ff>%s</color></style>] Group [<style=glow><color=#3399ff>%s</color></style>]</align> " , filename , group_name ) ;
2013-09-20 04:20:26 -07:00
else
snprintf ( buf , sizeof ( buf ) , " <align=right>File [<color=#000000>%s</color>] Group [<color=#000000>%s</color>]</align> " , filename , group_name ) ;
2013-07-20 01:51:56 -07:00
elm_object_part_text_set ( sd - > layout , " elm.text.file_group_name " , buf ) ;
2013-09-18 09:43:10 -07:00
sd - > group_name = eina_stringshare_add ( group_name ) ;
2013-07-20 01:51:56 -07:00
}
stats_data *
2013-08-24 10:41:53 -07:00
stats_init ( Evas_Object * parent , config_data * cd )
2013-07-20 01:51:56 -07:00
{
stats_data * sd = calloc ( 1 , sizeof ( stats_data ) ) ;
Evas_Object * layout = elm_layout_add ( parent ) ;
elm_layout_file_set ( layout , EDJE_PATH , " statusbar_layout " ) ;
evas_object_show ( layout ) ;
//FIXME: temporarily setup
2013-09-20 04:20:26 -07:00
if ( DARK_THEME )
elm_object_part_text_set ( layout , " elm.text.cur_pos " ,
2013-09-20 05:43:22 -07:00
" Cursor [<style=glow><color=#3399ff>0</color></style>,<style=glow><color=#3399ff>0</color></style>], [<style=glow><color=#3399ff>0.00</color></style>,<style=glow><color=#3399ff>0.00</color></style>] " ) ;
2013-09-20 04:20:26 -07:00
else
elm_object_part_text_set ( layout , " elm.text.cur_pos " ,
" Cursor [<color=#000000>0</color>,<color=#000000>0</color>] [<color=#000000>0.00</color>,<color=#000000>0.00</color>] " ) ;
2013-07-20 01:51:56 -07:00
sd - > layout = layout ;
2013-08-24 10:41:53 -07:00
sd - > cd = cd ;
2013-07-20 01:51:56 -07:00
stats_edc_file_set ( sd , NULL ) ;
return sd ;
}
Evas_Object *
stats_obj_get ( stats_data * sd )
{
return sd - > layout ;
}
2013-09-18 09:43:10 -07:00
Eina_Stringshare * stats_group_name_get ( stats_data * sd )
{
return sd - > group_name ;
}
2013-07-20 01:51:56 -07:00
void
stats_term ( stats_data * sd )
{
2013-07-25 09:31:49 -07:00
if ( ! sd ) return ;
2013-09-18 09:43:10 -07:00
eina_stringshare_del ( sd - > group_name ) ;
2013-07-20 01:51:56 -07:00
free ( sd ) ;
}
void
stats_info_msg_update ( stats_data * sd , const char * msg )
{
2013-08-24 10:41:53 -07:00
if ( ! config_stats_bar_get ( sd - > cd ) ) return ;
2013-07-20 13:30:49 -07:00
2013-07-20 01:51:56 -07:00
elm_object_part_text_set ( sd - > layout , " elm.text.info_msg " , msg ) ;
elm_object_signal_emit ( sd - > layout , " elm,action,info_msg,show " , " " ) ;
}
void
stats_view_size_update ( stats_data * sd )
{
Evas_Coord w , h ;
2013-08-24 10:41:53 -07:00
config_view_size_get ( sd - > cd , & w , & h ) ;
2013-07-20 01:51:56 -07:00
char buf [ 128 ] ;
2013-09-20 04:20:26 -07:00
if ( DARK_THEME )
snprintf ( buf , sizeof ( buf ) ,
2013-09-20 05:43:22 -07:00
" Size [<style=glow><color=#3399ff>%d</color></style>x<style=glow><color=#3399ff>%d</color></style>] " , w , h ) ;
2013-09-20 04:20:26 -07:00
else
snprintf ( buf , sizeof ( buf ) ,
" Size [<color=#000000>%d</color>x<color=#000000>%d</color>] " , w , h ) ;
2013-07-20 01:51:56 -07:00
elm_object_part_text_set ( sd - > layout , " elm.text.view_size " , buf ) ;
}
void
stats_cursor_pos_update ( stats_data * sd , Evas_Coord x , Evas_Coord y , float rel_x , float rel_y )
{
char buf [ 128 ] ;
2013-09-20 04:20:26 -07:00
if ( DARK_THEME )
snprintf ( buf , sizeof ( buf ) ,
2013-09-20 05:43:22 -07:00
" Cursor [<style=glow><color=#3399ff>%d</color>,<color=#3399ff>%d</color>] [<color=#3399ff>%0.2f</color>,<color=#3399ff>%0.2f</color>] " , x , y , rel_x , rel_y ) ;
2013-09-20 04:20:26 -07:00
else
snprintf ( buf , sizeof ( buf ) ,
" Cursor [<color=#000000>%d</color>,<color=#000000>%d</color>] [<color=#000000>%0.2f</color>,<color=#000000>%0.2f</color>] " , x , y , rel_x , rel_y ) ;
2013-07-20 01:51:56 -07:00
elm_object_part_text_set ( sd - > layout , " elm.text.cur_pos " , buf ) ;
}