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.
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.
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.
21
namespace Lsc.Backend {
22
public class AppsManager : Object {
24
public signal void app_added (Package app);
25
public signal void category_added (string category, string name);
26
public signal void loading_started (string text);
27
public signal void loading_finished ();
28
public signal void details_received (Package pkg, Details details);
31
private Client client;
32
private Control control;
33
private Cancellable transaction;
35
public void get_pkgs (string filters) {
37
filter = filter_bitfield_from_string(filters);
38
loading_started("Loading packages");
39
client.get_packages_async(filter, null, (pkg) => {
40
if (pkg.package != null) {
41
app_added(pkg.package);
43
while (Gtk.events_pending())
50
public void search_for_packages (string filters, string name) {
52
filter = filter_bitfield_from_string(filters);
53
loading_started("Loading packages");
54
client.search_names_async(filter, {name}, null, (pkg) => {
55
if (pkg.package != null) {
56
app_added(pkg.package);
58
while (Gtk.events_pending())
65
public void get_details (string pkg_id) {
66
client.get_details_async({pkg_id},
70
Results contains = client.generic_finish(res);
71
details_received(get_package_from_id(pkg_id), contains.get_details_array()[0]);
75
public Package get_package_from_id (string pkg_id) {
76
Results res = client.resolve(filter_bitfield_from_string(""),
80
return res.get_package_array()[0];
83
public void get_categories () {
84
category_added("gtk-yes", "Utilities");
85
category_added("gtk-yes", "Internet");
86
category_added("gtk-yes", "System");
87
category_added("gtk-yes", "Accessibility");
90
public AppsManager () {
91
client = new Client();
92
control = new Control();
93
transaction = new Cancellable();