Le mardi 10 janvier 2012 à 12:51 +0200, Alexander Yakushev a écrit : > 2012/1/10 Clément Démoulins <clem...@archivel.fr> > > > > > Hi, > > > > Could you try to provide a version of Menubar for the git version of > > awesome. Last version of awesome use a new API for the wibox and the > > layouts. > > I tried myself to update from your code but not successfully. > > > > Thanks, > > > > Clément Démoulins > > > > I'll fire up a virtual machine today with git version of awesome and try to > do that. > > Though I'm a bit anxious myself to migrate to git-version. Is there a place > to read all implications connected with it?
You can read the git logs and commits starting with the commit: 2eae7e5cf467d330ad0bc20b5e11a14273c3a446 I join a patch that almost working. Function menubar:show() is displaying a wibox but with no content, just the “Run app:”. And there are some bugs. -- Clef GPG : 0xDD51E028
From 4d446ae1d4cf8745eb4e1833c9c82c40cbacaae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20D=C3=A9moulins?= <clem...@archivel.fr> Date: Tue, 10 Jan 2012 13:21:31 +0100 Subject: [PATCH 1/1] Convert menubar to work on awesome-git, the menubar is almost working. --- init.lua | 39 +++++++++++++++++++++++---------------- prompt.lua | 16 ++++++++-------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/init.lua b/init.lua index 3e2445b..6d09fa6 100644 --- a/init.lua +++ b/init.lua @@ -5,7 +5,6 @@ -- Grab environment we need local capi = { widget = widget, - screen = screen, image = image, client = client, wibox = wibox, @@ -17,6 +16,10 @@ local theme = require("beautiful") local menu_gen = require("menubar.menu_gen") local prompt = require("menubar.prompt") local awful = require("awful") +local wibox = require("wibox") +local naughty = require("naughty") +local cairo = require("oocairo") +local common = require("awful.widget.common") local tonumber = tonumber local io = io local string = string @@ -38,7 +41,7 @@ instance = { prompt = nil, widget = nil, wibox = nil } -common_args = { w = { layout = awful.widget.layout.horizontal.leftright }, +common_args = { w = wibox.layout.fixed.horizontal(), data = setmetatable({}, { __mode = 'kv' }), widgets = { imagebox = { }, textbox = { ["margin"] = { ["left"] = 5, @@ -83,13 +86,19 @@ local function perform_action(o) end local function initialize() - instance.wibox = capi.wibox({}) + instance.wibox = awful.wibox({}) instance.widget = new() instance.wibox.ontop = true - instance.prompt = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }) - instance.wibox.widgets = { instance.prompt, - instance.widget, - layout = awful.widget.layout.horizontal.leftright } + instance.prompt = awful.widget.prompt() + local layout = wibox.layout.fixed.horizontal() + layout:add(instance.prompt) + layout:add(instance.widget) + instance.wibox:set_widget(layout) +end + +function file_exist(path) + local f = io.open(path, "r") + if f ~= nil then io.close(f) return true else return false end end function refresh(use_cache) @@ -113,7 +122,7 @@ function refresh(use_cache) local icon_path = f:read("*line") local category = tonumber(f:read("*line")) table.insert(menu_entries, { name = name, cmdline = cmdline, - icon = icon_path ~= "" and capi.image(icon_path) or nil, + icon = icon_path ~= "" and file_exist(icon_path) and cairo.image_surface_create_from_png(icon_path) or nil, category = category }) end end @@ -122,15 +131,14 @@ end function show(screen) if not instance.wibox then initialize() - elseif instance.wibox.screen then -- Menu already shown, exit + elseif instance.wibox.visible then -- Menu already shown, exit return elseif not cache_entries then refresh() end -- Set position and size - instance.wibox.screen = screen or mouse.screen - local scrgeom = capi.screen[instance.wibox.screen].workarea + local scrgeom = capi.screen[mouse.screen].workarea local x = g.x or scrgeom.x local y = g.y or scrgeom.y instance.wibox.height = g.height or 20 @@ -139,7 +147,6 @@ function show(screen) current_item = 1 current_category = nil - instance.wibox.screen = screen or mouse.screen menulist_update() prompt.run({ prompt = "Run app: " }, instance.prompt.widget, function(s) end, nil, awful.util.getdir("cache") .. "/history_menu", nil, @@ -173,7 +180,7 @@ end function hide() keygrabber.stop() - instance.wibox.screen = nil + instance.wibox.visible = false end local function nocase (s) @@ -238,7 +245,7 @@ function menulist_update(query) empty = true }) end - awful.widget.common.list_update(common_args.w, nil, label, + common.list_update(common_args.w, nil, label, common_args.data, common_args.widgets, shownitems) end @@ -250,11 +257,11 @@ function new() refresh() -- Load categories icons and add IDs to them for i, v in ipairs(menu_gen.all_categories) do - v.icon = (v.icon ~= nil) and capi.image(v.icon) or nil + v.icon = (v.icon ~= nil) and file_exist(v.icon) and cairo.image_surface_create_from_png(v.icon) or nil v.cat_id = i end menulist_update() return common_args.w end -setmetatable(_M, { __call = function(_, ...) return new(...) end }) \ No newline at end of file +setmetatable(_M, { __call = function(_, ...) return new(...) end }) diff --git a/prompt.lua b/prompt.lua index af82b20..44f3e4f 100644 --- a/prompt.lua +++ b/prompt.lua @@ -187,13 +187,13 @@ function run(args, textbox, exe_callback, completion_callback, if not textbox or not exe_callback then return end - textbox.text = prompt_text_with_cursor{ + textbox:set_markup(prompt_text_with_cursor{ text = text, text_color = inv_col, cursor_color = cur_col, cursor_pos = cur_pos, cursor_ul = cur_ul, selectall = selectall, - font = font, prompt = prettyprompt } + font = font, prompt = prettyprompt }) local exec = function() - textbox.text = "" + textbox:set_markup("") history_add(history_path, command) capi.keygrabber.stop() exe_callback(command) @@ -204,10 +204,10 @@ function run(args, textbox, exe_callback, completion_callback, function (modifiers, key, event) -- Update textbox local function update() - textbox.text = prompt_text_with_cursor{ + textbox:set_markup(prompt_text_with_cursor{ text = command, text_color = inv_col, cursor_color = cur_col, cursor_pos = cur_pos, cursor_ul = cur_ul, selectall = selectall, - font = font, prompt = prettyprompt } + font = font, prompt = prettyprompt }) end if event ~= "press" then @@ -238,7 +238,7 @@ function run(args, textbox, exe_callback, completion_callback, end -- Get out cases if (mod.Control and (key == "c" or key == "g")) or (not mod.Control and key == "Escape") then - textbox.text = "" + textbox:set_markup("") if done_callback then done_callback() end return false elseif (mod.Control and (key == "j" or key == "m")) or (not mod.Control and key == "Return") or (not mod.Control and key == "KP_Enter") then @@ -340,10 +340,10 @@ function run(args, textbox, exe_callback, completion_callback, if ncomp == 1 then return true end if ncomp == 2 then command = command_before_comp - textbox.text = prompt_text_with_cursor{ + textbox:set_markup(prompt_text_with_cursor{ text = command_before_comp, text_color = inv_col, cursor_color = cur_col, cursor_pos = cur_pos, cursor_ul = cur_ul, selectall = selectall, - font = font, prompt = prettyprompt } + font = font, prompt = prettyprompt }) return true end -- 1.7.8.3
signature.asc
Description: This is a digitally signed message part