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

« back to all changes in this revision

Viewing changes to search/Tiles/Manpage.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
 
//
2
 
// Manpage.cs
3
 
//
4
 
// Copyright (C) 2007 Lukas Lipka <lukaslipka@gmail.com>
5
 
//
6
 
 
7
 
using System;
8
 
using Mono.Unix;
9
 
 
10
 
using Beagle.Util;
11
 
 
12
 
namespace Search.Tiles {
13
 
 
14
 
        public class ManpageActivator : TileActivator {
15
 
 
16
 
                public ManpageActivator () : base ()
17
 
                {
18
 
                        AddSupportedFlavor (new HitFlavor (null, "File", null));
19
 
                }
20
 
 
21
 
                public override bool Validate (Beagle.Hit hit)
22
 
                {
23
 
                        if (! base.Validate (hit))
24
 
                                return false;
25
 
                        
26
 
                        if (hit ["beagle:FileType"] != "documentation")
27
 
                                return false;
28
 
                        
29
 
                        Weight += 2;
30
 
 
31
 
                        return true;
32
 
                }
33
 
 
34
 
                public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
35
 
                {
36
 
                        return new Manpage (hit, query);
37
 
                }
38
 
        }
39
 
 
40
 
        public class Manpage : TileTemplate {
41
 
 
42
 
                string path = null;
43
 
 
44
 
                public Manpage (Beagle.Hit hit, Beagle.Query query) : base (hit, query)
45
 
                {
46
 
                        if (! String.IsNullOrEmpty (hit.GetFirstProperty ("dc:title")))
47
 
                                Title = hit.GetFirstProperty ("dc:title");
48
 
                        else
49
 
                                Title = hit.GetFirstProperty ("beagle:ExactFilename");
50
 
 
51
 
                        if (hit ["beagle:IsChild"] == "true")
52
 
                                path =  hit.ParentUri.LocalPath;
53
 
                        else
54
 
                                path = hit.Uri.LocalPath;
55
 
 
56
 
                        Description = hit.GetFirstProperty ("dc:subject") ?? Catalog.GetString ("Manual page");
57
 
                }
58
 
 
59
 
                protected override void LoadIcon (Gtk.Image image, int size)
60
 
                {
61
 
                        image.Pixbuf = WidgetFu.LoadThemeIcon ("gtk-help", size);
62
 
                }
63
 
 
64
 
                public override void Open ()
65
 
                {
66
 
                        SafeProcess p = new SafeProcess ();
67
 
                        p.Arguments = new string [] { "yelp", path };
68
 
                        
69
 
                        try {
70
 
                                p.Start ();
71
 
                        } catch {
72
 
                                Console.WriteLine ("Failed to start '{0}'", p.Arguments [0]);
73
 
                        }
74
 
                }
75
 
        }
76
 
}