10 static void show_dive(int nr, struct dive *dive)
15 tm = gmtime(&dive->when);
17 printf("At %02d:%02d:%02d %04d-%02d-%02d (%d ft max, %d minutes)\n",
18 tm->tm_hour, tm->tm_min, tm->tm_sec,
19 tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
20 to_feet(dive->maxdepth), dive->duration.seconds / 60);
25 for (i = 0; i < dive->samples; i++) {
26 struct sample *s = dive->sample + i;
28 printf("%4d:%02d: %3d ft, %2d C, %4d PSI\n",
33 to_PSI(s->tankpressure));
37 static int sortfn(const void *_a, const void *_b)
39 const struct dive *a = *(void **)_a;
40 const struct dive *b = *(void **)_b;
42 if (a->when < b->when)
44 if (a->when > b->when)
50 * This doesn't really report anything at all. We just sort the
51 * dives, the GUI does the reporting
53 static void report_dives(void)
55 qsort(dive_table.dives, dive_table.nr, sizeof(struct dive *), sortfn);
58 static void parse_argument(const char *arg)
60 const char *p = arg+1;
68 fprintf(stderr, "Bad argument '%s'\n", arg);
74 static void on_destroy(GtkWidget* w, gpointer data)
79 static gboolean on_expose(GtkWidget* w, GdkEventExpose* e, gpointer data)
82 cr = gdk_cairo_create(w->window);
87 int main(int argc, char **argv)
94 gtk_init(&argc, &argv);
96 for (i = 1; i < argc; i++) {
97 const char *a = argv[i];
108 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
109 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
110 g_signal_connect(G_OBJECT(win), "expose-event", G_CALLBACK(on_expose), NULL);
111 gtk_widget_set_app_paintable(win, TRUE);
112 gtk_widget_show_all(win);