Eliminate pixbuf from IdCard
authorKevin Wasserman <kevin.wasserman@painless-security.com>
Tue, 22 Oct 2013 12:11:33 +0000 (08:11 -0400)
committerKevin Wasserman <kevin.wasserman@painless-security.com>
Tue, 22 Oct 2013 12:11:33 +0000 (08:11 -0400)
IdCard should not depend on GDK.
Instead, add utility function to find the correct pixbuf given an IdCard.
For now, it simply returns the "avatar-default" icon, but should eventually
do something intelligent based on the IdCard data.
This incidentally fixes the bug that id's from the keyring data store didn't
get the avatar-default icon.

src/moonshot-id.vala
src/moonshot-idcard-widget.vala
src/moonshot-identity-management-view.vala
src/moonshot-local-flat-file-store.vala
src/moonshot-utils.vala

index bc121f5..3198353 100644 (file)
@@ -47,8 +47,6 @@ public class IdCard : Object
 
   public TrustAnchor trust_anchor  { get; set; default = new TrustAnchor (); }
   
-  public Gdk.Pixbuf pixbuf { get; set; default = null; }    
-
   public unowned string nai { get {  _nai = username + "@" + issuer; return _nai;}}
 
   public bool store_password { get; set; default = false; }
index c6758af..8ea1f60 100644 (file)
@@ -95,7 +95,7 @@ class IdCardWidget : Box
     {
         this.id_card = id_card;
 
-        var image = new Image.from_pixbuf (id_card.get_data ("pixbuf"));
+        var image = new Image.from_pixbuf (get_pixbuf(id_card));
 
         label = new Label (null);
         label.set_alignment ((float) 0, (float) 0.5);
index a6e7955..dbeb556 100644 (file)
@@ -257,7 +257,6 @@ public class IdentityManagerView : Window {
         id_card.password = dialog.password;
         id_card.store_password = dialog.store_password;
         id_card.services = {};
-        id_card.set_data("pixbuf", find_icon ("avatar-default", 48));
 
         return id_card;
     }
@@ -267,7 +266,7 @@ public class IdentityManagerView : Window {
         TreeIter   iter;
         Gdk.Pixbuf pixbuf;
         this.listmodel->append (out iter);
-        pixbuf = id_card.get_data("pixbuf");
+        pixbuf = get_pixbuf(id_card);
         listmodel->set (iter,
                        Columns.IDCARD_COL, id_card,
                        Columns.LOGO_COL, pixbuf,
@@ -331,7 +330,6 @@ public class IdentityManagerView : Window {
 #endif
 
         if (ret == Gtk.ResponseType.YES) {
-            id_card.set_data ("pixbuf", find_icon ("avatar-default", 48));
             this.identities_manager.add_card (id_card, force_flat_file_store);
             return true;
         }
index baafa72..116e956 100644 (file)
@@ -52,7 +52,6 @@ public class LocalFlatFileStore : Object, IIdentityCardStore {
                 id_card.password = key_file.get_string (identity, "Password");
                 id_card.services = key_file.get_string_list (identity, "Services");
                 id_card.display_name = key_file.get_string (identity, "DisplayName");
-                id_card.set_data ("pixbuf", find_icon ("avatar-default", 48));
                 if (key_file.has_key (identity, "StorePassword")) {
                     id_card.store_password = (key_file.get_string (identity, "StorePassword") == "yes");
                 } else {
index 5f59343..402e6d7 100644 (file)
@@ -16,6 +16,11 @@ public Gdk.Pixbuf? find_icon_sized (string name, Gtk.IconSize icon_size)
 
 public bool gtk_available = false;
 
+public Gdk.Pixbuf? get_pixbuf(IdCard id)
+{
+    return find_icon("avatar-default", 48);
+}
+
 public Gdk.Pixbuf? find_icon (string name, int size)
 {
     if (!gtk_available)