1
public class DesktopFile : GLib.Object {
3
private string template = """
10
Keywords=webby;webapp;internet;
11
Icon=application-default-icon
15
X-GNOME-FullName=Webby
16
StartupWMClass=Webby""";
19
private GLib.KeyFile file;
22
public DesktopFile (string name, string url, string icon) {
23
file = new GLib.KeyFile();
24
file.load_from_data (template, -1, GLib.KeyFileFlags.NONE);
26
file.set_string ("Desktop Entry", "Name", name);
27
file.set_string ("Desktop Entry", "GenericName", name);
28
file.set_string ("Desktop Entry", "X-GNOME-FullName", name);
29
file.set_string ("Desktop Entry", "Exec", "webby " + url);
30
file.set_string ("Desktop Entry", "Icon", icon);
31
file.set_string ("Desktop Entry", "StartupWMClass", url);
34
public bool save_to_file () {
35
string filename = GLib.Environment.get_user_data_dir () + "/applications/" +file.get_string("Desktop Entry", "Name") + "-webby.desktop";
36
print("Desktop file created: " + filename);
37
file.save_to_file (filename);
41
public static Gee.HashMap<string, GLib.AppInfo> get_webby_applications() {
43
var list = new Gee.HashMap<string, GLib.AppInfo>();
45
foreach (GLib.AppInfo app in GLib.AppInfo.get_all()) {
47
var desktop_app = new GLib.DesktopAppInfo(app.get_id ());
49
//FIXME: This is not working, vala problem?
50
//var keywords = desktop_app.get_keywords ();
52
string keywords = desktop_app.get_string ("Keywords");
54
if (keywords != null && keywords.contains ("webby")) {
55
list.set(app.get_name(), app);
56
print(app.get_name());
62
public static Gee.HashMap<string, GLib.AppInfo> get_applications() {
64
var list = new Gee.HashMap<string, GLib.AppInfo>();
66
foreach (GLib.AppInfo app in GLib.AppInfo.get_all()) {
67
list.set(app.get_name(), app);