1
// Stephen Smally © 2012
1
// Copyright © 2012 Stephen Smally
2
2
// This program is free software; you can redistribute it and/or modify
3
3
// it under the terms of the GNU General Public License as published by
4
4
// the Free Software Foundation; either version 2 of the License, or
54
54
public PagesView pages_view;
55
55
public ProgressInfo progress_info;
57
58
private int _width = 0;
61
apps_manager = new AppsManager();
63
destroy.connect(Gtk.main_quit);
64
size_allocate.connect(on_size_allocate);
66
window_position = WindowPosition.CENTER;
67
title = "Light Software Center";
68
set_default_size(600, 400);
69
has_resize_grip = true;
71
main_box = new Box(Orientation.VERTICAL, 0);
73
toolbar = new MainToolbar();
74
main_box.pack_start(toolbar, false, false, 0);
76
progress_info = new ProgressInfo();
77
main_box.pack_start(progress_info, false, false, 0);
79
pages_view = new PagesView();
81
main_box.pack_start(pages_view, true, true, 0);
84
apps_manager.get_categories();
89
progress_info.set_visible(false);
90
pages_view.apps_info.reviews_box.set_visible(false);
94
load_packages("gui;application");
59
97
public void load_packages (string filters) {
60
98
pages_view.set_current_page(PageType.APPSVIEW);
61
99
pages_view.apps_view.apps_tree.clear();
65
103
public void update_back_button (Notebook nb, Widget pg, uint page_n) {
66
stdout.printf("Page: %s\n", ((PageType) page_n).to_string());
104
stdout.printf("Page->%s\n", ((PageType) page_n).to_string());
67
105
switch ((PageType) page_n) {
68
106
case PageType.HOMEPAGE:
69
107
toolbar.searchbar.set_sensitive(true);
88
126
public void connect_signals () {
89
127
apps_manager.app_added.connect(pages_view.apps_view.apps_tree.append_app);
90
128
apps_manager.loading_started.connect(progress_info.load_undefined);
91
apps_manager.loading_finished.connect(progress_info.clear);
129
apps_manager.loading_finished.connect(on_load_finished);
92
130
apps_manager.category_added.connect(pages_view.home_page.categories_view.add_category);
93
131
apps_manager.details_received.connect(pages_view.apps_info.set_details);
132
pages_view.home_page.categories_view.category_choosed.connect((gr) => {
133
stdout.printf("%s\n", gr);
94
135
pages_view.switch_page.connect(update_back_button);
95
136
pages_view.switch_page.connect(toolbar.update_label);
98
public void on_size_allocate (Allocation alloc) {
139
public void rework_categories_columns () {
99
140
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());
141
stdout.printf("Window.width->%d rework columns\n", get_allocated_width());
101
142
int size = get_allocated_width();
102
143
if (size < 150 ) {
112
apps_manager = new AppsManager();
114
destroy.connect(Gtk.main_quit);
116
window_position = WindowPosition.CENTER;
117
title = "Light Software Center";
118
set_default_size(600, 400);
119
set_has_resize_grip(true);
121
main_box = new Box(Orientation.VERTICAL, 0);
123
toolbar = new MainToolbar();
124
main_box.pack_start(toolbar, false, false, 0);
126
progress_info = new ProgressInfo();
127
main_box.pack_start(progress_info, false, false, 0);
129
pages_view = new PagesView();
131
main_box.pack_start(pages_view, true, true, 0);
138
apps_manager.get_categories();
139
size_allocate.connect(on_size_allocate);
141
progress_info.set_visible(false);
142
pages_view.apps_info.reviews_box.set_visible(false);
144
pages_view.set_page(PageType.HOMEPAGE);
152
public void on_size_allocate (Allocation alloc) {
153
rework_categories_columns();
156
public void on_load_finished (LoadingType load) {
158
case LoadingType.CATEGORIES:
159
rework_categories_columns();
161
case LoadingType.PACKAGES:
162
progress_info.clear();