[chronojump] adding/editing jump/run types avoids introducing quotations



commit d38edb80b82ea9b331317df2f79e1f0900540bda
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Jul 24 01:47:04 2017 +0200

    adding/editing jump/run types avoids introducing quotations

 src/gui/jumpType.cs |   30 ++++++++++++++++++++++++------
 src/gui/runType.cs  |   22 +++++++++++++++++++++-
 2 files changed, 45 insertions(+), 7 deletions(-)
---
diff --git a/src/gui/jumpType.cs b/src/gui/jumpType.cs
index 9153db6..4338e3e 100644
--- a/src/gui/jumpType.cs
+++ b/src/gui/jumpType.cs
@@ -59,6 +59,7 @@ public class JumpTypeAddWindow
        static JumpTypeAddWindow JumpTypeAddWindowBox;
 
        public bool InsertedSimple;
+       private bool descriptionChanging = false;
 
        JumpTypeAddWindow (Gtk.Window parent, bool simple) {
                Glade.XML gladeXML;
@@ -105,6 +106,24 @@ public class JumpTypeAddWindow
                //if simple don't show nothing
                label_main_options.Visible = ! simple;
                table_main_options.Visible = ! simple;
+
+               textview_description.Buffer.Changed += new EventHandler(descriptionChanged);
+               descriptionChanging = false;
+       }
+
+       private void descriptionChanged(object o,EventArgs args)
+       {
+               if(descriptionChanging)
+                       return;
+
+               descriptionChanging = true;
+
+               TextBuffer tb = o as TextBuffer;
+               if (o == null)
+                       return;
+
+               tb.Text = Util.MakeValidSQL(tb.Text);
+               descriptionChanging = false;
        }
 
        void on_button_cancel_clicked (object o, EventArgs args)
@@ -122,7 +141,6 @@ public class JumpTypeAddWindow
        void on_button_accept_clicked (object o, EventArgs args)
        {
                string name = Util.RemoveTildeAndColonAndDot(entry_name.Text);
-               name = Util.RemoveChar(name, '"');
 
                //check if this jump type exists, and check it's name is not AllJumpsName
                bool jumpTypeExists = Sqlite.Exists (false, Constants.JumpTypeTable, name);
@@ -225,15 +243,15 @@ public class JumpTypeAddWindow
                        spin_fixed_num.Sensitive = false;
                }
        }
-       
+
        void on_entries_required_changed (object o, EventArgs args)
        {
-               if(entry_name.Text.ToString().Length > 0) {
+               entry_name.Text = Util.MakeValidSQL(entry_name.Text);
+
+               if(entry_name.Text.ToString().Length > 0)
                        button_accept.Sensitive = true;
-               }
-               else {
+               else
                        button_accept.Sensitive = false;
-               }
        }
                
        public Button FakeButtonAccept 
diff --git a/src/gui/runType.cs b/src/gui/runType.cs
index f9c1f4d..4e0f9ed 100644
--- a/src/gui/runType.cs
+++ b/src/gui/runType.cs
@@ -81,6 +81,7 @@ public class RunTypeAddWindow
        static RunTypeAddWindow RunTypeAddWindowBox;
 
        public bool InsertedSimple;
+       private bool descriptionChanging = false;
 
        RunTypeAddWindow (Gtk.Window parent, bool simple) {
                Glade.XML gladeXML;
@@ -146,6 +147,24 @@ public class RunTypeAddWindow
        
                combo_distance_different_tracks.Active = 0;
                reset_hbox_distance_variable (2);
+
+               textview_description.Buffer.Changed += new EventHandler(descriptionChanged);
+               descriptionChanging = false;
+       }
+
+       private void descriptionChanged(object o,EventArgs args)
+       {
+               if(descriptionChanging)
+                       return;
+
+               descriptionChanging = true;
+
+               TextBuffer tb = o as TextBuffer;
+               if (o == null)
+                       return;
+
+               tb.Text = Util.MakeValidSQL(tb.Text);
+               descriptionChanging = false;
        }
                
        void on_button_cancel_clicked (object o, EventArgs args)
@@ -164,7 +183,6 @@ public class RunTypeAddWindow
        {
                //ConsoleB.Information(getEntriesString());
                string name = Util.RemoveTildeAndColonAndDot(entry_name.Text);
-               name = Util.RemoveChar(name, '"');
 
                //check if this run type exists, and check it's name is not AllRunsName
                bool runTypeExists = Sqlite.Exists (false, Constants.RunTypeTable, name);
@@ -385,6 +403,8 @@ public class RunTypeAddWindow
        
        void on_entries_required_changed (object o, EventArgs args)
        {
+               entry_name.Text = Util.MakeValidSQL(entry_name.Text);
+
                if(entry_name.Text.ToString().Length == 0) {
                        button_accept.Sensitive = false;
                        return;


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