2006-02-27 Gabor Kelemen <kelemeng@gnome.hu>
[beagle.git] / Tiles / TileContact.cs
blob46ebcb648e16a761cd61cb1462818dd5c2b078ca
1 //
2 // TileContact.cs
3 //
4 // Copyright (C) 2004 Novell, Inc.
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a
9 // copy of this software and associated documentation files (the "Software"),
10 // to deal in the Software without restriction, including without limitation
11 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 // and/or sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 // DEALINGS IN THE SOFTWARE.
27 using System;
28 using System.Diagnostics;
29 using System.IO;
31 using Beagle.Util;
33 namespace Beagle.Tile {
35 [HitFlavor (Name="People", Rank=1200, Emblem="emblem-contact.png", Color="#eeeebd",
36 Type="Contact")]
37 public class TileContact : TileFromHitTemplate {
39 static string default_contact_icon_data;
41 static TileContact ()
43 default_contact_icon_data = Images.GetHtmlSource ("contact-icon.png", "image/png");
46 public TileContact (Hit _hit) : base (_hit,
47 "template-contact.html")
51 protected override void PopulateTemplate ()
53 base.PopulateTemplate ();
55 string photo_filename = Hit["beagle:Photo"];
57 if (photo_filename != null) {
58 System.Console.WriteLine ("photo: {0}", photo_filename);
59 string height = "";
61 try {
62 // bad hack to scale the image
63 Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (photo_filename);
64 if (pixbuf.Width > pixbuf.Height) {
65 if (pixbuf.Width > 80)
66 height = "width=\"80\"";
67 } else {
68 if (pixbuf.Height > 80)
69 height = "height=\"80\"";
71 } catch {
74 Template["size_adjustment"] = height;
75 Template["Icon"] = StringFu.PathToQuotedFileUri (photo_filename);
76 } else {
77 Template["size_adjustment"] = "";
78 Template["Icon"] = default_contact_icon_data;
81 if (Hit["fixme:ImAim"] != null)
82 Template["CanSendIm"] = "";
84 #if ENABLE_GALAGO
85 if (Hit ["fixme:ImAim"] != null) {
86 string status = GalagoTools.GetPresence ("aim", Hit ["fixme:ImAim"]);
87 if (status != null && status != "")
88 Template ["Presence"] = status;
90 #endif
93 [TileAction]
94 public void SendMailEmail1 ()
96 SendMailToAddress (Hit ["fixme:Email1"], null);
99 [TileAction]
100 public void SendImAim ()
102 SendImAim (Hit["fixme:ImAim"]);