2 * Created by Rob Williams - 10 Aug 2008
4 * This file is part of Maemo Mapper.
6 * Maemo Mapper is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Maemo Mapper is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Maemo Mapper. If not, see <http://www.gnu.org/licenses/>.
27 #include "aprs_display.h"
28 #include "aprs_message.h"
37 #include <dbus/dbus-glib.h>
39 #include <gconf/gconf-client.h>
42 # include <hildon/hildon-help.h>
43 # include <hildon/hildon-note.h>
44 # include <hildon/hildon-color-button.h>
45 # include <hildon/hildon-file-chooser-dialog.h>
46 # include <hildon/hildon-number-editor.h>
47 # include <hildon/hildon-banner.h>
49 # include <osso-helplib.h>
50 # include <hildon-widgets/hildon-note.h>
51 # include <hildon-widgets/hildon-color-button.h>
52 # include <hildon-widgets/hildon-file-chooser-dialog.h>
53 # include <hildon-widgets/hildon-number-editor.h>
54 # include <hildon-widgets/hildon-banner.h>
55 # include <hildon-widgets/hildon-input-mode-hint.h>
64 #include "gdk-pixbuf-rotate.h"
71 extern AprsDataRow *n_first;
73 typedef struct _AprsStationSelectInfo AprsStationSelectInfo;
74 struct _AprsStationSelectInfo
82 static AprsStationSelectInfo selected_station;
86 double convert_lat_l2d(long lat);
87 double convert_lon_l2d(long lon);
88 static gboolean panto_station(GtkWidget *widget, AprsStationSelectInfo *aprs_station_sel);
90 void convert_temp_f_to_c(gchar * f, gchar ** c)
97 // Convert fahrenheit to fahrenheit (double)
98 df = g_ascii_strtod ( f, (gchar*)(f + strlen(f)));
101 dc = 5*((df - 32.0)/9);
103 // Convert fc to celsius
104 snprintf(*c, 8, "%0.1f°C", dc);
107 void setup_aprs_basic_wx_display_page(GtkWidget *notebook, AprsDataRow *p_station)
113 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
114 table = gtk_table_new(4/*rows*/, 4/*columns*/, FALSE/*All cells same size*/),
115 label = gtk_label_new(_("WX")));
118 gchar last_update_time[26];
120 gtk_table_attach(GTK_TABLE(table),
121 label = gtk_label_new("Updated:"),
122 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
123 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
127 if(p_station->weather_data && p_station->weather_data->wx_sec_time)
129 strftime(last_update_time, 25, "%x %X", localtime(&p_station->weather_data->wx_sec_time));
133 snprintf(last_update_time, 25, " ");
136 gtk_table_attach(GTK_TABLE(table),
137 label = gtk_label_new( last_update_time ),
138 1, 4, 0, 1, GTK_EXPAND |GTK_FILL, 0, 2, 4);
139 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
145 gtk_table_attach(GTK_TABLE(table),
146 label = gtk_label_new("Temp:"),
147 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
148 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
151 if(p_station->weather_data && p_station->weather_data->wx_temp)
153 convert_temp_f_to_c(p_station->weather_data->wx_temp, &temp);
160 gtk_table_attach(GTK_TABLE(table),
161 label = gtk_label_new( temp ),
162 1, 2, 1, 2, GTK_FILL, 0, 2, 4);
163 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
169 gtk_table_attach(GTK_TABLE(table),
170 label = gtk_label_new( (p_station->weather_data->wx_storm ? "SEVERE STORM" : "") ),
171 2, 4, 1, 2, GTK_EXPAND |GTK_FILL, 0, 2, 4);
172 gtk_misc_set_alignment(GTK_MISC(label), 0.5f, 0.5f);
177 gtk_table_attach(GTK_TABLE(table),
178 label = gtk_label_new( "Wind course:" ),
179 0, 1, 2, 3, GTK_FILL, 0, 2, 4);
180 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
182 snprintf(course, 6, "%0.f°",
183 g_ascii_strtod (p_station->weather_data->wx_course, p_station->weather_data->wx_course + strlen(p_station->weather_data->wx_course))
185 gtk_table_attach(GTK_TABLE(table),
186 label = gtk_label_new( course ),
187 1, 2, 2, 3, GTK_FILL, 0, 2, 4);
188 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
194 gtk_table_attach(GTK_TABLE(table),
195 label = gtk_label_new( "Wind speed:" ),
196 2, 3, 2, 3, GTK_FILL, 0, 2, 4);
197 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
199 snprintf(speed, 14, "%0.f->%0.f MPH",
200 g_ascii_strtod (p_station->weather_data->wx_speed, p_station->weather_data->wx_speed + strlen(p_station->weather_data->wx_speed)),
201 g_ascii_strtod (p_station->weather_data->wx_gust, p_station->weather_data->wx_gust + strlen(p_station->weather_data->wx_gust))
203 gtk_table_attach(GTK_TABLE(table),
204 label = gtk_label_new( speed ),
205 3, 4, 2, 3, GTK_FILL, 0, 2, 4);
206 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
213 gchar rain_total[17];
215 gtk_table_attach(GTK_TABLE(table),
216 label = gtk_label_new( "Rain fall:" ),
217 0, 1, 3, 4, GTK_FILL, 0, 2, 4);
218 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
220 if(p_station->weather_data->wx_rain)
222 snprintf(rain_ph, 16, "%0.f \"/hr",
223 g_ascii_strtod (p_station->weather_data->wx_rain, p_station->weather_data->wx_rain + strlen(p_station->weather_data->wx_rain))
228 snprintf(rain_ph, 1, " ");
230 gtk_table_attach(GTK_TABLE(table),
231 label = gtk_label_new( rain_ph ),
232 1, 2, 3, 4, GTK_FILL, 0, 2, 4);
233 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
236 gtk_table_attach(GTK_TABLE(table),
237 label = gtk_label_new( "Total:" ),
238 2, 3, 3, 4, GTK_FILL, 0, 2, 4);
239 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
241 if(p_station->weather_data->wx_rain_total)
243 snprintf(rain_total, 16, "%0.f \"",
244 g_ascii_strtod (p_station->weather_data->wx_rain_total, p_station->weather_data->wx_rain_total + strlen(p_station->weather_data->wx_rain_total))
249 snprintf(rain_total, 1, " ");
251 gtk_table_attach(GTK_TABLE(table),
252 label = gtk_label_new( rain_total ),
253 3, 4, 3, 4, GTK_FILL, 0, 2, 4);
254 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
260 char wx_hurricane_radius[4]; //nautical miles 3
261 char wx_trop_storm_radius[4]; //nautical miles 3
262 char wx_whole_gale_radius[4]; // nautical miles 3
263 char wx_snow[6]; // in inches/24h 3
264 char wx_prec_24[10]; // in hundredths inch/day 3
265 char wx_prec_00[10]; // in hundredths inch 3
266 char wx_hum[5]; // in % 3
267 char wx_baro[10]; // in hPa 6
268 char wx_fuel_temp[5]; // in °F 3
269 char wx_fuel_moisture[5];// in % 2
271 char wx_station[MAX_WXSTATION];
276 void setup_aprs_moving_display_page(GtkWidget *notebook, AprsDataRow *p_station)
281 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
282 table = gtk_table_new(4/*rows*/, 4/*columns*/, FALSE/*All cells same size*/),
283 label = gtk_label_new(_("Moving")));
287 gtk_table_attach(GTK_TABLE(table),
288 label = gtk_label_new("Speed:"),
289 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
290 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
295 // snprintf(speed, sizeof(speed), "%.01f %s", atof(p_station->speed) * UNITS_CONVERT[_units],
296 // UNITS_ENUM_TEXT[_units]);
298 if(_units == UNITS_NM)
299 snprintf(speed, sizeof(speed), "%.01f nmph", atof(p_station->speed));
300 else if(_units == UNITS_KM)
301 snprintf(speed, sizeof(speed), "%.01f kph", atof(p_station->speed)*1.852);
302 else if(_units == UNITS_MI)
303 snprintf(speed, sizeof(speed), "%.01f mph", atof(p_station->speed)*1.1508);
306 gtk_table_attach(GTK_TABLE(table),
307 label = gtk_label_new( speed ),
308 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
309 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
314 gtk_table_attach(GTK_TABLE(table),
315 label = gtk_label_new("Course:"),
316 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
317 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
320 gtk_table_attach(GTK_TABLE(table),
321 label = gtk_label_new( p_station->course ),
322 1, 2, 1, 2, GTK_FILL, 0, 2, 4);
323 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
326 gtk_table_attach(GTK_TABLE(table),
327 label = gtk_label_new("Alt (m):"),
328 0, 1, 2, 3, GTK_FILL, 0, 2, 4);
329 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
332 gtk_table_attach(GTK_TABLE(table),
333 label = gtk_label_new( p_station->altitude ),
334 1, 2, 2, 3, GTK_FILL, 0, 2, 4);
335 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
338 gtk_table_attach(GTK_TABLE(table),
339 label = gtk_label_new("Bearing:"),
340 0, 1, 3, 4, GTK_FILL, 0, 2, 4);
341 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
344 gtk_table_attach(GTK_TABLE(table),
345 label = gtk_label_new( p_station->bearing ),
346 1, 2, 3, 4, GTK_FILL, 0, 2, 4);
349 GdkPixmap *pixmap=gdk_pixmap_new(table->window,100,100,16);
350 //gdk_drawable_set_colormap (pixmap,gdk_colormap_get_system ());
353 GtkWidget *image = NULL;
357 gc = gdk_gc_new(pixmap);
362 gdk_gc_set_foreground(gc, &color);
367 gdk_gc_set_background(gc, &color);
370 gdk_gc_set_line_attributes(gc, _draw_width, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
381 gdouble heading = deg2rad(atof(p_station->course));
382 gint y = (gint)(48.0 * cosf(heading) );
383 gint x = (gint)(48.0 * sinf(heading) );
391 gtk_table_attach(GTK_TABLE(table),
392 image = gtk_image_new_from_pixmap(pixmap, NULL),
393 2, 3, 0, 4, GTK_FILL, 0, 2, 4);
394 //2, 3, 0, 4, GTK_SHRINK, GTK_SHRINK, 2, 4);
395 gtk_misc_set_alignment(GTK_MISC(image), 1.0f, 0.5f);
398 // g_object_unref(image);
399 // gdk_pixmap_unref(pixmap);
405 void setup_aprs_station_stats_page(GtkWidget *notebook, AprsDataRow *p_station)
410 gchar lat[15], lon[15];
414 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
415 table = gtk_table_new(4/*rows*/, 5/*columns*/, FALSE/*All cells same size*/),
416 label = gtk_label_new(_("Location")));
420 course_deg[0] = '\0';
426 if(p_station->coord_lat != 0 || p_station->coord_lon != 0)
428 gdouble d_lat = convert_lat_l2d(p_station->coord_lat);
429 gdouble d_lon = convert_lon_l2d(p_station->coord_lon);
431 format_lat_lon(d_lat, d_lon, lat, lon);
433 gfloat dist = (float)calculate_distance(_gps.lat, _gps.lon, d_lat, d_lon);
436 snprintf(distance, sizeof(distance), "%.01f %s", dist * UNITS_CONVERT[_units], UNITS_ENUM_TEXT[_units]);
438 snprintf(course_deg, sizeof(course_deg),
440 calculate_bearing(_gps.lat, _gps.lon, d_lat, d_lon));
444 gchar last_update_time[26];
446 gtk_table_attach(GTK_TABLE(table),
447 label = gtk_label_new("Last Heard:"),
448 0, 1, 4, 5, GTK_FILL, 0, 2, 4);
449 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
453 if(p_station->sec_heard)
455 strftime(last_update_time, 25, "%x %X", localtime(&p_station->sec_heard));
459 snprintf(last_update_time, 25, " ");
462 gtk_table_attach(GTK_TABLE(table),
463 label = gtk_label_new( last_update_time ),
464 1, 4, 4, 5, GTK_FILL, 0, 2, 4);
465 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
470 gtk_table_attach(GTK_TABLE(table),
471 label = gtk_label_new("Location:"),
472 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
473 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
475 gtk_table_attach(GTK_TABLE(table),
476 label = gtk_label_new( lat ),
477 1, 3, 1, 2, GTK_EXPAND |GTK_FILL, 0, 2, 4);
478 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
480 gtk_table_attach(GTK_TABLE(table),
481 label = gtk_label_new( lon ),
482 3, 5, 1, 2, GTK_EXPAND |GTK_FILL, 0, 2, 4);
483 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
487 gtk_table_attach(GTK_TABLE(table),
488 label = gtk_label_new(""),
489 0, 5, 2, 3, GTK_FILL, 0, 2, 4);
490 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
494 gtk_table_attach(GTK_TABLE(table),
495 label = gtk_label_new("Distance:"),
496 0, 1, 3, 4, GTK_FILL, 0, 2, 4);
497 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
499 gtk_table_attach(GTK_TABLE(table),
500 label = gtk_label_new( distance ),
501 1, 2, 3, 4, GTK_FILL, 0, 2, 4);
502 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
506 gtk_table_attach(GTK_TABLE(table),
507 label = gtk_label_new("Bearing:"),
508 2, 4, 3, 4, GTK_EXPAND |GTK_FILL, 0, 2, 4);
509 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
511 gtk_table_attach(GTK_TABLE(table),
512 label = gtk_label_new( course_deg ),
513 4, 5, 3, 4, GTK_FILL, 0, 2, 4);
514 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
522 void setup_aprs_basic_display_page(GtkWidget *notebook, AprsDataRow *p_station)
527 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
528 table = gtk_table_new(5/*rows*/, 5/*columns*/, FALSE/*All cells same size*/),
529 label = gtk_label_new(_("Basic")));
534 gtk_table_attach(GTK_TABLE(table),
535 label = gtk_label_new("Callsign:"),
536 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
537 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
541 gtk_table_attach(GTK_TABLE(table),
542 label = gtk_label_new( p_station->call_sign ),
543 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
544 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
547 GdkPixbuf *pixbuf = NULL;
549 gint symbol_column = 0;
551 gint symbol_size = 0;
553 extract_aprs_symbol(p_station->aprs_symbol.aprs_symbol, p_station->aprs_symbol.aprs_type, &pixbuf,
560 GdkPixmap *pixmap=gdk_pixmap_new(table->window,symbol_size,symbol_size,16);
563 // We found an icon to draw.
568 symbol_size*symbol_column, symbol_size*symbol_row,
571 symbol_size, symbol_size,
572 GDK_RGB_DITHER_NONE, 0, 0);
573 g_object_unref(pixbuf);
577 gtk_table_attach(GTK_TABLE(table),
578 image = gtk_image_new_from_pixmap(pixmap, NULL),
579 2, 3, 0, 1, GTK_FILL, 0, 2, 4);
580 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
582 gtk_table_attach(GTK_TABLE(table),
583 label = gtk_label_new("Packets:"),
584 3, 4, 0, 1, GTK_FILL, 0, 2, 4);
585 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
589 snprintf(packets, 4, "%u", p_station->num_packets);
591 gtk_table_attach(GTK_TABLE(table),
592 label = gtk_label_new( packets ),
593 4, 5, 0, 1, GTK_FILL, 0, 2, 4);
594 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
596 gtk_table_attach(GTK_TABLE(table),
597 label = gtk_label_new("Comment:"),
598 0, 1, 1, 3, GTK_FILL, 0, 2, 4);
599 gtk_misc_set_alignment(GTK_MISC(label ), 1.f, 0.5f);
601 gchar * comment = NULL;
604 if(p_station->comment_data && p_station->comment_data->text_ptr)
606 comment = g_strdup(p_station->comment_data->text_ptr);
610 comment = g_strdup("");
613 gtk_table_attach(GTK_TABLE(table),
614 label = gtk_label_new(comment),
615 1, 5, 1, 3, GTK_EXPAND |GTK_FILL, 0, 2, 4);
616 gtk_misc_set_alignment(GTK_MISC(label ), 0.f, 0.5f);
617 gtk_label_set_width_chars(label, 30);
623 gtk_table_attach(GTK_TABLE(table),
624 label = gtk_label_new("Status:"),
625 0, 1, 3, 4, GTK_FILL, 0, 2, 4);
626 gtk_misc_set_alignment(GTK_MISC(label ), 1.f, 0.5f);
628 gchar * status = NULL;
631 if(p_station->status_data && p_station->status_data->text_ptr)
633 status = g_strdup(p_station->status_data->text_ptr);
637 status = g_strdup("");
640 gtk_table_attach(GTK_TABLE(table),
641 label = gtk_label_new(status),
642 1, 5, 3, 4, GTK_FILL, 0, 2, 4);
643 gtk_misc_set_alignment(GTK_MISC(label ), 0.f, 0.5f);
648 gtk_table_attach(GTK_TABLE(table),
649 label = gtk_label_new("Path:"),
650 0, 1, 4, 5, GTK_FILL, 0, 2, 4);
651 gtk_misc_set_alignment(GTK_MISC(label ), 1.f, 0.5f);
655 if(p_station->node_path_ptr)
657 path = g_strdup(p_station->node_path_ptr);
664 gtk_table_attach(GTK_TABLE(table),
665 label = gtk_label_new(path),
666 1, 5, 4, 5, GTK_FILL, 0, 2, 4);
667 gtk_misc_set_alignment(GTK_MISC(label ), 0.f, 0.5f);
676 void ShowAprsStationPopup(AprsDataRow *p_station)
678 GtkWidget *dialog = NULL;
679 GtkWidget *notebook = NULL;
680 GtkWidget *btn_panto = NULL;
682 dialog = gtk_dialog_new_with_buttons(_("Station Details"),
683 GTK_WINDOW(_window), GTK_DIALOG_MODAL,
684 GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT,
685 // "Send Message...", GTK_RESPONSE_ACCEPT,
689 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
690 btn_panto = gtk_button_new_with_mnemonic(_("C_entre Map...")));
693 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
694 notebook = gtk_notebook_new(), TRUE, TRUE, 0);
697 selected_station.dialog = NULL;
698 selected_station.tree_view = NULL;
699 selected_station.column_index = 0;
700 selected_station.call_sign = p_station->call_sign;
702 g_signal_connect(G_OBJECT(btn_panto), "clicked",
703 G_CALLBACK(panto_station), &selected_station);
706 setup_aprs_basic_display_page(notebook, p_station);
709 if(p_station->weather_data )
710 setup_aprs_basic_wx_display_page(notebook, p_station);
714 if( ( p_station->flag & ST_MOVING) == ST_MOVING){
715 setup_aprs_moving_display_page(notebook, p_station);
720 setup_aprs_station_stats_page(notebook, p_station);
722 gtk_widget_show_all(dialog);
723 gtk_dialog_run(GTK_DIALOG(dialog));
724 gtk_widget_hide(dialog);
735 static GtkWidget *dialog = NULL;
736 static GtkWidget *list = NULL;
737 static GtkWidget *sw = NULL;
738 static GtkWidget *btn_panto = NULL;
739 static GtkTreeViewColumn *column = NULL;
740 static GtkCellRenderer *renderer = NULL;
741 GtkListStore *store = NULL;
743 gint station_count = 0;
747 printf("%s()\n", __PRETTY_FUNCTION__);
755 STATION_DISTANCE_NUM,
759 /* Initialize store. */
760 store = gtk_list_store_new(STATION_NUM_COLUMNS,
765 G_TYPE_DOUBLE);/* Category Label */
767 AprsDataRow *p_station = n_first;
769 while ( (p_station) != NULL)
773 gchar * comment = NULL;
774 gchar * callsign = g_strdup(p_station->call_sign);
776 gchar * formatted_distance = NULL;
777 gdouble distance = 0;
779 course_deg[0] = '\0';
782 if(p_station->coord_lat != 0 && p_station->coord_lon != 0)
784 distance = distance_from_my_station(callsign, course_deg, sizeof(course_deg));
786 if(_units == UNITS_KM)
787 formatted_distance = g_strdup_printf("%.01f km", distance);
788 else if(_units == UNITS_MI)
789 formatted_distance = g_strdup_printf("%.01f miles", distance);
790 else if(_units == UNITS_NM)
791 formatted_distance = g_strdup_printf("%.01f nm", distance);
795 formatted_distance = g_strdup_printf("");
798 if(p_station->comment_data) comment = g_strdup(p_station->comment_data->text_ptr);
799 else comment = g_strdup("");
802 gtk_list_store_append(store, &iter);
803 gtk_list_store_set(store, &iter,
804 STATION_CALLSIGN, callsign,
805 STATION_DISTANCE, formatted_distance,
806 STATION_BEARING, course_deg,
807 STATION_COMMENT, comment,
808 STATION_DISTANCE_NUM, distance,
814 g_free(formatted_distance);
816 (p_station) = (p_station)->n_next; // Next element in list
817 } // End of while loop
819 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), STATION_DISTANCE_NUM, GTK_SORT_ASCENDING);
825 dialog = gtk_dialog_new_with_buttons(_("Stations"),
826 GTK_WINDOW(_window), GTK_DIALOG_MODAL,
827 "Details", GTK_RESPONSE_ACCEPT,
828 GTK_STOCK_CLOSE, GTK_RESPONSE_REJECT,
832 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
833 btn_panto = gtk_button_new_with_mnemonic(_("C_entre Map...")));
837 gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
839 sw = gtk_scrolled_window_new (NULL, NULL);
841 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
842 GTK_SHADOW_ETCHED_IN);
843 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
845 GTK_POLICY_AUTOMATIC);
846 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
849 list = gtk_tree_view_new();
850 gtk_container_add(GTK_CONTAINER(sw), list);
852 gtk_tree_selection_set_mode(
853 gtk_tree_view_get_selection(GTK_TREE_VIEW(list)),
854 GTK_SELECTION_SINGLE);
855 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), TRUE);
859 renderer = gtk_cell_renderer_text_new();
860 column = gtk_tree_view_column_new_with_attributes(
861 _("Callsign"), renderer, "text", STATION_CALLSIGN, NULL);
862 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
865 renderer = gtk_cell_renderer_text_new();
866 column = gtk_tree_view_column_new_with_attributes(
867 _("Distance"), renderer, "text", STATION_DISTANCE, NULL);
868 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
871 renderer = gtk_cell_renderer_text_new();
872 column = gtk_tree_view_column_new_with_attributes(
873 _("Bearing"), renderer, "text", STATION_BEARING, NULL);
874 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
878 renderer = gtk_cell_renderer_text_new();
879 column = gtk_tree_view_column_new_with_attributes(
880 _("Comment"), renderer, "text", STATION_COMMENT, NULL);
881 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
885 selected_station.dialog = dialog;
886 selected_station.tree_view = list;
887 selected_station.call_sign = NULL;
888 selected_station.column_index = STATION_CALLSIGN;
890 g_signal_connect(G_OBJECT(btn_panto), "clicked",
891 G_CALLBACK(panto_station), &selected_station);
895 gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(store));
896 g_object_unref(G_OBJECT(store));
900 gchar *title = g_strdup_printf("Stations (Total: %u)", station_count);
901 gtk_window_set_title(GTK_WINDOW(dialog), title);
904 gtk_widget_show_all(dialog);
906 while(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog)))
909 if(gtk_tree_selection_get_selected(
910 gtk_tree_view_get_selection(GTK_TREE_VIEW(list)),
915 while(p_station != NULL)
917 gchar * callsign = NULL;
918 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
919 STATION_CALLSIGN, &(callsign),
922 if(strcmp(p_station->call_sign,callsign) == 0)
924 ShowAprsStationPopup(p_station);
930 p_station = p_station->n_next;
939 gtk_widget_hide(dialog);
941 vprintf("%s(): return %d\n", __PRETTY_FUNCTION__, selected);
948 send_message(GtkWidget *widget)
950 fprintf(stderr, "Send message...");
955 panto_station(GtkWidget *widget, AprsStationSelectInfo *aprs_station_selected)
959 GtkTreeSelection *selection;
960 gchar * callsign = NULL;
961 AprsDataRow *p_station = n_first;
964 printf("%s()\n", __PRETTY_FUNCTION__);
967 if(aprs_station_selected->call_sign != NULL)
968 callsign = aprs_station_selected->call_sign;
971 store = gtk_tree_view_get_model(GTK_TREE_VIEW(aprs_station_selected->tree_view));
972 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(aprs_station_selected->tree_view));
974 if(gtk_tree_selection_get_selected(selection, &store, &iter))
977 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
978 aprs_station_selected->column_index, &(callsign),
984 // Now findout the location of callsign
987 while(p_station != NULL)
989 if(strcmp(p_station->call_sign,callsign) == 0)
991 if(p_station->coord_lat == 0 && p_station->coord_lon == 0)
997 gdouble d_lat = convert_lat_l2d(p_station->coord_lat);
998 gdouble d_lon = convert_lon_l2d(p_station->coord_lon);
1002 latlon2unit(d_lat, d_lon, unit.unitx, unit.unity);
1004 if(_center_mode > 0)
1005 gtk_check_menu_item_set_active(
1006 GTK_CHECK_MENU_ITEM(_menu_view_ac_none_item), TRUE);
1008 map_center_unit(unit);
1017 p_station = p_station->n_next;
1022 vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
1026 void list_messages()
1028 static GtkWidget *dialog = NULL;
1029 // static GtkWidget *btn_send = NULL;
1030 static GtkWidget *list = NULL;
1031 static GtkWidget *sw = NULL;
1032 static GtkTreeViewColumn *column = NULL;
1033 static GtkCellRenderer *renderer = NULL;
1034 GtkListStore *store = NULL;
1038 printf("%s()\n", __PRETTY_FUNCTION__);
1049 /* Initialize store. */
1050 store = gtk_list_store_new(MSG_NUM_COLUMNS,
1057 // Loop through each message
1060 for (i = 0; i < msg_index_end; i++)
1062 gtk_list_store_append(store, &iter);
1063 gtk_list_store_set(store, &iter,
1064 MSG_FROM, msg_data[msg_index[i]].from_call_sign,
1065 MSG_TO, msg_data[msg_index[i]].call_sign,
1066 MSG_TEXT, msg_data[msg_index[i]].message_line,
1067 MSG_TIMESTAMP, (gdouble)msg_data[msg_index[i]].sec_heard,
1072 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), MSG_TIMESTAMP, GTK_SORT_ASCENDING);
1076 dialog = gtk_dialog_new_with_buttons(_("Messages"),
1077 GTK_WINDOW(_window), GTK_DIALOG_MODAL,
1078 GTK_STOCK_CLOSE, GTK_RESPONSE_REJECT,
1081 gtk_window_set_default_size(GTK_WINDOW(dialog), 550, 300);
1083 // gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
1084 // btn_send = gtk_button_new_with_label(_("Send...")));
1086 // g_signal_connect(G_OBJECT(btn_send), "clicked",
1087 // G_CALLBACK(send_message), dialog);
1089 sw = gtk_scrolled_window_new (NULL, NULL);
1091 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
1092 GTK_SHADOW_ETCHED_IN);
1093 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
1095 GTK_POLICY_AUTOMATIC);
1096 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
1100 list = gtk_tree_view_new();
1101 gtk_container_add(GTK_CONTAINER(sw), list);
1103 gtk_tree_selection_set_mode(
1104 gtk_tree_view_get_selection(GTK_TREE_VIEW(list)),
1105 GTK_SELECTION_SINGLE);
1106 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), TRUE);
1110 renderer = gtk_cell_renderer_text_new();
1111 column = gtk_tree_view_column_new_with_attributes(
1112 _("From"), renderer, "text", MSG_FROM, NULL);
1113 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
1115 renderer = gtk_cell_renderer_text_new();
1116 column = gtk_tree_view_column_new_with_attributes(
1117 _("To"), renderer, "text", MSG_TO, NULL);
1118 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
1120 renderer = gtk_cell_renderer_text_new();
1121 column = gtk_tree_view_column_new_with_attributes(
1122 _("Message"), renderer, "text", MSG_TEXT, NULL);
1123 gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
1128 gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(store));
1129 g_object_unref(G_OBJECT(store));
1132 gtk_widget_show_all(dialog);
1134 while(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog)))
1138 gtk_widget_hide(dialog);
1140 vprintf("%s(): return %d\n", __PRETTY_FUNCTION__, selected);
1144 #endif //INCLUDE_APRS