Merge lp:~elementary-pantheon/switchboard-plug-about/restore-dialog into lp:~elementary-apps/switchboard-plug-about/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: Adam Bieńkowski
Approved revision: 442
Merged at revision: 441
Proposed branch: lp:~elementary-pantheon/switchboard-plug-about/restore-dialog
Merge into: lp:~elementary-apps/switchboard-plug-about/trunk
Diff against target: 131 lines (+66/-38)
3 files modified
src/CMakeLists.txt (+1/-0)
src/Plug.vala (+2/-38)
src/RestoreDialog.vala (+63/-0)
To merge this branch: bzr merge lp:~elementary-pantheon/switchboard-plug-about/restore-dialog
Reviewer Review Type Date Requested Status
Adam Bieńkowski (community) code / testing Approve
Review via email: mp+320289@code.launchpad.net

Commit message

Rewrite settings restore dialog as its own widget

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

actually restore the dialog

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Perhaps you could call get_content_area () once like this, and do everything in one go:

var action_area = get_action_area ();
action_area.add (grid);
action_area.margin_right = 6;
action_area.margin_bottom = 6;
action_area.margin_top = 14;

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Ignore my first comment. Looking good.

review: Approve (code / testing)

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 2017-01-06 07:38:10 +0000
3+++ src/CMakeLists.txt 2017-03-19 18:19:27 +0000
4@@ -14,6 +14,7 @@
5 # Add all your vala files and requires packages to the List below to include them in the build
6 vala_precompile (VALA_C
7 Plug.vala
8+ RestoreDialog.vala
9 ${CMAKE_CURRENT_BINARY_DIR}/config.vala
10 PACKAGES
11 gtk+-3.0
12
13=== modified file 'src/Plug.vala'
14--- src/Plug.vala 2016-11-16 17:56:55 +0000
15+++ src/Plug.vala 2017-03-19 18:19:27 +0000
16@@ -489,45 +489,9 @@
17 * returns true to continue, false to cancel
18 */
19 private bool confirm_restore_action () {
20- var dialog = new Gtk.Dialog ();
21-
22- Gtk.Box box = dialog.get_content_area () as Gtk.Box;
23- var layout = new Gtk.Grid ();
24- var text = new Gtk.Label ("");
25-
26- text.set_markup ("<span weight='bold' size='larger'>" +
27- _("System settings will be restored to the factory defaults") + "</span>\n\n"+
28- _("All system settings and data will be reset to the default values.") + "\n" +
29- _("Personal data, such as music and pictures, will be uneffected."));
30-
31- var image = new Gtk.Image.from_icon_name ("dialog-warning",
32- Gtk.IconSize.DIALOG);
33- image.yalign = 0;
34- image.show ();
35-
36- layout.set_column_spacing (12);
37- layout.set_margin_right (6);
38- layout.set_margin_bottom (18);
39- layout.set_margin_left (6);
40-
41- layout.add (image);
42- layout.add (text);
43-
44- box.pack_start (layout);
45-
46- var continue_button = new Gtk.Button.with_label (_("Restore Settings"));
47- continue_button.get_style_context ().add_class ("destructive-action");
48-
49- var cancel_button = new Gtk.Button.with_label (_("Cancel"));
50- continue_button.show ();
51- cancel_button.show ();
52-
53- dialog.border_width = 6;
54- dialog.deletable = false;
55- dialog.add_action_widget (cancel_button, 0);
56- dialog.add_action_widget (continue_button, 1);
57-
58+ var dialog = new RestoreDialog ();
59 dialog.show_all ();
60+
61 var result = dialog.run ();
62 dialog.destroy ();
63
64
65=== added file 'src/RestoreDialog.vala'
66--- src/RestoreDialog.vala 1970-01-01 00:00:00 +0000
67+++ src/RestoreDialog.vala 2017-03-19 18:19:27 +0000
68@@ -0,0 +1,63 @@
69+/*
70+* Copyright (c) 2017 elementary LLC. (https://elementary.io)
71+*
72+* This program is free software; you can redistribute it and/or
73+* modify it under the terms of the GNU General Public
74+* License as published by the Free Software Foundation; either
75+* version 2 of the License, or (at your option) any later version.
76+*
77+* This program is distributed in the hope that it will be useful,
78+* but WITHOUT ANY WARRANTY; without even the implied warranty of
79+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
80+* General Public License for more details.
81+*
82+* You should have received a copy of the GNU General Public
83+* License along with this program; if not, write to the
84+* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
85+* Boston, MA 02110-1301 USA
86+*/
87+
88+public class RestoreDialog : Gtk.Dialog {
89+ public RestoreDialog () {
90+ Object (resizable: false, deletable: false, skip_taskbar_hint: true);
91+ }
92+
93+ construct {
94+ var image = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.DIALOG);
95+ image.valign = Gtk.Align.START;
96+
97+ var primary_label = new Gtk.Label (_("System Settings Will Be Restored to The Factory Defaults"));
98+ primary_label.get_style_context ().add_class ("primary");
99+ primary_label.max_width_chars = 50;
100+ primary_label.wrap = true;
101+ primary_label.xalign = 0;
102+
103+ var secondary_label = new Gtk.Label (_("All system settings and data will be reset to the default values. Personal data, such as music and pictures, will be uneffected."));
104+ secondary_label.max_width_chars = 50;
105+ secondary_label.wrap = true;
106+ secondary_label.xalign = 0;
107+
108+ var grid = new Gtk.Grid ();
109+ grid.column_spacing = 12;
110+ grid.row_spacing = 6;
111+ grid.margin_left = grid.margin_right = 12;
112+ grid.attach (image, 0, 0, 1, 2);
113+ grid.attach (primary_label, 1, 0, 1, 1);
114+ grid.attach (secondary_label, 1, 1, 1, 1);
115+
116+ get_content_area ().add (grid);
117+
118+ var continue_button = new Gtk.Button.with_label (_("Restore Settings"));
119+ continue_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
120+
121+ var cancel_button = new Gtk.Button.with_label (_("Cancel"));
122+
123+ add_action_widget (cancel_button, 0);
124+ add_action_widget (continue_button, 1);
125+
126+ var action_area = get_action_area ();
127+ action_area.margin_right = 6;
128+ action_area.margin_bottom = 6;
129+ action_area.margin_top = 14;
130+ }
131+}

Subscribers

People subscribed via source and target branches