Merge lp:~artem-anufrij/footnote/restore-button-and-note-selection into lp:footnote

Proposed by Artem Anufrij
Status: Merged
Approved by: Artem Anufrij
Approved revision: 316
Merged at revision: 316
Proposed branch: lp:~artem-anufrij/footnote/restore-button-and-note-selection
Merge into: lp:footnote
Diff against target: 242 lines (+36/-34)
4 files modified
src/Footnote.vala (+2/-8)
src/Widgets/EditView.vala (+22/-4)
src/Widgets/Note.vala (+1/-0)
src/Widgets/NoteView.vala (+11/-22)
To merge this branch: bzr merge lp:~artem-anufrij/footnote/restore-button-and-note-selection
Reviewer Review Type Date Requested Status
Artem Anufrij (community) Approve
Review via email: mp+245956@code.launchpad.net

Commit message

- Show last opened note after selecting a notebook (before: always first note was selected)
- Restore button will be disabled if the selected note hasn't changes.
- Don't cut the title text on start up.

Description of the change

- Show last opened note after selecting a notebook (before: always first note was selected)
- Restore button will be disabled if the selected note hasn't changes.
- Don't cut the title text on start up.

To post a comment you must log in.
Revision history for this message
Artem Anufrij (artem-anufrij) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Footnote.vala'
--- src/Footnote.vala 2015-01-08 20:01:16 +0000
+++ src/Footnote.vala 2015-01-09 13:10:45 +0000
@@ -296,12 +296,14 @@
296 add_button.sensitive = true;296 add_button.sensitive = true;
297 var selected_item = ((Widgets.NotebookItem)item).notebook;297 var selected_item = ((Widgets.NotebookItem)item).notebook;
298 switch_to_notebook (selected_item);298 switch_to_notebook (selected_item);
299 topbar.show ();
299 } else if (item is Widgets.BookmarkItem) { //bookmarks300 } else if (item is Widgets.BookmarkItem) { //bookmarks
300 edit_button.sensitive = false;301 edit_button.sensitive = false;
301 add_button.sensitive = false;302 add_button.sensitive = false;
302 var note = ((Widgets.BookmarkItem)item).note;303 var note = ((Widgets.BookmarkItem)item).note;
303 stack.set_visible_child (note.notebook.view);304 stack.set_visible_child (note.notebook.view);
304 note.notebook.view.open_note (note, true);305 note.notebook.view.open_note (note, true);
306 topbar.hide ();
305 }307 }
306 });308 });
307 /*add a new notebook*/309 /*add a new notebook*/
@@ -382,14 +384,6 @@
382 generate_year_combobox ();384 generate_year_combobox ();
383 });385 });
384386
385 notebook.view.start_editing.connect (() => {
386 topbar.hide ();
387 });
388
389 notebook.view.stop_editing.connect (() => {
390 topbar.show ();
391 });
392
393 notebook.note_trashed.connect ((note) => {387 notebook.note_trashed.connect ((note) => {
394 generate_year_combobox ();388 generate_year_combobox ();
395 });389 });
396390
=== modified file 'src/Widgets/EditView.vala'
--- src/Widgets/EditView.vala 2015-01-08 19:51:05 +0000
+++ src/Widgets/EditView.vala 2015-01-09 13:10:45 +0000
@@ -31,6 +31,8 @@
31 private Gtk.ToggleToolButton strike;31 private Gtk.ToggleToolButton strike;
32 private Gtk.ToggleToolButton mark;32 private Gtk.ToggleToolButton mark;
33 33
34 private Gtk.ToolButton revert;
35
34 private bool applying_style = false;36 private bool applying_style = false;
35 37
36 public signal void close (bool reverse=false);38 public signal void close (bool reverse=false);
@@ -100,7 +102,7 @@
100 current_note.tag ("marked", mark.active);102 current_note.tag ("marked", mark.active);
101 });103 });
102104
103 var revert = new Gtk.ToolButton (null, null);105 revert = new Gtk.ToolButton (null, null);
104 revert.label = _("revert");106 revert.label = _("revert");
105 revert.icon_name = "document-revert";107 revert.icon_name = "document-revert";
106 revert.tooltip_text = _("Restore this file");108 revert.tooltip_text = _("Restore this file");
@@ -121,6 +123,7 @@
121 this.content.wrap_mode = Gtk.WrapMode.WORD_CHAR;123 this.content.wrap_mode = Gtk.WrapMode.WORD_CHAR;
122 this.title.get_style_context ().add_class ("h2");124 this.title.get_style_context ().add_class ("h2");
123 this.title.margin_top = 12;125 this.title.margin_top = 12;
126 this.title.style_updated ();
124127
125 content_scroll.margin_left = content_scroll.margin_right = this.title.margin_left = 12;128 content_scroll.margin_left = content_scroll.margin_right = this.title.margin_left = 12;
126129
@@ -132,15 +135,23 @@
132 135
133 this.add (container);136 this.add (container);
134 137
135 title.key_press_event.connect ( (e) => {138 /*
139 * EVENTS
140 */
141
142 this.title.key_press_event.connect ( (e) => {
136 if (e.keyval == Gdk.Key.Tab || e.keyval == Gdk.Key.Return) {143 if (e.keyval == Gdk.Key.Tab || e.keyval == Gdk.Key.Return) {
137 content.grab_focus ();144 content.grab_focus ();
138 return true;145 return true;
139 }146 }
140 return false;147 return false;
141 });148 });
149
150 this.title.buffer.changed.connect ( () => {
151 this.revert.sensitive = true;
152 });
142153
143 revert.clicked.connect ( () => {154 this.revert.clicked.connect ( () => {
144 this.cancel ();155 this.cancel ();
145 });156 });
146157
@@ -160,11 +171,14 @@
160 171
161 this.title.buffer.set_modified (false);172 this.title.buffer.set_modified (false);
162 this.content.buffer.set_modified (false);173 this.content.buffer.set_modified (false);
174 this.revert.sensitive = false;
163 }175 }
164 }176 }
165 177
166 private void cancel () {178 private void cancel () {
167 current_note.restore ();179 current_note.restore ();
180 this.title.buffer.text = current_note.title.label;
181 this.revert.sensitive = false;
168 }182 }
169 183
170 public void open_note (Note n) {184 public void open_note (Note n) {
@@ -193,6 +207,10 @@
193 applying_style = false;207 applying_style = false;
194 });208 });
195 209
210 content.buffer.changed.connect ( () => {
211 revert.sensitive = true;
212 });
213
196 if (n.title.label == _("Untitled") || n.title.label == _("New Note")) {214 if (n.title.label == _("Untitled") || n.title.label == _("New Note")) {
197 title.grab_focus ();215 title.grab_focus ();
198 title.select_all (true);216 title.select_all (true);
@@ -202,7 +220,7 @@
202 220
203 this.title.buffer.set_modified (false);221 this.title.buffer.set_modified (false);
204 this.content.buffer.set_modified (false);222 this.content.buffer.set_modified (false);
205 223 this.revert.sensitive = false;
206 current_note = n;224 current_note = n;
207 }225 }
208 }226 }
209227
=== modified file 'src/Widgets/Note.vala'
--- src/Widgets/Note.vala 2015-01-08 19:51:05 +0000
+++ src/Widgets/Note.vala 2015-01-09 13:10:45 +0000
@@ -103,6 +103,7 @@
103 content.buffer.create_tag ("italic", "style", Pango.Style.ITALIC);103 content.buffer.create_tag ("italic", "style", Pango.Style.ITALIC);
104 content.buffer.create_tag ("strikethrough", "strikethrough", true);104 content.buffer.create_tag ("strikethrough", "strikethrough", true);
105 content.buffer.create_tag ("marked", "background", "#ffff00");105 content.buffer.create_tag ("marked", "background", "#ffff00");
106
106 content.override_background_color (Gtk.StateFlags.NORMAL, {0, 0, 0, 0});107 content.override_background_color (Gtk.StateFlags.NORMAL, {0, 0, 0, 0});
107108
108 if (bookmarked) {109 if (bookmarked) {
109110
=== modified file 'src/Widgets/NoteView.vala'
--- src/Widgets/NoteView.vala 2015-01-08 20:03:43 +0000
+++ src/Widgets/NoteView.vala 2015-01-09 13:10:45 +0000
@@ -102,7 +102,7 @@
102 /*102 /*
103 * minimal version of note, just the ui103 * minimal version of note, just the ui
104 **/104 **/
105 public class NoteViewer : Gtk.Box {105 /*public class NoteViewer : Gtk.Box {
106 106
107 public Gtk.Label date;107 public Gtk.Label date;
108 public Gtk.Label title;108 public Gtk.Label title;
@@ -176,7 +176,7 @@
176 this.title.label = n.title.label;176 this.title.label = n.title.label;
177 this.date.label = n.date.label;177 this.date.label = n.date.label;
178 }178 }
179 }179 }*/
180180
181 /**181 /**
182 * Display a (filtered) list of Notes for the currently182 * Display a (filtered) list of Notes for the currently
@@ -189,13 +189,11 @@
189189
190 private FootnoteApp app;190 private FootnoteApp app;
191191
192 private Gtk.ScrolledWindow list_scroll;
193 private Gtk.Paned miller_paned;192 private Gtk.Paned miller_paned;
194 private Gtk.ListBox miller_listbox;193 private Gtk.ListBox miller_listbox;
195 private Gtk.ScrolledWindow miller_scroll;194 private Gtk.ScrolledWindow miller_scroll;
196 public EditView miller_noteviewer;195 public EditView miller_noteviewer;
197 private Gtk.ScrolledWindow miller_view_scroll;196 private Gtk.ScrolledWindow miller_view_scroll;
198 private Gtk.ListBox note_list;
199 private Notebook notebook;197 private Notebook notebook;
200 private Gtk.Stack main_stack;198 private Gtk.Stack main_stack;
201199
@@ -240,11 +238,6 @@
240 deletion_infobar.hide ();238 deletion_infobar.hide ();
241 });239 });
242240
243 note_list = new Gtk.ListBox ();
244 list_scroll = new Gtk.ScrolledWindow (null, null);
245 list_scroll.add (note_list);
246 list_scroll.expand = true;
247
248 miller_paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);241 miller_paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
249 miller_paned.position = Settings.get_default ().miller_handle_position;242 miller_paned.position = Settings.get_default ().miller_handle_position;
250 miller_paned.key_press_event.connect ( (e) => {243 miller_paned.key_press_event.connect ( (e) => {
@@ -269,10 +262,6 @@
269 return should_appear (((MillerRow)row).note);262 return should_appear (((MillerRow)row).note);
270 });263 });
271264
272 note_list.set_filter_func ((row) => {
273 return should_appear ((Note)row.get_child ());
274 });
275
276 var empty_label = new Gtk.Label (_("Notebook \"%s\" is empty").printf (notebook.title));265 var empty_label = new Gtk.Label (_("Notebook \"%s\" is empty").printf (notebook.title));
277 empty_label.expand = true;266 empty_label.expand = true;
278 empty_label.halign = Gtk.Align.CENTER;267 empty_label.halign = Gtk.Align.CENTER;
@@ -292,7 +281,6 @@
292 main_stack = new Gtk.Stack ();281 main_stack = new Gtk.Stack ();
293 main_stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;282 main_stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
294 main_stack.add_named (empty_grid, "empty");283 main_stack.add_named (empty_grid, "empty");
295 main_stack.add_named (list_scroll, "list");
296 main_stack.add_named (miller_paned, "miller");284 main_stack.add_named (miller_paned, "miller");
297285
298 add (deletion_infobar);286 add (deletion_infobar);
@@ -316,7 +304,6 @@
316 * Add a note to the view304 * Add a note to the view
317 */305 */
318 public void add_note (Note n, int pos=0) {306 public void add_note (Note n, int pos=0) {
319 note_list.insert (n, pos);
320 update_view ();307 update_view ();
321308
322 var row = new MillerRow (n);309 var row = new MillerRow (n);
@@ -356,13 +343,16 @@
356 return;343 return;
357 }344 }
358345
346 if (miller_listbox.get_selected_row () == null) {
347 var row = miller_listbox.get_row_at_index (0);
348 if (row != null) {
349 miller_listbox.select_row (row);
350 miller_listbox.row_activated (row);
351 }
352 } else
353 miller_view_scroll.show ();
354
359 main_stack.set_visible_child_name ("miller");355 main_stack.set_visible_child_name ("miller");
360 var row = miller_listbox.get_row_at_index (0);
361 if (row != null) {
362 miller_listbox.select_row (row);
363 miller_listbox.row_activated (row);
364 }
365
366 }356 }
367357
368 public void change_month (int month) {358 public void change_month (int month) {
@@ -387,7 +377,6 @@
387377
388 private async void update_notes_visibility () {378 private async void update_notes_visibility () {
389 miller_listbox.invalidate_filter ();379 miller_listbox.invalidate_filter ();
390 note_list.invalidate_filter ();
391 }380 }
392381
393 private bool should_appear (Note? note) {382 private bool should_appear (Note? note) {

Subscribers

People subscribed via source and target branches