[totem] rotation-plugin: store/restore the state async



commit 99db20be5da786bb033c7e8f80eab236b1ccde4f
Author: Simon Wenner <simon wenner ch>
Date:   Fri Aug 5 23:08:57 2011 +0200

    rotation-plugin: store/restore the state async
    
    https://bugzilla.gnome.org/show_bug.cgi?id=589399

 src/plugins/rotation/totem-rotation-plugin.vala |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/rotation/totem-rotation-plugin.vala b/src/plugins/rotation/totem-rotation-plugin.vala
index f20b3db..5a98a67 100644
--- a/src/plugins/rotation/totem-rotation-plugin.vala
+++ b/src/plugins/rotation/totem-rotation-plugin.vala
@@ -178,7 +178,7 @@ class RotationPlugin: GLib.Object, Peas.Activatable
         this.try_restore_state (mrl);
     }
 
-    private void store_state ()
+    private async void store_state ()
     {
         Totem.Object t = (Totem.Object) this.object;
         string mrl = t.get_current_mrl ();
@@ -189,22 +189,26 @@ class RotationPlugin: GLib.Object, Peas.Activatable
 
         var file = GLib.File.new_for_uri (mrl);
         try {
+            var file_info = yield file.query_info_async (GIO_ROTATION_FILE_ATTRIBUTE,
+                    GLib.FileQueryInfoFlags.NONE);
+
             string state_str = "";
             if (this.state != Rotation._IDENTITY) {
                 state_str = "%u".printf ((uint) this.state);
             }
-            file.set_attribute_string (GIO_ROTATION_FILE_ATTRIBUTE, state_str,
-                    GLib.FileQueryInfoFlags.NONE);
+            file_info.set_attribute_string (GIO_ROTATION_FILE_ATTRIBUTE, state_str);
+            yield file.set_attributes_async (file_info, GLib.FileQueryInfoFlags.NONE,
+                    GLib.Priority.DEFAULT, null, null);
         } catch (GLib.Error e) {
             GLib.warning ("Could not store file attribute: %s", e.message);
         }
     }
 
-    private void try_restore_state (string mrl)
+    private async void try_restore_state (string mrl)
     {
         var file = GLib.File.new_for_uri (mrl);
         try {
-            var file_info = file.query_info (GIO_ROTATION_FILE_ATTRIBUTE,
+            var file_info = yield file.query_info_async (GIO_ROTATION_FILE_ATTRIBUTE,
                     GLib.FileQueryInfoFlags.NONE);
             string state_str = file_info.get_attribute_string (GIO_ROTATION_FILE_ATTRIBUTE);
             if (state_str != null) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]