summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 193d63f)
raw | patch | inline | side by side (parent: 193d63f)
author | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 19:23:07 +0000 (21:23 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 19:23:07 +0000 (21:23 +0200) |
src/screen.c | patch | blob | history | |
src/screen.h | patch | blob | history |
diff --git a/src/screen.c b/src/screen.c
index a7c46b943e7c080e1f65697f1ace76f900e95407..81b736468757535f225895c51eb2475d1c865b9c 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
/* screens */
-#ifndef NCMPC_MINI
-static gboolean welcome = TRUE;
-#endif
-
struct screen screen;
static const struct screen_functions *mode_fn = &screen_playlist;
static const struct screen_functions *mode_fn_prev = &screen_playlist;
delwin(screen.main_window.w);
progress_bar_deinit(&screen.progress_bar);
status_bar_deinit(&screen.status_bar);
+
+#ifndef NCMPC_MINI
+ if (screen.welcome_source_id != 0)
+ g_source_remove(screen.welcome_source_id);
+#endif
}
void
screen_paint(c);
}
+static gboolean
+welcome_timer_callback(gpointer data)
+{
+ struct mpdclient *c = data;
+
+ screen.welcome_source_id = 0;
+
+ paint_top_window(mode_fn->get_title != NULL
+ ? mode_fn->get_title(screen.buf, screen.buf_size)
+ : "",
+ c);
+ doupdate();
+
+ return false;
+}
+
void
screen_init(struct mpdclient *c)
{
screen.buf = g_malloc(screen.cols);
screen.buf_size = screen.cols;
screen.findbuf = NULL;
- screen.start_timestamp = time(NULL);
+
+#ifndef NCMPC_MINI
+ if (options.welcome_screen_list)
+ screen.welcome_source_id =
+ g_timeout_add(SCREEN_WELCOME_TIME * 1000,
+ welcome_timer_callback, c);
+#endif
/* create top window */
title_bar_init(&screen.title_bar, screen.cols, 0, 0);
screen_status_printf(_("Database updated"));
/* update title/header window */
- if (welcome && options.welcome_screen_list &&
- time(NULL)-screen.start_timestamp <= SCREEN_WELCOME_TIME)
+ if (screen.welcome_source_id != 0)
paint_top_window("", c);
else
#endif
if (mode_fn->get_title != NULL) {
paint_top_window(mode_fn->get_title(screen.buf,screen.buf_size), c);
-#ifndef NCMPC_MINI
- welcome = FALSE;
-#endif
} else
paint_top_window("", c);
screen_cmd(struct mpdclient *c, command_t cmd)
{
#ifndef NCMPC_MINI
- welcome = FALSE;
+ if (screen.welcome_source_id != 0) {
+ g_source_remove(screen.welcome_source_id);
+ screen.welcome_source_id = 0;
+ }
#endif
if (mode_fn->cmd != NULL && mode_fn->cmd(c, cmd))
diff --git a/src/screen.h b/src/screen.h
index b9486473c1531d032d310ac4335e1eae76c86ca5..0180e146308f4e0107042e2349bcba86199dfbcd 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
struct progress_bar progress_bar;
struct status_bar status_bar;
- /* GTime is equivalent to time_t */
- GTime start_timestamp;
-
unsigned cols, rows;
char *buf;
char *findbuf;
GList *find_history;
+
+#ifndef NCMPC_MINI
+ /**
+ * Non-zero when the welcome message is currently being
+ * displayed. The associated timer will disable it.
+ */
+ guint welcome_source_id;
+#endif
};
extern struct screen screen;