~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Tomboy/TomboyItemSource.cs

  • Committer: Richard Harding
  • Date: 2008-03-22 02:36:12 UTC
  • Revision ID: rharding@traken-20080322023612-1k329velnao3h83m
 * correct the source header of the AptUrl plugin 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  NotesItemSource.cs
 
1
//  TomboyItems.cs
2
2
//
3
 
//  GNOME Do is the legal property of its developers, whose names are too
4
 
//  numerous to list here.  Please refer to the COPYRIGHT file distributed with
5
 
//  this source distribution.
 
3
//  GNOME Do is the legal property of its developers, whose names are too numerous
 
4
//  to list here.  Please refer to the COPYRIGHT file distributed with this
 
5
//  source distribution.
6
6
//
7
7
//  This program is free software: you can redistribute it and/or modify
8
8
//  it under the terms of the GNU General Public License as published by
21
21
using System.Collections;
22
22
using System.Collections.Generic;
23
23
 
 
24
using Do.Addins;
24
25
using Do.Universe;
25
26
 
26
 
namespace Tomboy
27
 
{       
28
 
        public class NotesItemSource : IItemSource
29
 
        {
30
 
                List<IItem> notes;      
 
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
                }
31
42
 
32
43
                /// <summary>
33
44
                /// When creating an instance of this item source get the initial
34
45
                /// list of tomboy notes
35
46
                /// </summary>
36
 
                public NotesItemSource ()
37
 
                {
 
47
                public TomboyItemSource() {
38
48
                        notes = new List<IItem> ();                     
 
49
                        UpdateItems ();
39
50
                }
40
51
                
41
52
                /// <summary>
69
80
                public Type[] SupportedItemTypes {
70
81
                        get {
71
82
                                return new Type[] {
72
 
                                        typeof (NoteItem),
 
83
                                        typeof (TomboyItem),
73
84
                                };
74
85
                        }
75
86
                }
84
95
                /// A <see cref="ICollection`1"/>
85
96
                /// </returns>
86
97
                public ICollection<IItem> Items {
87
 
                        get { return notes; }
 
98
                        get {
 
99
                                return this.notes;
 
100
                        }
88
101
                }
89
102
                
90
103
                public ICollection<IItem> ChildrenOfItem (IItem item)
93
106
                }
94
107
                
95
108
                /// <summary>
96
 
                /// This method run in the constructor to find the notes we can get
97
 
                /// ahold of.
 
109
                /// This method run in the constructor to find the notes we can get a hold of
98
110
                /// </summary>
99
111
                public void UpdateItems ()
100
112
                {                       
101
 
                        TomboyDBus tb = new TomboyDBus();
102
 
                        foreach(string title in tb.GetAllNoteTitles ()) {
103
 
                                notes.Add (new NoteItem (title));
 
113
                        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));
 
121
                                }
 
122
                        } catch (Exception e) {
 
123
                                Console.WriteLine ("Cannot index Tomboy Notes because a {0} was thrown: {1}", e.GetType (), e.Message);
 
124
                                return;
104
125
                        }
105
126
                }
106
127
        }