Switch from GPLv2 to GPLv2+
[fw/altos] / ao-tools / ao-view / aoview_log.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; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #include "aoview.h"
20
21 static struct aoview_file       *aoview_log;
22
23 void
24 aoview_log_new(void)
25 {
26         aoview_file_finish(aoview_log);
27         aoview_state_new();
28 }
29
30 void
31 aoview_log_set_serial(int serial)
32 {
33         aoview_file_set_serial(aoview_log, serial);
34 }
35
36 int
37 aoview_log_get_serial(void)
38 {
39         return aoview_file_get_serial(aoview_log);
40 }
41
42 void
43 aoview_log_set_flight(int flight)
44 {
45         aoview_file_set_flight(aoview_log, flight);
46 }
47
48 int
49 aoview_log_get_flight(void)
50 {
51         return aoview_file_get_flight(aoview_log);
52 }
53
54 void
55 aoview_log_printf(char *format, ...)
56 {
57         va_list ap;
58
59         va_start(ap, format);
60         aoview_file_vprintf(aoview_log, format, ap);
61         va_end(ap);
62 }
63
64 static void
65 aoview_log_new_item(GtkWidget *widget, gpointer data)
66 {
67         aoview_file_finish(aoview_log);
68 }
69
70 void
71 aoview_log_init(GladeXML *xml)
72 {
73         GtkWidget       *log_new;
74
75         aoview_log = aoview_file_new("telem");
76         assert(aoview_log);
77
78         log_new = glade_xml_get_widget(xml, "log_new");
79         assert(log_new);
80         g_signal_connect(G_OBJECT(log_new), "activate",
81                          G_CALLBACK(aoview_log_new_item),
82                          NULL);
83 }