   (let [items-ids (vals (:items (vlc/get-playlist)))]
     (filter map? (map #(get-vlc-item-rule %) items-ids))))
 
-(defn- vlc-start-button-click [evt]
-  (update-vlc-config!)
-  (update-metric-bars! {:attention 0, :meditation 0})
-  (let [rules (get-vlc-rules)]
-    (when (seq rules)
-      (alter-connection! (partial (get backend->consume-fn "VLC") rules))
-      (ssc/config! (.getSource evt)
-                   :text (get vlc-button-texts (nsky/get-connection-status))))))
-
-(defn- make-vlc-start-button []
-  (ssc/button :id :start-vlc
-              :text (:disconnected vlc-button-texts)
-              :listen [:action vlc-start-button-click]))
-
 (defn- handle-control-metric-selection [evt]
   (let [metric (ssc/config (.getSource evt) :text)
         help-label (ssc/select window [:#metric-help-msg])]


(def ^:private window (ssc/frame :title "Neurolyzer Streamer" :width 500))

(def ^:private nl-button-texts {:disconnected "Connect"
                                :connected "Disconnect"})

(def ^:private vlc-button-texts {:disconnected "Start control VLC"
                                 :connected "Stop control VLC"})

(def ^:private label-texts {:disconnected "Not Connected"
                            :connected "Connected"})

(def ^:private combo-enabled {:disconnected true
                              :connected false})

(declare update-metric-bars!)

(def ^:private backend->consume-fn
  {"Neurolyzer" (fn [stat]
                  (update-metric-bars! stat)
                  (u/send-stat-to-neurolyzer stat))
   "VLC" (fn [rules stat]
           (update-metric-bars! stat)
           (vlc/send-play-command rules stat))})

(def ^:private stat-process-fns
  {"Attention" (fn [stat] (get stat :attention 0))

             [(ssc/text :id :vlc-password :columns 10)
              :gridx 5 :weightx 1.0 :gridwidth 3]
             [(make-vlc-refresh-button) :gridx 8 :gridwidth 2]
             [(ssc/label :halign :right :text "Metric")
              :grid :wrap :gridwidth 1]
             [(ssc/combobox :id :control-metric
                            :listen [:action handle-control-metric-selection]
                            :model (keys stat-process-fns))
              :gridx 1 :gridwidth 3 :weightx 1.0]
             [(ssc/label :text "Avg. per" :halign :right)
              :gridx 4 :gridwidth 1]
             [(ssc/text :id :average-interval :columns 4 :text "1")
              :gridx 5 :gridwidth 1]
             [(ssc/label :text "sec")
              :gridx 6 :gridwidth 1]
             [(ssc/label :text "Cmd. each" :halign :right)
              :gridx 7 :gridwidth 1]
             [(ssc/text :id :command-interval :columns 4 :text "1")
              :gridx 8 :gridwidth 1]
             [(ssc/label :text "sec")
              :gridx 9 :gridwidth 1]
             [(ssc/label :id :metric-help-msg
                         :halign :center
                         :text (get metric-help-messages "Attention"))
