~ubuntu-branches/ubuntu/precise/gnome-do/precise-proposed

« back to all changes in this revision

Viewing changes to Do.Addins/src/Do.Universe/FileItem.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-09-14 10:09:40 UTC
  • mto: (0.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20080914100940-kyghudg7py14bu2z
Tags: upstream-0.6.0.0
ImportĀ upstreamĀ versionĀ 0.6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
                                .Replace ("'", "\\'");
112
112
        }
113
113
                
114
 
                protected string path;
 
114
                protected string path, name, description, icon;
115
115
                
116
116
                /// <summary>
117
117
                /// Create a new FileItem for a given file.
122
122
                public FileItem (string path)
123
123
                {       
124
124
                        this.path = path;
 
125
                        this.name = System.IO.Path.GetFileName (Path);
 
126
                        
 
127
                        string short_path;
 
128
                                
 
129
                        short_path = ShortPath (Path);
 
130
                        if (short_path == "~")
 
131
                                // Sowing only "~" looks too abbreviated.
 
132
                                description = Path;
 
133
                        else
 
134
                                description = short_path;
 
135
                        
 
136
                        icon = MimeType;
 
137
                        try {
 
138
                                if (icon == "x-directory/normal") {
 
139
                                        icon = "folder";
 
140
                                } else if (icon.StartsWith ("image")) {
 
141
                                        icon = "gnome-mime-image";
 
142
                                } else {
 
143
                                        icon = icon.Replace ('/', '-');
 
144
                                        icon = string.Format ("gnome-mime-{0}", icon);
 
145
                                }
 
146
                        } catch (NullReferenceException) {
 
147
                                icon = "gtk-file";
 
148
                        }
125
149
                }
126
150
                
127
151
                public virtual string Name {
128
152
                        get {
129
 
                                return System.IO.Path.GetFileName (Path);
 
153
                                return name;
130
154
                        }
131
155
                }
132
156
                
133
157
                public virtual string Description {
134
158
                        get {
135
 
                                string short_path;
136
 
                                
137
 
                                short_path = ShortPath (Path);
138
 
                                if (short_path == "~")
139
 
                                        // Sowing only "~" looks too abbreviated.
140
 
                                        return Path;
141
 
                                else
142
 
                                        return short_path;
 
159
                                return description;
143
160
                        }
144
161
                }
145
162
                
146
163
                public virtual string Icon {
147
164
                        get {
148
 
                                string icon;
149
 
 
150
 
                                icon = MimeType;
151
 
                                try {
152
 
                                        if (icon == "x-directory/normal") {
153
 
                                                icon = "folder";
154
 
                                        } else if (icon.StartsWith ("image")) {
155
 
                                                icon = "gnome-mime-image";
156
 
                                        } else {
157
 
                                                icon = icon.Replace ('/', '-');
158
 
                                                icon = string.Format ("gnome-mime-{0}", icon);
159
 
                                        }
160
 
                                } catch (NullReferenceException) {
161
 
                                        icon = "gtk-file";
162
 
                                }
163
165
                                return icon;
164
166
                        }
165
167
                }