20
20
namespace Lsc.Widgets {
21
21
public class MainToolbar : Toolbar {
23
public signal void section_changed(int index);
26
public ToolButton back;
27
public RadioToolButton radio = null;
23
private ToolItem tool;
28
26
public SearchBar searchbar;
30
public void on_changed_radio (ToolButton widget) {
31
int index = get_children().index(widget)-1; // The radio position in the toolbar - 1
32
section_changed(index);
28
public void update_label (Notebook nb, Widget pg, uint page_n) {
29
label.label = ((PageType) page_n).to_string();
32
private void insert_with_tool (Widget widget, int pos) {
33
tool = new ToolItem();
35
38
public MainToolbar () {
39
get_style_context().add_class("primary-toolbar");
36
41
toolbar_style = ToolbarStyle.BOTH_HORIZ;
37
get_style_context().add_class("primary-toolbar");
38
42
show_arrow = false;
40
back = new ToolButton.from_stock(Stock.GO_BACK);
44
Box button_b = new Box(Orientation.HORIZONTAL, 0);
47
back.image = new Image.from_stock(Stock.GO_BACK, IconSize.BUTTON);
48
back.can_focus = false;
49
label = new Button.with_label(PageType.HOMEPAGE.to_string());
50
label.can_focus = false;
51
label.valign = Align.CENTER;
52
label.vexpand = false;
53
back.valign = Align.CENTER;
56
button_b.pack_start(back, false, false, 0);
57
button_b.pack_start(label, false, false, 0);
58
insert_with_tool(button_b, -1);
43
60
ToolItem space_item = new ToolItem();
44
61
space_item.set_expand(true);
47
64
searchbar = new SearchBar("Search apps...");
48
65
searchbar.text_changed_pause.connect((text) => {stdout.printf("%s\n", text); });
49
ToolItem searchbar_tool = new ToolItem();
50
searchbar_tool.add(searchbar);
51
insert(searchbar_tool, -1);
67
insert_with_tool(searchbar, -1);