Merge lp:~artem-anufrij/footnote/optimize-workflow into lp:footnote

Proposed by Artem Anufrij
Status: Merged
Approved by: Artem Anufrij
Approved revision: 319
Merged at revision: 315
Proposed branch: lp:~artem-anufrij/footnote/optimize-workflow
Merge into: lp:footnote
Diff against target: 687 lines (+111/-175)
5 files modified
src/Database.vala (+14/-12)
src/Footnote.vala (+6/-39)
src/Widgets/EditView.vala (+31/-44)
src/Widgets/Note.vala (+12/-15)
src/Widgets/NoteView.vala (+48/-65)
To merge this branch: bzr merge lp:~artem-anufrij/footnote/optimize-workflow
Reviewer Review Type Date Requested Status
Artem Anufrij (community) Approve
Review via email: mp+245903@code.launchpad.net

Commit message

- Show last save date, instead create date.
- autosave on selection_changed (like Scratch)
- autosave on window destroy (like Scratch)
- no "read_only" mode. The note can be instant modified after selected it.
- delete/export/bookmark - buttons are moved into listbox items (mouse over, like Geary).
- some improvement of code design

Description of the change

- Show last save date, instead create date.
- autosave on selection_changed (like Scratch)
- autosave on window destroy (like Scratch)
- no "read_only" mode. The note can be instant modified after selected it.
- delete/export/bookmark - buttons are moved into listbox items (mouse over, like Geary).
- some improvement of code design

To post a comment you must log in.
317. By artem-anufrij

remove // line

318. By artem-anufrij

remove comment lines

319. By artem-anufrij

