Merge lp:~artem-anufrij/snap-elementary/Bugfix-1322963 into lp:snap-elementary

Proposed by Artem Anufrij
Status: Merged
Merged at revision: 260
Proposed branch: lp:~artem-anufrij/snap-elementary/Bugfix-1322963
Merge into: lp:snap-elementary
Diff against target: 76 lines (+27/-4)
1 file modified
src/SnapWindow.vala (+27/-4)
To merge this branch: bzr merge lp:~artem-anufrij/snap-elementary/Bugfix-1322963
Reviewer Review Type Date Requested Status
Artem Anufrij (community) Approve
Cody Garver (community) Needs Information
Review via email: mp+235065@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Can you not combine the null check code?: http://paste.debian.net/121890/

review: Needs Information
260. By artem-anufrij

I combined The null check code.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Check my changes, please.

review: Needs Resubmitting
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
=== modified file 'src/SnapWindow.vala'
--- src/SnapWindow.vala 2014-05-27 11:23:34 +0000
+++ src/SnapWindow.vala 2014-09-19 17:51:03 +0000
@@ -31,6 +31,8 @@
31 private Granite.Widgets.ModeButton mode_button;31 private Granite.Widgets.ModeButton mode_button;
32 private Gtk.Button take_button;32 private Gtk.Button take_button;
33 private Gtk.Statusbar statusbar;33 private Gtk.Statusbar statusbar;
34 private File photo_path;
35 private File video_path;
3436
35 public SnapWindow (Snap.SnapApp snap_app) {37 public SnapWindow (Snap.SnapApp snap_app) {
3638
@@ -44,8 +46,8 @@
44 this.resizable = false;46 this.resizable = false;
4547
46 // Init thumbnail providers48 // Init thumbnail providers
47 var photo_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.PHOTO));49 photo_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.PHOTO));
48 var video_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.VIDEO));50 video_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.VIDEO));
49 Resources.photo_thumb_provider = new Services.ThumbnailProvider (photo_path);51 Resources.photo_thumb_provider = new Services.ThumbnailProvider (photo_path);
50 Resources.video_thumb_provider = new Services.ThumbnailProvider (video_path);52 Resources.video_thumb_provider = new Services.ThumbnailProvider (video_path);
5153
@@ -68,6 +70,7 @@
68 gallery_button_box.set_layout (Gtk.ButtonBoxStyle.START);70 gallery_button_box.set_layout (Gtk.ButtonBoxStyle.START);
6971
70 var gallery_button = new Gtk.ToggleButton.with_label (_("Gallery"));72 var gallery_button = new Gtk.ToggleButton.with_label (_("Gallery"));
73 gallery_button.sensitive = gallery_files_exists();
71 gallery_button.toggled.connect (() => {74 gallery_button.toggled.connect (() => {
72 if (this.stack.get_visible_child () == this.camera) {75 if (this.stack.get_visible_child () == this.camera) {
73 this.show_gallery ();76 this.show_gallery ();
@@ -133,7 +136,7 @@
133 });136 });
134 this.camera.capture_stop.connect (() => {137 this.camera.capture_stop.connect (() => {
135 // Enable extra buttons138 // Enable extra buttons
136 gallery_button.sensitive = true;139 gallery_button.sensitive = gallery_files_exists();
137 this.mode_button.sensitive = true;140 this.mode_button.sensitive = true;
138 this.set_take_button_icon (this.camera.get_action_type ());141 this.set_take_button_icon (this.camera.get_action_type ());
139 });142 });
@@ -156,7 +159,7 @@
156159
157 this.add (this.stack);160 this.add (this.stack);
158 this.show_all ();161 this.show_all ();
159162
160 }163 }
161 164
162 protected override bool delete_event (Gdk.EventAny event) {165 protected override bool delete_event (Gdk.EventAny event) {
@@ -228,5 +231,25 @@
228 this.unlock_camera_actions ();231 this.unlock_camera_actions ();
229 this.stack.set_visible_child (this.camera);232 this.stack.set_visible_child (this.camera);
230 }233 }
234
235 private bool gallery_files_exists() {
236 FileInfo file_info;
237
238 try {
239 FileEnumerator enumerator_photo = photo_path.enumerate_children (FileAttribute.STANDARD_NAME, 0);
240 FileEnumerator enumerator_video = video_path.enumerate_children (FileAttribute.STANDARD_NAME, 0);
241
242 if ((file_info = enumerator_photo.next_file ()) != null ||
243 (file_info = enumerator_video.next_file ()) != null) {
244 debug ("gallery is not empty\n");
245 return true;
246 }
247 } catch (Error perr) {
248 warning ("Error: check_gallery_files photo failed: %s", perr.message);
249 }
250
251 debug ("gallery is empty\n");
252 return false;
253 }
231 }254 }
232}255}
233\ No newline at end of file256\ No newline at end of file

Subscribers

People subscribed via source and target branches