[gnome-contacts] Revert back to real data on error setting property



commit c45ce1c5567f95e9cb752b587c81b8284c33408f
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Feb 1 12:03:20 2012 +0100

    Revert back to real data on error setting property

 src/contacts-contact-pane.vala |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 88b099a..31f399a 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -411,13 +411,26 @@ public abstract class Contacts.FieldSet : Grid {
 	    saving = false;
 	  } catch (PropertyError e1) {
 	    warning ("Unable to edit property '%s': %s", property_name, e1.message);
+	    refresh_from_persona ();
 	  } catch (Error e2) {
 	    warning ("Unable to create writeable persona: %s", e2.message);
+	    refresh_from_persona ();
 	  }
-
 						     });
     }
   }
+
+  public void refresh_from_persona () {
+    this.clear ();
+    this.populate ();
+
+    if (this.is_empty ())
+      this.remove_from_sheet ();
+    else {
+      this.show_all ();
+      this.add_to_sheet ();
+    }
+  }
 }
 
 public abstract class Contacts.DataFieldRow : FieldRow {
@@ -1408,15 +1421,7 @@ public class Contacts.PersonaSheet : Grid {
     var name = pspec.get_name ();
     foreach (var field_set in field_sets) {
       if (field_set.reads_param (name) && !field_set.saving) {
-	field_set.clear ();
-	field_set.populate ();
-
-	if (field_set.is_empty ())
-	  field_set.remove_from_sheet ();
-	else {
-	  field_set.show_all ();
-	  field_set.add_to_sheet ();
-	}
+	field_set.refresh_from_persona ();
       }
     }
   }



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