[longomatch] Add a new button to rescan databases
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a new button to rescan databases
- Date: Fri, 13 Feb 2015 13:21:58 +0000 (UTC)
commit f95a3580bec23ab9f5fbcf3c52f4381f362a8dc1
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Feb 13 14:21:32 2015 +0100
Add a new button to rescan databases
LongoMatch.Core/Interfaces/IDatabase.cs | 2 +
LongoMatch.GUI/Gui/Dialog/DatabasesManager.cs | 29 +++++++-
.../LongoMatch.Gui.Dialog.DatabasesManager.cs | 80 +++++++++++++-------
LongoMatch.GUI/gtk-gui/gui.stetic | 38 +++++-----
LongoMatch.Services/Services/FileDB.cs | 4 +-
5 files changed, 104 insertions(+), 49 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/IDatabase.cs b/LongoMatch.Core/Interfaces/IDatabase.cs
index 1569e3c..c050463 100644
--- a/LongoMatch.Core/Interfaces/IDatabase.cs
+++ b/LongoMatch.Core/Interfaces/IDatabase.cs
@@ -39,6 +39,8 @@ namespace LongoMatch.Core.Interfaces
bool Delete ();
+ void Reload ();
+
string Name {get;}
DateTime LastBackup {get;}
diff --git a/LongoMatch.GUI/Gui/Dialog/DatabasesManager.cs b/LongoMatch.GUI/Gui/Dialog/DatabasesManager.cs
index 77917b1..2ff36c0 100644
--- a/LongoMatch.GUI/Gui/Dialog/DatabasesManager.cs
+++ b/LongoMatch.GUI/Gui/Dialog/DatabasesManager.cs
@@ -22,6 +22,9 @@ using Mono.Unix;
using LongoMatch.Core.Interfaces;
using LongoMatch.Gui.Helpers;
+using LongoMatch.Core.Interfaces.GUI;
+using System.Threading.Tasks;
+using LongoMatch.Core.Common;
namespace LongoMatch.Gui.Dialog
{
@@ -36,8 +39,9 @@ namespace LongoMatch.Gui.Dialog
this.manager = Config.DatabaseManager;
ActiveDB = manager.ActiveDB;
SetTreeView ();
+ rescanbutton.Clicked += HandleRescanClicked;
}
-
+
IDatabase ActiveDB {
set {
dblabel.Text = Catalog.GetString("Active database") +": " + value.Name;
@@ -189,7 +193,30 @@ namespace LongoMatch.Gui.Dialog
delbutton.Sensitive = selected;
backupbutton.Sensitive = selected;
selectbutton.Sensitive = selected;
+ rescanbutton.Sensitive = selected;
}
+
+ void HandleRescanClicked (object sender, EventArgs e)
+ {
+ IDatabase db = SelectedDB;
+ if (db != null) {
+ IBusyDialog busy = Config.GUIToolkit.BusyDialog (Catalog.GetString ("Scanning
database..."), this);
+ Task task = new Task (() => {
+ try {
+ db.Reload ();
+ } catch (Exception ex) {
+ Log.Exception (ex);
+ }
+ Config.GUIToolkit.Invoke (delegate {
+ busy.Destroy ();
+ });
+ });
+ task.Start ();
+ busy.ShowSync ();
+ Config.GUIToolkit.InfoMessage (Catalog.GetString ("Database scanned
succesfully."));
+ }
+ }
+
}
}
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DatabasesManager.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DatabasesManager.cs
index 88add80..28d46b2 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DatabasesManager.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DatabasesManager.cs
@@ -13,6 +13,7 @@ namespace LongoMatch.Gui.Dialog
private global::Gtk.Button selectbutton;
private global::Gtk.Button delbutton;
private global::Gtk.Button backupbutton;
+ private global::Gtk.Button rescanbutton;
private global::Gtk.Button addbutton;
private global::Gtk.Button buttonOk;
@@ -146,48 +147,75 @@ namespace LongoMatch.Gui.Dialog
w31.Expand = false;
w31.Fill = false;
// Container child vbox3.Gtk.Box+BoxChild
- this.addbutton = new global::Gtk.Button ();
- this.addbutton.CanFocus = true;
- this.addbutton.Name = "addbutton";
- this.addbutton.UseUnderline = true;
- // Container child addbutton.Gtk.Container+ContainerChild
+ this.rescanbutton = new global::Gtk.Button ();
+ this.rescanbutton.Sensitive = false;
+ this.rescanbutton.CanFocus = true;
+ this.rescanbutton.Name = "rescanbutton";
+ this.rescanbutton.UseUnderline = true;
+ // Container child rescanbutton.Gtk.Container+ContainerChild
global::Gtk.Alignment w32 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F);
// Container child GtkAlignment.Gtk.Container+ContainerChild
global::Gtk.HBox w33 = new global::Gtk.HBox ();
w33.Spacing = 2;
// Container child GtkHBox.Gtk.Container+ContainerChild
global::Gtk.Image w34 = new global::Gtk.Image ();
- w34.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-add",
global::Gtk.IconSize.Menu);
+ w34.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-refresh",
global::Gtk.IconSize.Menu);
w33.Add (w34);
// Container child GtkHBox.Gtk.Container+ContainerChild
global::Gtk.Label w36 = new global::Gtk.Label ();
- w36.LabelProp = global::Mono.Unix.Catalog.GetString ("_Add");
+ w36.LabelProp = global::Mono.Unix.Catalog.GetString ("Re-scan");
w36.UseUnderline = true;
w33.Add (w36);
w32.Add (w33);
- this.addbutton.Add (w32);
- this.vbox3.Add (this.addbutton);
- global::Gtk.Box.BoxChild w40 = ((global::Gtk.Box.BoxChild)(this.vbox3
[this.addbutton]));
+ this.rescanbutton.Add (w32);
+ this.vbox3.Add (this.rescanbutton);
+ global::Gtk.Box.BoxChild w40 = ((global::Gtk.Box.BoxChild)(this.vbox3
[this.rescanbutton]));
w40.Position = 3;
w40.Expand = false;
w40.Fill = false;
+ // Container child vbox3.Gtk.Box+BoxChild
+ this.addbutton = new global::Gtk.Button ();
+ this.addbutton.CanFocus = true;
+ this.addbutton.Name = "addbutton";
+ this.addbutton.UseUnderline = true;
+ // Container child addbutton.Gtk.Container+ContainerChild
+ global::Gtk.Alignment w41 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F);
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
+ global::Gtk.HBox w42 = new global::Gtk.HBox ();
+ w42.Spacing = 2;
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Image w43 = new global::Gtk.Image ();
+ w43.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-add",
global::Gtk.IconSize.Menu);
+ w42.Add (w43);
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Label w45 = new global::Gtk.Label ();
+ w45.LabelProp = global::Mono.Unix.Catalog.GetString ("_Add");
+ w45.UseUnderline = true;
+ w42.Add (w45);
+ w41.Add (w42);
+ this.addbutton.Add (w41);
+ this.vbox3.Add (this.addbutton);
+ global::Gtk.Box.BoxChild w49 = ((global::Gtk.Box.BoxChild)(this.vbox3
[this.addbutton]));
+ w49.Position = 4;
+ w49.Expand = false;
+ w49.Fill = false;
this.hbox1.Add (this.vbox3);
- global::Gtk.Box.BoxChild w41 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox3]));
- w41.Position = 1;
- w41.Expand = false;
- w41.Fill = false;
+ global::Gtk.Box.BoxChild w50 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.vbox3]));
+ w50.Position = 1;
+ w50.Expand = false;
+ w50.Fill = false;
this.vbox2.Add (this.hbox1);
- global::Gtk.Box.BoxChild w42 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
- w42.Position = 1;
+ global::Gtk.Box.BoxChild w51 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
+ w51.Position = 1;
w1.Add (this.vbox2);
- global::Gtk.Box.BoxChild w43 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2]));
- w43.Position = 0;
+ global::Gtk.Box.BoxChild w52 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2]));
+ w52.Position = 0;
// Internal child LongoMatch.Gui.Dialog.DatabasesManager.ActionArea
- global::Gtk.HButtonBox w44 = this.ActionArea;
- w44.Name = "dialog1_ActionArea";
- w44.Spacing = 10;
- w44.BorderWidth = ((uint)(5));
- w44.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
+ global::Gtk.HButtonBox w53 = this.ActionArea;
+ w53.Name = "dialog1_ActionArea";
+ w53.Spacing = 10;
+ w53.BorderWidth = ((uint)(5));
+ w53.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
this.buttonOk = new global::Gtk.Button ();
this.buttonOk.CanDefault = true;
@@ -197,9 +225,9 @@ namespace LongoMatch.Gui.Dialog
this.buttonOk.UseUnderline = true;
this.buttonOk.Label = "gtk-ok";
this.AddActionWidget (this.buttonOk, -5);
- global::Gtk.ButtonBox.ButtonBoxChild w45 =
((global::Gtk.ButtonBox.ButtonBoxChild)(w44 [this.buttonOk]));
- w45.Expand = false;
- w45.Fill = false;
+ global::Gtk.ButtonBox.ButtonBoxChild w54 =
((global::Gtk.ButtonBox.ButtonBoxChild)(w53 [this.buttonOk]));
+ w54.Expand = false;
+ w54.Fill = false;
if ((this.Child != null)) {
this.Child.ShowAll ();
}
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index fe0ba10..3995903 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -2654,7 +2654,6 @@ Away</property>
<child>
<widget class="Gtk.Label" id="playLabel">
<property name="MemberName" />
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="LeftAttach">1</property>
@@ -4864,7 +4863,6 @@ You can continue with the current capture, cancel it or save your project.
<child>
<widget class="Gtk.Label" id="dblabel">
<property name="MemberName" />
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="Position">0</property>
@@ -4954,6 +4952,23 @@ You can continue with the current capture, cancel it or save your project.
</packing>
</child>
<child>
+ <widget class="Gtk.Button" id="rescanbutton">
+ <property name="MemberName" />
+ <property name="Sensitive">False</property>
+ <property name="CanFocus">True</property>
+ <property name="Type">TextAndIcon</property>
+ <property name="Icon">stock:gtk-refresh Menu</property>
+ <property name="Label" translatable="yes">Re-scan</property>
+ <property name="UseUnderline">True</property>
+ </widget>
+ <packing>
+ <property name="Position">3</property>
+ <property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ <child>
<widget class="Gtk.Button" id="addbutton">
<property name="MemberName" />
<property name="CanFocus">True</property>
@@ -4964,7 +4979,7 @@ You can continue with the current capture, cancel it or save your project.
<signal name="Clicked" handler="OnAddbuttonClicked" />
</widget>
<packing>
- <property name="Position">3</property>
+ <property name="Position">4</property>
<property name="AutoSize">True</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
@@ -8662,7 +8677,6 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Label" id="templatelabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="TopAttach">1</property>
@@ -8880,7 +8894,6 @@ You can continue with the current capture, cancel it or save your project.
<child>
<widget class="Gtk.Label" id="label1">
<property name="MemberName" />
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="type">tab</property>
@@ -8892,7 +8905,6 @@ You can continue with the current capture, cancel it or save your project.
<child>
<widget class="Gtk.Label" id="label3">
<property name="MemberName" />
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="type">tab</property>
@@ -9706,7 +9718,6 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Label" id="synclabel">
<property name="MemberName" />
<property name="WidthRequest">300</property>
- <property name="LabelProp" translatable="yes" />
<property name="UseMarkup">True</property>
</widget>
<packing>
@@ -10885,7 +10896,6 @@ You can continue with the current capture, cancel it or save your project.
<child>
<widget class="Gtk.Label" id="localPlaysList">
<property name="MemberName" />
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="type">tab</property>
@@ -10903,7 +10913,6 @@ You can continue with the current capture, cancel it or save your project.
<child>
<widget class="Gtk.Label" id="visitorPlaysList">
<property name="MemberName" />
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="type">tab</property>
@@ -10966,7 +10975,6 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Label" id="authorlabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="TopAttach">2</property>
@@ -10988,7 +10996,6 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Label" id="desclabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
<property name="Wrap">True</property>
<property name="WidthChars">70</property>
<property name="MaxWidthChars">100</property>
@@ -11012,7 +11019,6 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Label" id="filelabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
<property name="Wrap">True</property>
<property name="Ellipsize">Start</property>
<property name="SingleLineMode">True</property>
@@ -11118,7 +11124,6 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Label" id="namelabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="LeftAttach">1</property>
@@ -11462,7 +11467,6 @@ To avoid this, and to enjoy many additional functional benefits, we encourage yo
<widget class="Gtk.Label" id="filelabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
<property name="Ellipsize">Start</property>
</widget>
<packing>
@@ -11481,7 +11485,6 @@ To avoid this, and to enjoy many additional functional benefits, we encourage yo
<widget class="Gtk.Label" id="audiolabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="TopAttach">1</property>
@@ -11501,7 +11504,6 @@ To avoid this, and to enjoy many additional functional benefits, we encourage yo
<widget class="Gtk.Label" id="containerlabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="TopAttach">2</property>
@@ -11519,7 +11521,6 @@ To avoid this, and to enjoy many additional functional benefits, we encourage yo
<widget class="Gtk.Label" id="durationlabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="AutoSize">False</property>
@@ -11535,7 +11536,6 @@ To avoid this, and to enjoy many additional functional benefits, we encourage yo
<widget class="Gtk.Label" id="formatlabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="LeftAttach">1</property>
@@ -11553,7 +11553,6 @@ To avoid this, and to enjoy many additional functional benefits, we encourage yo
<widget class="Gtk.Label" id="label9">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="TopAttach">2</property>
@@ -11573,7 +11572,6 @@ To avoid this, and to enjoy many additional functional benefits, we encourage yo
<widget class="Gtk.Label" id="videolabel">
<property name="MemberName" />
<property name="Xalign">0</property>
- <property name="LabelProp" translatable="yes" />
</widget>
<packing>
<property name="TopAttach">1</property>
diff --git a/LongoMatch.Services/Services/FileDB.cs b/LongoMatch.Services/Services/FileDB.cs
index 8d3ba3d..8fd23e7 100644
--- a/LongoMatch.Services/Services/FileDB.cs
+++ b/LongoMatch.Services/Services/FileDB.cs
@@ -51,7 +51,7 @@ namespace LongoMatch.DB
}
}
if (projectsDB == null) {
- ReloadDB ();
+ Reload ();
}
DateTime now = DateTime.UtcNow;
if (projectsDB.LastBackup + maxDaysWithoutBackup < now) {
@@ -191,7 +191,7 @@ namespace LongoMatch.DB
AddProject (project);
}
- void ReloadDB ()
+ public void Reload ()
{
projectsDB = new LiteDB (dbPath);
DirectoryInfo dbDir = new DirectoryInfo (dbDirPath);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]