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
1=== modified file 'src/SnapWindow.vala'
2--- src/SnapWindow.vala 2014-05-27 11:23:34 +0000
3+++ src/SnapWindow.vala 2014-09-19 17:51:03 +0000
4@@ -31,6 +31,8 @@
5 private Granite.Widgets.ModeButton mode_button;
6 private Gtk.Button take_button;
7 private Gtk.Statusbar statusbar;
8+ private File photo_path;
9+ private File video_path;
10
11 public SnapWindow (Snap.SnapApp snap_app) {
12
13@@ -44,8 +46,8 @@
14 this.resizable = false;
15
16 // Init thumbnail providers
17- var photo_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.PHOTO));
18- var video_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.VIDEO));
19+ photo_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.PHOTO));
20+ video_path = File.new_for_path (Resources.get_media_dir (Widgets.Camera.ActionType.VIDEO));
21 Resources.photo_thumb_provider = new Services.ThumbnailProvider (photo_path);
22 Resources.video_thumb_provider = new Services.ThumbnailProvider (video_path);
23
24@@ -68,6 +70,7 @@
25 gallery_button_box.set_layout (Gtk.ButtonBoxStyle.START);
26
27 var gallery_button = new Gtk.ToggleButton.with_label (_("Gallery"));
28+ gallery_button.sensitive = gallery_files_exists();
29 gallery_button.toggled.connect (() => {
30 if (this.stack.get_visible_child () == this.camera) {
31 this.show_gallery ();
32@@ -133,7 +136,7 @@
33 });
34 this.camera.capture_stop.connect (() => {
35 // Enable extra buttons
36- gallery_button.sensitive = true;
37+ gallery_button.sensitive = gallery_files_exists();
38 this.mode_button.sensitive = true;
39 this.set_take_button_icon (this.camera.get_action_type ());
40 });
41@@ -156,7 +159,7 @@
42
43 this.add (this.stack);
44 this.show_all ();
45-
46+
47 }
48
49 protected override bool delete_event (Gdk.EventAny event) {
50@@ -228,5 +231,25 @@
51 this.unlock_camera_actions ();
52 this.stack.set_visible_child (this.camera);
53 }
54+
55+ private bool gallery_files_exists() {
56+ FileInfo file_info;
57+
58+ try {
59+ FileEnumerator enumerator_photo = photo_path.enumerate_children (FileAttribute.STANDARD_NAME, 0);
60+ FileEnumerator enumerator_video = video_path.enumerate_children (FileAttribute.STANDARD_NAME, 0);
61+
62+ if ((file_info = enumerator_photo.next_file ()) != null ||
63+ (file_info = enumerator_video.next_file ()) != null) {
64+ debug ("gallery is not empty\n");
65+ return true;
66+ }
67+ } catch (Error perr) {
68+ warning ("Error: check_gallery_files photo failed: %s", perr.message);
69+ }
70+
71+ debug ("gallery is empty\n");
72+ return false;
73+ }
74 }
75 }
76\ No newline at end of file

Subscribers

People subscribed via source and target branches