8 static int sortfn(const void *_a, const void *_b)
10 const struct dive *a = *(void **)_a;
11 const struct dive *b = *(void **)_b;
13 if (a->when < b->when)
15 if (a->when > b->when)
21 * This doesn't really report anything at all. We just sort the
22 * dives, the GUI does the reporting
24 static void report_dives(void)
26 qsort(dive_table.dives, dive_table.nr, sizeof(struct dive *), sortfn);
29 static void parse_argument(const char *arg)
31 const char *p = arg+1;
39 fprintf(stderr, "Bad argument '%s'\n", arg);
45 static void on_destroy(GtkWidget* w, gpointer data)
50 static GtkWidget *dive_profile;
52 void repaint_dive(void)
54 gtk_widget_queue_draw(dive_profile);
57 int main(int argc, char **argv)
67 gtk_init(&argc, &argv);
69 for (i = 1; i < argc; i++) {
70 const char *a = argv[i];
81 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
82 g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
84 /* Table for the list of dives, cairo window, and dive info */
85 table = gtk_table_new(2, 2, FALSE);
86 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
87 gtk_container_add(GTK_CONTAINER(win), table);
88 gtk_widget_show(table);
90 /* Create the atual divelist */
91 divelist = create_dive_list();
92 gtk_table_attach_defaults(GTK_TABLE(table), divelist, 0, 1, 0, 2);
94 /* Frame for dive profile */
95 frame = dive_profile_frame();
96 gtk_table_attach_defaults(GTK_TABLE(table), frame, 1, 2, 1, 2);
99 /* Frame for dive info */
100 frame = dive_info_frame();
101 gtk_table_attach_defaults(GTK_TABLE(table), frame, 1, 2, 0, 1);
103 gtk_widget_set_app_paintable(win, TRUE);
104 gtk_widget_show_all(win);