[chronojump] Log sent adds user comments
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Log sent adds user comments
- Date: Thu, 29 Jan 2015 15:48:49 +0000 (UTC)
commit 03055d3008b9e5979fd4cadb5622ce375daea5d5
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Jan 29 16:48:13 2015 +0100
Log sent adds user comments
glade/chronojump.glade | 219 ++++++++++++++++++++++++++++++++++++++++++++----
src/gui/error.cs | 6 +-
src/json.cs | 6 +-
src/util.cs | 19 ++++
4 files changed, 230 insertions(+), 20 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index cd98bfd..27c1868 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -6410,6 +6410,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -7194,6 +7200,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -8230,6 +8242,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -8907,6 +8925,12 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -19115,6 +19139,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -19700,6 +19730,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -20777,6 +20813,12 @@ by you</property>
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkButton" id="button_video_url">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -20911,6 +20953,12 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -24714,14 +24762,13 @@ comments</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
- <property name="label_yalign">0.69999998807907104</property>
<property name="shadow_type">out</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">8</property>
- <property name="spacing">6</property>
+ <property name="spacing">10</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
@@ -24731,6 +24778,7 @@ comments</property>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="xalign">0</property>
<property name="label" translatable="yes">Your email</property>
</widget>
<packing>
@@ -24741,7 +24789,7 @@ comments</property>
</child>
<child>
<widget class="GtkEntry" id="entry_send_log">
- <property name="width_request">175</property>
+ <property name="width_request">200</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
@@ -24756,6 +24804,63 @@ comments</property>
<property name="position">1</property>
</packing>
</child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Add comments</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow3">
+ <property name="height_request">55</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <widget class="GtkTextView" id="textview_comments">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">10</property>
<child>
<widget class="GtkButton" id="button_send_log">
<property name="label">Send error log</property>
@@ -24767,10 +24872,22 @@ comments</property>
</widget>
<packing>
<property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
@@ -24802,25 +24919,25 @@ comments</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_send_log_message">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label_send_log_message">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
@@ -30249,6 +30366,42 @@ options</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -32214,6 +32367,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -32837,6 +32996,12 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -35426,6 +35591,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -35675,6 +35846,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -35939,6 +36116,12 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/gui/error.cs b/src/gui/error.cs
index acdfe0e..607e75f 100644
--- a/src/gui/error.cs
+++ b/src/gui/error.cs
@@ -39,6 +39,7 @@ public class ErrorWindow
[Widget] Gtk.Image image_send_log_no;
[Widget] Gtk.Image image_send_log_yes;
[Widget] Gtk.Entry entry_send_log;
+ [Widget] Gtk.TextView textview_comments;
[Widget] Gtk.Button button_send_log;
[Widget] Gtk.Label label_send_log_message;
@@ -104,10 +105,13 @@ public class ErrorWindow
//1st save email on sqlite
if(email != null && email != "" && email != "0" && email != emailStored)
SqlitePreferences.Update("email", email, false);
+
+ //2nd if there are comments, add them at the beginning of the file
+ string comments = textview_comments.Buffer.Text;
//2nd send Json
Json js = new Json();
- bool success = js.PostCrashLog(email);
+ bool success = js.PostCrashLog(email, comments);
if(success) {
button_send_log.Label = Catalog.GetString("Thanks");
diff --git a/src/json.cs b/src/json.cs
index 3636a0b..7a35613 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -35,7 +35,7 @@ public class Json
ResultMessage = "";
}
- public bool PostCrashLog(string email)
+ public bool PostCrashLog(string email, string comments)
{
string serverUrl = "http://api.chronojump.org:8080";
string filePath = UtilAll.GetLogFileOld();
@@ -45,6 +45,10 @@ public class Json
return false;
}
+ if(comments != null && comments != "")
+ Util.InsertTextBeginningOfFile(
+ "----------\nUser comments:\n" + comments + "\n----------\n",
filePath);
+
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create (serverUrl + "/backtrace/" + UtilAll.ReadVersion() +
"-" + email);
diff --git a/src/util.cs b/src/util.cs
index a7fae04..5df0ec8 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1624,4 +1624,23 @@ public class Util
return false;
}
}
+
+ //http://stackoverflow.com/a/2401873
+ public static void InsertTextBeginningOfFile(string textToInsert, string filename)
+ {
+ try {
+ string tempfile = Path.GetTempFileName();
+ using (var writer = new StreamWriter(tempfile))
+ using (var reader = new StreamReader(filename))
+ {
+ writer.WriteLine(textToInsert);
+ while (! reader.EndOfStream)
+ writer.WriteLine(reader.ReadLine());
+ }
+ File.Copy(tempfile, filename, true);
+ LogB.Information("Insert text at the beginning of File successful");
+ } catch {
+ LogB.Error("Couldn't Insert text at the beginning of File");
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]