Store the logo in the ID Card
authorJavier Jardón <javier.jardon@codethink.co.uk>
Thu, 21 Apr 2011 13:31:13 +0000 (14:31 +0100)
committerJavier Jardón <javier.jardon@codethink.co.uk>
Thu, 21 Apr 2011 13:31:13 +0000 (14:31 +0100)
src/moonshot-id.vala
src/moonshot-idcard-widget.vala
src/moonshot-window.vala

index 627fb0a..473f107 100644 (file)
@@ -1,6 +1,7 @@
 
 class IdCard : Object {
 
+    public Gdk.Pixbuf pixbuf {get; set; default = null; }
     public string issuer { get; set; default = null; }
     public string username { get; set; default = null; }
     public string password { get; set; default = null; }
index 7e0bcc2..69345d5 100644 (file)
@@ -69,21 +69,7 @@ class IdCardWidget : Box
     {
         this.id_card = id_card;
 
-        Gdk.Pixbuf pixbuf;
-
-        var icon_theme = IconTheme.get_default ();
-        try
-        {
-            pixbuf = icon_theme.load_icon ("avatar-default",
-                                           48,
-                                           IconLookupFlags.FORCE_SIZE);
-        }
-        catch (Error e)
-        {
-            pixbuf = null;
-            stdout.printf("Error: %s\n", e.message);
-        }
-        var image = new Image.from_pixbuf (pixbuf);
+        var image = new Image.from_pixbuf (id_card.pixbuf);
 
         var issuer = Markup.printf_escaped ("<b>%s</b>", this.id_card.issuer);
         var services = Markup.printf_escaped ("<i>%s</i>", "Send Email, Connect to jabber");
index 2752476..f47490b 100644 (file)
@@ -85,7 +85,7 @@ class MainWindow : Window
        show_details (id_card_widget.id_card);
     }
 
-    private void add_identity (AddIdentityDialog dialog)
+    private IdCard get_id_card_data (AddIdentityDialog dialog)
     {
         var id_card = new IdCard ();
 
@@ -93,6 +93,26 @@ class MainWindow : Window
         id_card.username = dialog.username;
         id_card.password = dialog.password;
 
+        var icon_theme = IconTheme.get_default ();
+        try
+        {
+            id_card.pixbuf = icon_theme.load_icon ("avatar-default",
+                                                   48,
+                                                   IconLookupFlags.FORCE_SIZE);
+        }
+        catch (Error e)
+        {
+            id_card.pixbuf = null;
+            stdout.printf("Error: %s\n", e.message);
+        }
+
+        return id_card;
+    }
+
+    private void add_identity (AddIdentityDialog dialog)
+    {
+        var id_card = get_id_card_data (dialog);
+
         var id_card_widget = new IdCardWidget (id_card);
 
         this.custom_vbox.pack_start (id_card_widget, false, false);