using Gtk;
using GLib;
using Osso;
+using Pango;
public enum Reader {
RSS = 1,
}
}
- public string get_name() {
- return get_string("Desktop Entry", "Name");
+ public string? get_name() {
+ try {
+ return get_string("Desktop Entry", "Name");
+ } catch (KeyFileError e) {
+ stderr.printf("Cannot read exec key: %s\n", e.message);
+ }
+ return null;
+ }
+
+ public string? get_executable() {
+ try {
+ return get_string("Desktop Entry", "Exec");
+ } catch (KeyFileError e) {
+ stderr.printf("Cannot read exec key: %s\n", e.message);
+ }
+ return null;
}
}
}
public string [] get_desktop_files(string mimetype="application/news_reader") {
- return get_string("MIME Cache", mimetype).split(";");
+ try {
+ return get_string("MIME Cache", mimetype).split(";");
+ } catch (KeyFileError e) {
+ stderr.printf("Cannot get desktop files for %s\n", mimetype);
+ return new string [0];
+ }
}
}
public class FeedHandler : GLib.Object {
private MainLoop loop;
private DBus.Connection conn;
- private Context context;
+ private Osso.Context context;
private string args_url;
+ private MimeCache mime_cache;
public FeedHandler(MainLoop loop, DBus.Connection conn) {
this.loop = loop;
this.conn = conn;
this.context = new Osso.Context("feedhandler", "2.0", false, null);
this.args_url = null;
-
- foreach (string file in (new MimeCache().get_desktop_files("text/plain"))) {
- if (file == "") continue;
- var desktop_file = new DesktopFile(file);
- stderr.printf("%s\n", desktop_file.get_name());
+ this.mime_cache = new MimeCache();
+
+ foreach (string file in mime_cache.get_desktop_files("application/rss+xml")) {
+ if (file != "") {
+ var desktop_file = new DesktopFile(file);
+ var name = desktop_file.get_name();
+ var exec = desktop_file.get_executable();
+ if (name != null && exec != null) {
+ stderr.printf("File in Mime CACHE: %s (%s)\n", name, exec);
+ /* XXX: Add "Name" as option and on select, start exec + URL */
+ }
+ }
}
}
Gtk.Dialog dlg = new Gtk.Dialog();
dlg.add_button("RSS Reader", Reader.RSS);
dlg.add_button("Google Reader", Reader.GOOGLE);
- dlg.add_button("gPodder", Reader.GPODDER);
+ if (FileUtils.test("/usr/bin/gpodder", FileTest.EXISTS)) {
+ dlg.add_button("gPodder", Reader.GPODDER);
+ }
dlg.add_button("Cancel", Gtk.ResponseType.CLOSE);
dlg.title = "Select application for handling this feed";
- dlg.vbox.add(new Gtk.Label(url));
+ var label = new Gtk.Label(url);
+ label.ellipsize = Pango.EllipsizeMode.END;
+ dlg.vbox.add(label);
dlg.show_all();
result = dlg.run();
dlg.destroy();