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
1=== modified file 'src/Footnote.vala'
2--- src/Footnote.vala 2015-01-08 20:01:16 +0000
3+++ src/Footnote.vala 2015-01-09 13:10:45 +0000
4@@ -296,12 +296,14 @@
5 add_button.sensitive = true;
6 var selected_item = ((Widgets.NotebookItem)item).notebook;
7 switch_to_notebook (selected_item);
8+ topbar.show ();
9 } else if (item is Widgets.BookmarkItem) { //bookmarks
10 edit_button.sensitive = false;
11 add_button.sensitive = false;
12 var note = ((Widgets.BookmarkItem)item).note;
13 stack.set_visible_child (note.notebook.view);
14 note.notebook.view.open_note (note, true);
15+ topbar.hide ();
16 }
17 });
18 /*add a new notebook*/
19@@ -382,14 +384,6 @@
20 generate_year_combobox ();
21 });
22
23- notebook.view.start_editing.connect (() => {
24- topbar.hide ();
25- });
26-
27- notebook.view.stop_editing.connect (() => {
28- topbar.show ();
29- });
30-
31 notebook.note_trashed.connect ((note) => {
32 generate_year_combobox ();
33 });
34
35=== modified file 'src/Widgets/EditView.vala'
36--- src/Widgets/EditView.vala 2015-01-08 19:51:05 +0000
37+++ src/Widgets/EditView.vala 2015-01-09 13:10:45 +0000
38@@ -31,6 +31,8 @@
39 private Gtk.ToggleToolButton strike;
40 private Gtk.ToggleToolButton mark;
41
42+ private Gtk.ToolButton revert;
43+
44 private bool applying_style = false;
45
46 public signal void close (bool reverse=false);
47@@ -100,7 +102,7 @@
48 current_note.tag ("marked", mark.active);
49 });
50
51- var revert = new Gtk.ToolButton (null, null);
52+ revert = new Gtk.ToolButton (null, null);
53 revert.label = _("revert");
54 revert.icon_name = "document-revert";
55 revert.tooltip_text = _("Restore this file");
56@@ -121,6 +123,7 @@
57 this.content.wrap_mode = Gtk.WrapMode.WORD_CHAR;
58 this.title.get_style_context ().add_class ("h2");
59 this.title.margin_top = 12;
60+ this.title.style_updated ();
61
62 content_scroll.margin_left = content_scroll.margin_right = this.title.margin_left = 12;
63
64@@ -132,15 +135,23 @@
65
66 this.add (container);
67
68- title.key_press_event.connect ( (e) => {
69+ /*
70+ * EVENTS
71+ */
72+
73+ this.title.key_press_event.connect ( (e) => {
74 if (e.keyval == Gdk.Key.Tab || e.keyval == Gdk.Key.Return) {
75 content.grab_focus ();
76 return true;
77 }
78 return false;
79 });
80+
81+ this.title.buffer.changed.connect ( () => {
82+ this.revert.sensitive = true;
83+ });
84
85- revert.clicked.connect ( () => {
86+ this.revert.clicked.connect ( () => {
87 this.cancel ();
88 });
89
90@@ -160,11 +171,14 @@
91
92 this.title.buffer.set_modified (false);
93 this.content.buffer.set_modified (false);
94+ this.revert.sensitive = false;
95 }
96 }
97
98 private void cancel () {
99 current_note.restore ();
100+ this.title.buffer.text = current_note.title.label;
101+ this.revert.sensitive = false;
102 }
103
104 public void open_note (Note n) {
105@@ -193,6 +207,10 @@
106 applying_style = false;
107 });
108
109+ content.buffer.changed.connect ( () => {
110+ revert.sensitive = true;
111+ });
112+
113 if (n.title.label == _("Untitled") || n.title.label == _("New Note")) {
114 title.grab_focus ();
115 title.select_all (true);
116@@ -202,7 +220,7 @@
117
118 this.title.buffer.set_modified (false);
119 this.content.buffer.set_modified (false);
120-
121+ this.revert.sensitive = false;
122 current_note = n;
123 }
124 }
125
126=== modified file 'src/Widgets/Note.vala'
127--- src/Widgets/Note.vala 2015-01-08 19:51:05 +0000
128+++ src/Widgets/Note.vala 2015-01-09 13:10:45 +0000
129@@ -103,6 +103,7 @@
130 content.buffer.create_tag ("italic", "style", Pango.Style.ITALIC);
131 content.buffer.create_tag ("strikethrough", "strikethrough", true);
132 content.buffer.create_tag ("marked", "background", "#ffff00");
133+
134 content.override_background_color (Gtk.StateFlags.NORMAL, {0, 0, 0, 0});
135
136 if (bookmarked) {
137
138=== modified file 'src/Widgets/NoteView.vala'
139--- src/Widgets/NoteView.vala 2015-01-08 20:03:43 +0000
140+++ src/Widgets/NoteView.vala 2015-01-09 13:10:45 +0000
141@@ -102,7 +102,7 @@
142 /*
143 * minimal version of note, just the ui
144 **/
145- public class NoteViewer : Gtk.Box {
146+ /*public class NoteViewer : Gtk.Box {
147
148 public Gtk.Label date;
149 public Gtk.Label title;
150@@ -176,7 +176,7 @@
151 this.title.label = n.title.label;
152 this.date.label = n.date.label;
153 }
154- }
155+ }*/
156
157 /**
158 * Display a (filtered) list of Notes for the currently
159@@ -189,13 +189,11 @@
160
161 private FootnoteApp app;
162
163- private Gtk.ScrolledWindow list_scroll;
164 private Gtk.Paned miller_paned;
165 private Gtk.ListBox miller_listbox;
166 private Gtk.ScrolledWindow miller_scroll;
167 public EditView miller_noteviewer;
168 private Gtk.ScrolledWindow miller_view_scroll;
169- private Gtk.ListBox note_list;
170 private Notebook notebook;
171 private Gtk.Stack main_stack;
172
173@@ -240,11 +238,6 @@
174 deletion_infobar.hide ();
175 });
176
177- note_list = new Gtk.ListBox ();
178- list_scroll = new Gtk.ScrolledWindow (null, null);
179- list_scroll.add (note_list);
180- list_scroll.expand = true;
181-
182 miller_paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
183 miller_paned.position = Settings.get_default ().miller_handle_position;
184 miller_paned.key_press_event.connect ( (e) => {
185@@ -269,10 +262,6 @@
186 return should_appear (((MillerRow)row).note);
187 });
188
189- note_list.set_filter_func ((row) => {
190- return should_appear ((Note)row.get_child ());
191- });
192-
193 var empty_label = new Gtk.Label (_("Notebook \"%s\" is empty").printf (notebook.title));
194 empty_label.expand = true;
195 empty_label.halign = Gtk.Align.CENTER;
196@@ -292,7 +281,6 @@
197 main_stack = new Gtk.Stack ();
198 main_stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
199 main_stack.add_named (empty_grid, "empty");
200- main_stack.add_named (list_scroll, "list");
201 main_stack.add_named (miller_paned, "miller");
202
203 add (deletion_infobar);
204@@ -316,7 +304,6 @@
205 * Add a note to the view
206 */
207 public void add_note (Note n, int pos=0) {
208- note_list.insert (n, pos);
209 update_view ();
210
211 var row = new MillerRow (n);
212@@ -356,13 +343,16 @@
213 return;
214 }
215
216+ if (miller_listbox.get_selected_row () == null) {
217+ var row = miller_listbox.get_row_at_index (0);
218+ if (row != null) {
219+ miller_listbox.select_row (row);
220+ miller_listbox.row_activated (row);
221+ }
222+ } else
223+ miller_view_scroll.show ();
224+
225 main_stack.set_visible_child_name ("miller");
226- var row = miller_listbox.get_row_at_index (0);
227- if (row != null) {
228- miller_listbox.select_row (row);
229- miller_listbox.row_activated (row);
230- }
231-
232 }
233
234 public void change_month (int month) {
235@@ -387,7 +377,6 @@
236
237 private async void update_notes_visibility () {
238 miller_listbox.invalidate_filter ();
239- note_list.invalidate_filter ();
240 }
241
242 private bool should_appear (Note? note) {

Subscribers

People subscribed via source and target branches