Merge lp:~donadigo/pantheon-notes/improvements into lp:pantheon-notes

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Felipe Escoto
Approved revision: 5
Merged at revision: 4
Proposed branch: lp:~donadigo/pantheon-notes/improvements
Merge into: lp:pantheon-notes
Diff against target: 206 lines (+44/-40)
6 files modified
src/Application.vala (+1/-1)
src/Main.vala (+3/-3)
src/Widgets/Editor.vala (+1/-2)
src/Widgets/Headerbar.vala (+0/-9)
src/Widgets/PagesList.vala (+25/-10)
src/Widgets/Window.vala (+14/-15)
To merge this branch: bzr merge lp:~donadigo/pantheon-notes/improvements
Reviewer Review Type Date Requested Status
Felipe Escoto (community) Approve
Review via email: mp+288282@code.launchpad.net

Commit message

Fixes:
#1553826 "Larger margin",
#1553820 "Delete icon is sensitive when nothing is selected",
#1553822 "Window title should be either "Notes" or file name",
#1553824 "Deleting everything leaves you with an unclickable text area".

Description of the change

The branch improves general UI list management as well as fixes some problems with current set_focus () warnings.

Some notes:
* The Notes path is now located in ~/.local/share/pantheon-notes.
* On startup Notes now will automatically select the page that you were previously working on.
* Page object wasn't removed at all from pages variable which caused wrong information and blocked fixing #1553824, now it is.

Also I'm not sure about some things like if margin should be also at the bottom.

Fixes:
#1553826 "Larger margin",
#1553820 "Delete icon is sensitive when nothing is selected",
#1553822 "Window title should be either "Notes" or file name",
#1553824 "Deleting everything leaves you with an unclickable text area".

