From 6ffc1449361e408bccb734f5264cd325b7825793 Mon Sep 17 00:00:00 2001 From: Lynne Date: Sun, 6 Sep 2020 13:33:03 +1000 Subject: [PATCH] now you can add notes --- .gitignore | 1 + MainWindow.cs | 26 ++++++++++++ ui/main.glade | 108 ++++++++++++++++++++++++++++---------------------- 3 files changed, 88 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index a9e7e1f..5f51670 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ out/ yahoo.html .vs/ /buypeeb.sln +\#*.glade# diff --git a/MainWindow.cs b/MainWindow.cs index a0cfb43..ec062af 100755 --- a/MainWindow.cs +++ b/MainWindow.cs @@ -336,6 +336,12 @@ namespace Buypeeb { l.Text = row.Value; } + var noteBuffer = (TextBuffer)this.builder.GetObject("TextBufferSelectedNotes"); + noteBuffer.Clear(); + if (!String.IsNullOrWhiteSpace(item.notes)) { + noteBuffer.Text = item.notes; + } + var f = (ToggleButton)this.builder.GetObject("ButtonSelectedFavourite"); f.Active = item.favourite; @@ -651,6 +657,26 @@ namespace Buypeeb { } } + private void ButtonSelectedNotesClearClicked(object sender, EventArgs args) { + var item = this.selectedItem; + var md = this.MsgBox($"Are you sure you want to clear the notes for \"{item.name}\"?"); + if (md.Run() == (int)ResponseType.Ok) { + var noteBuffer = (TextBuffer)this.builder.GetObject("TextBufferSelectedNotes"); + noteBuffer.Clear(); + this.selectedItem.notes = null; + } + md.Dispose(); + } + + private void TextViewSelectedNotesFocusOut(object sender, FocusOutEventArgs args) { + // the "save" button does nothing, however, when you click the save button, you transfer focus to it, firing this event! + // how very sneaky + var noteBuffer = (TextBuffer)this.builder.GetObject("TextBufferSelectedNotes"); + if (this.selectedItem != null) { + this.selectedItem.notes = String.IsNullOrWhiteSpace(noteBuffer.Text) ? null : noteBuffer.Text; + } + } + // timers private bool UpdateSelectionEndTime() { diff --git a/ui/main.glade b/ui/main.glade index 8f45d2d..b53ce11 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -232,48 +232,6 @@ False - - - True - False - False - Undo - Undo - True - gtk-undo - - - - False - True - - - - - True - False - False - Redo - Redo - True - gtk-redo - - - - False - True - - - - - True - False - - - False - True - - True @@ -979,16 +937,72 @@ + True True 5 5 - - 100 + True - True - word - TextBufferSelectedNotes + False + 3 + 3 + vertical + 5 + + + 100 + True + True + word + TextBufferSelectedNotes + + + + False + True + 0 + + + + + True + False + + + Clear + True + True + True + + + + False + True + 0 + + + + + Save + True + True + True + + + False + True + end + 1 + + + + + False + True + 1 + +