[chronojump] several improvements to copy database
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] several improvements to copy database
- Date: Wed, 17 Jul 2019 14:53:44 +0000 (UTC)
commit 0647706006d015e53eb390e393a622e000095821
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jul 17 16:52:13 2019 +0200
several improvements to copy database
glade/preferences_win.glade | 67 ++++++++++++++++++++++++++++++++-------------
src/gui/preferences.cs | 27 ++++++++++++------
src/util.cs | 32 +++++++++++++++++-----
3 files changed, 91 insertions(+), 35 deletions(-)
---
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index 7816612a..da806d23 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -256,52 +256,81 @@
</packing>
</child>
<child>
- <widget class="GtkVBox" id="vbox18">
+ <widget class="GtkLabel" id="label_backup">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">8</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_backup_doing">
+ <property name="can_focus">False</property>
<child>
- <widget class="GtkHBox" id="hbox_backup_doing">
+ <widget class="GtkTable" id="table2">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">8</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">8</property>
+ <property name="row_spacing">12</property>
<child>
- <widget class="GtkLabel" id="label19">
+ <widget class="GtkProgressBar" id="pulsebarBackupDirs">
+ <property name="width_request">300</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Please, wait.</property>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options"/>
</packing>
</child>
<child>
- <widget class="GtkProgressBar" id="pulsebarBackupDirs">
+ <widget class="GtkProgressBar" id="pulsebarBackupSecondDirs">
+ <property name="width_request">300</property>
<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>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"/>
</packing>
</child>
<child>
- <widget class="GtkProgressBar" id="pulsebarBackupActivity">
+ <widget class="GtkLabel" id="label99">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Directory</property>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
+ <property name="x_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label101">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Subdirectory</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options"/>
</packing>
</child>
</widget>
<packing>
<property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -309,7 +338,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 667e3f87..a428508b 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -59,9 +59,10 @@ public class PreferencesWindow
[Widget] Gtk.CheckButton check_backup_multimedia_and_encoder;
[Widget] Gtk.Button button_db_backup;
- [Widget] Gtk.Box hbox_backup_doing;
+ [Widget] Gtk.HBox hbox_backup_doing;
+ [Widget] Gtk.Label label_backup;
[Widget] Gtk.ProgressBar pulsebarBackupDirs;
- [Widget] Gtk.ProgressBar pulsebarBackupActivity;
+ [Widget] Gtk.ProgressBar pulsebarBackupSecondDirs;
//jumps tab
@@ -1337,7 +1338,7 @@ public class PreferencesWindow
File.Copy(fileDB, fileCopy);
string myString = string.Format(Catalog.GetString("Copied to
{0}"), fileCopy);
- new DialogMessage(Constants.MessageTypes.INFO, myString);
+ label_backup.Text = myString;
}
}
}
@@ -1413,7 +1414,7 @@ public class PreferencesWindow
fc.Hide ();
string myString = string.Format(Catalog.GetString("Copied to {0}"), fileCopy);
- new DialogMessage(Constants.MessageTypes.INFO, myString);
+ label_backup.Text = myString;
}
} catch {
string myString = string.Format(Catalog.GetString("Cannot copy to {0} "), fileCopy);
@@ -1434,7 +1435,7 @@ public class PreferencesWindow
sw.Start();
//Util.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new
DirectoryInfo(fileCopy), out backupMainDirsDone);
- uc.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new
DirectoryInfo(fileCopy), true);
+ uc.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new
DirectoryInfo(fileCopy), 0);
sw.Stop();
copyRecursiveElapsedMs = sw.ElapsedMilliseconds;
@@ -1586,8 +1587,12 @@ public class PreferencesWindow
return false;
}
- pulsebarBackupDirs.Fraction = Util.DivideSafeFraction(uc.BackupMainDirsDone, 6); //6 for:
database, encoder, forceSensor, logs, multimedia, raceAnalyzer
- pulsebarBackupActivity.Pulse();
+ pulsebarBackupDirs.Fraction = Util.DivideSafeFraction(uc.BackupMainDirsCount, 6); //6 for:
database, encoder, forceSensor, logs, multimedia, raceAnalyzer
+ pulsebarBackupDirs.Text = uc.LastMainDir;
+ //pulsebarBackupActivity.Pulse();
+ pulsebarBackupSecondDirs.Fraction = Util.DivideSafeFraction(uc.BackupSecondDirsCount,
uc.BackupSecondDirsLength);
+ pulsebarBackupSecondDirs.Text = uc.LastSecondDir;
+
Thread.Sleep (50);
//LogB.Debug(thread.ThreadState.ToString());
return true;
@@ -1595,15 +1600,19 @@ public class PreferencesWindow
private void endPulse() {
pulsebarBackupDirs.Fraction = 1;
- pulsebarBackupActivity.Fraction = 1;
+ pulsebarBackupSecondDirs.Fraction = 1;
+ //pulsebarBackupActivity.Fraction = 1;
backup_doing_sensitive_start_end(false);
fc.Hide ();
string myString = string.Format(Catalog.GetString("Copied to {0} in {1} ms"), fileCopy,
copyRecursiveElapsedMs);
- new DialogMessage(Constants.MessageTypes.INFO, myString);
+ label_backup.Text = myString;
}
private void backup_doing_sensitive_start_end(bool start)
{
+ if(start)
+ label_backup.Text = Catalog.GetString("Please, wait.");
+
hbox_backup_doing.Visible = start;
button_db_backup.Sensitive = ! start;
diff --git a/src/util.cs b/src/util.cs
index e476c945..2ed69fa8 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -2213,25 +2213,43 @@ public class Util
public class UtilCopy
{
- public int BackupMainDirsDone;
+ public int BackupMainDirsCount;
+ public int BackupSecondDirsCount;
+ public int BackupSecondDirsLength;
+ public string LastMainDir;
+ public string LastSecondDir;
//to go faster on CopyFilesRecursively
static string backupDir = Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "backup";
public UtilCopy()
{
- BackupMainDirsDone = 0;
+ BackupMainDirsCount = 0;
+ BackupSecondDirsCount = 0;
+ BackupSecondDirsLength = 0;
+ LastMainDir = "";
+ LastSecondDir = "";
}
//http://stackoverflow.com/a/58779
- public void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target, bool mainDir)
+ public void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target, uint level)
{
- foreach (DirectoryInfo dir in source.GetDirectories())
+ DirectoryInfo [] diArray = source.GetDirectories();
+ foreach (DirectoryInfo dir in diArray)
if(dir.ToString() != backupDir) //do not copy backup files
{
- CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name), false);
- if(mainDir)
- BackupMainDirsDone ++;
+ CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name), level ++);
+
+ if(level == 0)
+ {
+ BackupMainDirsCount ++;
+ LastMainDir = Util.GetLastPartOfPath (dir.ToString());
+ BackupSecondDirsCount = 0;
+ } else if(level == 1) {
+ BackupSecondDirsLength = diArray.Length;
+ BackupSecondDirsCount ++;
+ LastSecondDir = Util.GetLastPartOfPath (dir.ToString());
+ }
}
foreach (FileInfo file in source.GetFiles())
file.CopyTo(Path.Combine(target.FullName, file.Name));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]