void KeyOpenStartHere(object sender, EventArgs args) { manager.GtkInvoke(() => { Note note = manager.FindByUri(NoteManager.StartNoteUri); if (note != null) { note.Window.Present(); } }); }
bool PastePrimaryClipboard() { Gtk.Clipboard clip = GetClipboard(Gdk.Selection.Primary); string text = clip.WaitForText(); if (text == null || text.Trim() == string.Empty) { return(false); } Note link_note = manager.FindByUri(NoteManager.StartNoteUri); if (link_note == null) { return(false); } link_note.Window.Present(); PrependTimestampedText(link_note, DateTime.Now, text); return(true); }
public override object GetEntity(Uri absolute_uri, string role, Type of_object_to_return) { Note note = _manager.FindByUri(absolute_uri.ToString()); if (note == null) { return(null); } StringWriter writer = new StringWriter(); NoteArchiver.Write(writer, note.Data); Stream stream = WriterToStream(writer); writer.Close(); return(stream); }
public bool DisplayNote(string uri) { Note note; note = note_manager.FindByUri(uri); if (note == null) { return(false); } note.Window.Present(); return(true); }
public void AddRecentlyChangedNotes() { int min_size = (int)Preferences.Get(Preferences.MENU_NOTE_COUNT); int max_size = (int)Preferences.Get(Preferences.MENU_MAX_NOTE_COUNT); if (max_size < min_size) { max_size = min_size; } int list_size = 0; bool menuOpensUpward = tray.MenuOpensUpward(); NoteMenuItem item; // Remove the old dynamic items RemoveRecentlyChangedNotes(); // Assume menu opens downward, move common items to top of menu Gtk.MenuItem newNoteItem = Tomboy.ActionManager.GetWidget( "/TrayIconMenu/TrayNewNotePlaceholder/TrayNewNote") as Gtk.MenuItem; Gtk.MenuItem searchNotesItem = Tomboy.ActionManager.GetWidget( "/TrayIconMenu/ShowSearchAllNotes") as Gtk.MenuItem; tray_menu.ReorderChild(newNoteItem, 0); int insertion_point = 1; // If menu opens downward // Find all child widgets under the TrayNewNotePlaceholder // element. Make sure those added by add-ins are // properly accounted for and reordered. List <Gtk.Widget> newNotePlaceholderWidgets = new List <Gtk.Widget> (); IList <Gtk.Widget> allChildWidgets = Tomboy.ActionManager.GetPlaceholderChildren("/TrayIconMenu/TrayNewNotePlaceholder"); foreach (Gtk.Widget child in allChildWidgets) { if (child is Gtk.MenuItem && child != newNoteItem) { newNotePlaceholderWidgets.Add(child); tray_menu.ReorderChild(child, insertion_point); insertion_point++; } } tray_menu.ReorderChild(searchNotesItem, insertion_point); insertion_point++; DateTime days_ago = DateTime.Today.AddDays(-3); // Prevent template notes from appearing in the menu Tag template_tag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag); // List the most recently changed notes, any currently // opened notes, and any pinned notes... foreach (Note note in manager.Notes) { if (note.IsSpecial) { continue; } // Skip template notes if (note.ContainsTag(template_tag)) { continue; } bool show = false; // Test for note.IsPinned first so that all of the pinned notes // are guaranteed to be included regardless of the size of the // list. if (note.IsPinned) { show = true; } else if ((note.IsOpened && note.Window.IsMapped) || note.ChangeDate > days_ago || list_size < min_size) { if (list_size <= max_size) { show = true; } } if (show) { item = new NoteMenuItem(note, true); // Add this widget to the menu (+insertion_point to add after new+search+...) tray_menu.Insert(item, list_size + insertion_point); // Keep track of this item so we can remove it later recent_notes.Add(item); list_size++; } } Note start = manager.FindByUri(NoteManager.StartNoteUri); if (start != null) { item = new NoteMenuItem(start, false); if (menuOpensUpward) { tray_menu.Insert(item, list_size + insertion_point); } else { tray_menu.Insert(item, insertion_point); } recent_notes.Add(item); list_size++; bool enable_keybindings = (bool) Preferences.Get(Preferences.ENABLE_KEYBINDINGS); if (enable_keybindings) { GConfKeybindingToAccel.AddAccelerator( item, Preferences.KEYBINDING_OPEN_START_HERE); } } // FIXME: Rearrange this stuff to have less wasteful reordering if (menuOpensUpward) { // Relocate common items to bottom of menu insertion_point -= 1; tray_menu.ReorderChild(searchNotesItem, list_size + insertion_point); foreach (Gtk.Widget widget in newNotePlaceholderWidgets) { tray_menu.ReorderChild(widget, list_size + insertion_point); } tray_menu.ReorderChild(newNoteItem, list_size + insertion_point); insertion_point = list_size; } Gtk.SeparatorMenuItem separator = new Gtk.SeparatorMenuItem(); tray_menu.Insert(separator, insertion_point); recent_notes.Add(separator); }
private static void AddRecentNotes(ICustomDestinationList custom_destinationd_list, NoteManager note_manager, uint slots) { IObjectCollection object_collection = (IObjectCollection)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID.EnumerableObjectCollection)); // Prevent template notes from appearing in the menu Tag template_tag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag); uint index = 0; foreach (Note note in note_manager.Notes) { if (note.IsSpecial) { continue; } // Skip template notes if (note.ContainsTag(template_tag)) { continue; } string note_title = note.Title; if (note.IsNew) { note_title = String.Format(Catalog.GetString("{0} (new)"), note_title); } IShellLink note_link = CreateShellLink(note_title, tomboy_path, "--open-note " + note.Uri, System.IO.Path.Combine(icons_path, NoteIcon), -1); if (note_link != null) { object_collection.AddObject(note_link); } if (++index == slots - 1) { break; } } // Add Start Here note Note start_note = note_manager.FindByUri(NoteManager.StartNoteUri); if (start_note != null) { IShellLink start_note_link = CreateShellLink(start_note.Title, tomboy_path, "--open-note " + NoteManager.StartNoteUri, System.IO.Path.Combine(icons_path, NoteIcon), -1); if (start_note_link != null) { object_collection.AddObject(start_note_link); } } custom_destinationd_list.AppendCategory(Catalog.GetString("Recent Notes"), (IObjectArray)object_collection); Marshal.ReleaseComObject(object_collection); object_collection = null; }