seamus

commit 92e4c4d947077dc1b20b5fb5d6ac51b0444a1806

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

ui: rig tickit with seamus and start rendering

 include/ui.h | 5 ++++
 src/seamus.c | 6 +++-
 src/ui.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++


diff --git a/include/ui.h b/include/ui.h
index e618799d4fc9a68afa4982390a706eca24f66fb6..32148ba1baf553882029c32bd03344e3650c6ea4 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -5,5 +5,10 @@ #include 
 #include "seamus.h"
 
 int tickit_init(struct seamus_frontend *s);
+int tickit_start(struct seamus_frontend *s);
 int tickit_finish(struct seamus_frontend *s);
+
+
+static int render_main_window(TickitWindow *win, TickitEventFlags flags, void *_info, void *data);
+static int render_root(TickitWindow *win, TickitEventFlags flags, void *_info, void *data);
 #endif




diff --git a/src/seamus.c b/src/seamus.c
index 8aa1ffa3bd4d6ba5476db50e600866442ddbea1d..325d1a724fc79f3b72bc88c69c4939925351b71d 100755
--- a/src/seamus.c
+++ b/src/seamus.c
@@ -146,9 +146,11 @@ 		log_fatal("Something went wrong when initializing tickit");
 		goto exit_tickit;
 	}
 
-	fetch_mpd_from_current_queue(&seamus, 10);
+	tickit_start(&seamus);
 
-	print_songs_from_queue(&seamus);
+	//fetch_mpd_from_current_queue(&seamus, 10);
+
+	//print_songs_from_queue(&seamus);
 
 exit_tickit:
 	tickit_finish(&seamus);




diff --git a/src/ui.c b/src/ui.c
index 16fb2681dbdccd3bff6033650909b6bec2195c8b..3df866d2d27a4ff717d1ae83b1144f4a41a454df 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -9,7 +9,7 @@ 	Tickit *t = tickit_new_stdtty();
 	TickitWindow *root = tickit_get_rootwin(t);
 
 	if (!root) {
-		log_debug("Cannot create TickitTerm - %d\n", strerror(errno));
+		log_error("Cannot create TickitTerm - %d\n", strerror(errno));
 		return 1;
 	}
 
@@ -23,6 +23,65 @@
 	s->main_window = main_window;
 
 	return 0;
+}
+
+int
+tickit_start(struct seamus_frontend *s)
+{
+
+	TickitWindow *root = tickit_get_rootwin(s->t);
+
+	tickit_window_bind_event(s->main_window, TICKIT_WINDOW_ON_EXPOSE, 0, &render_main_window, s);
+	tickit_window_bind_event(root, TICKIT_WINDOW_ON_EXPOSE, 0, &render_root, s);
+
+	tickit_run(s->t);
+}
+
+static int
+render_root(TickitWindow *win, TickitEventFlags flags, void *_info, void *data)
+{
+	log_info("Starting to render root window");
+
+	TickitExposeEventInfo *info = _info;
+	TickitRenderBuffer *render_buffer = info->rb;
+	struct seamus_frontend *seamus = (struct seamus_frontend*) data;
+
+	int right = tickit_window_cols(win) - 1;
+	int bottom = tickit_window_lines(win) - 1;
+
+	tickit_renderbuffer_eraserect(render_buffer, &(TickitRect){
+		.top = 0, .left = 0, .lines = bottom+1, .cols = right+1,
+	});
+
+	return 1;
+}
+
+static int
+render_main_window(TickitWindow *win, TickitEventFlags flags, void *_info, void *data)
+{
+	log_info("Starting the rendering of main window");
+
+	TickitExposeEventInfo *info = _info;
+	TickitRenderBuffer *render_buffer = info->rb;
+	struct seamus_frontend *seamus = (struct seamus_frontend*) data;
+
+	tickit_renderbuffer_eraserect(render_buffer, &info->rect);
+
+	tickit_renderbuffer_goto(render_buffer, 0, 0);
+	{
+		tickit_renderbuffer_savepen(render_buffer);
+
+		TickitPen *pen = tickit_pen_new_attrs(
+			TICKIT_PEN_FG, 1,
+			TICKIT_PEN_BOLD, 1,
+		0);
+
+		tickit_renderbuffer_setpen(render_buffer, pen);
+		tickit_renderbuffer_text(render_buffer, "Hello, welcome to seamus");
+		tickit_renderbuffer_restore(render_buffer);
+	}
+
+	return 1;
 }
 
 int