~ubuntu-branches/ubuntu/natty/gnome-do/natty

« back to all changes in this revision

Viewing changes to Do.Platform.Linux/src/Do.Universe/ApplicationItem.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 10:40:45 UTC
  • mfrom: (1.1.8 upstream) (0.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090627104045-7st10y1cqr6dpz37
Tags: 0.8.2+dfsg-1
* New upstream release
  + No longer uses a plugin repository.  Fixes many plugin-
    related issues. (LP: #343096, LP: #330025, LP #345001)
  + No longer blocks on "About Do" (LP: #361679)
  + Reacts correctly when a Composite manager is enabled/
    disabled at runtime. (LP: #346347, LP: #390150)
  + Fixes for space reserved by Docky blocking drag and 
    drop operations. (LP: #354729, LP: #347052, LP: #382843)
  + Properly sets "Hidden" key on autostart files in response to 
    "Start on login" option.  (Closes: #526023) (LP: #369988)
* debian/patches/10_application_search_path:
  + Drop; included upstream
* debian/patches/10_sk_translation_update:
  + Import sk translation update from Debian BTS.
    (Closes: #531779)
* debian/patches/11_fix_autostart_when_directory_does_not_exist:
  + Patch from upstream.  Fixes the "Start on login" option when the 
    ~/.config/autostart directory does not exist. (LP: #393729)
* debian/control:
  + Update standards version to 3.8.2; no changes required.
  + Add libtool to Build-Depends; required for autoreconf.
  + Add Recommends: on new gnome-do-docklets package.
* debian/gnome-do.1
  + Fix spelling: GNOME-Do => GNOME Do.
  + Miscelaneous lintian fixes; NAME section, escaping minus signs with \-
* debian/copyright:
  + Update for new copyright holders.
  + Minor update to DEP-5 format

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
using System.Linq;
23
23
using System.Collections.Generic;
24
24
using System.Runtime.InteropServices;
 
25
using System.Text.RegularExpressions;
25
26
 
26
27
using Gnome;
27
28
using Mono.Unix;
68
69
                        }
69
70
                        return appItem;
70
71
                }
 
72
                
 
73
                public static ApplicationItem MaybeCreateFromCmd (string cmd)
 
74
                {
 
75
                        if (string.IsNullOrEmpty (cmd))
 
76
                                return null;
 
77
                        
 
78
                        List<ApplicationItem> appItems = new List<ApplicationItem> ();
 
79
                        
 
80
                        cmd = Regex.Escape (cmd);
 
81
                        Regex regex = new Regex (string .Format ("(^| ){0}( |)", cmd));
 
82
                        foreach (ApplicationItem item in Instances.Values) {
 
83
                                string path = item.Location;
 
84
                                try {
 
85
                                        if (path.StartsWith ("file://"))
 
86
                                                path = path.Substring ("file://".Length); 
 
87
                                
 
88
                                        path = Path.GetFileName (path);
 
89
                                } catch { continue; }
 
90
                                
 
91
                                try {
 
92
                                        if (!string.IsNullOrEmpty (path) && !string.IsNullOrEmpty (item.Exec) &&
 
93
                                            (regex.IsMatch (path) || regex.IsMatch (item.Exec))) {
 
94
                                                appItems.Add (item);
 
95
                                        }
 
96
                                } catch {
 
97
                                        // it failed, probably a null somewhere, we dont care really
 
98
                                }
 
99
                        }
 
100
                        
 
101
                        ApplicationItem bestMatch = null;
 
102
                        
 
103
                        foreach (ApplicationItem item in appItems) {
 
104
                                if (bestMatch == null) {
 
105
                                        bestMatch = item;
 
106
                                        continue;
 
107
                                }
 
108
                                if (!item.Hidden) {
 
109
                                        if (bestMatch.Hidden) {
 
110
                                                bestMatch = item;
 
111
                                                continue;
 
112
                                        }
 
113
                                        if (item.IsAppropriateForCurrentDesktop) {
 
114
                                                if (!bestMatch.IsAppropriateForCurrentDesktop || item.Exec.Length < bestMatch.Exec.Length)
 
115
                                                        bestMatch = item;
 
116
                                        }
 
117
                                }
 
118
                        }
 
119
                        
 
120
                        return bestMatch;
 
121
                }
71
122
 
72
123
                protected DesktopItem item;
73
124
                string name, description, icon, mimetype;
 
125
                IEnumerable<string> categories;
74
126
 
75
127
                /// <summary>
76
128
                /// Create an application item from a desktop file.
86
138
                                name = item.GetLocalestring ("Name");
87
139
                                description = item.GetLocalestring ("Comment");
88
140
                                icon = item.GetString ("Icon") ?? DefaultApplicationIcon;
 
141
                                
 
142
                                if (item.AttrExists ("Categories"))
 
143
                                        categories = item.GetString ("Categories").Split (';');
 
144
                                else
 
145
                                        categories = Enumerable.Empty<string> ();
89
146
                        } else {
90
147
                                name = Path.GetFileName (item.Location);
91
148
                                description =
92
149
                                        Catalog.GetString ("This application could not be indexed.");
93
150
                                icon = DefaultApplicationIcon;
 
151
                                categories = Enumerable.Empty<string> ();
94
152
                        }
95
153
                }
96
154
                
105
163
                public override string Icon {
106
164
                        get { return icon; }
107
165
                }
 
166
                
 
167
                public IEnumerable<string> Categories {
 
168
                        get { return categories; }
 
169
                }
108
170
 
109
171
                public bool NoDisplay {
110
172
                        get {
115
177
                public string Exec {
116
178
                        get { return item.GetString ("Exec"); }
117
179
                }
 
180
                
 
181
                protected string Location {
 
182
                        get { return item.Location; }
 
183
                }
118
184
 
119
185
                public bool Hidden {
120
186
                        get { return item.GetBoolean ("NoDisplay"); }