[chronojump] RaceAnalyzer: open data folder on session menu



commit 1489a8a3cdfe60a04700d41137ca07ceb88b75d1
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Jun 11 17:05:20 2019 +0200

    RaceAnalyzer: open data folder on session menu

 glade/app1.glade      | 24 ++++++++++++++++++++++++
 src/gui/chronojump.cs |  1 +
 src/gui/runEncoder.cs | 16 ++++++++++++++++
 src/runEncoder.cs     | 15 +++++++++++++++
 4 files changed, 56 insertions(+)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index b74cd903..fc689ad4 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -207,6 +207,21 @@
                         </child>
                       </widget>
                     </child>
+                    <child>
+                      <widget class="GtkImageMenuItem" id="menuitem_race_analyzer_open_folder">
+                        <property name="label" translatable="yes">Race analyzer - Open data folder</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_stock">False</property>
+                        <signal name="activate" handler="on_menuitem_race_analyzer_open_folder_activate" 
swapped="no"/>
+                        <child internal-child="image">
+                          <widget class="GtkImage" id="image7">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-open</property>
+                          </widget>
+                        </child>
+                      </widget>
+                    </child>
                     <child>
                       <widget class="GtkSeparatorMenuItem" id="separador6">
                         <property name="visible">True</property>
@@ -1929,6 +1944,9 @@
                                                             <placeholder/>
                                                             </child>
                                                             <child>
+                                                            <placeholder/>
+                                                            </child>
+                                                            <child>
                                                             <widget class="GtkLabel" 
id="label_start_selector_jumps">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">False</property>
@@ -20984,6 +21002,9 @@ Concentric</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
@@ -29697,6 +29718,9 @@ then click this button.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="expand">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 39b5c80c..98ca1f23 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -3500,6 +3500,7 @@ public partial class ChronoJumpWindow
 
                menuitem_force_sensor_open_folder.Visible = (m == Constants.Menuitem_modes.FORCESENSOR);
                menuitem_force_sensor_check_version.Visible = (m == Constants.Menuitem_modes.FORCESENSOR);
+               menuitem_race_analyzer_open_folder.Visible = (m == Constants.Menuitem_modes.RUNSENCODER);
        }
 
 
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index be69dfbf..a2afec75 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -32,6 +32,7 @@ using Mono.Unix;
 
 public partial class ChronoJumpWindow 
 {
+       [Widget] Gtk.MenuItem menuitem_race_analyzer_open_folder;
        [Widget] Gtk.SpinButton race_analyzer_spinbutton_distance;
        [Widget] Gtk.SpinButton race_analyzer_spinbutton_temperature;
        [Widget] Gtk.Image image_race_encoder_graph;
@@ -602,4 +603,19 @@ LogB.Information(" fc R ");
                                image_race_encoder_graph);
        }
 
+       private void on_menuitem_race_analyzer_open_folder_activate (object o, EventArgs args)
+       {
+               if(currentSession == null || currentSession.UniqueID == -1)
+               {
+                       System.Diagnostics.Process.Start(RunEncoderGraph.GetDataDir(-1));
+                       return;
+               }
+
+               string dataDir = RunEncoderGraph.GetDataDir(currentSession.UniqueID);
+               if(dataDir != "")
+                       System.Diagnostics.Process.Start(dataDir);
+               else
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.DirectoryCannotOpen);
+       }
+
 }
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 4b7e3b52..ba0105d3 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -71,4 +71,19 @@ public class RunEncoderGraph
                writer.Close();
                ((IDisposable)writer).Dispose();
        }
+
+       public static string GetDataDir(int sessionID)
+       {
+               System.IO.DirectoryInfo folderSession =
+                       new System.IO.DirectoryInfo(Util.GetRaceAnalyzerSessionDir(sessionID));
+               System.IO.DirectoryInfo folderGeneric =
+                       new System.IO.DirectoryInfo(Util.GetRaceAnalyzerDir());
+
+               if(folderSession.Exists)
+                       return Util.GetRaceAnalyzerSessionDir(sessionID);
+               else if(folderGeneric.Exists)
+                       return Util.GetRaceAnalyzerDir();
+               else
+                       return "";
+       }
 }


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