private bool is_running = false;
private string file_path;
- public bool available { get; private set; }
-
const string THUMBNAILER_IFACE = "org.freedesktop.thumbnails.Thumbnailer1";
const string THUMBNAILER_SERVICE =
"/org/freedesktop/thumbnails/Thumbnailer1";
public DbusThumbnailer () throws GLib.IOError {
- this.available = false;
- Bus.watch_name (BusType.SESSION,
- THUMBNAILER_IFACE,
- BusNameWatcherFlags.AUTO_START,
- this.on_name_available,
- this.on_name_unavailable);
-
- }
-
- public void on_name_available (DBusConnection connection,
- string name,
- string owner) {
- try {
- this.tumbler = connection.get_proxy_sync (THUMBNAILER_IFACE,
- THUMBNAILER_SERVICE);
-
- tumbler.Finished.connect (on_finished);
- tumbler.Error.connect (on_error);
- this.available = true;
- debug ("DBus thumbnailer service available");
- } catch (Error error) {
- this.available = false;
- }
- }
+ this.tumbler = GLib.Bus.get_proxy_sync (BusType.SESSION,
+ THUMBNAILER_IFACE,
+ THUMBNAILER_SERVICE);
- public void on_name_unavailable (DBusConnection connection,
- string name) {
- this.available = false;
- debug ("DBus thumbnailer service not available");
+ tumbler.Finished.connect (on_finished);
+ tumbler.Error.connect (on_error);
}
public async void create_thumbnail_task (string file_path,
try {
yield this.tumbler.Queue (uris, mimes, flavor, "default", 0);
- } catch (Error error) {
- this.available = false;
- }
+ } catch (Error error) { }
}
public bool in_progress () {
try {
this.thumbler = new DbusThumbnailer ();
- } catch (GLib.Error error) {
- }
+ } catch (GLib.IOError error) {}
+
}
public static Thumbnailer? get_default () {
var file = File.new_for_path (full_path);
// send a request to create thumbnail if it does not exist
- if (this.thumbler != null &&
- this.thumbler.available &&
- !file.query_exists ()) {
+ if ((this.thumbler != null) && (!file.query_exists ())) {
this.thumbler.create_thumbnail_task (uri, mime_type, "normal");
}