]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/widgets/mpd_widget.lua
awesome/mpd_widget: put scroll widget part of mpd_widget
[dotfiles.git] / awesome / widgets / mpd_widget.lua
index f5f0ce74f640a32424504a1fc27d53e8bb539202..180705492ec564a8336eede662a13fbdceb0b241 100644 (file)
@@ -4,6 +4,7 @@ local gears = require("gears")
 local awful = require("awful")
 local naughty = require("naughty")
 local timer = require("gears.timer")
+local wibox = require("wibox")
 
 --TODO remove
 local dbg = require("gears.debug")
@@ -12,6 +13,19 @@ local widget = {}
 widget._textbox = textbox()
 widget._currentsong = {}
 
+widget.scroll = wibox.widget {
+    layout = wibox.container.scroll.horizontal,
+    forced_width = 200,
+    expand = true,
+    step_function = wibox.container.scroll.step_functions.linear_increase,
+    speed = 20,
+    {
+        widget = widget._textbox,
+        align = 'center',
+        valign = 'center'
+    }
+}
+
 function widget:update_widget()
     local text = ""
     local artist = self._currentsong.artist
@@ -131,13 +145,13 @@ function widget:run()
     self._timer:connect_signal("timeout", function() self:popup_update() end)
 
     self._hover = false;
-    self._textbox:connect_signal("mouse::enter", function() self._hover = true;  self:popup_show()  end)
-    self._textbox:connect_signal("mouse::leave", function() self._hover = false; self:popup_hide(2) end)
+    self.scroll:connect_signal("mouse::enter", function() self._hover = true;  self:popup_show()  end)
+    self.scroll:connect_signal("mouse::leave", function() self._hover = false; self:popup_hide(2) end)
 end
 
 widget:run()
 
-widget._textbox:buttons(gears.table.join(
+widget.scroll:buttons(gears.table.join(
   awful.button({}, 1, function() widget._connection:toggle_play() end)
 , awful.button({}, 4, function() widget._connection:change_volume(5) end)
 , awful.button({}, 5, function() widget._connection:change_volume(-5) end))
@@ -153,4 +167,4 @@ globalkeys = gears.table.join(globalkeys,
     awful.key({ modkey }, ".", function() widget._connection:send("next") end,
               { description = "next track", group = "mpd" })
 )
-return widget._textbox
+return widget.scroll