~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Tomboy/src/TomboyItemSource.cs

Spring cleaning. God Monodevelop is a luxury.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
using System.Collections;
22
22
using System.Collections.Generic;
23
23
 
24
 
using Do.Addins;
25
24
using Do.Universe;
26
25
 
27
 
namespace Do.Addins.Tomboy
28
 
{
29
 
        
30
 
        public class TomboyItemSource : IItemSource {
31
 
                private List<IItem> notes = null;       
32
 
 
33
 
                public struct NoteStruct {
34
 
                        public string title;
35
 
                        public long changed_date;
36
 
                        
37
 
                        public NoteStruct(string note_title, long note_changed_date) {
38
 
                                title = note_title;
39
 
                                changed_date = note_changed_date;
40
 
                        }
41
 
                }
 
26
namespace Tomboy
 
27
{       
 
28
        public class TomboyItemSource : IItemSource
 
29
        {
 
30
                List<IItem> notes;      
42
31
 
43
32
                /// <summary>
44
33
                /// When creating an instance of this item source get the initial
45
34
                /// list of tomboy notes
46
35
                /// </summary>
47
 
                public TomboyItemSource() {
 
36
                public TomboyItemSource ()
 
37
                {
48
38
                        notes = new List<IItem> ();                     
49
39
                        UpdateItems ();
50
40
                }
96
86
                /// </returns>
97
87
                public ICollection<IItem> Items {
98
88
                        get {
99
 
                                return this.notes;
 
89
                                return notes;
100
90
                        }
101
91
                }
102
92
                
111
101
                public void UpdateItems ()
112
102
                {                       
113
103
                        try {
114
 
                                TomboyDBus TBoy = new TomboyDBus();
115
 
                                ArrayList note_titles = TBoy.GetAllNoteTitles();
116
 
                                
117
 
                                foreach(string title in note_titles) {
118
 
                                        long changed_date = TBoy.GetNoteChangedDate(title);
119
 
                                        NoteStruct new_note = new NoteStruct(title, changed_date);
120
 
                                        notes.Add(new TomboyItem(new_note));
 
104
                                TomboyDBus tb = new TomboyDBus();
 
105
                                foreach(string title in tb.GetAllNoteTitles ()) {
 
106
                                        notes.Add (new TomboyItem (title));
121
107
                                }
122
108
                        } catch (Exception e) {
123
 
                                Console.WriteLine ("Cannot index Tomboy Notes because a {0} was thrown: {1}", e.GetType (), e.Message);
124
 
                                return;
 
109
                                Console.Error.WriteLine ("Cannot index Tomboy Notes: {0}", e.Message);
125
110
                        }
126
111
                }
127
112
        }