summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 182bfa4)
raw | patch | inline | side by side (parent: 182bfa4)
author | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 23:10:28 +0000 (01:10 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 23:10:28 +0000 (01:10 +0200) |
Don't schedule the timer_mpd_update() call. Always return "true" from
timer_mpd_update().
This sets the full event mask after a connection was established. The
"database updated" message appears only if the connection existed
before.
timer_mpd_update().
This sets the full event mask after a connection was established. The
"database updated" message appears only if the connection existed
before.
src/main.c | patch | blob | history | |
src/screen.c | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 726f098f3d046414dfcd88b1930b6e8c07b67134..8669b6358bda9dcf87617790a99f8793f814add2 100644 (file)
--- a/src/main.c
+++ b/src/main.c
return;
update_source_id = g_timeout_add(update_interval,
- timer_mpd_update,
- GINT_TO_POINTER(TRUE));
+ timer_mpd_update, NULL);
}
static void
update_source_id = 0;
}
+static void
+check_reconnect(void);
+
+static void
+do_mpd_update(void)
+{
+ if (mpdclient_is_connected(mpd))
+ mpdclient_update(mpd);
+
+#ifndef NCMPC_MINI
+ if (options.enable_xterm_title)
+ update_xterm_title();
+#endif
+
+ screen_update(mpd);
+ mpd->events = 0;
+
+ check_reconnect();
+}
+
/**
* This timer is installed when the connection to the MPD server is
* broken. It tries to recover by reconnecting periodically.
doupdate();
/* update immediately */
- g_timeout_add(1, timer_mpd_update, GINT_TO_POINTER(FALSE));
+ mpd->events = MPD_IDLE_DATABASE|MPD_IDLE_STORED_PLAYLIST|
+ MPD_IDLE_QUEUE|MPD_IDLE_PLAYER|MPD_IDLE_MIXER|MPD_IDLE_OUTPUT|
+ MPD_IDLE_OPTIONS|MPD_IDLE_UPDATE;
+
+ do_mpd_update();
return FALSE;
}
}
static gboolean
-timer_mpd_update(gpointer data)
+timer_mpd_update(G_GNUC_UNUSED gpointer data)
{
- if (mpdclient_is_connected(mpd))
- mpdclient_update(mpd);
-
-#ifndef NCMPC_MINI
- if (options.enable_xterm_title)
- update_xterm_title();
-#endif
-
- screen_update(mpd);
- mpd->events = 0;
-
- check_reconnect();
+ do_mpd_update();
- return GPOINTER_TO_INT(data);
+ return true;
}
void begin_input_event(void)
diff --git a/src/screen.c b/src/screen.c
index efbd37ff6fb8729cca81f1db00a92981faf7b099..19441707f0329c6d958ef21af55075db9ef50ad3 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
screen_update(struct mpdclient *c)
{
#ifndef NCMPC_MINI
+ static bool was_connected;
static bool initialized = false;
static bool repeat;
static bool random_enabled;
crossfade = mpd_status_get_crossfade(c->status);
}
- if (c->events & MPD_IDLE_DATABASE)
+ if ((c->events & MPD_IDLE_DATABASE) != 0 && was_connected)
screen_status_printf(_("Database updated"));
+ was_connected = mpdclient_is_connected(c);
/* update title/header window */
if (screen.welcome_source_id != 0)