~ubuntu-branches/ubuntu/jaunty/beagle/jaunty-security

« back to all changes in this revision

Viewing changes to search/Tiles/RSSFeed.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-05-04 00:31:32 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20080504003132-2tkm5o8moo5952ri
Tags: 0.3.7-2ubuntu1
 * Merge from Debian unstable. (LP: #225746) Remaining Ubuntu changes:
  - debian/control:
    + Rename ice{weasel,dove}-beagle to {mozilla,thunderbird}-beagle and
      and update the dependencies accordingly.
    + Change Maintainer to Ubuntu Mono Team.
  - debian/rules:
    + Install the mozilla-beagle and thunderbird-beagle extensions.
  - ice{dove,weasel}.dirs:
    + Renamed to {mozilla,thunderbird}-beagle.dirs.
    + Fixed paths to point to usr/lib/{firefox,thunderbird}

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
using System;
2
 
using System.IO;
3
 
using System.Diagnostics;
4
 
using System.Collections;
5
 
using Mono.Unix;
6
 
using Beagle.Util;
7
 
 
8
 
namespace Search.Tiles {
9
 
 
10
 
        public class RSSFeedActivator : TileActivator {
11
 
 
12
 
                public RSSFeedActivator () : base ()
13
 
                {
14
 
                        AddSupportedFlavor (new HitFlavor (null, "FeedItem", null));
15
 
                }
16
 
 
17
 
                public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
18
 
                {
19
 
                        return new RSSFeed (hit, query);
20
 
                }
21
 
        }
22
 
 
23
 
        public class RSSFeed : TileTemplate {
24
 
 
25
 
                public RSSFeed (Beagle.Hit hit, Beagle.Query query) : base (hit, query)
26
 
                {
27
 
                        Group = TileGroup.Feed;
28
 
 
29
 
                        Title = Hit ["dc:title"];
30
 
                        Description = Hit ["dc:publisher"];
31
 
                }
32
 
 
33
 
                protected override void LoadIcon (Gtk.Image image, int size)
34
 
                {
35
 
                        Gdk.Pixbuf pixbuf = null;
36
 
 
37
 
                        string path = Hit ["fixme:cachedimg"];
38
 
                        if (path != null && File.Exists (path)) {
39
 
                                try {
40
 
                                        pixbuf = new Gdk.Pixbuf (path);
41
 
                                } catch (GLib.GException) {
42
 
                                        // Catch in case of an invalid pixbuf.
43
 
                                }
44
 
                        }
45
 
 
46
 
                        if (pixbuf != null && (pixbuf.Width > size || pixbuf.Height > size))
47
 
                                pixbuf = pixbuf.ScaleSimple (size, size, Gdk.InterpType.Bilinear);
48
 
 
49
 
                        if (pixbuf == null)
50
 
                                pixbuf = WidgetFu.LoadThemeIcon ("gnome-fs-bookmark", size); // FIXME: RSS icon?
51
 
 
52
 
                        image.Pixbuf = pixbuf;
53
 
                }
54
 
 
55
 
                protected override DetailsPane GetDetails ()
56
 
                {
57
 
                        DetailsPane details = new DetailsPane ();
58
 
 
59
 
                        details.AddLabelPair (Catalog.GetString ("Title:"), Hit ["dc:title"]);
60
 
                        details.AddLabelPair (Catalog.GetString ("Site:"), Hit ["dc:identifier"]);
61
 
                        details.AddLabelPair (Catalog.GetString ("Date Viewed:"), Utils.NiceLongDate (Timestamp));
62
 
                        details.AddSnippet ();
63
 
 
64
 
                        return details;
65
 
                }
66
 
 
67
 
                public override void Open ()
68
 
                {
69
 
                        // If we are not a feed from Thunderbird just open based on mime
70
 
                        if (Hit.GetFirstProperty ("fixme:client") != "thunderbird") {
71
 
                                base.OpenFromUri (Hit ["dc:identifier"]);
72
 
                                return;
73
 
                        }
74
 
 
75
 
#if ENABLE_THUNDERBIRD                  
76
 
                        // Here's the Thunderbird specific part
77
 
                        SafeProcess p = Thunderbird.GetSafeProcess ("-viewbeagle", Hit.GetFirstProperty ("fixme:uri"));
78
 
                        
79
 
                        try {
80
 
                                p.Start ();
81
 
                        } catch (SafeProcessException e) {
82
 
                                Console.WriteLine ("Unable to run {0}: {1}", p.Arguments [0], e.Message);
83
 
                        }
84
 
#endif
85
 
                }
86
 
        }
87
 
}