bool OnLinkTagActivated(NoteTag sender, NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { return(OpenOrCreateLink(start, end)); }
void OnNoteDeleted(object sender, Note deleted) { if (deleted == this.Note) { return; } if (!ContainsText(deleted.Title)) { return; } string old_title_lower = deleted.Title.ToLower(); // Turn all link:internal to link:broken for the deleted note. NoteTag link_tag = Note.TagTable.LinkTag; NoteTag broken_link_tag = Note.TagTable.BrokenLinkTag; TextTagEnumerator enumerator = new TextTagEnumerator(Buffer, link_tag); foreach (TextRange range in enumerator) { if (range.Text.ToLower() != old_title_lower) { continue; } Buffer.RemoveTag(link_tag, range.Start, range.End); Buffer.ApplyTag(broken_link_tag, range.Start, range.End); } }
void OpenLinkActivate(object sender, EventArgs args) { Gtk.TextIter click_iter = Buffer.GetIterAtMark(click_mark); Gtk.TextIter start, end; NoteTag url_tag = Note.TagTable.UrlTag; url_tag.GetExtents(click_iter, out start, out end); OnUrlTagActivated(url_tag, (NoteEditor)Window.Editor, start, end); }
protected override void OnTagRemoved(Gtk.TextTag tag) { added_tags.Remove(tag); NoteTag note_tag = tag as NoteTag; if (note_tag != null) { note_tag.Changed -= OnTagChanged; } }
public override void Initialize() { if (Note.TagTable.Lookup ("lang:cjk") == null) { cjk_tag = new NoteTag ("lang:cjk"); cjk_tag.CanUndo = true; cjk_tag.CanGrow = true; cjk_tag.CanSpellCheck = false; Note.TagTable.Add (cjk_tag); } else { cjk_tag = (NoteTag)Note.TagTable.Lookup ("lang:cjk"); } }
void AddLanguageTag() { eal_tag = (NoteTag)Note.TagTable.Lookup ("language:eal"); if (eal_tag == null) { eal_tag = new NoteTag ("language:eal"); eal_tag.CanUndo = true; eal_tag.CanGrow = true; eal_tag.CanSpellCheck = false; // Trun off spell check Note.TagTable.Add (eal_tag); } }
public override void Initialize() { bold_tag = (NoteTag) Note.TagTable.Lookup ("bold"); italic_tag = (NoteTag) Note.TagTable.Lookup ("italic"); highlight_tag = (NoteTag) Note.TagTable.Lookup ("highlight"); underline_tag = (NoteTag) Note.TagTable.Lookup ("underline"); strikethrough_tag = (NoteTag) Note.TagTable.Lookup ("strikethrough"); /* url_tag = (NoteTag) Note.TagTable.Lookup ("link:url"); link_tag = (NoteTag) Note.TagTable.Lookup ("link:internal"); broken_link_tag = (NoteTag) Note.TagTable.Lookup ("link:broken"); */ }
protected int GetSplitOffset() { int offset = 0; foreach (TagData tag in splitTags) { NoteTag noteTag = tag.tag as NoteTag; if (noteTag.Image != null) { offset++; } } return(offset); }
// Called when the NoteAddin is attached to a Note public override void Initialize() { csList = new List<CodeSnippetWindow> (); if (Note.TagTable.Lookup ("codesnippet_code") == null) { NoteTag codesnippet_code_tag = new NoteTag ("codesnippet_code"); /* Invisible causes instability, replaced by Size = 1 * But it seems not to work in Windows. */ codesnippet_code_tag.Invisible = true; codesnippet_code_tag.Size = 1; codesnippet_code_tag.Editable = false; codesnippet_code_tag.CanSerialize = false; Note.TagTable.Add (codesnippet_code_tag); } }
bool OnUrlTagActivated(NoteTag sender, NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { string url = GetUrl(start, end); try { OpenUrl(url); } catch (GLib.GException e) { GuiUtils.ShowOpeningLocationError(Window, url, e.Message); } // Kill the middle button paste... return(true); }
void Attach() { // Make sure we add this tag before attaching, so // gtkspell will use our version. if (Note.TagTable.Lookup("gtkspell-misspelled") == null) { NoteTag tag = new NoteTag("gtkspell-misspelled"); tag.CanSerialize = false; tag.CanSpellCheck = true; tag.Underline = Pango.Underline.Error; Note.TagTable.Add(tag); } Buffer.TagApplied += TagApplied; if (obj_ptr == IntPtr.Zero) { obj_ptr = gtkspell_new_attach(Window.Editor.Handle, null, IntPtr.Zero); } }
/// <summary> /// Maps a Gtk.TextTag to ChangeType for saving notes /// </summary> /// <param name="tag">Gtk.TextTag to map</param> /// <returns>ChangeType to save this NoteTag</returns> public ChangeType GetChangeType(Gtk.TextTag tag) { ChangeType change; // Use tag Name for Gtk.TextTags switch (tag.Name) { // For extensibility, add Gtk.TextTag names here default: change = ChangeType.OtherDataChanged; break; } // Use SaveType for NoteTags NoteTag note_tag = tag as NoteTag; if (note_tag != null) { switch (note_tag.SaveType) { case TagSaveType.Meta: change = ChangeType.OtherDataChanged; break; case TagSaveType.Content: change = ChangeType.ContentChanged; break; case TagSaveType.NoSave: default: change = ChangeType.NoChange; break; } } return(change); }
public void Split(Gtk.TextIter iter, Gtk.TextBuffer buffer) { foreach (Gtk.TextTag tag in iter.Tags) { NoteTag noteTag = tag as NoteTag; if (noteTag != null && !noteTag.CanSplit) { Gtk.TextIter start = iter; Gtk.TextIter end = iter; // We only care about enclosing tags if (start.TogglesTag(tag) || end.TogglesTag(tag)) { continue; } start.BackwardToTagToggle(tag); end.ForwardToTagToggle(tag); AddSplitTag(start, end, tag); buffer.RemoveTag(tag, start, end); } } }
void OnPopulatePopup(object sender, Gtk.PopulatePopupArgs args) { Gtk.TextIter click_iter = Buffer.GetIterAtMark(click_mark); NoteTag url_tag = Note.TagTable.UrlTag; if (click_iter.HasTag(url_tag) || click_iter.EndsTag(url_tag)) { Gtk.MenuItem item; item = new Gtk.SeparatorMenuItem(); item.Show(); args.Menu.Prepend(item); item = new Gtk.MenuItem(Catalog.GetString("_Copy Link Address")); item.Activated += CopyLinkActivate; item.Show(); args.Menu.Prepend(item); item = new Gtk.MenuItem(Catalog.GetString("_Open Link")); item.Activated += OpenLinkActivate; item.Show(); args.Menu.Prepend(item); } }
void InitCommonTags() { NoteTag tag; // Font stylings tag = new NoteTag("centered"); tag.Justification = Gtk.Justification.Center; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("bold"); tag.Weight = Pango.Weight.Bold; tag.PaletteForeground = ContrastPaletteColor.Black; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("italic"); tag.Style = Pango.Style.Italic; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("strikethrough"); tag.Strikethrough = true; tag.PaletteForeground = ContrastPaletteColor.LightGrey; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("highlight"); tag.Background = "yellow"; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("find-match"); tag.Background = "lightgreen"; tag.CanSerialize = false; tag.CanSpellCheck = true; tag.SaveType = TagSaveType.Meta; Add(tag); tag = new NoteTag("note-title"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Blue; tag.Scale = Pango.Scale.XXLarge; // FiXME: Hack around extra rewrite on open tag.CanSerialize = false; tag.SaveType = TagSaveType.Meta; Add(tag); tag = new NoteTag("related-to"); tag.Scale = Pango.Scale.Small; tag.LeftMargin = 40; tag.Editable = false; tag.SaveType = TagSaveType.Meta; Add(tag); tag = new NoteTag("datetime"); tag.Scale = Pango.Scale.Small; tag.Style = Pango.Style.Italic; tag.PaletteForeground = ContrastPaletteColor.Grey; tag.CanGrow = true; tag.SaveType = TagSaveType.Meta; Add(tag); // Font sizes tag = new NoteTag("size:huge"); tag.Scale = Pango.Scale.XXLarge; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("size:large"); tag.Scale = Pango.Scale.XLarge; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("size:normal"); tag.Scale = Pango.Scale.Medium; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); tag = new NoteTag("size:small"); tag.Scale = Pango.Scale.Small; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add(tag); // Links tag = new NoteTag("link:broken"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Grey; tag.CanActivate = true; tag.SaveType = TagSaveType.Meta; Add(tag); BrokenLinkTag = tag; tag = new NoteTag("link:internal"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Blue; tag.CanActivate = true; tag.SaveType = TagSaveType.Meta; Add(tag); LinkTag = tag; tag = new NoteTag("link:url"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Green; tag.CanActivate = true; tag.SaveType = TagSaveType.Meta; Add(tag); UrlTag = tag; }
/// <summary> /// Initialize the Note (but no loading/buffer yet) /// </summary> public override void Initialize() { NoteTag tag = new NoteTag ("locked"); tag.Editable = false; tag.CanSerialize = false; if (Note.TagTable.Lookup ("locked") == null) Note.TagTable.Add (tag); // tag = new NoteTag ("priority"); // tag.CanActivate = true; // tag.CanSerialize = false; // tag.Foreground = "blue"; // tag.Family = "monospace"; // tag.Activated += OnPriorityClicked; tag = new PriorityTag ("priority", this); if (Note.TagTable.Lookup ("priority") == null) Note.TagTable.Add (tag); tag = new NoteTag ("checkbox-active"); //tag.CanActivate = true; tag.CanSerialize = false; tag.Family = "monospace"; //tag.Activated += ToggleCheckbox; if (Note.TagTable.Lookup ("checkbox-active") == null) Note.TagTable.Add (tag); tag = new NoteTag ("checkbox"); tag.CanActivate = true; tag.CanSerialize = false; tag.Family = "monospace"; if (Note.TagTable.Lookup ("checkbox") == null) Note.TagTable.Add (tag); if (Note.TagTable.Lookup ("duedate") == null) Note.TagTable.Add (new DateTag ("duedate", this)); //TaskTag if (!Note.TagTable.IsDynamicTagRegistered ("task")) Note.TagTable.RegisterDynamicTag ("task", typeof(TaskTag)); //TaskListTag if (!Note.TagTable.IsDynamicTagRegistered ("tasklist")) Note.TagTable.RegisterDynamicTag ("tasklist", typeof(TaskListTag)); if (!Note.TagTable.IsDynamicTagRegistered ("color")) Note.TagTable.RegisterDynamicTag ("color", typeof(ColorTag)); //StartListeners (); }
void InitCommonTags () { NoteTag tag; // Font stylings tag = new NoteTag ("centered"); tag.Justification = Gtk.Justification.Center; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("bold"); tag.Weight = Pango.Weight.Bold; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("italic"); tag.Style = Pango.Style.Italic; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("strikethrough"); tag.Strikethrough = true; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("highlight"); tag.Background = "yellow"; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("find-match"); tag.Background = "green"; tag.CanSerialize = false; tag.CanSpellCheck = true; tag.SaveType = TagSaveType.Meta; Add (tag); tag = new NoteTag ("note-title"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Blue; tag.Scale = Pango.Scale.XXLarge; // FiXME: Hack around extra rewrite on open tag.CanSerialize = false; tag.SaveType = TagSaveType.Meta; Add (tag); tag = new NoteTag ("related-to"); tag.Scale = Pango.Scale.Small; tag.LeftMargin = 40; tag.Editable = false; tag.SaveType = TagSaveType.Meta; Add (tag); tag = new NoteTag ("datetime"); tag.Scale = Pango.Scale.Small; tag.Style = Pango.Style.Italic; tag.PaletteForeground = ContrastPaletteColor.Grey; tag.CanGrow = true; tag.SaveType = TagSaveType.Meta; Add (tag); // Font sizes tag = new NoteTag ("size:huge"); tag.Scale = Pango.Scale.XXLarge; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("size:large"); tag.Scale = Pango.Scale.XLarge; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("size:normal"); tag.Scale = Pango.Scale.Medium; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); tag = new NoteTag ("size:small"); tag.Scale = Pango.Scale.Small; tag.CanUndo = true; tag.CanGrow = true; tag.CanSpellCheck = true; Add (tag); // Links tag = new NoteTag ("link:broken"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Grey; tag.CanActivate = true; tag.SaveType = TagSaveType.Meta; Add (tag); BrokenLinkTag = tag; tag = new NoteTag ("link:internal"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Blue; tag.CanActivate = true; tag.SaveType = TagSaveType.Meta; Add (tag); LinkTag = tag; tag = new NoteTag ("link:url"); tag.Underline = Pango.Underline.Single; tag.PaletteForeground = ContrastPaletteColor.Blue; tag.CanActivate = true; tag.SaveType = TagSaveType.Meta; Add (tag); UrlTag = tag; }
void Attach () { // Make sure we add this tag before attaching, so // gtkspell will use our version. if (Note.TagTable.Lookup ("gtkspell-misspelled") == null) { NoteTag tag = new NoteTag ("gtkspell-misspelled"); tag.CanSerialize = false; tag.CanSpellCheck = true; tag.Underline = Pango.Underline.Error; Note.TagTable.Add (tag); } Buffer.TagApplied += TagApplied; if (obj_ptr == IntPtr.Zero) { obj_ptr = gtkspell_new_attach (Window.Editor.Handle, null, IntPtr.Zero); } }
bool OnUrlTagActivated (NoteTag sender, NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { string url = GetUrl (start, end); try { OpenUrl (url); } catch (GLib.GException e) { GuiUtils.ShowOpeningLocationError (Window, url, e.Message); } // Kill the middle button paste... return true; }
bool OnLinkTagActivated (NoteTag sender, NoteEditor editor, Gtk.TextIter start, Gtk.TextIter end) { return OpenOrCreateLink (start, end); }
void WidgetSwap (NoteTag tag, Gtk.TextIter start, Gtk.TextIter end, bool adding) { if (tag.Widget == null) return; Gtk.TextIter prev = start; prev.BackwardChar (); WidgetInsertData data = new WidgetInsertData (); data.buffer = start.Buffer; data.tag = tag; data.widget = tag.Widget; data.adding = adding; if (adding) { data.position = start.Buffer.CreateMark (null, start, true); } else { data.position = tag.WidgetLocation; } widgetQueue.Enqueue (data); if (widgetQueueTimeout == 0) { widgetQueueTimeout = GLib.Idle.Add(RunWidgetQueue); } }