Set() public static method

public static Set ( string key, object value ) : void
key string
value object
return void
Beispiel #1
0
        protected virtual void LoadNotes()
        {
            Logger.Debug("Loading notes");
            string [] files = Directory.GetFiles(notes_dir, "*.note");

            foreach (string file_path in files)
            {
                try {
                    Note note = Note.Load(file_path, this);
                    if (note != null)
                    {
                        note.Renamed       += OnNoteRename;
                        note.Saved         += OnNoteSave;
                        note.BufferChanged += OnBufferChanged;
                        notes.Add(note);
                    }
                } catch (System.Xml.XmlException e) {
                    Logger.Error("Error parsing note XML, skipping \"{0}\": {1}",
                                 file_path,
                                 e.Message);
                } catch (System.IO.IOException e) {
                    Logger.Error("Note {0} can not be loaded - file corrupted?: {1}",
                                 file_path,
                                 e.Message);
                    Gtk.MessageDialog md =
                        new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent,
                                              Gtk.MessageType.Error,
                                              Gtk.ButtonsType.Close,
                                              "Skipping a note.\n {0} can not be loaded - Error loading file!",
                                              file_path
                                              );
                    md.Run();
                    md.Destroy();
                } catch (System.UnauthorizedAccessException e) {
                    Logger.Error("Note {0} can not be loaded - access denied: {1}",
                                 file_path,
                                 e.Message);
                    Gtk.MessageDialog md =
                        new Gtk.MessageDialog(null, Gtk.DialogFlags.DestroyWithParent,
                                              Gtk.MessageType.Error,
                                              Gtk.ButtonsType.Close,
                                              "Skipping a note.\n {0} can not be loaded - Access denied!",
                                              file_path
                                              );
                    md.Run();
                    md.Destroy();
                }
            }

            notes.Sort(new CompareDates());

            // Update the trie so addins can access it, if they want.
            trie_controller.Update();

            bool startup_notes_enabled = (bool)
                                         Preferences.Get(Preferences.ENABLE_STARTUP_NOTES);

            // Load all the addins for our notes.
            // Iterating through copy of notes list, because list may be
            // changed when loading addins.
            List <Note> notesCopy = new List <Note> (notes);

            foreach (Note note in notesCopy)
            {
                addin_mgr.LoadAddinsForNote(note);

                // Show all notes that were visible when tomboy was shut down
                if (note.IsOpenOnStartup)
                {
                    if (startup_notes_enabled)
                    {
                        note.Window.Show();
                    }

                    note.QueueSave(ChangeType.NoChange);
                }
            }

            // Make sure that a Start Note Uri is set in the preferences, and
            // make sure that the Uri is valid to prevent bug #508982. This
            // has to be done here for long-time Tomboy users who won't go
            // through the CreateStartNotes () process.
            if (StartNoteUri == String.Empty ||
                FindByUri(StartNoteUri) == null)
            {
                // Attempt to find an existing Start Here note
                Note start_note = Find(Catalog.GetString("Start Here"));
                if (start_note != null)
                {
                    Preferences.Set(Preferences.START_NOTE_URI, start_note.Uri);
                }
            }

            if (NotesLoaded != null)
            {
                NotesLoaded(this, EventArgs.Empty);
            }
        }
Beispiel #2
0
        protected virtual void CreateStartNotes()
        {
            // FIXME: Delay the creation of the start notes so the panel/tray
            // icon has enough time to appear so that Tomboy.TrayIconShowing
            // is valid.  Then, we'll be able to instruct the user where to
            // find the Tomboy icon.
            //string icon_str = Tomboy.TrayIconShowing ?
            //     Catalog.GetString ("System Tray Icon area") :
            //     Catalog.GetString ("GNOME Panel");
            string start_note_content =
                Catalog.GetString("<note-content>" +
                                  "Start Here\n\n" +
                                  "<bold>Welcome to Tomboy!</bold>\n\n" +
                                  "Use this \"Start Here\" note to begin organizing " +
                                  "your ideas and thoughts.\n\n" +
                                  "You can create new notes to hold your ideas by " +
                                  "selecting the \"Create New Note\" item from the " +
                                  "Tomboy Notes menu in your GNOME Panel. " +
                                  "Your note will be saved automatically.\n\n" +
                                  "Then organize the notes you create by linking " +
                                  "related notes and ideas together!\n\n" +
                                  "We've created a note called " +
                                  "<link:internal>Using Links in Tomboy</link:internal>.  " +
                                  "Notice how each time we type <link:internal>Using " +
                                  "Links in Tomboy</link:internal> it automatically " +
                                  "gets underlined?  Click on the link to open the note." +
                                  "</note-content>");

            string links_note_content =
                Catalog.GetString("<note-content>" +
                                  "Using Links in Tomboy\n\n" +
                                  "Notes in Tomboy can be linked together by " +
                                  "highlighting text in the current note and clicking" +
                                  " the <bold>Link</bold> button above in the toolbar.  " +
                                  "Doing so will create a new note and also underline " +
                                  "the note's title in the current note.\n\n" +
                                  "Changing the title of a note will update links " +
                                  "present in other notes.  This prevents broken links " +
                                  "from occurring when a note is renamed.\n\n" +
                                  "Also, if you type the name of another note in your " +
                                  "current note, it will automatically be linked for you." +
                                  "</note-content>");

            try {
                Note start_note = Create(Catalog.GetString("Start Here"),
                                         start_note_content);
                start_note.QueueSave(ChangeType.ContentChanged);
                Preferences.Set(Preferences.START_NOTE_URI, start_note.Uri);

                Note links_note = Create(Catalog.GetString("Using Links in Tomboy"),
                                         links_note_content);
                links_note.QueueSave(ChangeType.ContentChanged);

                if (!Tomboy.IsPanelApplet)
                {
                    start_note.Window.Show();
                }
            } catch (Exception e) {
                Logger.Warn("Error creating start notes: {0}\n{1}",
                            e.Message, e.StackTrace);
            }
        }