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
=== modified file 'src/Application.vala'
--- src/Application.vala 2016-03-06 22:15:46 +0000
+++ src/Application.vala 2016-03-07 12:16:33 +0000
@@ -23,7 +23,7 @@
23 settings = new Notes.Services.Settings ();23 settings = new Notes.Services.Settings ();
2424
25 if (settings.notes_location == "") {25 if (settings.notes_location == "") {
26 settings.notes_location = GLib.Environment.get_home_dir () + "/.pantheon-notes/";26 settings.notes_location = Path.build_filename (Environment.get_user_data_dir (), CODE_NAME);
27 }27 }
2828
29 Notes.NOTES_DIR = settings.notes_location;29 Notes.NOTES_DIR = settings.notes_location;
3030
=== modified file 'src/Main.vala'
--- src/Main.vala 2016-03-06 21:56:56 +0000
+++ src/Main.vala 2016-03-07 12:16:33 +0000
@@ -14,8 +14,8 @@
14 with this program. If not, see <http://www.gnu.org/licenses/>.14 with this program. If not, see <http://www.gnu.org/licenses/>.
15***/15***/
1616
17public static const string APP_NAME = "Pantheon Notes";17public static const string APP_NAME = "Notes";
18public static const string TERMINAL_NAME = "pantheon-notes";18public static const string CODE_NAME = "pantheon-notes";
1919
20public static int main (string[] args) {20public static int main (string[] args) {
21 /* Initiliaze gettext support */21 /* Initiliaze gettext support */
@@ -23,7 +23,7 @@
23 //Intl.textdomain (Config.GETTEXT_PACKAGE);23 //Intl.textdomain (Config.GETTEXT_PACKAGE);
2424
25 Environment.set_application_name (APP_NAME);25 Environment.set_application_name (APP_NAME);
26 Environment.set_prgname (APP_NAME);26 Environment.set_prgname (CODE_NAME);
2727
28 var application = new Notes.Application ();28 var application = new Notes.Application ();
2929
3030
=== modified file 'src/Widgets/Editor.vala'
--- src/Widgets/Editor.vala 2016-03-06 21:56:56 +0000
+++ src/Widgets/Editor.vala 2016-03-07 12:16:33 +0000
@@ -19,7 +19,6 @@
1919
20 current_page = page;20 current_page = page;
21 code_buffer.text = page.load_text ();21 code_buffer.text = page.load_text ();
22 window.set_title (page.name);
2322
24 code_buffer.end_not_undoable_action ();23 code_buffer.end_not_undoable_action ();
2524
@@ -104,7 +103,7 @@
104103
105 code_buffer.changed.connect (trigger_changed);104 code_buffer.changed.connect (trigger_changed);
106105
107 code_view.left_margin = 12;106 code_view.left_margin = code_view.right_margin = code_view.top_margin = 24;
108 code_view.pixels_above_lines = 6;107 code_view.pixels_above_lines = 6;
109 code_view.wrap_mode = Gtk.WrapMode.WORD;108 code_view.wrap_mode = Gtk.WrapMode.WORD;
110 code_view.show_line_numbers = false;109 code_view.show_line_numbers = false;
111110
=== modified file 'src/Widgets/Headerbar.vala'
--- src/Widgets/Headerbar.vala 2016-03-06 21:56:56 +0000
+++ src/Widgets/Headerbar.vala 2016-03-07 12:16:33 +0000
@@ -5,20 +5,11 @@
5 }5 }
66
7 private void build_ui () {7 private void build_ui () {
8 set_title (null);
9 set_show_close_button (true);8 set_show_close_button (true);
10 9
11 Granite.Widgets.Utils.set_theming_for_screen (this.get_screen (), CUSTOM_STYLESHEET, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);10 Granite.Widgets.Utils.set_theming_for_screen (this.get_screen (), CUSTOM_STYLESHEET, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
12 }11 }
1312
14 public new void set_title (string? title) {
15 if (title != null) {
16 this.title = title + " - " + APP_NAME;
17 } else {
18 this.title = APP_NAME;
19 }
20 }
21
22 private const string CUSTOM_STYLESHEET = """13 private const string CUSTOM_STYLESHEET = """
23 @define-color colorPrimary #695E56;14 @define-color colorPrimary #695E56;
24 .titlebar .label {15 .titlebar .label {
2516
=== modified file 'src/Widgets/PagesList.vala'
--- src/Widgets/PagesList.vala 2016-03-06 22:15:46 +0000
+++ src/Widgets/PagesList.vala 2016-03-07 12:16:33 +0000
@@ -77,6 +77,21 @@
77 return frame;77 return frame;
78 }78 }
7979
80 public void select_first () {
81 listbox.select_row (listbox.get_row_at_index (0));
82 }
83
84 public Gtk.ListBoxRow? get_row_from_path (string full_path) {
85 foreach (var row in listbox.get_children ()) {
86 if (row is Notes.PageItem
87 && ((Notes.PageItem)row).page.full_path == full_path) {
88 return (Gtk.ListBoxRow)row;
89 }
90 }
91
92 return null;
93 }
94
80 public void clear_pages () {95 public void clear_pages () {
81 listbox.unselect_all ();96 listbox.unselect_all ();
82 var childerns = listbox.get_children ();97 var childerns = listbox.get_children ();
@@ -87,11 +102,6 @@
87 }102 }
88 }103 }
89104
90 private void refresh () {
91 current_notebook.refresh ();
92 load_pages (current_notebook);
93 }
94
95 public void load_pages (Notes.Notebook notebook) {105 public void load_pages (Notes.Notebook notebook) {
96 clear_pages ();106 clear_pages ();
97 this.current_notebook = notebook;107 this.current_notebook = notebook;
@@ -142,17 +152,22 @@
142 });152 });
143153
144 minus_button.clicked.connect (() => {154 minus_button.clicked.connect (() => {
145 editor.set_sensitive (false);
146 editor.reset (false);155 editor.reset (false);
147 window.set_title (null);156 var row = (Notes.PageItem)listbox.get_selected_row ();
148 var row = listbox.get_selected_row ();157 if (row != null) {
149 ((Notes.PageItem) row).trash_page ();158 row.trash_page ();
150 refresh ();159 current_notebook.pages.remove (row.page);
160 row.destroy ();
161 select_first ();
162 editor.give_focus ();
163 }
151 });164 });
152165
153 listbox.row_selected.connect ((row) => {166 listbox.row_selected.connect ((row) => {
167 minus_button.sensitive = (row != null);
154 if (row == null) return;168 if (row == null) return;
155 editor.load_file (((Notes.PageItem) row).page);169 editor.load_file (((Notes.PageItem) row).page);
170 editor.give_focus ();
156 });171 });
157 }172 }
158}173}
159174
=== modified file 'src/Widgets/Window.vala'
--- src/Widgets/Window.vala 2016-03-06 21:56:56 +0000
+++ src/Widgets/Window.vala 2016-03-07 12:16:33 +0000
@@ -31,6 +31,15 @@
31 return false;31 return false;
32 }32 }
3333
34 protected override bool key_press_event (Gdk.EventKey event) {
35 if (pages_list.current_notebook.pages.length () <= 0) {
36 new_page ();
37 pages_list.select_first ();
38 }
39
40 return base.key_press_event (event);
41 }
42
34 private void load_settings () {43 private void load_settings () {
35 resize (settings.window_width, settings.window_height);44 resize (settings.window_width, settings.window_height);
36 pane.position = settings.panel_size;45 pane.position = settings.panel_size;
@@ -42,18 +51,15 @@
42 pages_list.load_pages (notebook);51 pages_list.load_pages (notebook);
43 }52 }
4453
45 string path = settings.page_path;54 var row = pages_list.get_row_from_path (settings.page_path);
46 55 if (row != null) {
47 if (path != "") {56 row.activate ();
48 var page = new Notes.Page (path);
49
50 if (!page.new_page)
51 editor.load_file (page);
52 }57 }
53 }58 }
5459
55 private void build_ui () {60 private void build_ui () {
56 headerbar = new Notes.Headerbar ();61 headerbar = new Notes.Headerbar ();
62 headerbar.set_title (APP_NAME);
57 set_titlebar (headerbar);63 set_titlebar (headerbar);
5864
59 pane = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);65 pane = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
@@ -102,13 +108,6 @@
102 show ();108 show ();
103 present ();109 present ();
104110
105 set_focus (editor);111 editor.give_focus ();
106 }
107
108 public new void set_title (string? title) {
109 if (title != null)
110 headerbar.set_title (title);
111 else
112 headerbar.set_title (APP_NAME);
113 }112 }
114}113}

Subscribers

People subscribed via source and target branches