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

« back to all changes in this revision

Viewing changes to Do/src/Do.Core/DoObject.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:
21
21
using System;
22
22
using System.Collections.Generic;
23
23
 
 
24
using Do.Addins;
24
25
using Do.Universe;
25
26
 
26
27
namespace Do.Core {
27
28
 
28
 
        public abstract class DoObject : IObject, IComparable<IObject> {
 
29
        public class DoObject : IObject, IConfigurable, IComparable<IObject> {
29
30
 
30
31
                const string DefaultName = "No name";
31
32
                const string DefaultDescription = "No description.";
32
33
                const string DefaultIcon = "emblem-noread";
33
34
                
34
 
                static RelevanceProvider relevanceProvider;
35
 
 
36
 
                static DoObject ()
37
 
                {
38
 
                        relevanceProvider = RelevanceProvider.GetProvider ();
39
 
                }
 
35
                static RelevanceProvider relevanceProvider = RelevanceProvider.GetProvider ();
40
36
 
41
37
                public static bool IObjectTypeCheck (IObject o, Type [] types)
42
38
                {
103
99
                
104
100
                protected IObject inner;
105
101
                protected float relevance;
 
102
                protected string uid;
106
103
                
107
 
                protected DoObject (IObject inner)
 
104
                internal DoObject (IObject inner)
108
105
                {
109
106
                        if (inner == null)
110
 
                                throw new ArgumentNullException ("Inner IObject may not be null.");
111
 
 
 
107
                                throw new ArgumentNullException ("inner","Inner IObject may not be null.");
112
108
                        this.inner = inner;
 
109
                        
 
110
                        uid = string.Format ("{0}{1}{2}",
 
111
                                        inner.GetType (), Name, Description);
113
112
                }
114
113
 
115
114
                public virtual IObject Inner {
164
163
                        }
165
164
                }
166
165
                
 
166
                public Gtk.Bin GetConfiguration ()
 
167
                {
 
168
                        Gtk.Bin config = null;
 
169
                        try {
 
170
                                if (Inner is IConfigurable)
 
171
                                        config = (Inner as IConfigurable).GetConfiguration ();
 
172
                        } catch {
 
173
                        }
 
174
                        return config;
 
175
                }
 
176
                
167
177
                public virtual string UID {
168
178
                        get {
169
 
                                return string.Format ("{0}{1}{2}",
170
 
                                        inner.GetType (), Name, Description);
 
179
                                return uid;
171
180
                        }
172
181
                }
173
182
                
222
231
 
223
232
                protected void LogError (string where, Exception e, string name)
224
233
                {
225
 
                        Log.Error ("\"{0}\" ({1}) encountered an error in {2}:\n\t" +
226
 
                                       "{3}: {4}",
227
 
                                name, (inner != null ? inner.GetType () : GetType ()),
228
 
                                where, e.GetType (), e.Message);
 
234
                        Type t = inner != null ? inner.GetType () : GetType ();
 
235
                        Log.Error ("\"{0}\" ({1}) encountered an error in {2}: {3}",
 
236
                                name, t, where, e.Message);
229
237
                }
230
238
        }
231
239
}