seamus

commit b615e5d4ac0f3dac037955702e326ec0a67a2da0

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

status: kick initial update loop

 include/ui.h | 1 +
 src/queue.c | 6 +++++-
 src/status.c | 5 +++--
 src/ui.c | 16 ++++++++++++++--


diff --git a/include/ui.h b/include/ui.h
index f6e80fc602618455f9afc12acbda8bf34b951325..6e8e6f4db090cb90c312d0bda79a95709c6b33e8 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -9,6 +9,7 @@ int tickit_start(struct seamus_frontend *s);
 int tickit_finish(struct seamus_frontend *s);
 
 
+static int update_status(Tickit *t, TickitEventFlags flags, void *_info, void*user);
 static int render_main_window(TickitWindow *win, TickitEventFlags flags, void *_info, void *data);
 static int render_status_window(TickitWindow *win, TickitEventFlags flags, void *_info, void *data);
 static int render_root(TickitWindow *win, TickitEventFlags flags, void *_info, void *data);




diff --git a/src/queue.c b/src/queue.c
index 64bdbb23696f3e34ce28d221706840ebad455aaa..1ee4a3f74e7e5a566630ced018cb9d7232ced6df 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -52,9 +52,13 @@ 				mpd_entity_free(entity);
 			}
 		}
 
+		mpd_response_finish(seamus->conn);
+
 		return 0;
 	} else {
-		log_fatal("Couldn't fetch the queue");
+		const char *message = mpd_connection_get_error_message(seamus->conn);
+		log_error("MPD Error - Queue: %s", message);
+
 		return 1;
 	}
 }




diff --git a/src/status.c b/src/status.c
index 0c7b33b27767118bb23b033743a260768b8993a7..211c8ceaf1f8073009fba678a940be3fb1ee3220 100644
--- a/src/status.c
+++ b/src/status.c
@@ -83,10 +83,11 @@ 			free(total_time);
 			free(elapsed_time);
 			free(str);
 			mpd_song_free(song);
-
-			return 0;
 		}
 	}
 
 	mpd_status_free(status);
+	mpd_response_finish(s->conn);
+
+	return 0;
 }




diff --git a/src/ui.c b/src/ui.c
index a766e17487de80f8fe74b444302e194b953e7898..9c5afb67b3b8c81f2fb95f83cb55d242beda7c4d 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -43,14 +43,26 @@ 	tickit_window_bind_event(s->main_window, TICKIT_WINDOW_ON_EXPOSE, 0, &render_main_window, s);
 	tickit_window_bind_event(s->status_window, TICKIT_WINDOW_ON_EXPOSE, 0, &render_status_window, s);
 	tickit_window_bind_event(root, TICKIT_WINDOW_ON_EXPOSE, 0, &render_root, s);
 
+	// Kick initial update event
+	tickit_watch_timer_after_msec(s->t, 1000, 0, &update_status, s);
+
 	tickit_run(s->t);
 }
 
 static int
-render_root(TickitWindow *win, TickitEventFlags flags, void *_info, void *data)
+update_status(Tickit *t, TickitEventFlags flags, void *_info, void *user)
 {
-	log_info("Starting to render root window");
+	struct seamus_frontend *seamus = (struct seamus_frontend*) user;
 
+	tickit_window_expose(seamus->status_window, NULL);
+	tickit_watch_timer_after_msec(t, 1000, 0, &update_status, user);
+
+	return 0;
+}
+
+static int
+render_root(TickitWindow *win, TickitEventFlags flags, void *_info, void *data)
+{
 	TickitExposeEventInfo *info = _info;
 	TickitRenderBuffer *render_buffer = info->rb;
 	struct seamus_frontend *seamus = (struct seamus_frontend*) data;