~ted/ubuntu/lucid/tomboy/with-patch

« back to all changes in this revision

Viewing changes to Tomboy/Addins/NoteOfTheDay/NoteOfTheDay.cs

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2008-01-15 11:32:52 UTC
  • mfrom: (1.1.31 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080115113252-p59wg7nqkl6vcg7a
Tags: 0.9.4-0ubuntu1
* New upstream release (LP: #181798)
  - Fix crash during note deletion 
  - Fix null reference exception 
  - Fix mnemonics in sync preferences dialog 
  - Fix fuse mount timeout for sync 
  - New port option for SSH sync 
  - New multi-select notes support in Search All Notes window
  - New config dialog for Insert Timestamp Add-in 
  - New gconf preference, middle-click paste on Tomboy icon
  - New gconf preference, disable ESC closing notes 
  - New paragraph within a bullet with SHIFT + ENTER
  - New bug numbers as links in Export to HTML 
  - New notebook notes can be created off notebook's context menu.
  - New sketching add-in (still incomplete, --enable-sketching)
  - New "Unfiled Notes" item to notebook list 
  - New drag note to "Unfiled Notes" to remove from notebook 
 * debian/tomboy.menu: updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
namespace Tomboy.NoteOfTheDay
7
7
{
8
 
        public class NoteOfTheDay 
 
8
        public class NoteOfTheDay
9
9
        {
10
10
                public static string TemplateTitle = Catalog.GetString ("Today: Template");
11
 
                
 
11
 
12
12
                static string title_prefix = Catalog.GetString ("Today: ");
13
13
 
14
14
                public static string GetTitle (DateTime day)
28
28
                        else
29
29
                                return GetTemplateContent (title);
30
30
                }
31
 
                
 
31
 
32
32
                public static string GetTemplateContent (string title)
33
33
                {
34
34
                        const string base_xml =
35
 
                                "<note-content>" +
36
 
                                "<note-title>{0}</note-title>\n\n\n\n" +
37
 
                                "<size:huge>{1}</size:huge>\n\n\n" +
38
 
                                "<size:huge>{2}</size:huge>\n\n\n" +
39
 
                                "</note-content>";
 
35
                                "<note-content>" +
 
36
                                "<note-title>{0}</note-title>\n\n\n\n" +
 
37
                                "<size:huge>{1}</size:huge>\n\n\n" +
 
38
                                "<size:huge>{2}</size:huge>\n\n\n" +
 
39
                                "</note-content>";
40
40
 
41
 
                        return string.Format (base_xml, 
42
 
                                      title, 
43
 
                                      Catalog.GetString ("Tasks"),
44
 
                                      Catalog.GetString ("Appointments"));
 
41
                        return string.Format (base_xml,
 
42
                                              title,
 
43
                                              Catalog.GetString ("Tasks"),
 
44
                                              Catalog.GetString ("Appointments"));
45
45
                }
46
46
 
47
47
                public static Note Create (NoteManager manager, DateTime day)
55
55
                        } catch (Exception e) {
56
56
                                // Prevent blowup if note creation fails
57
57
                                Logger.Error (
58
 
                                        "NoteOfTheDay could not create \"{0}\": {1}",
59
 
                                        title,
60
 
                                        e.Message);
 
58
                                        "NoteOfTheDay could not create \"{0}\": {1}",
 
59
                                        title,
 
60
                                        e.Message);
61
61
                                notd = null;
62
62
                        }
63
63
 
64
64
                        if (notd != null) {
65
65
                                // Automatically tag all new Note of the Day notes
66
 
                                Tag notd_tag = TagManager.GetOrCreateTag (
67
 
                                                Catalog.GetString ("Note of the Day"));
 
66
                                Tag notd_tag = TagManager.GetOrCreateSystemTag (
 
67
                                                                        Catalog.GetString ("NoteOfTheDay"));
68
68
                                notd.AddTag (notd_tag);
69
 
                                
 
69
 
70
70
                                // notd.AddTag queues a save so the following is no longer necessary
71
71
                                //notd.Save ();
72
72
                        }
82
82
                public static bool HasChanged (Note note)
83
83
                {
84
84
                        string original_xml = GetContent(note.CreateDate, note.Manager);
85
 
                        if (GetContentWithoutTitle (note.TextContent) == 
86
 
                            GetContentWithoutTitle (XmlDecoder.Decode (original_xml))) {
 
85
                        if (GetContentWithoutTitle (note.TextContent) ==
 
86
                                        GetContentWithoutTitle (XmlDecoder.Decode (original_xml))) {
87
87
                                return false;
88
88
                        }
89
89
                        return true;
96
96
 
97
97
                        foreach (Note note in manager.Notes) {
98
98
                                if (note.Title.StartsWith (title_prefix) &&
99
 
                                    note.Title != TemplateTitle &&
100
 
                                    note.CreateDate.Date != date_today &&
101
 
                                    !HasChanged (note)) {
 
99
                                                note.Title != TemplateTitle &&
 
100
                                                note.CreateDate.Date != date_today &&
 
101
                                                !HasChanged (note)) {
102
102
                                        kill_list.Add (note);
103
103
                                }
104
104
                        }
105
 
                        
 
105
 
106
106
                        foreach (Note note in kill_list) {
107
107
                                Logger.Log ("NoteOfTheDay: Deleting old unmodified '{0}'",
108
 
                                                   note.Title);
 
108
                                            note.Title);
109
109
                                manager.Delete (note);
110
110
                        }
111
111
                }
112
 
                
 
112
 
113
113
                ///
114
114
                /// Returns the NotD note for the specified date
115
115
                ///
122
122
                        // created on the date specified.
123
123
                        foreach (Note note in manager.Notes) {
124
124
                                if (note.Title.StartsWith (title_prefix) &&
125
 
                                                note.Title != TemplateTitle) {
 
125
                                                note.Title != TemplateTitle) {
126
126
                                        DateTime note_date = note.CreateDate.Date;
127
127
                                        if (note_date == normalized_date) {
128
128
                                                found_note = note;
130
130
                                        }
131
131
                                }
132
132
                        }
133
 
                        
 
133
 
134
134
                        return found_note;
135
135
                }
136
136
        }