fixed errors on destroying util window
This commit is contained in:
parent
b0c97d889e
commit
e82a8b3630
|
@ -9,18 +9,11 @@
|
||||||
gboolean update_images(gpointer* pars){
|
gboolean update_images(gpointer* pars){
|
||||||
myParameters* parameters = (myParameters*) pars;
|
myParameters* parameters = (myParameters*) pars;
|
||||||
struct data_frame *df = TSB[0].first_data_frame;
|
struct data_frame *df = TSB[0].first_data_frame;
|
||||||
if(parameters->g_green_image == NULL){
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (parameters->util_map == NULL){
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (df == NULL){
|
if (df == NULL){
|
||||||
return FALSE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
int freq = to_intconvertor(df->dpmu[0]->freq);
|
int freq = to_intconvertor(df->dpmu[0]->freq);
|
||||||
gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
|
gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
|
||||||
if(parameters->util_map != NULL){
|
|
||||||
|
|
||||||
// if(parameters->g_last_image != 0){
|
// if(parameters->g_last_image != 0){
|
||||||
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
||||||
|
@ -28,7 +21,7 @@ gboolean update_images(gpointer* pars){
|
||||||
// if (freq > 300){
|
// if (freq > 300){
|
||||||
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
|
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
|
||||||
// }else{
|
// }else{
|
||||||
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
|
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
|
||||||
// }
|
// }
|
||||||
if(parameters->g_last_image != 0){
|
if(parameters->g_last_image != 0){
|
||||||
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
||||||
|
@ -38,8 +31,6 @@ gboolean update_images(gpointer* pars){
|
||||||
}else{
|
}else{
|
||||||
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
|
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
|
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
|
@ -17,6 +17,13 @@
|
||||||
// osm_gps_map_image_add(map, lat, lon, image);
|
// osm_gps_map_image_add(map, lat, lon, image);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// on closing the window kill the g_timeout_add
|
||||||
|
void on_window_destroy(GtkWidget *widget, gpointer data)
|
||||||
|
{
|
||||||
|
g_source_remove(GPOINTER_TO_UINT(data));
|
||||||
|
gtk_main_quit();
|
||||||
|
}
|
||||||
|
|
||||||
void utility_tools(GtkButton *but, gpointer udata)
|
void utility_tools(GtkButton *but, gpointer udata)
|
||||||
{
|
{
|
||||||
OsmGpsMap *util_map;
|
OsmGpsMap *util_map;
|
||||||
|
@ -41,7 +48,7 @@ void utility_tools(GtkButton *but, gpointer udata)
|
||||||
|
|
||||||
|
|
||||||
util_map = g_object_new (OSM_TYPE_GPS_MAP,
|
util_map = g_object_new (OSM_TYPE_GPS_MAP,
|
||||||
"map-source", OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID,
|
"map-source", OSM_GPS_MAP_SOURCE_OPENSTREETMAP,
|
||||||
"tile-cache", "/tmp/",
|
"tile-cache", "/tmp/",
|
||||||
NULL);
|
NULL);
|
||||||
osm_gps_map_set_center_and_zoom (util_map, 15.4589, 75.0078, 10);
|
osm_gps_map_set_center_and_zoom (util_map, 15.4589, 75.0078, 10);
|
||||||
|
@ -50,12 +57,12 @@ void utility_tools(GtkButton *but, gpointer udata)
|
||||||
g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image);
|
g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image);
|
||||||
myParameters parameters = {util_map, g_red_image, g_green_image, g_last_image};
|
myParameters parameters = {util_map, g_red_image, g_green_image, g_last_image};
|
||||||
gpointer data = (gpointer) ¶meters;
|
gpointer data = (gpointer) ¶meters;
|
||||||
g_timeout_add(20, (GSourceFunc) update_images, data);
|
guint pid = g_timeout_add(20, (GSourceFunc) update_images, data);
|
||||||
|
|
||||||
gtk_widget_set_size_request(GTK_WIDGET(util_map), 600, 500);
|
gtk_widget_set_size_request(GTK_WIDGET(util_map), 600, 500);
|
||||||
|
|
||||||
gtk_container_add(map_container, GTK_WIDGET(util_map));
|
gtk_container_add(map_container, GTK_WIDGET(util_map));
|
||||||
g_signal_connect(window, "destroy", G_CALLBACK(gtk_widget_destroy), NULL);
|
g_signal_connect(window, "destroy", G_CALLBACK(on_window_destroy), GUINT_TO_POINTER(pid));
|
||||||
|
|
||||||
gtk_widget_show_all(window);
|
gtk_widget_show_all(window);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
Loading…
Reference in New Issue