=== modified file 'src/Footnote.vala' --- src/Footnote.vala 2011-12-24 10:29:11 +0000 +++ src/Footnote.vala 2011-12-25 20:52:21 +0000 @@ -47,6 +47,8 @@ public ToolButton edit_button; public Selected selected; public bool showing_search; + public Category cat; + public Adjustment VAdj; public Gtk.ActionGroup main_actions; Gtk.UIManager ui; @@ -210,6 +212,8 @@ scrolled2.add (note_view); hmain.pack_start (scrolled2); + this.VAdj = note_view.get_vadjustment (); + mainwindow.add (vmain); mainwindow.show_all (); @@ -245,6 +249,20 @@ selected.category.view.update_view (); } + public void set_view_to (Note n){ + var _notes = n.category.notes; + for (int i=0;i<_notes.size;i++) { + if (_notes[i] == n) { + var last_note = _notes[i-1]; + // 222 is the size of a new note. 15 is the size of the border under the note + this.VAdj.set_upper (this.VAdj.upper + 222 + 15); + // it scrolls till last note plus the the size of a new note + this.VAdj.set_value (last_note.y + last_note.height + 222); + break; + } + } + } + private void set_actions () { main_actions = new Gtk.ActionGroup ("MainActionGroup"); /* Actions and UIManager */ main_actions.set_translation_domain ("footnote"); @@ -307,6 +325,7 @@ public void action_new_note (){ // FIXME: move Note creation into Category nt.selected.category.add_note(new Note.add (nt, nt.selected.category)); + nt.set_view_to (nt.selected.note); } public void action_new_notebook (){ new Category.add (nt); === modified file 'src/Widgets/Note.vala' --- src/Widgets/Note.vala 2011-12-24 10:29:11 +0000 +++ src/Widgets/Note.vala 2011-12-25 20:59:15 +0000 @@ -35,6 +35,8 @@ public TextView content_entry; public string date; public Widgets.TaggingArea tag_area; + public int y; + public int height; public Note.from_existing (FootnoteApp app, Category category, string title, string content, string tags, int id, string date){ this.title = title; @@ -55,7 +57,7 @@ public override bool draw (Cairo.Context ctx){ int w = this.get_allocated_width() - 8; int h = this.get_allocated_height() - 8; - + //shadow double [] opacity = {0.4, 0.3, 0.2, 0.1}; for (var i=1;i<4;i++){ @@ -71,6 +73,13 @@ } private void build (FootnoteApp app){ + this.size_allocate.connect ( ()=>{ + Allocation alloc; + this.get_allocation (out alloc); + this.y = alloc.y; + this.height = get_allocated_height(); + }); + this.visible_window = false; this.set_resize_mode (ResizeMode.PARENT); var entry_box = new VBox (false,0); @@ -172,6 +181,7 @@ app.selected.note = this; app.selected.category = this.category; //just make sure... }); + app.selected.note = this; } private void on_focus_in (FootnoteApp app) {