altos: Switch ao_rssi.c __xdata to __pdata
[fw/altos] / ao-tools / ao-view / aoview_main.c
1 /*
2  * Copyright © 2009 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #include "aoview.h"
19
20 static const char aoview_glade[] = {
21 #include "aoview_glade.h"
22 };
23
24 static void usage(void) {
25         printf("aoview [--device|-d device_file]");
26         exit(1);
27 }
28
29 static void destroy_event(GtkWidget *widget, gpointer data)
30 {
31         gtk_main_quit();
32 }
33
34 char *aoview_tty = NULL;
35
36 int main(int argc, char **argv)
37 {
38         GladeXML *xml = NULL;
39         GtkWidget *mainwindow;
40         GtkAboutDialog *about_dialog;
41
42         static struct option long_options[] = {
43                 { "tty", 1, 0, 'T'},
44                 { 0, 0, 0, 0 }
45         };
46         for (;;) {
47                 int c, temp;
48
49                 c = getopt_long_only(argc, argv, "T:", long_options, &temp);
50                 if (c == -1)
51                         break;
52
53                 switch (c) {
54                 case 'T':
55                         aoview_tty = optarg;
56                         break;
57                 default:
58                         usage();
59                 }
60         }
61
62         g_thread_init(NULL);
63         gtk_init(&argc, &argv);
64         glade_init();
65
66         xml = glade_xml_new_from_buffer(aoview_glade, sizeof (aoview_glade), NULL, NULL);
67
68         /* connect the signals in the interface */
69         glade_xml_signal_autoconnect(xml);
70
71         /* Hook up the close button. */
72         mainwindow = glade_xml_get_widget(xml, "aoview");
73         assert(mainwindow);
74
75         g_signal_connect (G_OBJECT(mainwindow), "destroy",
76             G_CALLBACK(destroy_event), NULL);
77
78         about_dialog = GTK_ABOUT_DIALOG(glade_xml_get_widget(xml, "about_dialog"));
79         assert(about_dialog);
80         gtk_about_dialog_set_version(about_dialog, AOVIEW_VERSION);
81
82         aoview_voice_init(xml);
83
84         aoview_channel_init(xml);
85
86         aoview_dev_dialog_init(xml);
87
88         aoview_state_init(xml);
89
90         aoview_file_init(xml);
91
92         aoview_log_init(xml);
93
94         aoview_table_init(xml);
95
96         aoview_eeprom_init(xml);
97
98         aoview_replay_init(xml);
99
100         aoview_label_init(xml);
101
102         if (aoview_tty) {
103                 if (!aoview_monitor_connect(aoview_tty)) {
104                         perror(aoview_tty);
105                         exit(1);
106                 }
107         }
108         aoview_voice_speak("rocket flight monitor ready\n");
109
110         gtk_main();
111
112         return 0;
113 }