Merge lp:~donadigo/screenshot-tool/show-preview into lp:~elementary-apps/screenshot-tool/trunk

Proposed by Adam Bieńkowski
Status: Merged
Approved by: Danielle Foré
Approved revision: 141
Merged at revision: 140
Proposed branch: lp:~donadigo/screenshot-tool/show-preview
Merge into: lp:~elementary-apps/screenshot-tool/trunk
Diff against target: 101 lines (+28/-10)
2 files modified
src/ScreenshotWindow.vala (+5/-6)
src/Widgets/SaveDialog.vala (+23/-4)
To merge this branch: bzr merge lp:~donadigo/screenshot-tool/show-preview
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+286682@code.launchpad.net

Commit message

Fix bug: #1497758 "Show image previews in save dialog".

Description of the change

Fix bug: #1497758 "Show image previews in save dialog".

From my testing this branch also fixes segfault when clicking "Cancel" in SaveDialog and then trying to perform another action in main dialog (please test this with trunk).

To post a comment you must log in.
141. By Adam Bieńkowski

Fix stupid screenshot variable creation; added parenthesies

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ScreenshotWindow.vala'
2--- src/ScreenshotWindow.vala 2016-01-30 09:08:18 +0000
3+++ src/ScreenshotWindow.vala 2016-02-19 16:11:35 +0000
4@@ -276,20 +276,20 @@
5 }
6 }
7
8- save_dialog = new Screenshot.Widgets.SaveDialog (settings, this);
9+ save_dialog = new Screenshot.Widgets.SaveDialog (screenshot, settings, this);
10
11 save_dialog.save_response.connect ((response, folder_dir, output_name, format) => {
12- save_dialog.set_opacity (0);
13 save_dialog.destroy ();
14
15 if (response == true) {
16- string file_name = folder_dir + "/" + output_name + "." + format;
17+ string file_name = Path.build_filename (folder_dir, output_name + "." + format);
18
19 try {
20 screenshot.save (file_name, format);
21
22- if (close_on_save == true)
23+ if (close_on_save == true) {
24 this.destroy ();
25+ }
26 } catch (GLib.Error e) {
27 Gtk.MessageDialog dialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
28 Gtk.ButtonsType.CLOSE, _("Could not capture screenshot"));
29@@ -299,8 +299,7 @@
30 dialog.destroy ();
31 debug (e.message);
32 }
33- } else
34- return;
35+ }
36 });
37
38 return false;
39
40=== modified file 'src/Widgets/SaveDialog.vala'
41--- src/Widgets/SaveDialog.vala 2016-01-25 12:38:10 +0000
42+++ src/Widgets/SaveDialog.vala 2016-02-19 16:11:35 +0000
43@@ -35,7 +35,7 @@
44
45 public signal void save_response (bool response, string folder_dir, string output_name, string format);
46
47- public SaveDialog (Settings settings, Gtk.Window parent) {
48+ public SaveDialog (Gdk.Pixbuf pixbuf, Settings settings, Gtk.Window parent) {
49
50 resizable = false;
51 deletable = false;
52@@ -49,12 +49,12 @@
53 if (settings.get_string ("folder-dir") != folder_dir && settings.get_string ("folder-dir") != "")
54 folder_dir = settings.get_string ("folder-dir");
55
56- build (settings, parent);
57+ build (pixbuf, settings, parent);
58 show_all ();
59 name_entry.grab_focus ();
60 }
61
62- public void build (Settings settings, Gtk.Window parent) {
63+ public void build (Gdk.Pixbuf pixbuf, Settings settings, Gtk.Window parent) {
64
65 date_time = new GLib.DateTime.now_local ().format ("%Y-%m-%d %H:%M:%S");
66 file_name = _("Screenshot from ") + date_time;
67@@ -66,6 +66,22 @@
68
69 var content = this.get_content_area () as Gtk.Box;
70
71+ var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
72+
73+ int width = pixbuf.get_width () / 4;
74+ int height = pixbuf.get_height () / 4;
75+ if (pixbuf.get_width () > Gdk.Screen.width () / 2) {
76+ width /= 2;
77+ }
78+
79+ if (pixbuf.get_height () > Gdk.Screen.height () / 2) {
80+ height /= 2;
81+ }
82+
83+ var screenshot = pixbuf.scale_simple (width, height, Gdk.InterpType.BILINEAR);
84+
85+ var preview = new Gtk.Image.from_pixbuf (screenshot);
86+
87 dialog_label = new Gtk.Label (_("Save Image as…"));
88 dialog_label.get_style_context ().add_class ("h4");
89 dialog_label.halign = Gtk.Align.START;
90@@ -154,7 +170,10 @@
91 grid.attach (location_label, 0, 3, 1, 1);
92 grid.attach (location, 1, 3, 1, 1);
93
94- content.add (grid);
95+ main_box.add (preview);
96+ main_box.add (grid);
97+
98+ content.add (main_box);
99 }
100 }
101 }

Subscribers

People subscribed via source and target branches