Hy,
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.

Regards,
Thomas.

-- 
Thomas Brunko                                   [email protected]
From 765867ed2d9d4850774554d7a829e7fb138dc864 Mon Sep 17 00:00:00 2001
From: Thomas Brunko <[email protected]>
Date: Sat, 7 Nov 2009 13:54:37 +0100
Subject: [PATCH] Exposing the parameters of awful.prompt.run to awful.widget.promp.new and awful.widget.promp.run.
 The callback-parameters of awful.prompt.run make it a powerfull but hard to use
 tool. By adding a parameter to the new and run methods of awful.widget.promp,
 the full power of awful.prompt.run is available to advanced users without
 confusing new users.

Signed-off-by: Thomas Brunko <[email protected]>
---
 lib/awful/widget/prompt.lua.in |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

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
 
 --- 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
 end
 
-- 
1.6.5.2

Reply via email to