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

« back to all changes in this revision

Viewing changes to src/Widgets/LscToolbar.vala

  • Committer: Stephen Smally
  • Date: 2012-02-20 15:48:23 UTC
  • Revision ID: eco.stefi@fastwebnet.it-20120220154823-xz8snvspmssegjcs
Starting working seriously on Vala rewrite, not porting, just rewriting

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  Stephen Smally © 2012
 
2
//      This program is free software; you can redistribute it and/or modify
 
3
//      it under the terms of the GNU General Public License as published by
 
4
//      the Free Software Foundation; either version 2 of the License, or
 
5
//      (at your option) any later version.
 
6
//      
 
7
//      This program is distributed in the hope that it will be useful,
 
8
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
//      GNU General Public License for more details.
 
11
//      
 
12
//      You should have received a copy of the GNU General Public License
 
13
//      along with this program; if not, write to the Free Software
 
14
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
15
//      MA 02110-1301, USA.
 
16
//      
 
17
 
 
18
using Gtk;
 
19
 
 
20
namespace Lsc.Widgets {
 
21
    public class LscToolbar : Toolbar {
 
22
        // Misc
 
23
        public signal void section_changed(int index);
 
24
        
 
25
        // Widgets
 
26
        public ToolButton back;
 
27
        public RadioToolButton radio = null;
 
28
        public SearchBar searchbar;
 
29
        
 
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);
 
33
        }
 
34
        
 
35
        public LscToolbar () {
 
36
            toolbar_style = ToolbarStyle.BOTH_HORIZ;
 
37
            get_style_context().add_class("primary-toolbar");
 
38
            show_arrow = false;
 
39
            
 
40
            back = new ToolButton.from_stock(Stock.GO_BACK);
 
41
            insert(back, -1);
 
42
            
 
43
            // This has to be fixed with the Section enum
 
44
            string[] SectionStrings = {
 
45
                "Get",
 
46
                "Installed",
 
47
                "Basket"
 
48
            };
 
49
            
 
50
            foreach (string section in SectionStrings) {
 
51
                if (radio == null) {
 
52
                    radio = new RadioToolButton(null);
 
53
                } else {
 
54
                    radio = new RadioToolButton.from_widget(radio);
 
55
                }
 
56
                radio.label = section;
 
57
                radio.icon_name = "applications-other";
 
58
                radio.set_is_important(true);
 
59
                radio.clicked.connect(on_changed_radio);
 
60
                insert(radio, -1);
 
61
            }
 
62
            
 
63
            ToolItem spacer = new ToolItem();
 
64
            spacer.set_expand(true);
 
65
            insert(spacer, -1);
 
66
            
 
67
            searchbar = new SearchBar("Search apps...");
 
68
            searchbar.text_changed_pause.connect((text) => {stdout.printf("%s\n", text); });
 
69
            ToolItem searchbar_tool = new ToolItem();
 
70
            searchbar_tool.add(searchbar);
 
71
            insert(searchbar_tool, -1);
 
72
        }
 
73
    }
 
74
}
 
75