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

« back to all changes in this revision

Viewing changes to src/Widgets/Pages/CategoriesView.vala

  • Committer: Stephen Smally
  • Date: 2012-07-04 13:40:36 UTC
  • Revision ID: eco.stefi@fastwebnet.it-20120704134036-jzxry23ch4in5o80
Implemented packages list via Database, listing works and is fast!

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
namespace Lsc.Widgets {   
23
23
    public class CategoryButton : EventBox {
 
24
                private LscCategory desc;
 
25
                public signal void category_clicked (LscCategory cat);
 
26
                
 
27
                private bool emit_clicked (Widget box, Gdk.EventButton button) {
 
28
                        category_clicked (desc);
 
29
                        return true;
 
30
                }
 
31
                
24
32
        public CategoryButton (LscCategory desc, bool fill = false) {
 
33
                        this.desc = desc;
 
34
                        
25
35
            sensitive = ! fill;
26
36
            visible_window = false;
27
37
            
40
50
                
41
51
                tooltip_text = desc.summary;
42
52
                
43
 
                Label description = new Label("%s".printf (desc.summary));
 
53
                Label description = new Label("<i>%d elements</i>".printf (desc.records));
44
54
                description.ellipsize = Pango.EllipsizeMode.END;
45
55
                description.halign = Align.START;
46
56
                description.valign = Align.START;
47
 
                //description.use_markup = true;
 
57
                description.use_markup = true;
48
58
                
49
59
                label_box.pack_start(title, false, false, 0);
50
60
                label_box.pack_start(description, false, false, 0);
52
62
                container.pack_start(image_widget, false, false, 0);
53
63
                container.pack_start(label_box, false, false, 0);
54
64
                add(container);
 
65
                
 
66
                button_press_event.connect(emit_clicked);
55
67
            }
56
68
        }
57
69
    }
58
70
    
59
71
    public class CategoriesView : GridView {
60
 
        public signal void category_choosed (string group);
 
72
        public signal void category_choosed (LscCategory cat);
61
73
        
62
74
        // Vars
63
75
        private Box box_child;
86
98
                    actual_col = 0;
87
99
                }
88
100
                button_child = new CategoryButton(button_desc);
89
 
                button_child.button_press_event.connect(() => {
90
 
                    category_choosed("cat");
91
 
                    return true;
92
 
                });
 
101
                button_child.category_clicked.connect((i) => {
 
102
                                        category_choosed (i);
 
103
                                });
93
104
            
94
105
                box_child.pack_start(button_child, true, true, 0);
95
106
                button_child.show_all();