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

« back to all changes in this revision

Viewing changes to src/Frontend.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:
54
54
        public PagesView pages_view;
55
55
        public ProgressInfo progress_info;
56
56
        
 
57
        private int _width = 0;
 
58
        
57
59
        public void load_packages (string filters) {
58
60
            pages_view.set_current_page(PageType.APPSVIEW);
59
61
            pages_view.apps_view.apps_tree.clear();
61
63
        }
62
64
        
63
65
        public void update_back_button (Notebook nb, Widget pg, uint page_n) {
 
66
            stdout.printf("Page: %s\n", ((PageType) page_n).to_string());
64
67
            switch ((PageType) page_n) {
65
 
                
 
68
                case PageType.HOMEPAGE:
 
69
                    toolbar.searchbar.set_sensitive(true);
 
70
                    toolbar.label.margin_left = 5;
 
71
                    toolbar.back.set_visible(false);
 
72
                    break;
 
73
                
 
74
                case PageType.APPSINFO:
 
75
                    toolbar.searchbar.set_sensitive(false);
 
76
                    toolbar.label.margin_left = 0;
 
77
                    toolbar.back.set_visible(true);
 
78
                    break;
 
79
                
 
80
                default:
 
81
                    toolbar.searchbar.set_sensitive(true);
 
82
                    toolbar.label.margin_left = 0;
 
83
                    toolbar.back.set_visible(true);
 
84
                    break;
66
85
            }
67
86
        }
68
87
        
73
92
            apps_manager.category_added.connect(pages_view.home_page.categories_view.add_category);
74
93
            apps_manager.details_received.connect(pages_view.apps_info.set_details);
75
94
            pages_view.switch_page.connect(update_back_button);
76
 
            pages_view.home_page.categories_view.category_choosed.connect(() => {
77
 
                load_packages("installed;gui");
78
 
            });
79
 
        }
80
 
        
81
 
        public Frontend () {            
 
95
            pages_view.switch_page.connect(toolbar.update_label);
 
96
        }
 
97
        
 
98
        public void on_size_allocate (Allocation alloc) {
 
99
            if (_width != get_allocated_width() && get_allocated_width()/150 != pages_view.home_page.categories_view.columns) {
 
100
                stdout.printf("Allocating main window to width: %d, need to rework columns\n", get_allocated_width());
 
101
                int size = get_allocated_width();
 
102
                if (size < 150 ) {
 
103
                    size = 150;
 
104
                }
 
105
                pages_view.home_page.categories_view.columns = size/150;
 
106
                
 
107
                _width = get_allocated_width();
 
108
            }
 
109
        }
 
110
        
 
111
        public Frontend () {
82
112
            apps_manager = new AppsManager();
83
113
            
84
114
            destroy.connect(Gtk.main_quit);
 
115
            
85
116
            window_position = WindowPosition.CENTER;
86
117
            title = "Light Software Center";
87
118
            set_default_size(600, 400);
 
119
            set_has_resize_grip(true);
88
120
            
89
121
            main_box = new Box(Orientation.VERTICAL, 0);
90
122
            
104
136
            connect_signals();
105
137
            
106
138
            apps_manager.get_categories();
107
 
            pages_view.home_page.categories_view.fill_space();
 
139
            size_allocate.connect(on_size_allocate);
108
140
            
109
141
            progress_info.set_visible(false);
110
 
            
111
 
            pages_view.set_current_page(PageType.APPSINFO);
112
 
            apps_manager.get_details("app-install-data;0.11.10.6;all;");
 
142
            pages_view.apps_info.reviews_box.set_visible(false);
 
143
            
 
144
            pages_view.set_page(PageType.HOMEPAGE);
 
145
            
 
146
            set_focus(null);
113
147
        }
114
148
    }
115
149
}