Hi Thomas, At 1257599279 time_t, Thomas Brunko wrote: > this is a small patch for lib/awful/widget/prompt.lua.in. It exposes the > parameters of awful.prompt.run to the awful.widget.prompt object. I've been > missing the done_callback of awful.prompt.run: My promt sits in a hidden > wibox that pops up when the command prompt is needed and hides itself > afterwards. I've hidden the wibox with the done_callback.
Seems a good idea. But I am not sure about your implementation.
> diff --git a/lib/awful/widget/prompt.lua.in b/lib/awful/widget/prompt.lua.in
> index 2ae7eb6..7a3b01a 100644
> --- a/lib/awful/widget/prompt.lua.in
> +++ b/lib/awful/widget/prompt.lua.in
> @@ -16,20 +16,28 @@ module("awful.widget.prompt")
>
> --- Run method for promptbox.
> -- @param promptbox The promptbox to run.
> -local function run(promptbox)
> - return prompt.run({ prompt = promptbox.prompt },
> +-- @param ctrl Contains the parameters exe_callback, completion_callback,
> history_path,
> +-- history_max, done_callback from awful.prompt.run.
> +local function run(promptbox, ctrl)
> + ctrl = ctrl or {}
> + return prompt.run({ prompt = ctrl.prompt or promptbox.prompt },
> promptbox.widget,
> - function (...) promptbox.widget.text = util.spawn(...)
> end,
> - completion.shell,
> - util.getdir("cache") .. "/history")
> + ctrl.exe_callback or promptbox.exe_callback,
> + ctrl.completion_callback or
> promptbox.completion_callback,
> + ctrl.history_path or promptbox.history_path,
> + ctrl.history_max or promptbox.history_max,
> + ctrl.done_callback or promptbox.done_callback)
> end
Do we really need the ctrl paramater? To me it's useless and just
complicate things. If you want to change stuff, just change
promptbox.field to something else.
>
> --- Create a prompt widget which will launch a command.
> -- @param args Standard widget table arguments, with prompt to change the
> -- default prompt.
> +-- @param ctrl Contains the parameters exe_callback, completion_callback,
> history_path,
> +-- history_max, done_callback from awful.prompt.run.
> -- @return A launcher widget.
> -function new(args)
> - local args = args or {}
> +function new(args, ctrl)
> + args = args or {}
> + ctrl = ctrl or {}
> local promptbox = {}
> args.type = "textbox"
> promptbox.widget = capi.widget(args)
> @@ -38,6 +46,11 @@ function new(args)
> promptbox.run = run
> promptbox.prompt = args.prompt or "Run: "
> promptbox.layout = args.layout or layout.horizontal.leftright
> + promptbox.exe_callback = ctrl.exe_callback or function (...)
> promptbox.widget.text = util.spawn(...) end
> + promptbox.completion_callback = ctrl.completion_callback or
> completion.shell
> + promptbox.history_path = ctrl.history_path or util.getdir("cache") ..
> "/history"
> + promptbox.history_max = ctrl.history_max
> + promptbox.done_callback = ctrl.done_callback
> return promptbox
Again, I'm not sure a new argument ctrl is a good choice. Taking values
from 'args' is simpler.
Cheers,
--
Julien Danjou
// ᐰ <[email protected]> http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD
// I'm no superman.
signature.asc
Description: Digital signature