remove comment lines

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
1=== modified file 'src/Database.vala'
2--- src/Database.vala 2015-01-06 21:31:31 +0000
3+++ src/Database.vala 2015-01-08 20:03:55 +0000
4@@ -31,10 +31,10 @@
5 private SQLHeavy.Database db;
6
7 private DataBase () {
8- var db_file = File.new_for_path (Environment.get_user_data_dir ()+"/footnote/notes.db");
9+ var db_file = File.new_for_path (Environment.get_user_data_dir () + "/footnote/notes.db");
10 var need_create = !db_file.query_exists ();
11 try {
12- db = new SQLHeavy.Database (Environment.get_user_data_dir ()+"/footnote/notes.db",
13+ db = new SQLHeavy.Database (Environment.get_user_data_dir () + "/footnote/notes.db",
14 SQLHeavy.FileMode.READ | SQLHeavy.FileMode.WRITE | SQLHeavy.FileMode.CREATE);
15 if (need_create) {
16 db.execute ("CREATE TABLE notebooks (name TEXT, color TEXT, id INTEGER PRIMARY KEY AUTOINCREMENT);");
17@@ -66,6 +66,7 @@
18
19 public void update_note (Widgets.Note note) {
20 try {
21+ DateTime datetime = new DateTime.now_local ();
22 Gtk.TextIter s, e;
23 note.content.buffer.get_bounds (out s, out e);
24 uint8 [] data = note.content.buffer.serialize (note.content.buffer, note.format, s, e);
25@@ -73,9 +74,10 @@
26 q.set_string (":title", note.title.label);
27 q.set_blob (":content", data);
28 q.set_int (":bookmarked", (int)note.bookmarked);
29- q.set_int64 (":date", note.datetime.to_unix ());
30+ q.set_int64 (":date", datetime.to_unix ());
31 q.set_int (":id", note.id);
32 q.execute ();
33+ note.datetime = datetime;
34 note.edited ();
35 } catch (SQLHeavy.Error e) {
36 critical (e.message);
37@@ -95,12 +97,12 @@
38 public void restore_note (Widgets.Note note) {
39
40 try {
41- var q = db.prepare ("SELECT title,content,rowid,date,bookmarked FROM 'notes' WHERE rowid=:id");
42+ var q = db.prepare ("SELECT title, content, rowid, date, bookmarked FROM 'notes' WHERE rowid=:id");
43 q.set_int (":id", note.id);
44-
45+
46 var res = q.execute ();
47
48- DateTime datetime = datetime_converter (res);
49+ DateTime datetime = datetime_converter (res, 3);
50
51 // TITLE
52 note.title.label = res.fetch_string (0);
53@@ -138,10 +140,10 @@
54 public Gee.ArrayList<Widgets.Note> get_notes_from_notebook (Widgets.Notebook nb) {
55 var list = new Gee.ArrayList<Widgets.Note> ();
56 try {
57- var q = db.prepare ("SELECT title,content,rowid,date,bookmarked FROM 'notes' WHERE notebook = :id ORDER BY rowid ASC;");
58+ var q = db.prepare ("SELECT title, content, rowid, date, bookmarked FROM 'notes' WHERE notebook = :id ORDER BY rowid ASC;");
59 q.set_int (":id", nb.id);
60 for (var res = q.execute (); !res.finished; res.next ()) {
61- DateTime datetime = datetime_converter (res);
62+ DateTime datetime = datetime_converter (res, 3);
63
64 var note = new Widgets.Note.from_existing (nb, res.fetch_string (0), res.fetch_blob (1),
65 res.fetch_int (2), datetime, (bool)res.fetch_int (4));
66@@ -262,12 +264,12 @@
67 dialog.destroy ();
68 }
69
70- public DateTime datetime_converter (SQLHeavy.QueryResult res) {
71+ public DateTime datetime_converter (SQLHeavy.QueryResult res, int column_index) {
72 DateTime return_value = new DateTime.now_local ();
73
74 try {
75- if (res.field_type (3) == typeof(string)) {
76- var date_string = res.fetch_string (3);
77+ if (res.field_type (column_index) == typeof(string)) {
78+ var date_string = res.fetch_string (column_index);
79 var parts = date_string.split (" ", 3);
80 var hour_parts = parts[0].split (":", 2);
81 var day_parts = parts[2].split (".", 3);
82@@ -279,7 +281,7 @@
83
84 return_value = new DateTime.local (year, month, day, hours, minutes, 0);
85 } else
86- return_value = new DateTime.from_unix_local (res.fetch_int64 (3));
87+ return_value = new DateTime.from_unix_local (res.fetch_int64 (column_index));
88 } catch (SQLHeavy.Error e) {
89 critical (e.message);
90 }
91
92=== modified file 'src/Footnote.vala'
93--- src/Footnote.vala 2015-01-03 23:38:01 +0000
94+++ src/Footnote.vala 2015-01-08 20:03:55 +0000
95@@ -55,7 +55,6 @@
96 public Gtk.Window mainwindow;
97 public Widgets.SideBar sidebar;
98 public Granite.Widgets.Welcome welcome;
99- public Granite.Widgets.ModeButton view_mode;
100 public Granite.Widgets.ThinPaned hmain;
101 private Gtk.Stack stack;
102
103@@ -86,7 +85,7 @@
104 public bool showing_search;
105 public bool fullscreened;
106 public Gtk.InfoBar undo_bar;
107- private Gtk.ToolButton add_new_button;
108+ private Gtk.ToolButton add_new_button;
109
110 public int year;
111 public int month;
112@@ -170,9 +169,10 @@
113 settings.window_state = window_state;
114
115 settings.sidebar_width = hmain.position;
116- settings.view_mode = view_mode.selected;
117- if (selected_notebook != null)
118+ if (selected_notebook != null) {
119 settings.last_notebook = selected_notebook.id;
120+ selected_notebook.view.miller_noteviewer.save ();
121+ }
122
123 Gtk.main_quit ();
124 });
125@@ -201,20 +201,13 @@
126 export_button.icon_name = "document-export";
127 export_button.name = _("Export notebook");
128 export_button.tooltip_text = _("Export current notebook…");
129-
130- view_mode = new Granite.Widgets.ModeButton ();
131- view_mode.append (new Gtk.Image.from_icon_name ("view-filter-symbolic", Gtk.IconSize.BUTTON));
132- view_mode.append (new Gtk.Image.from_icon_name ("view-column-symbolic", Gtk.IconSize.BUTTON));
133- view_mode.valign = Gtk.Align.CENTER;
134- view_mode.selected = settings.view_mode;
135-
136+
137 search = new Gtk.SearchEntry ();
138 search.placeholder_text = _("Search Notes");
139
140 var tb = new Gtk.HeaderBar ();
141 tb.show_close_button = true;
142 tb.pack_start (add_new_button);
143- tb.pack_start (view_mode);
144 tb.pack_end (export_button);
145 tb.pack_end (search);
146
147@@ -283,10 +276,6 @@
148 /**
149 * events
150 **/
151- /*switch views*/
152- view_mode.mode_changed.connect (() => {
153- selected_notebook.view.update_view ();
154- });
155 /*search on every keypress*/
156 search.search_changed.connect (() => {
157 on_search_changed ();
158@@ -312,7 +301,7 @@
159 add_button.sensitive = false;
160 var note = ((Widgets.BookmarkItem)item).note;
161 stack.set_visible_child (note.notebook.view);
162- note.notebook.view.open_note (note);
163+ note.notebook.view.open_note (note, true);
164 }
165 });
166 /*add a new notebook*/
167@@ -376,11 +365,6 @@
168 sidebar.selected = notebook.sidebar_item;
169 selected_notebook.view.update_view ();
170 generate_year_combobox ();
171- if (notebook.is_empty ()) {
172- view_mode.sensitive = false;
173- } else {
174- view_mode.sensitive = true;
175- }
176 }
177
178 private void on_search_changed () {
179@@ -396,23 +380,6 @@
180 sidebar.add_notebook (notebook);
181 notebook.note_added.connect ((note) => {
182 generate_year_combobox ();
183- if (notebook == selected_notebook) {
184- if (notebook.is_empty ()) {
185- view_mode.sensitive = false;
186- } else {
187- view_mode.sensitive = true;
188- }
189- }
190- });
191-
192- notebook.note_trashed.connect (() => {
193- if (notebook == selected_notebook) {
194- if (notebook.is_empty ()) {
195- view_mode.sensitive = false;
196- } else {
197- view_mode.sensitive = true;
198- }
199- }
200 });
201
202 notebook.view.start_editing.connect (() => {
203
204=== modified file 'src/Widgets/EditView.vala'
205--- src/Widgets/EditView.vala 2015-01-06 21:31:31 +0000
206+++ src/Widgets/EditView.vala 2015-01-08 20:03:55 +0000
207@@ -23,9 +23,9 @@
208
209 public class EditView : Gtk.EventBox {
210
211- public Gtk.TextView title;
212- public Gtk.TextView content;
213- public Gtk.Toolbar editbar;
214+ public Gtk.TextView title;
215+ public Gtk.TextView content;
216+ public Gtk.Toolbar editbar;
217 private Gtk.ToggleToolButton bold;
218 private Gtk.ToggleToolButton italic;
219 private Gtk.ToggleToolButton strike;
220@@ -100,19 +100,12 @@
221 current_note.tag ("marked", mark.active);
222 });
223
224- var done = new Gtk.ToolButton (null, null);
225- done.label = _("Save");
226- done.icon_name = "document-save";
227- done.tooltip_text = _("Save the current note");
228- done.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);
229-
230- var cancel = new Gtk.ToolButton (null, null);
231- cancel.label = _("Cancel");
232- cancel.icon_name = "go-previous";
233- cancel.tooltip_text = _("Cancel all changes");
234-
235- editbar.insert (cancel, -1);
236- editbar.insert (done, -1);
237+ var revert = new Gtk.ToolButton (null, null);
238+ revert.label = _("revert");
239+ revert.icon_name = "document-revert";
240+ revert.tooltip_text = _("Restore this file");
241+
242+ editbar.insert (revert, -1);
243 editbar.insert (new Gtk.SeparatorToolItem (), -1);
244 editbar.insert (undo, -1);
245 editbar.insert (redo, -1);
246@@ -126,13 +119,13 @@
247 content_scroll.add (this.content);
248 content_scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;
249 this.content.wrap_mode = Gtk.WrapMode.WORD_CHAR;
250- title.get_style_context ().add_class ("h2");
251+ this.title.get_style_context ().add_class ("h2");
252 this.title.margin_top = 12;
253
254 content_scroll.margin_left = content_scroll.margin_right = this.title.margin_left = 12;
255-
256+
257 container.pack_start (editbar, false);
258- container.pack_start (title, false);
259+ container.pack_start (title, false);
260 container.pack_start (content_scroll);
261
262 this.title.margin_bottom = 12;
263@@ -146,46 +139,37 @@
264 }
265 return false;
266 });
267-
268- done.clicked.connect ( () => {
269- this.done ();
270- });
271-
272- cancel.clicked.connect ( () => {
273+
274+ revert.clicked.connect ( () => {
275 this.cancel ();
276 });
277-
278- title.buffer.changed.connect ( () => {
279- if (title.buffer.text == "")
280- done.sensitive = false;
281- else
282- done.sensitive = true;
283- });
284-
285+
286 this.key_press_event.connect ( (e) => {
287- if (e.keyval == Gdk.Key.Escape) {
288- this.cancel ();
289- return true;
290- } else if (e.keyval == Gdk.Key.s && Gdk.ModifierType.CONTROL_MASK in e.state) {
291- this.done ();
292+ if (e.keyval == Gdk.Key.s && Gdk.ModifierType.CONTROL_MASK in e.state) {
293+ this.save ();
294 return true;
295 }
296 return false;
297 });
298 }
299
300- private void done () {
301- current_note.title.label = this.title.buffer.text;
302- current_note.save ();
303- this.close ();
304+ public void save () {
305+ if (current_note != null && (this.title.buffer.get_modified () || this.content.buffer.get_modified ())) {
306+ current_note.title.label = this.title.buffer.text;
307+ current_note.save ();
308+
309+ this.title.buffer.set_modified (false);
310+ this.content.buffer.set_modified (false);
311+ }
312 }
313
314 private void cancel () {
315 current_note.restore ();
316- this.close ();
317 }
318
319 public void open_note (Note n) {
320+ this.save ();
321+
322 if (parent == null)
323 open (); //show the edit view
324
325@@ -215,7 +199,10 @@
326 }
327 else
328 content.grab_focus ();
329-
330+
331+ this.title.buffer.set_modified (false);
332+ this.content.buffer.set_modified (false);
333+
334 current_note = n;
335 }
336 }
337
338=== modified file 'src/Widgets/Note.vala'
339--- src/Widgets/Note.vala 2015-01-06 21:31:31 +0000
340+++ src/Widgets/Note.vala 2015-01-08 20:03:55 +0000
341@@ -32,8 +32,8 @@
342 public Gtk.TextView content;
343 public Gtk.Label date;
344 public Notebook notebook;
345- public Gtk.Button bookmarked_button;
346- public bool bookmarked;
347+ public Gtk.Button bookmarked_button;
348+ public bool bookmarked;
349
350 public int id;
351 public int month;
352@@ -47,7 +47,7 @@
353 public Gdk.Atom deformat;
354
355 public Note.from_existing (Notebook notebook,
356- string title, uint8[] content_, int id, DateTime datetime, bool bookmarked){
357+ string title, uint8[] content_, int id, DateTime datetime, bool bookmarked) {
358 this.bookmarked = bookmarked;
359 this.notebook = notebook;
360 this.id = id;
361@@ -94,7 +94,6 @@
362 date.get_style_context ().add_class ("h3");
363 date.margin_top = date.margin_bottom = 6;
364 date.selectable = true;
365- set_time_label ();
366
367 content.editable = false;
368 content.cursor_visible = false;
369@@ -241,7 +240,10 @@
370 DataBase.get_default ().add_note (this);
371 }
372
373- private void set_time_label () {
374+ public string get_time_label (DateTime? dt) {
375+ if (dt == null)
376+ return "";
377+
378 // If AM/PM doesn't exist, use 24h.
379 string time_format;
380 if (Posix.nl_langinfo (Posix.NLItem.AM_STR) == null || Posix.nl_langinfo (Posix.NLItem.AM_STR) == "") {
381@@ -251,20 +253,15 @@
382 // If AM/PM exists, assume it is the default time format and check for format override.
383 var setting = new GLib.Settings ("org.gnome.desktop.interface");
384 var clockformat = setting.get_user_value ("clock-format");
385- if (clockformat == null) {
386+
387+ if (clockformat == null || clockformat.get_string ().contains ("12h"))
388 time_format = Granite.DateTime.get_default_time_format (true);
389- } else {
390-
391- if (clockformat.get_string ().contains ("12h")) {
392- time_format = Granite.DateTime.get_default_time_format (true);
393- } else {
394- time_format = Granite.DateTime.get_default_time_format (false);
395- }
396- }
397+ else
398+ time_format = Granite.DateTime.get_default_time_format (false);
399 }
400
401 var date_format = Granite.DateTime.get_default_date_format (false, true, true);
402- date.label = datetime.format (date_format + " - " + time_format);
403+ return dt.format (date_format + " " + time_format);
404 }
405
406 public void save () {
407
408=== modified file 'src/Widgets/NoteView.vala'
409--- src/Widgets/NoteView.vala 2015-01-07 21:46:07 +0000
410+++ src/Widgets/NoteView.vala 2015-01-08 20:03:55 +0000
411@@ -21,7 +21,6 @@
412 public class ActionMenu : Gtk.Revealer {
413
414 public Gtk.Button export_button;
415- public Gtk.Button edit_button;
416 public Gtk.Button delete_button;
417 public Gtk.Button bookmarked_button;
418
419@@ -32,10 +31,6 @@
420 export_button.tooltip_text = _("Export");
421 export_button.relief = Gtk.ReliefStyle.NONE;
422
423- edit_button = new Gtk.Button.from_icon_name ("edit-symbolic", Gtk.IconSize.BUTTON);
424- edit_button.tooltip_text = _("Edit");
425- edit_button.relief = Gtk.ReliefStyle.NONE;
426-
427 delete_button = new Gtk.Button.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.BUTTON);
428 delete_button.tooltip_text = _("Delete");
429 delete_button.relief = Gtk.ReliefStyle.NONE;
430@@ -56,21 +51,18 @@
431
432 var buttons = new Gtk.Grid ();
433 buttons.orientation = orientation;
434+ buttons.add (bookmarked_button);
435+ buttons.add (export_button);
436 buttons.add (delete_button);
437- buttons.add (export_button);
438- buttons.add (edit_button);
439- buttons.add (bookmarked_button);
440-
441+
442+ buttons.opacity = 0.5;
443 this.transition_type = Gtk.RevealerTransitionType.CROSSFADE;
444 this.add (buttons);
445
446 /**
447 * Events
448 **/
449- /*ask the app to edit the note*/
450- edit_button.clicked.connect ( () => {
451- this.note.edit ();
452- });
453+
454 /*export clicked, show contractor dialog*/
455 export_button.clicked.connect ( () => {
456 var app = (Gtk.Application)GLib.Application.get_default ();
457@@ -86,12 +78,14 @@
458 contr.run_selected ();
459 dialog.destroy ();
460 });
461+
462 /*delete note*/
463 delete_button.clicked.connect ( () => {
464 this.note.is_trashed = true;
465 this.note.trashed ();
466 });
467
468+ /*bookmark note*/
469 bookmarked_button.clicked.connect (() => {
470 this.note.bookmarked = !this.note.bookmarked;
471 this.note.bookmark (this.note.bookmarked);
472@@ -199,8 +193,8 @@
473 private Gtk.Paned miller_paned;
474 private Gtk.ListBox miller_listbox;
475 private Gtk.ScrolledWindow miller_scroll;
476- public NoteViewer miller_noteviewer;
477- private EditView edit_view;
478+ public EditView miller_noteviewer;
479+ private Gtk.ScrolledWindow miller_view_scroll;
480 private Gtk.ListBox note_list;
481 private Notebook notebook;
482 private Gtk.Stack main_stack;
483@@ -216,13 +210,11 @@
484 * Constructor
485 */
486 public NoteView (FootnoteApp app, Notebook notebook) {
487-
488+ this.orientation = Gtk.Orientation.VERTICAL;
489 this.app = app;
490 this.notebook = notebook;
491 this.filter = "";
492
493- edit_view = new EditView (app);
494-
495 deletion_infobar = new Gtk.InfoBar ();
496 deletion_infobar.message_type = Gtk.MessageType.INFO;
497 deletion_infobar.no_show_all = true;
498@@ -264,13 +256,13 @@
499 });
500
501 miller_listbox = new Gtk.ListBox ();
502- miller_noteviewer = new NoteViewer ();
503+ miller_noteviewer = new EditView (app);
504
505 miller_scroll = new Gtk.ScrolledWindow (null, null);
506 miller_scroll.add (miller_noteviewer);
507
508 miller_listbox.row_activated.connect ((row) => {
509- miller_noteviewer.open_note (((MillerRow)row).note);
510+ open_note (((MillerRow)row).note);
511 });
512
513 miller_listbox.set_filter_func ((row) => {
514@@ -281,18 +273,6 @@
515 return should_appear ((Note)row.get_child ());
516 });
517
518- notebook.note_edit.connect ((note) => {
519- open_note (note);
520- });
521-
522- edit_view.close.connect ( (reverse) => {
523- toggle_edit (false);
524-
525- Gtk.ListBoxRow selected_row = miller_listbox.get_selected_row ();
526- if (selected_row != null)
527- selected_row.activate ();
528- });
529-
530 var empty_label = new Gtk.Label (_("Notebook \"%s\" is empty").printf (notebook.title));
531 empty_label.expand = true;
532 empty_label.halign = Gtk.Align.CENTER;
533@@ -302,7 +282,7 @@
534 empty_grid.expand = true;
535 empty_grid.add (empty_label);
536
537- var miller_view_scroll = new Gtk.ScrolledWindow (null, null);
538+ miller_view_scroll = new Gtk.ScrolledWindow (null, null);
539 miller_view_scroll.add (miller_listbox);
540 miller_view_scroll.hscrollbar_policy = Gtk.PolicyType.NEVER;
541
542@@ -314,7 +294,6 @@
543 main_stack.add_named (empty_grid, "empty");
544 main_stack.add_named (list_scroll, "list");
545 main_stack.add_named (miller_paned, "miller");
546- main_stack.add_named (edit_view, "editor");
547
548 add (deletion_infobar);
549 add (main_stack);
550@@ -327,15 +306,9 @@
551 **/
552 public void toggle_edit (bool show) {
553 if (show) {
554- main_stack.set_visible_child_name ("editor");
555 start_editing ();
556 } else {
557 stop_editing ();
558- if (app.view_mode.selected == 1) {
559- main_stack.set_visible_child_name ("miller");
560- } else {
561- main_stack.set_visible_child_name ("list");
562- }
563 }
564 }
565
566@@ -377,25 +350,19 @@
567 * filter string (e.g. in title, text or as a tag).
568 */
569 public void update_view () {
570- /*switch view if necessary*/
571- if (main_stack.get_visible_child () == edit_view)
572- edit_view.close (true);
573-
574 if (notebook.is_empty ()) {
575 start_editing ();
576 main_stack.set_visible_child_name ("empty");
577 return;
578 }
579
580- if (app.view_mode.selected == 1) {
581- main_stack.set_visible_child_name ("miller");
582- var row = miller_listbox.get_row_at_index (0);
583- if (row != null) {
584- miller_listbox.select_row (row);
585- miller_listbox.row_activated (row);
586- }
587- } else
588- main_stack.set_visible_child_name ("list");
589+ main_stack.set_visible_child_name ("miller");
590+ var row = miller_listbox.get_row_at_index (0);
591+ if (row != null) {
592+ miller_listbox.select_row (row);
593+ miller_listbox.row_activated (row);
594+ }
595+
596 }
597
598 public void change_month (int month) {
599@@ -441,9 +408,15 @@
600 /**
601 * Scroll to a certain note in the list.
602 */
603- public void open_note (Footnote.Widgets.Note n) {
604+ public void open_note (Footnote.Widgets.Note n, bool bookmarked = false) {
605 toggle_edit (true);
606- edit_view.open_note (n);
607+
608+ miller_noteviewer.open_note (n);
609+
610+ if (bookmarked)
611+ miller_view_scroll.hide ();
612+ else
613+ miller_view_scroll.show ();
614 }
615 }
616
617@@ -467,28 +440,31 @@
618 date_label.xalign = 0;
619 date_label.opacity = 0.8;
620 date_label.ellipsize = Pango.EllipsizeMode.END;
621+ date_label.use_markup = true;
622 date_label.halign = Gtk.Align.END;
623+ date_label.margin_right = 6;
624
625 summary_label = new Gtk.Label ("");
626 summary_label.xalign = 0;
627 summary_label.valign = Gtk.Align.START;
628 summary_label.ellipsize = Pango.EllipsizeMode.END;
629- summary_label.expand = true;
630- summary_label.set_lines (5);
631 summary_label.use_markup = true;
632 summary_label.opacity = 0.8;
633+ summary_label.margin_right = 6;
634+ summary_label.expand = true;
635+
636 var buttons_revealer = new ActionMenu (note, Gtk.Orientation.VERTICAL);
637
638 var grid = new Gtk.Grid ();
639 grid.margin_top = 6;
640- grid.row_spacing = 2;
641+ grid.row_spacing = 4;
642 grid.column_spacing = 2;
643 grid.attach (buttons_revealer, 0, 0, 1, 2);
644 grid.attach (title_label, 1, 0, 1, 1);
645 grid.attach (date_label, 2, 0, 1, 1);
646 grid.attach (summary_label, 1, 1, 2, 1);
647 grid.attach (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), 0, 3, 3, 1);
648-
649+
650 var event_box = new Gtk.EventBox ();
651 event_box.add (grid);
652 event_box.events |= Gdk.EventMask.ENTER_NOTIFY_MASK|Gdk.EventMask.LEAVE_NOTIFY_MASK;
653@@ -504,7 +480,7 @@
654 buttons_revealer.set_reveal_child (false);
655 return false;
656 });
657-
658+
659 add (event_box);
660 this.show_all();
661 update_labels ();
662@@ -523,13 +499,20 @@
663 string [] lines = note.content.buffer.text.split ("\n");
664
665 var result = "";
666-
667- for (int i = 0; i < 5 && i < lines.length ; i++) {
668- result += lines [i] + "\n";
669+ var result_lines = 0;
670+ foreach (string line in lines) {
671+ if (line.strip ().length == 0)
672+ continue;
673+
674+ result += line + "\n";
675+ result_lines ++;
676+
677+ if (result_lines == 3)
678+ break;
679 }
680
681- summary_label.label = "<span font_size=\"small\">" + result + "</span>";;
682- date_label.label = note.date.label;
683+ summary_label.label = "<span font_size=\"small\">" + result.strip () + "</span>";;
684+ date_label.label = "<span font_size=\"small\">" + note.get_time_label (note.datetime) + "</span>";
685 title_label.label = note.title.label;
686 }
687 }

Subscribers

People subscribed via source and target branches