[gitg] Bidirectionally bind amend and sign-off properties in commit dialog



commit 3d58f1929fe7428f6f2dba6117489eba599b1877
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Jul 6 11:59:48 2013 +0200

    Bidirectionally bind amend and sign-off properties in commit dialog

 data/org.gnome.gitg.gschema.xml.in.in |    3 +++
 gitg/commit/gitg-commit-dialog.vala   |   30 ++++++++++++++++++++++--------
 2 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/data/org.gnome.gitg.gschema.xml.in.in b/data/org.gnome.gitg.gschema.xml.in.in
index f28fc76..db26536 100644
--- a/data/org.gnome.gitg.gschema.xml.in.in
+++ b/data/org.gnome.gitg.gschema.xml.in.in
@@ -147,5 +147,8 @@
     <key name="paned-sidebar-position" type="i">
       <default>200</default>
     </key>
+    <key name="sign-off" type="b">
+      <default>false</default>
+    </key>
   </schema>
 </schemalist>
diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala
index 8727bb5..0bee0df 100644
--- a/gitg/commit/gitg-commit-dialog.vala
+++ b/gitg/commit/gitg-commit-dialog.vala
@@ -56,15 +56,11 @@ class Dialog : Gtk.Dialog
                }
        }
 
-       public bool amend
-       {
-               get { return d_check_button_amend.active; }
-       }
+       [Notify]
+       public bool amend { get; set; }
 
-       public bool sign_off
-       {
-               get { return d_check_button_sign_off.active; }
-       }
+       [Notify]
+       public bool sign_off { get; set; }
 
        construct
        {
@@ -81,6 +77,24 @@ class Dialog : Gtk.Dialog
                d_source_view_message.buffer.changed.connect(() => {
                        d_button_ok.sensitive = message != "";
                });
+
+               d_check_button_amend.bind_property("active",
+                                                  this, "amend",
+                                                  BindingFlags.BIDIRECTIONAL |
+                                                  BindingFlags.SYNC_CREATE);
+
+               d_check_button_sign_off.bind_property("active",
+                                                     this, "sign-off",
+                                                     BindingFlags.BIDIRECTIONAL |
+                                                     BindingFlags.SYNC_CREATE);
+
+               var commit_settings = new Settings("org.gnome.gitg.state.commit");
+
+               commit_settings.bind("sign-off",
+                                    this,
+                                    "sign-off",
+                                    SettingsBindFlags.GET |
+                                    SettingsBindFlags.SET);
        }
 
        private void update_font_settings()



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