To post a comment you must log in.
Revision history for this message
Felipe Escoto (philip.scott) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Application.vala'
2--- src/Application.vala 2016-03-06 22:15:46 +0000
3+++ src/Application.vala 2016-03-07 12:16:33 +0000
4@@ -23,7 +23,7 @@
5 settings = new Notes.Services.Settings ();
6
7 if (settings.notes_location == "") {
8- settings.notes_location = GLib.Environment.get_home_dir () + "/.pantheon-notes/";
9+ settings.notes_location = Path.build_filename (Environment.get_user_data_dir (), CODE_NAME);
10 }
11
12 Notes.NOTES_DIR = settings.notes_location;
13
14=== modified file 'src/Main.vala'
15--- src/Main.vala 2016-03-06 21:56:56 +0000
16+++ src/Main.vala 2016-03-07 12:16:33 +0000
17@@ -14,8 +14,8 @@
18 with this program. If not, see <http://www.gnu.org/licenses/>.
19 ***/
20
21-public static const string APP_NAME = "Pantheon Notes";
22-public static const string TERMINAL_NAME = "pantheon-notes";
23+public static const string APP_NAME = "Notes";
24+public static const string CODE_NAME = "pantheon-notes";
25
26 public static int main (string[] args) {
27 /* Initiliaze gettext support */
28@@ -23,7 +23,7 @@
29 //Intl.textdomain (Config.GETTEXT_PACKAGE);
30
31 Environment.set_application_name (APP_NAME);
32- Environment.set_prgname (APP_NAME);
33+ Environment.set_prgname (CODE_NAME);
34
35 var application = new Notes.Application ();
36
37
38=== modified file 'src/Widgets/Editor.vala'
39--- src/Widgets/Editor.vala 2016-03-06 21:56:56 +0000
40+++ src/Widgets/Editor.vala 2016-03-07 12:16:33 +0000
41@@ -19,7 +19,6 @@
42
43 current_page = page;
44 code_buffer.text = page.load_text ();
45- window.set_title (page.name);
46
47 code_buffer.end_not_undoable_action ();
48
49@@ -104,7 +103,7 @@
50
51 code_buffer.changed.connect (trigger_changed);
52
53- code_view.left_margin = 12;
54+ code_view.left_margin = code_view.right_margin = code_view.top_margin = 24;
55 code_view.pixels_above_lines = 6;
56 code_view.wrap_mode = Gtk.WrapMode.WORD;
57 code_view.show_line_numbers = false;
58
59=== modified file 'src/Widgets/Headerbar.vala'
60--- src/Widgets/Headerbar.vala 2016-03-06 21:56:56 +0000
61+++ src/Widgets/Headerbar.vala 2016-03-07 12:16:33 +0000
62@@ -5,20 +5,11 @@
63 }
64
65 private void build_ui () {
66- set_title (null);
67 set_show_close_button (true);
68
69 Granite.Widgets.Utils.set_theming_for_screen (this.get_screen (), CUSTOM_STYLESHEET, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
70 }
71
72- public new void set_title (string? title) {
73- if (title != null) {
74- this.title = title + " - " + APP_NAME;
75- } else {
76- this.title = APP_NAME;
77- }
78- }
79-
80 private const string CUSTOM_STYLESHEET = """
81 @define-color colorPrimary #695E56;
82 .titlebar .label {
83
84=== modified file 'src/Widgets/PagesList.vala'
85--- src/Widgets/PagesList.vala 2016-03-06 22:15:46 +0000
86+++ src/Widgets/PagesList.vala 2016-03-07 12:16:33 +0000
87@@ -77,6 +77,21 @@
88 return frame;
89 }
90
91+ public void select_first () {
92+ listbox.select_row (listbox.get_row_at_index (0));
93+ }
94+
95+ public Gtk.ListBoxRow? get_row_from_path (string full_path) {
96+ foreach (var row in listbox.get_children ()) {
97+ if (row is Notes.PageItem
98+ && ((Notes.PageItem)row).page.full_path == full_path) {
99+ return (Gtk.ListBoxRow)row;
100+ }
101+ }
102+
103+ return null;
104+ }
105+
106 public void clear_pages () {
107 listbox.unselect_all ();
108 var childerns = listbox.get_children ();
109@@ -87,11 +102,6 @@
110 }
111 }
112
113- private void refresh () {
114- current_notebook.refresh ();
115- load_pages (current_notebook);
116- }
117-
118 public void load_pages (Notes.Notebook notebook) {
119 clear_pages ();
120 this.current_notebook = notebook;
121@@ -142,17 +152,22 @@
122 });
123
124 minus_button.clicked.connect (() => {
125- editor.set_sensitive (false);
126 editor.reset (false);
127- window.set_title (null);
128- var row = listbox.get_selected_row ();
129- ((Notes.PageItem) row).trash_page ();
130- refresh ();
131+ var row = (Notes.PageItem)listbox.get_selected_row ();
132+ if (row != null) {
133+ row.trash_page ();
134+ current_notebook.pages.remove (row.page);
135+ row.destroy ();
136+ select_first ();
137+ editor.give_focus ();
138+ }
139 });
140
141 listbox.row_selected.connect ((row) => {
142+ minus_button.sensitive = (row != null);
143 if (row == null) return;
144 editor.load_file (((Notes.PageItem) row).page);
145+ editor.give_focus ();
146 });
147 }
148 }
149
150=== modified file 'src/Widgets/Window.vala'
151--- src/Widgets/Window.vala 2016-03-06 21:56:56 +0000
152+++ src/Widgets/Window.vala 2016-03-07 12:16:33 +0000
153@@ -31,6 +31,15 @@
154 return false;
155 }
156
157+ protected override bool key_press_event (Gdk.EventKey event) {
158+ if (pages_list.current_notebook.pages.length () <= 0) {
159+ new_page ();
160+ pages_list.select_first ();
161+ }
162+
163+ return base.key_press_event (event);
164+ }
165+
166 private void load_settings () {
167 resize (settings.window_width, settings.window_height);
168 pane.position = settings.panel_size;
169@@ -42,18 +51,15 @@
170 pages_list.load_pages (notebook);
171 }
172
173- string path = settings.page_path;
174-
175- if (path != "") {
176- var page = new Notes.Page (path);
177-
178- if (!page.new_page)
179- editor.load_file (page);
180+ var row = pages_list.get_row_from_path (settings.page_path);
181+ if (row != null) {
182+ row.activate ();
183 }
184 }
185
186 private void build_ui () {
187 headerbar = new Notes.Headerbar ();
188+ headerbar.set_title (APP_NAME);
189 set_titlebar (headerbar);
190
191 pane = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
192@@ -102,13 +108,6 @@
193 show ();
194 present ();
195
196- set_focus (editor);
197- }
198-
199- public new void set_title (string? title) {
200- if (title != null)
201- headerbar.set_title (title);
202- else
203- headerbar.set_title (APP_NAME);
204+ editor.give_focus ();
205 }
206 }

Subscribers

People subscribed via source and target branches