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
=== modified file 'src/ScreenshotWindow.vala'
--- src/ScreenshotWindow.vala 2016-01-30 09:08:18 +0000
+++ src/ScreenshotWindow.vala 2016-02-19 16:11:35 +0000
@@ -276,20 +276,20 @@
276 }276 }
277 }277 }
278278
279 save_dialog = new Screenshot.Widgets.SaveDialog (settings, this);279 save_dialog = new Screenshot.Widgets.SaveDialog (screenshot, settings, this);
280280
281 save_dialog.save_response.connect ((response, folder_dir, output_name, format) => {281 save_dialog.save_response.connect ((response, folder_dir, output_name, format) => {
282 save_dialog.set_opacity (0);
283 save_dialog.destroy ();282 save_dialog.destroy ();
284283
285 if (response == true) {284 if (response == true) {
286 string file_name = folder_dir + "/" + output_name + "." + format;285 string file_name = Path.build_filename (folder_dir, output_name + "." + format);
287286
288 try {287 try {
289 screenshot.save (file_name, format);288 screenshot.save (file_name, format);
290289
291 if (close_on_save == true)290 if (close_on_save == true) {
292 this.destroy ();291 this.destroy ();
292 }
293 } catch (GLib.Error e) {293 } catch (GLib.Error e) {
294 Gtk.MessageDialog dialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,294 Gtk.MessageDialog dialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
295 Gtk.ButtonsType.CLOSE, _("Could not capture screenshot"));295 Gtk.ButtonsType.CLOSE, _("Could not capture screenshot"));
@@ -299,8 +299,7 @@
299 dialog.destroy ();299 dialog.destroy ();
300 debug (e.message);300 debug (e.message);
301 }301 }
302 } else302 }
303 return;
304 });303 });
305304
306 return false;305 return false;
307306
=== modified file 'src/Widgets/SaveDialog.vala'
--- src/Widgets/SaveDialog.vala 2016-01-25 12:38:10 +0000
+++ src/Widgets/SaveDialog.vala 2016-02-19 16:11:35 +0000
@@ -35,7 +35,7 @@
3535
36 public signal void save_response (bool response, string folder_dir, string output_name, string format);36 public signal void save_response (bool response, string folder_dir, string output_name, string format);
3737
38 public SaveDialog (Settings settings, Gtk.Window parent) {38 public SaveDialog (Gdk.Pixbuf pixbuf, Settings settings, Gtk.Window parent) {
3939
40 resizable = false;40 resizable = false;
41 deletable = false;41 deletable = false;
@@ -49,12 +49,12 @@
49 if (settings.get_string ("folder-dir") != folder_dir && settings.get_string ("folder-dir") != "")49 if (settings.get_string ("folder-dir") != folder_dir && settings.get_string ("folder-dir") != "")
50 folder_dir = settings.get_string ("folder-dir");50 folder_dir = settings.get_string ("folder-dir");
5151
52 build (settings, parent);52 build (pixbuf, settings, parent);
53 show_all ();53 show_all ();
54 name_entry.grab_focus ();54 name_entry.grab_focus ();
55 }55 }
5656
57 public void build (Settings settings, Gtk.Window parent) {57 public void build (Gdk.Pixbuf pixbuf, Settings settings, Gtk.Window parent) {
5858
59 date_time = new GLib.DateTime.now_local ().format ("%Y-%m-%d %H:%M:%S");59 date_time = new GLib.DateTime.now_local ().format ("%Y-%m-%d %H:%M:%S");
60 file_name = _("Screenshot from ") + date_time;60 file_name = _("Screenshot from ") + date_time;
@@ -66,6 +66,22 @@
6666
67 var content = this.get_content_area () as Gtk.Box;67 var content = this.get_content_area () as Gtk.Box;
6868
69 var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
70
71 int width = pixbuf.get_width () / 4;
72 int height = pixbuf.get_height () / 4;
73 if (pixbuf.get_width () > Gdk.Screen.width () / 2) {
74 width /= 2;
75 }
76
77 if (pixbuf.get_height () > Gdk.Screen.height () / 2) {
78 height /= 2;
79 }
80
81 var screenshot = pixbuf.scale_simple (width, height, Gdk.InterpType.BILINEAR);
82
83 var preview = new Gtk.Image.from_pixbuf (screenshot);
84
69 dialog_label = new Gtk.Label (_("Save Image as…"));85 dialog_label = new Gtk.Label (_("Save Image as…"));
70 dialog_label.get_style_context ().add_class ("h4");86 dialog_label.get_style_context ().add_class ("h4");
71 dialog_label.halign = Gtk.Align.START;87 dialog_label.halign = Gtk.Align.START;
@@ -154,7 +170,10 @@
154 grid.attach (location_label, 0, 3, 1, 1);170 grid.attach (location_label, 0, 3, 1, 1);
155 grid.attach (location, 1, 3, 1, 1);171 grid.attach (location, 1, 3, 1, 1);
156172
157 content.add (grid);173 main_box.add (preview);
174 main_box.add (grid);
175
176 content.add (main_box);
158 }177 }
159 }178 }
160}179}

Subscribers

People subscribed via source and target branches