+static gboolean
+topmost_notify (GObject * object, GParamSpec * pspec, gpointer user_data)
+{
+ AppData * appdata = (AppData *) user_data;
+
+ if (hildon_program_get_is_topmost (HILDON_PROGRAM (object))) {
+ /* cancel pipeline stop timer if it is ticking */
+ if (appdata->stop_timer_id != 0) {
+ g_source_remove (appdata->stop_timer_id);
+ appdata->stop_timer_id = 0;
+ }
+
+ set_pipeline_states (appdata, GST_STATE_PLAYING);
+
+ /* keep display on */
+ if (appdata->display_timer_id == 0)
+ display_keepalive (user_data);
+ }
+ else {
+ /* pause pipelines so that we don't update the UI needlessly */
+ set_pipeline_states (appdata, GST_STATE_PAUSED);
+ /* stop pipelines fully if the app stays in the background for 30 seconds */
+ appdata->stop_timer_id = g_timeout_add (30000, (GSourceFunc) stop_pipelines, user_data);
+ /* let display dim and switch off */
+ if (appdata->display_timer_id) {
+ g_source_remove (appdata->display_timer_id);
+ appdata->display_timer_id = 0;
+ }
+ }
+
+ return FALSE;
+}
+#endif
+