~lubuntu-software-center-team/lubuntu-software-center/vala-port

« back to all changes in this revision

Viewing changes to src/Widgets/Toolbar.vala

  • Committer: Stephen Smally
  • Date: 2012-03-18 10:38:53 UTC
  • Revision ID: eco.stefi@fastwebnet.it-20120318103853-v7wg1qfuifjkc3gc
Implemented dynamic category view

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
namespace Lsc.Widgets {
21
21
    public class MainToolbar : Toolbar {
22
 
        // Misc
23
 
        public signal void section_changed(int index);
24
 
        
25
22
        // Widgets
26
 
        public ToolButton back;
27
 
        public RadioToolButton radio = null;
 
23
        private ToolItem tool;
 
24
        public Button back;
 
25
        public Button label;
28
26
        public SearchBar searchbar;
29
27
        
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();
 
30
        }
 
31
        
 
32
        private void insert_with_tool (Widget widget, int pos) {
 
33
            tool = new ToolItem();
 
34
            tool.add(widget);
 
35
            insert(tool, pos);
33
36
        }
34
37
        
35
38
        public MainToolbar () {
 
39
            get_style_context().add_class("primary-toolbar");
 
40
            
36
41
            toolbar_style = ToolbarStyle.BOTH_HORIZ;
37
 
            get_style_context().add_class("primary-toolbar");
38
42
            show_arrow = false;
39
43
            
40
 
            back = new ToolButton.from_stock(Stock.GO_BACK);
41
 
            insert(back, -1);
 
44
            Box button_b = new Box(Orientation.HORIZONTAL, 0);
 
45
            
 
46
            back = new Button();
 
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;
 
54
            back.vexpand = false;
 
55
            
 
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);
42
59
            
43
60
            ToolItem space_item = new ToolItem();
44
61
            space_item.set_expand(true);
46
63
            
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);
 
66
            searchbar.margin = 5;
 
67
            insert_with_tool(searchbar, -1);
52
68
        }
53
69
    }
54
70
}