[chronojump] moved database backup from preferences win to main gui
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] moved database backup from preferences win to main gui
- Date: Thu, 21 May 2020 12:43:37 +0000 (UTC)
commit e54b7157a07da4a2b10f014665aca1f631b98ed4
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu May 21 14:42:12 2020 +0200
moved database backup from preferences win to main gui
glade/app1.glade | 245 ++++++++++++++++++--------
glade/preferences_win.glade | 297 ++------------------------------
po/POTFILES.in | 1 +
src/gui/app1/chronojump.cs | 4 +-
src/gui/app1/session/backup.cs | 278 +++++++++++++++++++++++++++++-
src/gui/app1/session/loadAndImport.cs | 4 +-
src/gui/app1/session/main.cs | 18 +-
src/gui/chronojumpImporter.cs | 6 +-
src/gui/preferences.cs | 313 +++-------------------------------
src/utilDate.cs | 4 +
10 files changed, 514 insertions(+), 656 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 775b6cb5..a5de7f2e 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -24343,6 +24343,15 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -27183,6 +27192,18 @@ Concentric</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
+ <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Tests
will be filmed</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox"
id="hbox_video_encoder_capturing">
<property name="can_focus">False</property>
<property name="spacing">4</property>
@@ -27219,18 +27240,6 @@ Concentric</property>
</packing>
</child>
<child>
- <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Tests
will be filmed</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
<widget class="GtkHBox"
id="hbox_video_encoder_no_capturing">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -35103,6 +35112,15 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -36015,14 +36033,14 @@ then click this button.</property>
<property name="can_focus">False</property>
<property name="spacing">20</property>
<child>
- <widget class="GtkButton" id="button_db_backup">
+ <widget class="GtkButton"
id="button_db_backup_pre">
<property name="label" translatable="yes">Backup
all data</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property
name="receives_default">False</property>
<property name="tooltip" translatable="yes">Make
a copy of all the data</property>
<property name="use_underline">True</property>
- <signal name="clicked"
handler="on_button_db_backup_clicked" swapped="no"/>
+ <signal name="clicked"
handler="on_button_db_backup_pre_clicked" swapped="no"/>
</widget>
<packing>
<property name="expand">True</property>
@@ -38960,25 +38978,11 @@ then click this button.</property>
<widget class="GtkVBox" id="vbox221">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">12</property>
+ <property name="spacing">10</property>
<child>
- <widget class="GtkHBox" id="hbox366">
+ <widget class="GtkVButtonBox" id="vbuttonbox5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">30</property>
- <child>
- <widget class="GtkLabel" id="label531">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Select
destination</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
<child>
<widget class="GtkButton"
id="app1s_button_backup_select">
<property name="visible">True</property>
@@ -39006,7 +39010,7 @@ then click this button.</property>
<widget class="GtkLabel"
id="app1s_label_button_backup_select">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label"
translatable="yes">Select</property>
+ <property name="label" translatable="yes">Select
destination</property>
</widget>
<packing>
<property name="expand">True</property>
@@ -39018,9 +39022,9 @@ then click this button.</property>
</child>
</widget>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</widget>
@@ -39034,11 +39038,12 @@ then click this button.</property>
<widget class="GtkLabel"
id="app1s_label_backup_destination">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="ellipsize">middle</property>
+ <property name="wrap">True</property>
+ <property name="wrap_mode">word-char</property>
</widget>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
@@ -39083,7 +39088,136 @@ then click this button.</property>
</packing>
</child>
<child>
- <placeholder/>
+ <widget class="GtkVBox" id="vbox223">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">20</property>
+ <child>
+ <widget class="GtkHBox" id="hbox425">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkHBox" id="hbox426">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">20</property>
+ <child>
+ <widget class="GtkLabel"
id="app1s_label_backup_progress">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkProgressBar"
id="app1s_pulsebarBackupActivity">
+ <property name="width_request">50</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">True</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">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox"
id="app1s_hbox_backup_doing">
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkTable" id="table10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</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="GtkProgressBar"
id="app1s_pulsebarBackupDirs">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkProgressBar"
id="app1s_pulsebarBackupSecondDirs">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <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="GtkLabel" id="label540">
+ <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="x_options"/>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label541">
+ <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">False</property>
+ <property name="position">0</property>
+ </packing>
+ </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">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
</child>
</widget>
</child>
@@ -39175,13 +39309,13 @@ then click this button.</property>
<widget class="GtkHButtonBox" id="hbuttonbox7">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="layout_style">spread</property>
+ <property name="layout_style">center</property>
<child>
<widget class="GtkVBox" id="vbox222">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <widget class="GtkButton"
id="app1s_button_backup_cancel">
+ <widget class="GtkButton"
id="app1s_button_backup_cancel_close">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
@@ -39189,11 +39323,11 @@ then click this button.</property>
<signal name="clicked"
handler="on_app1s_button_backup_cancel_or_close_clicked" swapped="no"/>
<accelerator key="Escape" signal="clicked"/>
<child>
- <widget class="GtkEventBox"
id="app1s_eventbox_button_backup_cancel">
+ <widget class="GtkEventBox"
id="app1s_eventbox_button_backup_cancel_close">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <widget class="GtkLabel" id="label538">
+ <widget class="GtkLabel"
id="app1s_label_backup_cancel_close">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label"
translatable="yes">Cancel</property>
@@ -39215,39 +39349,10 @@ then click this button.</property>
<property name="position">0</property>
</packing>
</child>
- <child>
- <widget class="GtkButton"
id="app1s_button_backup_close">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property
name="receives_default">False</property>
- <signal name="clicked"
handler="on_app1s_button_backup_cancel_or_close_clicked" swapped="no"/>
- <accelerator key="Escape" signal="clicked"/>
- <child>
- <widget class="GtkEventBox"
id="app1s_eventbox_button_backup_close">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <widget class="GtkLabel" id="label539">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label"
translatable="yes">Close</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
diff --git a/glade/preferences_win.glade b/glade/preferences_win.glade
index 0d4fa7cd..dd81884f 100644
--- a/glade/preferences_win.glade
+++ b/glade/preferences_win.glade
@@ -723,267 +723,6 @@
<property name="type">tab</property>
</packing>
</child>
- <child>
- <widget class="GtkVBox" id="vbox27">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">16</property>
- <property name="spacing">25</property>
- <child>
- <widget class="GtkFrame" id="frame3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">in</property>
- <child>
- <widget class="GtkVBox" id="vbox9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">8</property>
- <property name="spacing">20</property>
- <child>
- <widget class="GtkVButtonBox" id="vbuttonbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">20</property>
- <child>
- <widget class="GtkButton" id="button_db_backup">
- <property name="label" translatable="yes">Backup all data</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="tooltip" translatable="yes">Make a copy of all the
data</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_button_db_backup_clicked" swapped="no"/>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">False</property>
- <property name="position">0</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="GtkHBox" id="hbox49">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <widget class="GtkHBox" id="hbox50">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">20</property>
- <child>
- <widget class="GtkLabel" id="label_backup">
- <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">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkProgressBar" id="pulsebarBackupActivity">
- <property name="width_request">50</property>
- <property name="can_focus">False</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">True</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">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox_backup_doing">
- <property name="can_focus">False</property>
- <child>
- <widget class="GtkTable" id="table2">
- <property name="visible">True</property>
- <property name="can_focus">False</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="GtkProgressBar" id="pulsebarBackupDirs">
- <property name="width_request">300</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options"/>
- </packing>
- </child>
- <child>
- <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="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="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="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">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkLabel" id="label18">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Backup data</property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkFrame" id="frame7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">in</property>
- <child>
- <widget class="GtkAlignment" id="alignment7">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="left_padding">12</property>
- <child>
- <widget class="GtkVButtonBox" id="vbuttonbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">8</property>
- <property name="spacing">20</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <widget class="GtkButton" id="button_db_restore">
- <property name="label" translatable="yes">Restore data</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="on_button_db_restore_clicked" swapped="no"/>
- </widget>
- <packing>
- <property name="expand">True</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkLabel" id="label36">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Others</property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label69">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Database</property>
- </widget>
- <packing>
- <property name="position">1</property>
- <property name="tab_fill">False</property>
- <property name="type">tab</property>
- </packing>
- </child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
@@ -1619,7 +1358,7 @@
</child>
</widget>
<packing>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -1630,7 +1369,7 @@
<property name="label" translatable="yes">Jumps</property>
</widget>
<packing>
- <property name="position">2</property>
+ <property name="position">1</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -2157,7 +1896,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">3</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -2169,7 +1908,7 @@ It starts before and arrives there with some speed.</property>
<property name="label" translatable="yes">Races</property>
</widget>
<packing>
- <property name="position">3</property>
+ <property name="position">2</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -3334,7 +3073,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">4</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -3380,7 +3119,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">4</property>
+ <property name="position">3</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -3804,7 +3543,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">5</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -3850,7 +3589,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">5</property>
+ <property name="position">4</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -4455,7 +4194,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">6</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
@@ -4465,7 +4204,7 @@ It starts before and arrives there with some speed.</property>
<property name="label" translatable="yes">Force sensor</property>
</widget>
<packing>
- <property name="position">6</property>
+ <property name="position">5</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -4624,7 +4363,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">7</property>
+ <property name="position">6</property>
</packing>
</child>
<child>
@@ -4634,7 +4373,7 @@ It starts before and arrives there with some speed.</property>
<property name="label" translatable="yes">Race analyzer</property>
</widget>
<packing>
- <property name="position">7</property>
+ <property name="position">6</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -5835,7 +5574,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">8</property>
+ <property name="position">7</property>
</packing>
</child>
<child>
@@ -5846,7 +5585,7 @@ It starts before and arrives there with some speed.</property>
<property name="label" translatable="yes">Multimedia</property>
</widget>
<packing>
- <property name="position">8</property>
+ <property name="position">7</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -6228,7 +5967,7 @@ It starts before and arrives there with some speed.</property>
</child>
</widget>
<packing>
- <property name="position">9</property>
+ <property name="position">8</property>
</packing>
</child>
<child>
@@ -6239,7 +5978,7 @@ It starts before and arrives there with some speed.</property>
<property name="label" translatable="yes">Language</property>
</widget>
<packing>
- <property name="position">9</property>
+ <property name="position">8</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
@@ -6707,7 +6446,7 @@ version:</property>
</child>
</widget>
<packing>
- <property name="position">10</property>
+ <property name="position">9</property>
</packing>
</child>
<child>
@@ -6718,7 +6457,7 @@ version:</property>
<property name="label" translatable="yes">Advanced</property>
</widget>
<packing>
- <property name="position">10</property>
+ <property name="position">9</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b847b30b..98afbc7c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -73,6 +73,7 @@ src/gui/app1/run.cs
src/gui/app1/runEncoder.cs
src/gui/app1/runEncoderAnalyze.cs
src/gui/app1/session/addEdit.cs
+src/gui/app1/session/backup.cs
src/gui/app1/session/loadAndImport.cs
src/gui/app1/session/main.cs
src/gui/app1/shortcuts.cs
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index 81b31613..64d49713 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -2642,7 +2642,7 @@ public partial class ChronoJumpWindow
else
preferencesWin = PreferencesWindow.Show(preferences, current_menuitem_mode,
configChronojump.Compujump, progVersion);
- preferencesWin.FakeButtonImported.Clicked += new
EventHandler(on_preferences_import_configuration);
+ preferencesWin.FakeButtonConfigurationImported.Clicked += new
EventHandler(on_preferences_import_configuration);
preferencesWin.FakeButtonDebugModeStart.Clicked += new
EventHandler(on_preferences_debug_mode_start);
preferencesWin.Button_accept.Clicked += new EventHandler(on_preferences_accepted);
}
@@ -2650,7 +2650,7 @@ public partial class ChronoJumpWindow
private void on_preferences_import_configuration (object o, EventArgs args)
{
/*
- preferencesWin.FakeButtonImported.Clicked -= new
EventHandler(on_preferences_import_configuration);
+ preferencesWin.FakeButtonConfigurationImported.Clicked -= new
EventHandler(on_preferences_import_configuration);
configInit();
LogB.Information("Initialized configuration");
diff --git a/src/gui/app1/session/backup.cs b/src/gui/app1/session/backup.cs
index 2ab64c6d..7815c731 100644
--- a/src/gui/app1/session/backup.cs
+++ b/src/gui/app1/session/backup.cs
@@ -19,32 +19,294 @@
*/
using System;
+using System.IO;
using Gtk;
-//using Glade;
-//using GLib; //for Value
-//using System.Text; //StringBuilder
-//using System.Collections; //ArrayList
-//using Mono.Unix;
+using System.Diagnostics; //Stopwatch
+using System.Threading;
+using Mono.Unix;
public partial class ChronoJumpWindow
{
- private void on_button_db_backup_clicked (object o, EventArgs args)
+ string app1s_fileDB;
+ string app1s_fileCopy;
+ Gtk.FileChooserDialog app1s_fc;
+ static UtilCopy app1s_uc;
+ private Thread app1s_threadBackup; //TODO: ensure this ended on quit program
+
+ private void on_button_db_backup_pre_clicked (object o, EventArgs args)
{
+ if(! app1s_getDatabaseFile())
+ {
+ new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error. Cannot
find database."));
+ return;
+ }
+
app1s_label_backup_destination.Text = "";
+ app1s_label_backup_progress.Text = "";
+ app1s_button_backup_select.Sensitive = true;
app1s_button_backup_start.Sensitive = false;
- app1s_button_backup_cancel.Visible = true;
- app1s_button_backup_close.Visible = false;
+ app1s_button_backup_cancel_close.Sensitive = true;
+ app1s_label_backup_cancel_close.Text = Catalog.GetString("Cancel");
app1s_notebook.CurrentPage = app1s_PAGE_BACKUP;
}
+ private bool app1s_getDatabaseFile ()
+ {
+ string databaseURL = Util.GetDatabaseDir() +
+ System.IO.Path.DirectorySeparatorChar + "chronojump.db";
+ string databaseTempURL = Util.GetDatabaseTempDir() +
+ System.IO.Path.DirectorySeparatorChar + "chronojump.db";
+
+ System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL);
+ System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL);
+ app1s_fileDB = "";
+
+ long length1 = 0;
+ if(file1.Exists)
+ length1 = file1.Length;
+ long length2 = 0;
+ if(file2.Exists)
+ length2 = file2.Length;
+
+ if(length1 == 0 && length2 == 0)
+ return false;
+ else if(length1 > length2)
+ app1s_fileDB = databaseURL;
+ else
+ app1s_fileDB = databaseTempURL;
+
+ return true;
+ }
+
private void on_app1s_button_backup_select_clicked (object o, EventArgs args)
{
+ app1s_fc = new Gtk.FileChooserDialog(Catalog.GetString("Copy database to:"),
+ app1,
+ FileChooserAction.SelectFolder,
+ Catalog.GetString("Cancel"),ResponseType.Cancel,
+ Catalog.GetString("Copy"),ResponseType.Accept
+ );
+
+ if (app1s_fc.Run() == (int)ResponseType.Accept)
+ {
+ //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the
db file
+ //if(check_backup_multimedia_and_encoder.Active)
+ app1s_fileCopy = app1s_fc.Filename + Path.DirectorySeparatorChar +
"chronojump_" + UtilDate.ToFile();
+ //else
+ // app1s_fileCopy = app1s_fc.Filename + Path.DirectorySeparatorChar +
"chronojump_copy.db";
+
+ app1s_label_backup_destination.Text = app1s_fileCopy;
+
+ app1s_button_backup_start.Sensitive = true;
+ }
+
+ app1s_fc.Hide ();
+
+ //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
+ app1s_fc.Destroy();
}
private void on_app1s_button_backup_start_clicked (object o, EventArgs args)
{
+ try {
+ bool exists = false;
+ //if(check_backup_multimedia_and_encoder.Active) {
+ if(Directory.Exists(app1s_fileCopy)) {
+ LogB.Information(string.Format("Directory {0} exists, created at {1}",
+ app1s_fileCopy,
Directory.GetCreationTime(app1s_fileCopy)));
+ exists = true;
+ }
+ /*} else {
+ if (File.Exists(app1s_fileCopy)) {
+ LogB.Information(string.Format("File {0} exists with attributes {1}, created at
{2}",
+ app1s_fileCopy, File.GetAttributes(app1s_fileCopy),
File.GetCreationTime(app1s_fileCopy)));
+ exists = true;
+ }
+ }
+ */
+
+ if(exists) {
+ LogB.Information("Overwrite...");
+ ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are you sure
you want to overwrite: "), "", app1s_fileCopy);
+ confirmWin.Button_accept.Clicked += new
EventHandler(app1s_backup_on_overwrite_file_accepted);
+ } else {
+ //if multimedia_and_encoder, then copy the folder. If not checked, then copy
only the db file
+ //if(check_backup_multimedia_and_encoder.Active) {
+ app1s_uc = new UtilCopy();
+ app1s_threadBackup = new Thread(new ThreadStart(app1s_copyRecursive));
+ GLib.Idle.Add (new GLib.IdleHandler (app1s_BackupPulseGTK));
+
+ app1s_backup_doing_sensitive_start_end(true);
+
+ LogB.ThreadStart();
+ app1s_threadBackup.Start();
+ /*} else {
+ File.Copy(app1s_fileDB, app1s_fileCopy);
+
+ label_backup.Text = string.Format(Catalog.GetString("Copied to {0}"),
app1s_fileCopy);
+ }
+ */
+ }
+ }
+ catch {
+ string myString = string.Format(Catalog.GetString("Cannot copy to {0} "),
app1s_fileCopy);
+ new DialogMessage(Constants.MessageTypes.WARNING, myString);
+ }
+ }
+
+ private bool app1s_BackupPulseGTK ()
+ {
+ if ( ! app1s_threadBackup.IsAlive ) {
+ LogB.ThreadEnding();
+ app1s_BackupPulseEnd();
+
+ LogB.ThreadEnded();
+ return false;
+ }
+
+ app1s_pulsebarBackupActivity.Pulse();
+ app1s_pulsebarBackupDirs.Fraction = UtilAll.DivideSafeFraction(app1s_uc.BackupMainDirsCount,
6);
+ //6 for: database, encoder, forceSensor, logs, multimedia, raceAnalyzer
+
+ app1s_pulsebarBackupDirs.Text = app1s_uc.LastMainDir;
+ app1s_pulsebarBackupSecondDirs.Fraction =
+ UtilAll.DivideSafeFraction(app1s_uc.BackupSecondDirsCount,
app1s_uc.BackupSecondDirsLength);
+ app1s_pulsebarBackupSecondDirs.Text = app1s_uc.LastSecondDir;
+
+ Thread.Sleep (30);
+ //LogB.Debug(app1s_threadBackup.ThreadState.ToString());
+ return true;
+ }
+
+ private void app1s_BackupPulseEnd()
+ {
+ app1s_pulsebarBackupActivity.Fraction = 1;
+ app1s_pulsebarBackupDirs.Fraction = 1;
+ app1s_pulsebarBackupSecondDirs.Fraction = 1;
+ app1s_backup_doing_sensitive_start_end(false);
+ app1s_fc.Hide ();
+ app1s_label_backup_progress.Text =
+ string.Format(Catalog.GetString("Copied in {0} ms"),
+ app1s_copyRecursiveElapsedMs);
+ }
+
+ private void app1s_backup_doing_sensitive_start_end(bool start)
+ {
+ if(start)
+ app1s_label_backup_progress.Text = Catalog.GetString("Please, wait.");
+
+ app1s_pulsebarBackupActivity.Visible = start;
+ app1s_hbox_backup_doing.Visible = start;
+
+ app1s_button_backup_select.Sensitive = ! start;
+ app1s_button_backup_start.Sensitive = false;
+
+ if(start) {
+ app1s_button_backup_cancel_close.Sensitive = false; //or make cancel sensitive while
process?
+ } else {
+ app1s_button_backup_cancel_close.Sensitive = true;
+ app1s_label_backup_cancel_close.Text = Catalog.GetString("Close");
+ }
+ }
+
+ private void app1s_backup_on_overwrite_file_accepted(object o, EventArgs args)
+ {
+ try {
+ //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the
db file
+ //if(check_backup_multimedia_and_encoder.Active) {
+ Directory.Delete(app1s_fileCopy, true);
+ app1s_uc = new UtilCopy();
+ app1s_threadBackup = new Thread(new ThreadStart(app1s_copyRecursive));
+ GLib.Idle.Add (new GLib.IdleHandler (app1s_BackupPulseGTK));
+
+ app1s_backup_doing_sensitive_start_end(true);
+
+ LogB.ThreadStart();
+ app1s_threadBackup.Start();
+ /* } else {
+ File.Delete(app1s_fileCopy);
+ File.Copy(app1s_fileDB, app1s_fileCopy);
+
+ app1s_fc.Hide ();
+ app1s_label_backup_progress.Text =
+ string.Format(Catalog.GetString("Copied to {0}"), app1s_fileCopy);
+ } */
+ } catch {
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ string.Format(Catalog.GetString("Cannot copy to {0} "), app1s_fileCopy));
+ }
+ }
+
+ /*
+ * deprecated since 1.6.0. Use backup method below
+ */
+ static long app1s_copyRecursiveElapsedMs;
+ static int app1s_backupMainDirsDone;
+ //static UtilCopy uc;
+ private void app1s_copyRecursive()
+ {
+ app1s_copyRecursiveElapsedMs = 0;
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+
+ //Util.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new
DirectoryInfo(app1s_fileCopy), out app1s_backupMainDirsDone);
+ app1s_uc.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new
DirectoryInfo(app1s_fileCopy), 0);
+ sw.Stop();
+
+ app1s_copyRecursiveElapsedMs = sw.ElapsedMilliseconds;
+ }
+
+ /*
+ * Temporarily disabled
+ *
+ //from Longomatch
+ //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
+ private bool backup(string path)
+ {
+ try {
+ string storageName = path + Path.DirectorySeparatorChar + "chronojump_backup-" +
DateTime.UtcNow.ToString() + ".tar.gz";
+ using (FileStream fs = new FileStream (outputFilename, FileMode.Create,
FileAccess.Write, FileShare.None)) {
+ using (Stream gzipStream = new GZipOutputStream (fs)) {
+ using (TarArchive tarArchive = TarArchive.CreateOutputTarArchive
(gzipStream)) {
+ //foreach (string n in new string[] {"", "-wal", "-shm"}) {
+ // TarEntry tarEntry = TarEntry.CreateEntryFromFile (
+ // Path.Combine (Config.DBDir,
storageName + ".cblite" + n));
+ // tarArchive.WriteEntry (tarEntry, true);
+ //}
+ //AddDirectoryFilesToTar (tarArchive, Path.Combine
(Config.DBDir, storageName + " attachments"), true);
+ AddDirectoryFilesToTar (tarArchive, Util.GetParentDir(false),
true);
+ }
+ }
+ }
+ //LastBackup = DateTime.UtcNow;
+ } catch (Exception ex) {
+ LogB.Error (ex);
+ return false;
+ }
+ return true;
+ }
+
+
+ //from Longomatch
+ //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
+ void AddDirectoryFilesToTar (TarArchive tarArchive, string sourceDirectory, bool recurse)
+ {
+ // Recursively add sub-folders
+ if (recurse) {
+ string[] directories = Directory.GetDirectories (sourceDirectory);
+ foreach (string directory in directories)
+ AddDirectoryFilesToTar (tarArchive, directory, recurse);
+ }
+
+ // Add files
+ string[] filenames = Directory.GetFiles (sourceDirectory);
+ foreach (string filename in filenames) {
+ TarEntry tarEntry = TarEntry.CreateEntryFromFile (filename);
+ tarArchive.WriteEntry (tarEntry, true);
+ }
}
+ */
private void on_app1s_button_backup_cancel_or_close_clicked (object o, EventArgs args)
{
diff --git a/src/gui/app1/session/loadAndImport.cs b/src/gui/app1/session/loadAndImport.cs
index 254059ed..69fac67f 100644
--- a/src/gui/app1/session/loadAndImport.cs
+++ b/src/gui/app1/session/loadAndImport.cs
@@ -447,13 +447,13 @@ public partial class ChronoJumpWindow
}
//TODO: do not need to be public ? maybe for import
- public void app1s_Pulse(string str)
+ public void app1s_ImportPulse(string str)
{
app1s_progressbarImport.Pulse();
app1s_progressbarImport.Text = str;
}
//TODO: do not need to be public ? maybe for import
- public void app1s_PulseEnd()
+ public void app1s_ImportPulseEnd()
{
app1s_progressbarImport.Fraction = 1;
app1s_hbuttonbox_page4.Sensitive = true;
diff --git a/src/gui/app1/session/main.cs b/src/gui/app1/session/main.cs
index af22f5d5..602c1a24 100644
--- a/src/gui/app1/session/main.cs
+++ b/src/gui/app1/session/main.cs
@@ -85,13 +85,18 @@ public partial class ChronoJumpWindow
[Widget] Gtk.EventBox app1s_eventbox_button_delete_close;
//notebook tab 6 (backup)
+ [Widget] Gtk.Button app1s_button_backup_select;
+ [Widget] Gtk.Button app1s_button_backup_start;
+ [Widget] Gtk.Button app1s_button_backup_cancel_close;
+ [Widget] Gtk.Label app1s_label_backup_cancel_close;
+ [Widget] Gtk.EventBox app1s_eventbox_button_backup_cancel_close;
[Widget] Gtk.Image app1s_image_button_backup_select;
[Widget] Gtk.Label app1s_label_backup_destination;
- [Widget] Gtk.Button app1s_button_backup_start;
- [Widget] Gtk.Button app1s_button_backup_cancel;
- [Widget] Gtk.Button app1s_button_backup_close;
- [Widget] Gtk.EventBox app1s_eventbox_button_backup_cancel;
- [Widget] Gtk.EventBox app1s_eventbox_button_backup_close;
+ [Widget] Gtk.HBox app1s_hbox_backup_doing;
+ [Widget] Gtk.Label app1s_label_backup_progress;
+ [Widget] Gtk.ProgressBar app1s_pulsebarBackupActivity;
+ [Widget] Gtk.ProgressBar app1s_pulsebarBackupDirs;
+ [Widget] Gtk.ProgressBar app1s_pulsebarBackupSecondDirs;
const int app1s_PAGE_MODES = 0;
const int app1s_PAGE_IMPORT_START = 1;
@@ -133,8 +138,7 @@ public partial class ChronoJumpWindow
UtilGtk.EventBoxColorBackgroundActive (app1s_eventbox_button_import_close, UtilGtk.YELLOW,
UtilGtk.YELLOW_LIGHT);
UtilGtk.EventBoxColorBackgroundActive (app1s_eventbox_button_import_again, UtilGtk.YELLOW,
UtilGtk.YELLOW_LIGHT);
UtilGtk.EventBoxColorBackgroundActive (app1s_eventbox_button_delete_close, UtilGtk.YELLOW,
UtilGtk.YELLOW_LIGHT);
- UtilGtk.EventBoxColorBackgroundActive (app1s_eventbox_button_backup_cancel, UtilGtk.YELLOW,
UtilGtk.YELLOW_LIGHT);
- UtilGtk.EventBoxColorBackgroundActive (app1s_eventbox_button_backup_close, UtilGtk.YELLOW,
UtilGtk.YELLOW_LIGHT);
+ UtilGtk.EventBoxColorBackgroundActive (app1s_eventbox_button_backup_cancel_close,
UtilGtk.YELLOW, UtilGtk.YELLOW_LIGHT);
}
private void app1s_label_session_set_name()
diff --git a/src/gui/chronojumpImporter.cs b/src/gui/chronojumpImporter.cs
index cf00ed0f..d121d633 100644
--- a/src/gui/chronojumpImporter.cs
+++ b/src/gui/chronojumpImporter.cs
@@ -102,8 +102,8 @@ public partial class ChronoJumpWindow
LogB.ThreadEnding();
importSessionFromDatabaseEnd();
- app1s_Pulse(chronojumpImporter.MessageToPulsebar);
- app1s_PulseEnd();
+ app1s_ImportPulse(chronojumpImporter.MessageToPulsebar);
+ app1s_ImportPulseEnd();
LogB.ThreadEnded();
return false;
@@ -125,7 +125,7 @@ public partial class ChronoJumpWindow
if(File.Exists(statusDir + "allData.txt"))
message = "All data imported, finishing";
- app1s_Pulse(message);
+ app1s_ImportPulse(message);
Thread.Sleep (100);
//LogB.Debug(threadImport.ThreadState.ToString());
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 5d1b26e9..6385bff6 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -29,7 +29,6 @@ using System.Text; //StringBuilder
using System.Collections; //ArrayList
using System.Collections.Generic; //List<T>
using Mono.Unix;
-using System.Threading;
using System.Globalization; //CultureInfo stuff
using System.Diagnostics; //Stopwatch
@@ -74,19 +73,6 @@ public class PreferencesWindow
[Widget] Gtk.DrawingArea drawingarea_background_color;
[Widget] Gtk.CheckButton check_logo_animated;
- //database tab
-// [Widget] Gtk.Button button_data_folder_open;
-
- //[Widget] Gtk.CheckButton check_backup_multimedia_and_encoder;
-
- [Widget] Gtk.Button button_db_backup;
- [Widget] Gtk.HBox hbox_backup_doing;
- [Widget] Gtk.Label label_backup;
- [Widget] Gtk.ProgressBar pulsebarBackupActivity;
- [Widget] Gtk.ProgressBar pulsebarBackupDirs;
- [Widget] Gtk.ProgressBar pulsebarBackupSecondDirs;
-
-
//jumps tab
[Widget] Gtk.CheckButton checkbutton_power;
[Widget] Gtk.CheckButton checkbutton_stiffness;
@@ -250,7 +236,7 @@ public class PreferencesWindow
[Widget] Gtk.Button button_accept;
[Widget] Gtk.Button button_cancel;
- public Gtk.Button FakeButtonImported;
+ public Gtk.Button FakeButtonConfigurationImported;
public Gtk.Button FakeButtonDebugModeStart;
static PreferencesWindow PreferencesWindowBox;
@@ -259,19 +245,19 @@ public class PreferencesWindow
private UtilAll.OperatingSystems operatingSystem;
private Preferences preferences; //stored to update SQL if anything changed
- private Thread thread;
+// private Thread thread;
string databaseURL;
string databaseTempURL;
ListStore langsStore;
- const int JUMPSPAGE = 2;
- const int RUNSPAGE = 3;
- const int ENCODERCAPTUREPAGE = 4;
- const int ENCODEROTHERPAGE = 5;
- const int FORCESENSORPAGE = 6;
- const int RUNENCODERPAGE = 7;
+ const int JUMPSPAGE = 1;
+ const int RUNSPAGE = 2;
+ const int ENCODERCAPTUREPAGE = 3;
+ const int ENCODEROTHERPAGE = 4;
+ const int FORCESENSORPAGE = 5;
+ const int RUNENCODERPAGE = 6;
static private WebcamDeviceList wd_list;
private WebcamFfmpegSupportedModes wfsm;
@@ -289,7 +275,7 @@ public class PreferencesWindow
databaseURL = Util.GetDatabaseDir() + System.IO.Path.DirectorySeparatorChar +
"chronojump.db";
databaseTempURL = Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar +
"chronojump.db";
- FakeButtonImported = new Gtk.Button();
+ FakeButtonConfigurationImported = new Gtk.Button();
FakeButtonDebugModeStart = new Gtk.Button();
}
@@ -1395,35 +1381,35 @@ public class PreferencesWindow
void on_preferences_delete_event (object o, DeleteEventArgs args)
{
+/*
//do not hide/exit if copyiing
if (thread != null && thread.IsAlive)
args.RetVal = true;
else {
+*/
PreferencesWindowBox.preferences_win.Hide();
PreferencesWindowBox = null;
- }
+// }
}
-
- void on_button_db_restore_clicked (object o, EventArgs args)
- {
- /*
- * TODO: problem is database stored is a chronojump.db or a folder (if images and videos were
saved).
- * FileChooserAction only lets you use one type
- * In the future backup db as tgz or similar
- */
- /*
+ /*
+ * TODO: problem is database stored is a chronojump.db or a folder (if images and videos were saved).
+ * FileChooserAction only lets you use one type
+ * In the future backup db as tgz or similar
+
+ void on_button_db_restore_clicked (object o, EventArgs args)
+ {
fc = new Gtk.FileChooserDialog(Catalog.GetString("Restore database from:"),
- preferences_win,
- FileChooserAction.SelectFolder,
- Catalog.GetString("Cancel"),ResponseType.Cancel,
- Catalog.GetString("Restore"),ResponseType.Accept
- );
+ preferences_win,
+ FileChooserAction.SelectFolder,
+ Catalog.GetString("Cancel"),ResponseType.Cancel,
+ Catalog.GetString("Restore"),ResponseType.Accept
+ );
ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are you sure you want to
restore?"));
confirmWin.Button_accept.Clicked += new EventHandler(on_overwrite_file_accepted);
- */
- }
+ }
+ */
void on_button_logs_folder_open_clicked (object o, EventArgs args)
@@ -1466,107 +1452,9 @@ public class PreferencesWindow
LogB.Warning(dir);
}
-
-
- string fileDB;
- string fileCopy;
- Gtk.FileChooserDialog fc;
- void on_button_db_backup_clicked (object o, EventArgs args)
- {
- System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL); //potser cal una arrobar
abans (a windows)
- System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL); //potser cal una arrobar
abans (a windows)
- fileDB = "";
-
- long length1 = 0;
- if(file1.Exists)
- length1 = file1.Length;
- long length2 = 0;
- if(file2.Exists)
- length2 = file2.Length;
-
- if(length1 == 0 && length2 == 0)
- new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error. Cannot
find database."));
- else if(length1 > length2)
- fileDB = databaseURL;
- else
- fileDB = databaseTempURL;
-
- fc = new Gtk.FileChooserDialog(Catalog.GetString("Copy database to:"),
- preferences_win,
- FileChooserAction.SelectFolder,
- Catalog.GetString("Cancel"),ResponseType.Cancel,
- Catalog.GetString("Copy"),ResponseType.Accept
- );
-
- if (fc.Run() == (int)ResponseType.Accept)
- {
- //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the
db file
- //if(check_backup_multimedia_and_encoder.Active)
- fileCopy = fc.Filename + Path.DirectorySeparatorChar + "chronojump";
- //else
- // fileCopy = fc.Filename + Path.DirectorySeparatorChar + "chronojump_copy.db";
-
- try {
- fc.Hide ();
-
- bool exists = false;
- //if(check_backup_multimedia_and_encoder.Active) {
- if(Directory.Exists(fileCopy)) {
- LogB.Information(string.Format("Directory {0} exists, created
at {1}",
- fileCopy,
Directory.GetCreationTime(fileCopy)));
- exists = true;
- }
- /*} else {
- if (File.Exists(fileCopy)) {
- LogB.Information(string.Format("File {0} exists with
attributes {1}, created at {2}",
- fileCopy,
File.GetAttributes(fileCopy), File.GetCreationTime(fileCopy)));
- exists = true;
- }
- }
- */
-
- if(exists) {
- LogB.Information("Overwrite...");
- ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are
you sure you want to overwrite: "), "", fileCopy);
- confirmWin.Button_accept.Clicked += new
EventHandler(on_overwrite_file_accepted);
- } else {
- //if multimedia_and_encoder, then copy the folder. If not checked,
then copy only the db file
- //if(check_backup_multimedia_and_encoder.Active) {
- uc = new UtilCopy();
- thread = new Thread(new ThreadStart(copyRecursive));
- GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
-
- backup_doing_sensitive_start_end(true);
-
- LogB.ThreadStart();
- thread.Start();
- /*} else {
- File.Copy(fileDB, fileCopy);
-
- string myString = string.Format(Catalog.GetString("Copied to
{0}"), fileCopy);
- label_backup.Text = myString;
- }
- */
- }
- }
- catch {
- string myString = string.Format(Catalog.GetString("Cannot copy to {0} "),
fileCopy);
- new DialogMessage(Constants.MessageTypes.WARNING, myString);
- }
- }
- else {
- fc.Hide ();
- return ;
- }
-
- //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
- fc.Destroy();
-
- }
-
void on_button_import_configuration_clicked (object o, EventArgs args)
{
- fc = new Gtk.FileChooserDialog(Catalog.GetString("Import configuration file"),
+ Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(Catalog.GetString("Import configuration
file"),
preferences_win,
FileChooserAction.Open,
Catalog.GetString("Cancel"),ResponseType.Cancel,
@@ -1586,7 +1474,7 @@ public class PreferencesWindow
LogB.Information("Imported configuration");
//will launch configInit() from gui/chronojump.cs
- FakeButtonImported.Click();
+ FakeButtonConfigurationImported.Click();
success = true;
} catch {
@@ -1600,104 +1488,6 @@ public class PreferencesWindow
if(success)
new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Successfully
imported."));
}
-
- private void on_overwrite_file_accepted(object o, EventArgs args)
- {
- try {
- //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the
db file
- //if(check_backup_multimedia_and_encoder.Active) {
- Directory.Delete(fileCopy, true);
- uc = new UtilCopy();
- thread = new Thread(new ThreadStart(copyRecursive));
- GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
-
- backup_doing_sensitive_start_end(true);
-
- LogB.ThreadStart();
- thread.Start();
- /* } else {
- File.Delete(fileCopy);
- File.Copy(fileDB, fileCopy);
-
- fc.Hide ();
- string myString = string.Format(Catalog.GetString("Copied to {0}"), fileCopy);
- label_backup.Text = myString;
- } */
- } catch {
- string myString = string.Format(Catalog.GetString("Cannot copy to {0} "), fileCopy);
- new DialogMessage(Constants.MessageTypes.WARNING, myString);
- }
- }
-
- /*
- * deprecated since 1.6.0. Use backup method below
- */
- static long copyRecursiveElapsedMs;
- static int backupMainDirsDone;
- static UtilCopy uc;
- private void copyRecursive()
- {
- copyRecursiveElapsedMs = 0;
- Stopwatch sw = new Stopwatch();
- sw.Start();
-
- //Util.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new
DirectoryInfo(fileCopy), out backupMainDirsDone);
- uc.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new
DirectoryInfo(fileCopy), 0);
- sw.Stop();
-
- copyRecursiveElapsedMs = sw.ElapsedMilliseconds;
- }
-
- /*
- * Temprarily disabled
- *
- //from Longomatch
- //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
- private bool backup(string path)
- {
- try {
- string storageName = path + Path.DirectorySeparatorChar + "chronojump_backup-" +
DateTime.UtcNow.ToString() + ".tar.gz";
- using (FileStream fs = new FileStream (outputFilename, FileMode.Create,
FileAccess.Write, FileShare.None)) {
- using (Stream gzipStream = new GZipOutputStream (fs)) {
- using (TarArchive tarArchive = TarArchive.CreateOutputTarArchive
(gzipStream)) {
- //foreach (string n in new string[] {"", "-wal", "-shm"}) {
- // TarEntry tarEntry = TarEntry.CreateEntryFromFile (
- // Path.Combine (Config.DBDir,
storageName + ".cblite" + n));
- // tarArchive.WriteEntry (tarEntry, true);
- //}
- //AddDirectoryFilesToTar (tarArchive, Path.Combine
(Config.DBDir, storageName + " attachments"), true);
- AddDirectoryFilesToTar (tarArchive, Util.GetParentDir(false),
true);
- }
- }
- }
- //LastBackup = DateTime.UtcNow;
- } catch (Exception ex) {
- LogB.Error (ex);
- return false;
- }
- return true;
- }
-
-
- //from Longomatch
- //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
- void AddDirectoryFilesToTar (TarArchive tarArchive, string sourceDirectory, bool recurse)
- {
- // Recursively add sub-folders
- if (recurse) {
- string[] directories = Directory.GetDirectories (sourceDirectory);
- foreach (string directory in directories)
- AddDirectoryFilesToTar (tarArchive, directory, recurse);
- }
-
- // Add files
- string[] filenames = Directory.GetFiles (sourceDirectory);
- foreach (string filename in filenames) {
- TarEntry tarEntry = TarEntry.CreateEntryFromFile (filename);
- tarArchive.WriteEntry (tarEntry, true);
- }
- }
- */
//encoder
private void on_button_inactivity_help_clicked (object o, EventArgs args)
@@ -1786,53 +1576,6 @@ public class PreferencesWindow
}
}
- private bool PulseGTK ()
- {
- if ( ! thread.IsAlive ) {
- LogB.ThreadEnding();
- endPulse();
-
- LogB.ThreadEnded();
- return false;
- }
-
- pulsebarBackupActivity.Pulse();
- pulsebarBackupDirs.Fraction = UtilAll.DivideSafeFraction(uc.BackupMainDirsCount, 6); //6 for:
database, encoder, forceSensor, logs, multimedia, raceAnalyzer
- pulsebarBackupDirs.Text = uc.LastMainDir;
- pulsebarBackupSecondDirs.Fraction = UtilAll.DivideSafeFraction(uc.BackupSecondDirsCount,
uc.BackupSecondDirsLength);
- pulsebarBackupSecondDirs.Text = uc.LastSecondDir;
-
- Thread.Sleep (30);
- //LogB.Debug(thread.ThreadState.ToString());
- return true;
- }
-
- private void endPulse()
- {
- pulsebarBackupActivity.Fraction = 1;
- pulsebarBackupDirs.Fraction = 1;
- pulsebarBackupSecondDirs.Fraction = 1;
- backup_doing_sensitive_start_end(false);
- fc.Hide ();
- string myString = string.Format(Catalog.GetString("Copied to {0} in {1} ms"), fileCopy,
copyRecursiveElapsedMs);
- label_backup.Text = myString;
- }
-
- private void backup_doing_sensitive_start_end(bool start)
- {
- if(start)
- label_backup.Text = Catalog.GetString("Please, wait.");
-
- pulsebarBackupActivity.Visible = start;
- hbox_backup_doing.Visible = start;
-
- button_db_backup.Sensitive = ! start;
-// button_data_folder_open.Sensitive = ! start;
-
- button_cancel.Sensitive = ! start;
- button_accept.Sensitive = ! start;
- }
-
//change stuff in Sqlite and in preferences object that will be retrieved by GetPreferences
void on_button_accept_clicked (object o, EventArgs args)
{
diff --git a/src/utilDate.cs b/src/utilDate.cs
index 5487160a..2285b9bd 100644
--- a/src/utilDate.cs
+++ b/src/utilDate.cs
@@ -38,6 +38,10 @@ public class UtilDate
//records date & time, useful to backup database without having strange chars on filename
//used also on SQL when time wants to be stored also
+ public static string ToFile ()
+ {
+ return ToFile(DateTime.Now);
+ }
public static string ToFile (DateTime dt)
{
return UtilAll.DigitsCreate(dt.Year,4) + "-" +
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]