summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-30 19:48:00 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-08-30 19:48:00 -0700
commit0ca546b31e5527713f11676bc965aa1ed8dac619 (patch)
treea2911d8a5bf48f9ee8176c72cf2bdb1923a752ca /main.c
parent19e670a23b60c044a8492cc43d3db8dc64685042 (diff)
downloadsubsurface-0ca546b31e5527713f11676bc965aa1ed8dac619.tar.gz
Create a gtk window
It doesn't *do* anything, but some day it will. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'main.c')
-rw-r--r--main.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/main.c b/main.c
index 6da386ccd..adceca9e6 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <cairo.h>
#include "dive.h"
@@ -43,13 +46,13 @@ static int sortfn(const void *_a, const void *_b)
return 0;
}
+/*
+ * This doesn't really report anything at all. We just sort the
+ * dives, the GUI does the reporting
+ */
static void report_dives(void)
{
- int i;
-
qsort(dive_table.dives, dive_table.nr, sizeof(struct dive *), sortfn);
- for (i = 0; i < dive_table.nr; i++)
- show_dive(i+1, dive_table.dives[i]);
}
static void parse_argument(const char *arg)
@@ -68,12 +71,28 @@ static void parse_argument(const char *arg)
} while (*++p);
}
+static void on_destroy(GtkWidget* w, gpointer data)
+{
+ gtk_main_quit();
+}
+
+static gboolean on_expose(GtkWidget* w, GdkEventExpose* e, gpointer data)
+{
+ cairo_t* cr;
+ cr = gdk_cairo_create(w->window);
+ cairo_destroy(cr);
+ return FALSE;
+}
+
int main(int argc, char **argv)
{
int i;
+ GtkWidget* win;
parse_xml_init();
+ gtk_init(&argc, &argv);
+
for (i = 1; i < argc; i++) {
const char *a = argv[i];
@@ -83,7 +102,16 @@ int main(int argc, char **argv)
}
parse_xml_file(a);
}
+
report_dives();
+
+ win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
+ g_signal_connect(G_OBJECT(win), "expose-event", G_CALLBACK(on_expose), NULL);
+ gtk_widget_set_app_paintable(win, TRUE);
+ gtk_widget_show_all(win);
+
+ gtk_main();
return 0;
}