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
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2017-01-06 07:38:10 +0000
+++ src/CMakeLists.txt 2017-03-19 18:19:27 +0000
@@ -14,6 +14,7 @@
14# Add all your vala files and requires packages to the List below to include them in the build14# Add all your vala files and requires packages to the List below to include them in the build
15vala_precompile (VALA_C15vala_precompile (VALA_C
16 Plug.vala16 Plug.vala
17 RestoreDialog.vala
17 ${CMAKE_CURRENT_BINARY_DIR}/config.vala18 ${CMAKE_CURRENT_BINARY_DIR}/config.vala
18PACKAGES19PACKAGES
19 gtk+-3.020 gtk+-3.0
2021
=== modified file 'src/Plug.vala'
--- src/Plug.vala 2016-11-16 17:56:55 +0000
+++ src/Plug.vala 2017-03-19 18:19:27 +0000
@@ -489,45 +489,9 @@
489 * returns true to continue, false to cancel489 * returns true to continue, false to cancel
490 */490 */
491private bool confirm_restore_action () {491private bool confirm_restore_action () {
492 var dialog = new Gtk.Dialog ();492 var dialog = new RestoreDialog ();
493
494 Gtk.Box box = dialog.get_content_area () as Gtk.Box;
495 var layout = new Gtk.Grid ();
496 var text = new Gtk.Label ("");
497
498 text.set_markup ("<span weight='bold' size='larger'>" +
499 _("System settings will be restored to the factory defaults") + "</span>\n\n"+
500 _("All system settings and data will be reset to the default values.") + "\n" +
501 _("Personal data, such as music and pictures, will be uneffected."));
502
503 var image = new Gtk.Image.from_icon_name ("dialog-warning",
504 Gtk.IconSize.DIALOG);
505 image.yalign = 0;
506 image.show ();
507
508 layout.set_column_spacing (12);
509 layout.set_margin_right (6);
510 layout.set_margin_bottom (18);
511 layout.set_margin_left (6);
512
513 layout.add (image);
514 layout.add (text);
515
516 box.pack_start (layout);
517
518 var continue_button = new Gtk.Button.with_label (_("Restore Settings"));
519 continue_button.get_style_context ().add_class ("destructive-action");
520
521 var cancel_button = new Gtk.Button.with_label (_("Cancel"));
522 continue_button.show ();
523 cancel_button.show ();
524
525 dialog.border_width = 6;
526 dialog.deletable = false;
527 dialog.add_action_widget (cancel_button, 0);
528 dialog.add_action_widget (continue_button, 1);
529
530 dialog.show_all ();493 dialog.show_all ();
494
531 var result = dialog.run ();495 var result = dialog.run ();
532 dialog.destroy ();496 dialog.destroy ();
533497
534498
=== added file 'src/RestoreDialog.vala'
--- src/RestoreDialog.vala 1970-01-01 00:00:00 +0000
+++ src/RestoreDialog.vala 2017-03-19 18:19:27 +0000
@@ -0,0 +1,63 @@
1/*
2* Copyright (c) 2017 elementary LLC. (https://elementary.io)
3*
4* This program is free software; you can redistribute it and/or
5* modify it under the terms of the GNU General Public
6* License as published by the Free Software Foundation; either
7* version 2 of the License, or (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12* General Public License for more details.
13*
14* You should have received a copy of the GNU General Public
15* License along with this program; if not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17* Boston, MA 02110-1301 USA
18*/
19
20public class RestoreDialog : Gtk.Dialog {
21 public RestoreDialog () {
22 Object (resizable: false, deletable: false, skip_taskbar_hint: true);
23 }
24
25 construct {
26 var image = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.DIALOG);
27 image.valign = Gtk.Align.START;
28
29 var primary_label = new Gtk.Label (_("System Settings Will Be Restored to The Factory Defaults"));
30 primary_label.get_style_context ().add_class ("primary");
31 primary_label.max_width_chars = 50;
32 primary_label.wrap = true;
33 primary_label.xalign = 0;
34
35 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."));
36 secondary_label.max_width_chars = 50;
37 secondary_label.wrap = true;
38 secondary_label.xalign = 0;
39
40 var grid = new Gtk.Grid ();
41 grid.column_spacing = 12;
42 grid.row_spacing = 6;
43 grid.margin_left = grid.margin_right = 12;
44 grid.attach (image, 0, 0, 1, 2);
45 grid.attach (primary_label, 1, 0, 1, 1);
46 grid.attach (secondary_label, 1, 1, 1, 1);
47
48 get_content_area ().add (grid);
49
50 var continue_button = new Gtk.Button.with_label (_("Restore Settings"));
51 continue_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
52
53 var cancel_button = new Gtk.Button.with_label (_("Cancel"));
54
55 add_action_widget (cancel_button, 0);
56 add_action_widget (continue_button, 1);
57
58 var action_area = get_action_area ();
59 action_area.margin_right = 6;
60 action_area.margin_bottom = 6;
61 action_area.margin_top = 14;
62 }
63}

Subscribers

People subscribed via source and target branches