wibox.widget.calendar: Stop using make_widget_declarative

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-07-09 19:00:16 +02:00
parent d72893692e
commit 07d561ee91
1 changed files with 23 additions and 29 deletions

View File

@ -123,13 +123,12 @@ local properties = { "date", "font", "spacing", "week_numbers", "start_sunday",
-- @tparam boolean center Center the text horizontally -- @tparam boolean center Center the text horizontally
-- @treturn wibox.widget.textbox -- @treturn wibox.widget.textbox
local function make_cell(text, font, center) local function make_cell(text, font, center)
return base.make_widget_declarative { local w = textbox()
markup = text, w:set_markup(text)
align = center and "center" or "right", w:set_align(center and "center" or "right")
valign = 'center', w:set_valign("center")
font = font, w:set_font(font)
widget = textbox return w
}
end end
--- Create a grid layout with the month calendar --- Create a grid layout with the month calendar
@ -144,14 +143,13 @@ local function create_month(props, date)
local num_columns = props.week_numbers and 8 or 7 local num_columns = props.week_numbers and 8 or 7
-- Create grid layout -- Create grid layout
local layout = base.make_widget_declarative{ local layout = grid()
layout = grid, layout:set_expand(true)
expand = true, layout:set_expand(true)
homogeneous = true, layout:set_homogeneous(true)
spacing = props.spacing, layout:set_spacing(props.spacing)
forced_num_rows = num_rows, layout:set_forced_num_rows(num_rows)
forced_num_cols = num_columns, layout:set_forced_num_cols(num_columns)
}
local start_row = 3 local start_row = 3
local start_column = num_columns - 6 local start_column = num_columns - 6
@ -229,14 +227,12 @@ end
-- @treturn widget Grid layout -- @treturn widget Grid layout
local function create_year(props, date) local function create_year(props, date)
-- Create a grid widget with the 12 months -- Create a grid widget with the 12 months
local in_layout = base.make_widget_declarative{ local in_layout = grid()
layout = grid, in_layout:set_expand(true)
expand = true, in_layout:set_homogeneous(true)
homogeneous = true, in_layout:set_spacing(2*props.spacing)
spacing = 2*props.spacing, in_layout:set_forced_num_cols(4)
forced_num_cols = 4, in_layout:set_forced_num_rows(3)
forced_num_rows = 3,
}
local month_date local month_date
local current_date = os.date("*t") local current_date = os.date("*t")
@ -253,12 +249,10 @@ local function create_year(props, date)
-- Create a vertical layout -- Create a vertical layout
local flag, text = "yearheader", string.format("%s", date.year) local flag, text = "yearheader", string.format("%s", date.year)
local year_header = props.fn_embed(make_cell(text, props.font, true), flag, date) local year_header = props.fn_embed(make_cell(text, props.font, true), flag, date)
local out_layout = base.make_widget_declarative{ local out_layout = vertical()
year_header, out_layout:set_spacing(2*props.spacing) -- separate header from calendar grid
in_layout, out_layout:add(year_header)
spacing = 2*props.spacing, -- separate header from calendar grid out_layout:add(in_layout)
layout = vertical
}
return props.fn_embed(out_layout, "year", date) return props.fn_embed(out_layout, "year", date)
end end