Merge lp:~elementary-apps/pantheon-mail/ask-to-open-dialog into lp:~elementary-apps/pantheon-mail/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Danielle Foré
Approved revision: 2061
Merged at revision: 2060
Proposed branch: lp:~elementary-apps/pantheon-mail/ask-to-open-dialog
Merge into: lp:~elementary-apps/pantheon-mail/trunk
Diff against target: 121 lines (+86/-8)
3 files modified
src/CMakeLists.txt (+1/-0)
src/client/application/geary-controller.vala (+4/-8)
src/client/dialogs/OpenAttachmentDialog.vala (+81/-0)
To merge this branch: bzr merge lp:~elementary-apps/pantheon-mail/ask-to-open-dialog
Reviewer Review Type Date Requested Status
Zisu Andrei (community) Approve
Review via email: mp+295977@code.launchpad.net

Commit message

Create AskToOpenDialog.vala
Move strings and logic from geary-controller.vala to AskToOpenDialog.vala

To post a comment you must log in.
2059. By Danielle Foré

more sane naming

Revision history for this message
Zisu Andrei (matzipan) wrote :

Diff comment below. Otherwise, LGTM.

But there is no option in the Preferences panel to enable this dialog, you have to use dconf.

review: Needs Fixing
2060. By Danielle Foré

use style class for dialog title text

Revision history for this message
Danielle Foré (danrabbit) wrote :

Created a style class in egtk for dialog primary text and made use of it.

Yep that's correct that there's currently no option to re-enable this dialog. That's the same as trunk and I think outside of this branch's scope

2061. By Danielle Foré

use markup line no longer necessary

Revision history for this message
Zisu Andrei (matzipan) wrote :

I know it is out of scope, I was just checking, maybe I missed something.

review: Approve
Revision history for this message
Danielle Foré (danrabbit) wrote :

Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CMakeLists.txt'
2--- src/CMakeLists.txt 2016-03-20 20:04:33 +0000
3+++ src/CMakeLists.txt 2016-05-29 16:52:19 +0000
4@@ -363,6 +363,7 @@
5 client/conversation-viewer/AttachmentWidget.vala
6
7 client/dialogs/alert-dialog.vala
8+client/dialogs/OpenAttachmentDialog.vala
9 client/dialogs/attachment-dialog.vala
10 client/dialogs/certificate-warning-dialog.vala
11 client/dialogs/password-dialog.vala
12
13=== modified file 'src/client/application/geary-controller.vala'
14--- src/client/application/geary-controller.vala 2016-03-17 15:51:02 +0000
15+++ src/client/application/geary-controller.vala 2016-05-29 16:52:19 +0000
16@@ -1942,15 +1942,11 @@
17
18 private void on_open_attachment(Geary.Attachment attachment) {
19 if (GearyApplication.instance.config.ask_open_attachment) {
20- QuestionDialog ask_to_open = new QuestionDialog.with_checkbox(main_window,
21- _("Are you sure you want to open \"%s\"?").printf(attachment.file.get_basename()),
22- _("Attachments may cause damage to your system if opened. Only open files from trusted sources."),
23- Stock._OPEN_BUTTON, Stock._CANCEL, _("Don't _ask me again"), false);
24- if (ask_to_open.run() != Gtk.ResponseType.OK)
25+ var ask_to_open = new OpenAttachmentDialog (main_window, attachment);
26+ if (ask_to_open.run() != Gtk.ResponseType.OK) {
27 return;
28-
29- // only save checkbox state if OK was selected
30- GearyApplication.instance.config.ask_open_attachment = !ask_to_open.is_checked;
31+ }
32+ ask_to_open.destroy ();
33 }
34
35 // Open the attachment if we know what to do with it.
36
37=== added file 'src/client/dialogs/OpenAttachmentDialog.vala'
38--- src/client/dialogs/OpenAttachmentDialog.vala 1970-01-01 00:00:00 +0000
39+++ src/client/dialogs/OpenAttachmentDialog.vala 2016-05-29 16:52:19 +0000
40@@ -0,0 +1,81 @@
41+/*
42+* Copyright (c) 2016 elementary LLC (http://launchpad.net/pantheon-mail
43+*
44+* This program is free software; you can redistribute it and/or
45+* modify it under the terms of the GNU General Public
46+* License as published by the Free Software Foundation; either
47+* version 2 of the License, or (at your option) any later version.
48+*
49+* This program is distributed in the hope that it will be useful,
50+* but WITHOUT ANY WARRANTY; without even the implied warranty of
51+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
52+* General Public License for more details.
53+*
54+* You should have received a copy of the GNU General Public
55+* License along with this program; if not, write to the
56+* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
57+* Boston, MA 02111-1307, USA.
58+*
59+* Authored by: Daniel Foré <daniel@elementary.io>
60+*/
61+
62+public class OpenAttachmentDialog : Gtk.Dialog {
63+ private Gtk.CheckButton checkbox;
64+
65+ public OpenAttachmentDialog (Gtk.Window parent, Geary.Attachment attachment) {
66+ border_width = 6;
67+ deletable = false;
68+ resizable = false;
69+ transient_for = parent;
70+
71+ var warning_image = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.DIALOG);
72+ warning_image.valign = Gtk.Align.START;
73+
74+ var primary_label = new Gtk.Label (_("Are you sure you want to open %s?").printf(attachment.file.get_basename()));
75+ primary_label.get_style_context ().add_class ("primary");
76+ primary_label.max_width_chars = 60;
77+ primary_label.wrap = true;
78+ primary_label.xalign = 0;
79+
80+ var secondary_label = new Gtk.Label (_("Attachments may cause damage to your system if opened. Only open files from trusted sources."));
81+ secondary_label.max_width_chars = 60;
82+ secondary_label.wrap = true;
83+ secondary_label.xalign = 0;
84+
85+ checkbox = new Gtk.CheckButton.with_label (_("Don't ask me again"));
86+ checkbox.margin_top = 6;
87+
88+ var open_button = new Gtk.Button.with_label (_("Open Anyway"));
89+ open_button.get_style_context ().add_class ("destructive-action");
90+
91+ var layout = new Gtk.Grid ();
92+ layout.margin = 6;
93+ layout.margin_top = 0;
94+ layout.column_spacing = 12;
95+ layout.row_spacing = 6;
96+ layout.attach (warning_image, 0, 0, 1, 3);
97+ layout.attach (primary_label, 1, 0, 1, 1);
98+ layout.attach (secondary_label, 1, 1, 1, 1);
99+ layout.attach (checkbox, 1, 2, 1, 1);
100+
101+ var content = get_content_area () as Gtk.Box;
102+ content.add (layout);
103+
104+ add_button (_("Cancel"), Gtk.ResponseType.CLOSE);
105+ add_action_widget (open_button, Gtk.ResponseType.OK);
106+ show_all ();
107+
108+ response.connect (on_response);
109+ }
110+
111+ private void on_response (Gtk.Dialog source, int response_id) {
112+ switch (response_id) {
113+ case Gtk.ResponseType.OK:
114+ GearyApplication.instance.config.ask_open_attachment = !checkbox.active;
115+ break;
116+ case Gtk.ResponseType.CLOSE:
117+ destroy ();
118+ break;
119+ }
120+ }
121+}

Subscribers

People subscribed via source and target branches