[dconf-editor] Simple warning dialog, needs design.



commit ca441ce1b76b0e14a3b4c31c6cd9665930d2fcdc
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Fri Oct 16 10:13:26 2015 +0200

    Simple warning dialog, needs design.

 editor/ca.desrt.dconf-editor.gschema.xml |    5 +++++
 editor/dconf-editor.ui                   |    1 +
 editor/dconf-window.vala                 |   20 ++++++++++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/editor/ca.desrt.dconf-editor.gschema.xml b/editor/ca.desrt.dconf-editor.gschema.xml
index ad978a9..f4a53eb 100644
--- a/editor/ca.desrt.dconf-editor.gschema.xml
+++ b/editor/ca.desrt.dconf-editor.gschema.xml
@@ -37,6 +37,11 @@
       <summary>A path to restore the last view</summary>
       <description>If the 'restore-view' key is set to 'true', Dconf Editor tries at launch to navigate to 
this path.</description>
     </key>
+    <key name="show-warning" type="b">
+      <default>true</default>
+      <summary>Show initial warning</summary>
+      <description>If 'true', Dconf Editor opens a popup when launched reminding the user to be 
careful.</description>
+    </key>
   </schema>
   <enum id="ca.desrt.dconf-editor.DemoEnum">
     <value value="0" nick="Red"/>
diff --git a/editor/dconf-editor.ui b/editor/dconf-editor.ui
index cb17340..2dffee6 100644
--- a/editor/dconf-editor.ui
+++ b/editor/dconf-editor.ui
@@ -6,6 +6,7 @@
     <property name="title" translatable="yes">dconf Editor</property>
     <property name="height-request">525</property>
     <property name="width-request">700</property>
+    <signal name="show" handler="on_show"/>
     <signal name="key-press-event" handler="on_key_press_event"/>
     <signal name="window-state-event" handler="on_window_state_event"/>
     <signal name="size-allocate" handler="on_size_allocate"/>
diff --git a/editor/dconf-window.vala b/editor/dconf-window.vala
index afb90c2..fec47bd 100644
--- a/editor/dconf-window.vala
+++ b/editor/dconf-window.vala
@@ -67,6 +67,26 @@ class DConfWindow : ApplicationWindow
     \*/
 
     [GtkCallback]
+    private void on_show ()
+    {
+        if (!settings.get_boolean ("show-warning"))
+            return;
+
+        Gtk.MessageDialog dialog = new MessageDialog (this, DialogFlags.MODAL, MessageType.INFO, 
ButtonsType.NONE, _("Thanks for using Dconf Editor for editing your configurations!"));
+        dialog.format_secondary_text (_("Don't forget that some option may break applications, so be 
careful."));
+        dialog.add_buttons (_("I'd be careful."), ResponseType.ACCEPT);
+        Box box = (Box) dialog.get_message_area ();
+        CheckButton checkbutton = new CheckButton.with_label (_("Show this dialog next time."));
+        checkbutton.visible = true;
+        checkbutton.active = true;
+        checkbutton.margin_top = 5;
+        checkbutton.toggled.connect (() => { if (!checkbutton.active) settings.set_boolean ("show-warning", 
false); });
+        box.add (checkbutton);
+        dialog.run ();
+        dialog.destroy ();
+    }
+
+    [GtkCallback]
     private bool on_window_state_event (Widget widget, Gdk.EventWindowState event)
     {
         if ((event.changed_mask & Gdk.WindowState.MAXIMIZED) != 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]