Merge lp:~vikoadi/pantheon-photos/welcome-when-empty into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Viko Adi Rahmawan
Status: Merged
Approved by: meese
Approved revision: 2633
Merged at revision: 2665
Proposed branch: lp:~vikoadi/pantheon-photos/welcome-when-empty
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 148 lines (+52/-19)
6 files modified
src/CollectionPage.vala (+9/-1)
src/Page.vala (+5/-3)
src/library/LibraryWindow.vala (+18/-15)
src/library/PhotosPage.vala (+8/-0)
src/library/RawsPage.vala (+8/-0)
src/library/TrashPage.vala (+4/-0)
To merge this branch: bzr merge lp:~vikoadi/pantheon-photos/welcome-when-empty
Reviewer Review Type Date Requested Status
meese Approve
Review via email: mp+236228@code.launchpad.net

Commit message

Use welcome empty screen for all pages

Description of the change

override get_view_empty_message for PhotosPage, VideosPage, trash and CollectionPage to call proper toggle_welcome_page,
now empty message will use welcome screen, on trashpage and collectionpage (tags and smarttags too) we will not show import button and change library button

To post a comment you must log in.
2626. By Viko Adi Rahmawan

remove commented line

2627. By Viko Adi Rahmawan

use dynamic type casting with null checking

2628. By Viko Adi Rahmawan

dont return empty string

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

Use "return_val_if_fail" where needed "return_if_fail" is not compatible with non-void methods.

This snippet is probably applicable in most cases here.

var foo = get_bar () as Foo;
warn_if_fail (foo != null);
if (foo != null)
    foo.do_baz ();
return "bla";

where "var foo = get_bar () as Foo;" could be "unowned Foo foo = get_bar () as Foo;" if possible to avoid useless refs/unrefs.

2629. By Viko Adi Rahmawan

destroy object properly

2630. By Viko Adi Rahmawan

change to AppWindow.get_instance instead of get_container which is not type safe

2631. By Viko Adi Rahmawan

remove type checking as AppWindow.get_get_instance is type safe

2632. By Viko Adi Rahmawan

seems to be im wrong, reverting

2633. By Viko Adi Rahmawan

merge trunk

Revision history for this message
Viko Adi Rahmawan (vikoadi) wrote :

i change how to get the LibraryWindow instead of using get_container now we use AppWindow.get_instance.
Does the type checking look alrigh?

