Beispiel #1
0
        /// <summary>
        /// Returns an array of NoteAddin objects that tomboy
        /// currently knows about.
        /// </summary>
        public NoteAddin [] GetNoteAddins()
        {
            NoteAddin [] addins;

            try {
                addins = (NoteAddin [])
                         Mono.Addins.AddinManager.GetExtensionObjects(
                    "/Tomboy/NoteAddins",
                    typeof(NoteAddin));
            } catch (Exception e) {
                Logger.Warn("No NoteAddins found: {0}", e.Message);
                addins = new NoteAddin [0];
            }

            return(addins);
        }
Beispiel #2
0
        void AttachAddin(string ext_node_id, Note note, NoteAddin addin)
        {
            if (ext_node_id == null || note == null || addin == null)
            {
                throw new ArgumentNullException("Cannot pass in a null parameter to AttachAddin");
            }

            // Loading the addin to the note
            try {
                addin.Initialize(note);
            } catch (Exception e) {
                Logger.Warn("Error initializing addin: {0}: {1}",
                            addin.GetType().ToString(), e.Message);
                // TODO: Would be nice to figure out how to just disable
                // the addin altogether if it's failing to initialize so
                // it doesn't keep causing problems.
                return;
            }

            NoteAddinInfo        info = new NoteAddinInfo(ext_node_id, note, addin);
            List <NoteAddinInfo> note_addin_list;
            List <NoteAddinInfo> ext_node_addin_list;

            if (note_addins.ContainsKey(note))
            {
                note_addin_list = note_addins [note];
            }
            else
            {
                note_addin_list    = new List <NoteAddinInfo> ();
                note_addins [note] = note_addin_list;
            }

            if (note_addin_infos.ContainsKey(ext_node_id))
            {
                ext_node_addin_list = note_addin_infos [ext_node_id];
            }
            else
            {
                ext_node_addin_list            = new List <NoteAddinInfo> ();
                note_addin_infos [ext_node_id] = ext_node_addin_list;
            }

            note_addin_list.Add(info);
            ext_node_addin_list.Add(info);
        }
Beispiel #3
0
        public void LoadAddinsForNote(Note note)
        {
            Mono.Addins.ExtensionNodeList list = Mono.Addins.AddinManager.GetExtensionNodes("/Tomboy/NoteAddins");
            foreach (Mono.Addins.ExtensionNode node in list)
            {
                Mono.Addins.TypeExtensionNode type_node =
                    node as Mono.Addins.TypeExtensionNode;

                try {
                    NoteAddin n_addin = type_node.CreateInstance() as NoteAddin;

                    // Keep track of the addins added to each note
                    AttachAddin(type_node.Id, note, n_addin);
                } catch (Exception e) {
                    Logger.Warn("Couldn't create a NoteAddin instance: {0}", e.Message);
                }
            }

            // Make sure we remove addins when a note is deleted
            note.Manager.NoteDeleted += OnNoteDeleted;
        }
Beispiel #4
0
        void OnNoteAddinEnabled(Mono.Addins.ExtensionNodeEventArgs args)
        {
            // Load NoteAddins
            if (Tomboy.DefaultNoteManager == null)
            {
                return;                 // too early -- YUCK!  Bad hack
            }

            foreach (Note note in Tomboy.DefaultNoteManager.Notes)
            {
                // Create a new NoteAddin
                Mono.Addins.TypeExtensionNode type_node =
                    args.ExtensionNode as Mono.Addins.TypeExtensionNode;

                try {
                    NoteAddin n_addin = type_node.CreateInstance() as NoteAddin;

                    // Keep track of the addins added to each note
                    AttachAddin(type_node.Id, note, n_addin);
                } catch (Exception e) {
                    Logger.Debug("Couldn't create a NoteAddin instance: {0}", e.Message);
                }
            }
        }
Beispiel #5
0
 public NoteAddinInfo(string node_id, Note note, NoteAddin addin)
 {
     this.extension_node_id = node_id;
     this.note       = note;
     this.note_addin = addin;
 }
Beispiel #6
0
		public NoteAddinInfo (string node_id, Note note, NoteAddin addin)
		{
			this.extension_node_id = node_id;
			this.note = note;
			this.note_addin = addin;
		}
Beispiel #7
0
		void AttachAddin (string ext_node_id, Note note, NoteAddin addin)
		{
			if (ext_node_id == null || note == null || addin == null)
				throw new ArgumentNullException ("Cannot pass in a null parameter to AttachAddin");

			// Loading the addin to the note
			try {
				addin.Initialize (note);
			} catch (Exception e) {
				Logger.Warn ("Error initializing addin: {0}: {1}",
				             addin.GetType ().ToString (), e.Message);
				// TODO: Would be nice to figure out how to just disable
				// the addin altogether if it's failing to initialize so
				// it doesn't keep causing problems.
				return;
			}

			NoteAddinInfo info = new NoteAddinInfo (ext_node_id, note, addin);
			List<NoteAddinInfo> note_addin_list;
			List<NoteAddinInfo> ext_node_addin_list;

			if (note_addins.ContainsKey (note))
				note_addin_list = note_addins [note];
			else {
				note_addin_list = new List<NoteAddinInfo> ();
				note_addins [note] = note_addin_list;
			}

			if (note_addin_infos.ContainsKey (ext_node_id))
				ext_node_addin_list = note_addin_infos [ext_node_id];
			else {
				ext_node_addin_list = new List<NoteAddinInfo> ();
				note_addin_infos [ext_node_id] = ext_node_addin_list;
			}

			note_addin_list.Add (info);
			ext_node_addin_list.Add (info);
		}
Beispiel #8
0
		/// <summary>
		/// Returns an array of NoteAddin objects that tomboy
		/// currently knows about.
		/// </summary>
		public NoteAddin [] GetNoteAddins ()
		{
			NoteAddin [] addins;

			try {
				addins = (NoteAddin [])
				         Mono.Addins.AddinManager.GetExtensionObjects (
				                 "/Tomboy/NoteAddins",
				                 typeof (NoteAddin));
			} catch (Exception e) {
				Logger.Warn ("No NoteAddins found: {0}", e.Message);
				addins = new NoteAddin [0];
			}

			return addins;
		}