[dconf-editor] Use the same UI file for KeyEditor and KeyEditorNoSchema.



commit 8bf67891e2ac6d2b33310e2584e723b55c1ae74b
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sat May 7 18:12:47 2016 +0200

    Use the same UI file for KeyEditor and KeyEditorNoSchema.

 editor/Makefile.am                |    1 -
 editor/dconf-editor.gresource.xml |    1 -
 editor/dconf-view.vala            |   34 +++++++++++++++++++---------------
 editor/key-editor.ui              |   24 ++++++++++++++++++++++--
 4 files changed, 41 insertions(+), 19 deletions(-)
---
diff --git a/editor/Makefile.am b/editor/Makefile.am
index c8c2b05..3ebf8f1 100644
--- a/editor/Makefile.am
+++ b/editor/Makefile.am
@@ -27,7 +27,6 @@ resource_data = \
        folder-list-box-row.ui \
        key-list-box-row.ui \
        key-editor.ui \
-       key-editor-no-schema.ui \
        bookmarks.ui \
        bookmark.ui \
        help-overlay.ui \
diff --git a/editor/dconf-editor.gresource.xml b/editor/dconf-editor.gresource.xml
index 08fc477..9db9def 100644
--- a/editor/dconf-editor.gresource.xml
+++ b/editor/dconf-editor.gresource.xml
@@ -8,7 +8,6 @@
     <file preprocess="xml-stripblanks">folder-list-box-row.ui</file>
     <file preprocess="xml-stripblanks">key-list-box-row.ui</file>
     <file preprocess="xml-stripblanks">key-editor.ui</file>
-    <file preprocess="xml-stripblanks">key-editor-no-schema.ui</file>
     <file preprocess="xml-stripblanks">pathbar.ui</file>
     <file preprocess="xml-stripblanks">pathbar-item.ui</file>
     <file preprocess="xml-stripblanks">property-row.ui</file>
diff --git a/editor/dconf-view.vala b/editor/dconf-view.vala
index c2fb512..7f4b3f7 100644
--- a/editor/dconf-view.vala
+++ b/editor/dconf-view.vala
@@ -83,8 +83,19 @@ private class PropertyRow : ListBoxRow
     }
 }
 
+[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/key-editor.ui")]
 private abstract class KeyEditorDialog : Dialog
 {
+    [GtkChild] protected Button button_apply;
+    [GtkChild] protected InfoBar no_schema_warning;
+    [GtkChild] protected PropertyRow schema_row;
+    [GtkChild] protected PropertyRow summary_row;
+    [GtkChild] protected PropertyRow description_row;
+    [GtkChild] protected PropertyRow type_row;
+    [GtkChild] protected PropertyRow default_row;
+    [GtkChild] protected PropertyRow custom_value_row;
+    [GtkChild] protected PropertyRow value_row;
+
     protected bool custom_value_is_valid { get; set; default = true; }
     protected KeyEditorChild key_editor_child;
 
@@ -266,13 +277,8 @@ private abstract class KeyEditorDialog : Dialog
     }
 }
 
-[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/key-editor-no-schema.ui")]
 private class KeyEditorNoSchema : KeyEditorDialog       // TODO add type information, or integrate type 
information in KeyEditorChilds; doesn't have a "Custom value" text
 {
-    [GtkChild] private Button button_apply;
-    [GtkChild] private PropertyRow type_row;
-    [GtkChild] private PropertyRow value_row;
-
     private DConfKey key;
 
     public KeyEditorNoSchema (DConfKey _key)
@@ -289,6 +295,13 @@ private class KeyEditorNoSchema : KeyEditorDialog       // TODO add type informa
         type_row.set_text (key_to_description ());
 
         notify ["custom-value-is-valid"].connect (() => { button_apply.set_sensitive 
(custom_value_is_valid); });
+
+        no_schema_warning.show ();
+        schema_row.destroy ();
+        summary_row.destroy ();
+        description_row.destroy ();
+        default_row.destroy ();
+        custom_value_row.destroy ();
     }
 
     protected override void on_response_apply ()
@@ -299,18 +312,8 @@ private class KeyEditorNoSchema : KeyEditorDialog       // TODO add type informa
     }
 }
 
-[GtkTemplate (ui = "/ca/desrt/dconf-editor/ui/key-editor.ui")]
 private class KeyEditor : KeyEditorDialog
 {
-    [GtkChild] private Button button_apply;
-    [GtkChild] private PropertyRow schema_row;
-    [GtkChild] private PropertyRow summary_row;
-    [GtkChild] private PropertyRow description_row;
-    [GtkChild] private PropertyRow type_row;
-    [GtkChild] private PropertyRow default_row;
-    [GtkChild] private PropertyRow custom_value_row;
-    [GtkChild] private PropertyRow value_row;
-
     private Switch custom_value_switch;
 
     protected GSettingsKey key;
@@ -334,6 +337,7 @@ private class KeyEditor : KeyEditorDialog
 
         // infos
 
+        no_schema_warning.destroy ();
         schema_row.set_text (key.schema_id);
         summary_row.set_text (key.summary);
         description_row.set_text (key.description);
diff --git a/editor/key-editor.ui b/editor/key-editor.ui
index 399364a..3aa7639 100644
--- a/editor/key-editor.ui
+++ b/editor/key-editor.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <template class="KeyEditor" parent="KeyEditorDialog">
+  <template class="KeyEditorDialog" parent="GtkDialog">
     <property name="visible">False</property>
     <property name="valign">center</property> <!-- TODO bug of GtkDialog, that adds space at the bottom -->
     <property name="modal">True</property>
@@ -30,6 +30,26 @@
       <object class="GtkBox">
         <property name="border-width">0</property>
         <child>
+          <object class="GtkInfoBar" id="no_schema_warning">
+            <property name="visible">False</property>
+            <property name="message-type">info</property>
+            <child internal-child="content_area">
+              <object class="GtkBox">
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="max-width-chars">40</property>
+                    <property name="use-markup">True</property>
+                    <property name="wrap">True</property>
+                    <property name="label" translatable="yes">&#60;b&#62;No schema available.&#60;/b&#62; 
Dconf Editor can’t find a schema associated with this key. The application that installed this key may have 
been removed, may have stop the use of this key, or may use a relocatable schema for defining its 
keys.</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
           <object class="GtkListBox">
             <property name="visible">True</property>
             <property name="selection-mode">none</property>
@@ -41,7 +61,7 @@
                 <property name="visible">True</property>
                 <property name="label" translatable="yes">Schema</property>
               </object>
-            </child>
+            </child><!-- TODO report bug; doesn't warn if </child><child> is removed -->
             <child>
               <object class="PropertyRow" id="summary_row">
                 <property name="visible">True</property>


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