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