Revision history for this message
meese (meese) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CollectionPage.vala'
2--- src/CollectionPage.vala 2014-09-06 19:39:38 +0000
3+++ src/CollectionPage.vala 2014-09-29 15:33:04 +0000
4@@ -830,7 +830,15 @@
5 return base.on_ctrl_released (event);
6 }
7
8+ protected override string get_view_empty_message () {
9+ var window = AppWindow.get_instance () as LibraryWindow;
10+ warn_if_fail (window != null);
11+ if (window != null)
12+ window.toggle_welcome_page (true, "", _ ("No photos/videos"));
13+ return _ ("No photos/videos");
14+ }
15+
16 public override SearchViewFilter get_search_view_filter () {
17 return search_filter;
18 }
19-}
20+}
21\ No newline at end of file
22
23=== modified file 'src/Page.vala'
24--- src/Page.vala 2014-09-02 19:42:49 +0000
25+++ src/Page.vala 2014-09-29 15:33:04 +0000
26@@ -1368,7 +1368,6 @@
27 }
28
29 protected virtual string get_view_empty_message () {
30- (get_container () as LibraryWindow).toggle_welcome_page (true);
31 return _ ("No photos/videos");
32 }
33
34@@ -1448,7 +1447,10 @@
35 }
36
37 private void update_view_filter_message () {
38- (get_container () as LibraryWindow).toggle_welcome_page (false);
39+ var window = AppWindow.get_instance () as LibraryWindow;
40+ warn_if_fail (window != null);
41+ if (window != null)
42+ window.toggle_welcome_page (false);
43
44 if (get_view ().are_items_filtered_out () && get_view ().get_count () == 0) {
45 set_page_message (get_filter_no_match_message ());
46@@ -2718,4 +2720,4 @@
47 warning (err.message);
48 }
49 }
50-}
51+}
52\ No newline at end of file
53
54=== modified file 'src/library/LibraryWindow.vala'
55--- src/library/LibraryWindow.vala 2014-09-07 01:47:31 +0000
56+++ src/library/LibraryWindow.vala 2014-09-29 15:33:04 +0000
57@@ -1368,21 +1368,24 @@
58 return (get_current_page () is CheckerboardPage) ? is_search_toolbar_visible : false;
59 }
60
61- public void toggle_welcome_page (bool show) {
62- if (show == true && welcome_page == null) {
63- welcome_page = new Granite.Widgets.Welcome (_ ("Add Some Photos"), _ ("No photos were found in your library."));
64- welcome_page.append ("document-import", _ ("Import Photos"), _ ("Copy photos from a folder or external device."));
65- welcome_page.append ("folder-pictures", _ ("Change Library Folder"), _ ("Choose where to keep your photos."));
66- welcome_page.activated.connect ((index) => {
67- switch (index) {
68- case 0:
69- on_file_import ();
70- break;
71- case 1:
72- on_preferences ();
73- break;
74- }
75- });
76+ public void toggle_welcome_page (bool show, string title = "", string subtitle = "", bool show_import = false) {
77+ if (show == true) {
78+ welcome_page = null;
79+ welcome_page = new Granite.Widgets.Welcome (title, subtitle);
80+ if (show_import) {
81+ welcome_page.append ("document-import", _ ("Import Photos"), _ ("Copy photos from a folder or external device."));
82+ welcome_page.append ("folder-pictures", _ ("Change Library Folder"), _ ("Choose where to keep your photos."));
83+ welcome_page.activated.connect ((index) => {
84+ switch (index) {
85+ case 0:
86+ on_file_import ();
87+ break;
88+ case 1:
89+ on_preferences ();
90+ break;
91+ }
92+ });
93+ }
94 }
95
96 right_frame.remove (welcome_page);
97
98=== modified file 'src/library/PhotosPage.vala'
99--- src/library/PhotosPage.vala 2014-09-23 03:13:45 +0000
100+++ src/library/PhotosPage.vala 2014-09-29 15:33:04 +0000
101@@ -43,6 +43,14 @@
102 get_view ().monitor_source_collection (sources, view_manager, null, null, monitor);
103 }
104
105+ protected override string get_view_empty_message () {
106+ var window = AppWindow.get_instance () as LibraryWindow;
107+ warn_if_fail (window != null);
108+ if (window != null)
109+ window.toggle_welcome_page (true, _ ("Add Some Photos"),_("No Photos were found in your library."), true);
110+ return _ ("No photos/videos");
111+ }
112+
113 private class PhotosSearchViewFilter : CollectionPage.CollectionSearchViewFilter {
114 public override uint get_criteria () {
115 return SearchFilterCriteria.TEXT | SearchFilterCriteria.MEDIA |
116
117=== modified file 'src/library/RawsPage.vala'
118--- src/library/RawsPage.vala 2014-09-23 03:13:45 +0000
119+++ src/library/RawsPage.vala 2014-09-29 15:33:04 +0000
120@@ -43,6 +43,14 @@
121 get_view ().monitor_source_collection (sources, view_manager, null, null, monitor);
122 }
123
124+ protected override string get_view_empty_message () {
125+ var window = AppWindow.get_instance () as LibraryWindow;
126+ warn_if_fail (window != null);
127+ if (window != null)
128+ window.toggle_welcome_page (true, _ ("Add Some Photos"),_("No Photos were found in your library."), true);
129+ return _ ("No photos/videos");
130+ }
131+
132 private class RawsSearchViewFilter : CollectionPage.CollectionSearchViewFilter {
133 public override uint get_criteria () {
134 return SearchFilterCriteria.TEXT | SearchFilterCriteria.MEDIA |
135
136=== modified file 'src/library/TrashPage.vala'
137--- src/library/TrashPage.vala 2014-09-27 23:06:48 +0000
138+++ src/library/TrashPage.vala 2014-09-29 15:33:04 +0000
139@@ -165,6 +165,10 @@
140 }
141
142 protected override string get_view_empty_message () {
143+ var window = AppWindow.get_instance () as LibraryWindow;
144+ warn_if_fail (window != null);
145+ if (window != null)
146+ window.toggle_welcome_page (true, "", _ ("Trash is empty"));
147 return _ ("Trash is empty");
148 }
149

Subscribers

People subscribed via source and target branches