[longomatch] Update team shield in the list
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Update team shield in the list
- Date: Mon, 7 Jul 2014 11:20:14 +0000 (UTC)
commit d8da3aab906614398ef4f19e628f62b0b6d0fe9a
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Mar 24 18:59:52 2014 +0100
Update team shield in the list
LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs | 3 ++
LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs | 31 +++++++++++++++----
LongoMatch.GUI/gtk-gui/objects.xml | 6 +++-
3 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
index 95283d1..9838fe3 100644
--- a/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
+++ b/LongoMatch.GUI/Gui/Component/TeamTemplateEditor.cs
@@ -33,6 +33,7 @@ namespace LongoMatch.Gui.Component
[System.ComponentModel.ToolboxItem(true)]
public partial class TeamTemplateEditor : Gtk.Bin
{
+ public event EventHandler TemplateSaved;
enum Columns {
Desc,
@@ -222,6 +223,8 @@ namespace LongoMatch.Gui.Component
Config.TeamTemplatesProvider.Update (template);
Edited = false;
}
+ if (TemplateSaved != null)
+ TemplateSaved (this, null);
}
void HandleNewPlayerClicked (object sender, EventArgs e)
diff --git a/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs b/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs
index 0a00209..10f4689 100644
--- a/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/TeamsTemplatesPanel.cs
@@ -43,6 +43,7 @@ namespace LongoMatch.Gui.Panel
ListStore teams;
List<string> selectedTeams;
TeamTemplate loadedTeam;
+ Dictionary<string, TreeIter> itersDict;
ITeamTemplatesProvider provider;
@@ -52,6 +53,7 @@ namespace LongoMatch.Gui.Panel
provider = Config.TeamTemplatesProvider;
teams = new ListStore (typeof(Pixbuf), typeof(string), typeof (string));
+ itersDict = new Dictionary<string, TreeIter>();
teamstreeview.Model = teams;
teamstreeview.Model = teams;
@@ -72,6 +74,7 @@ namespace LongoMatch.Gui.Panel
selectedTeams = new List<string>();
newteam.Clicked += HandleNewTeamClicked;
deleteteambutton.Clicked += HandleDeleteTeamClicked;
+ teamtemplateeditor1.TemplateSaved += (s, e) => {SaveLoadedTeam ();};
backbutton.Clicked += (sender, o) => {
if (BackEvent != null)
@@ -86,6 +89,7 @@ namespace LongoMatch.Gui.Panel
bool first = true;
teams.Clear ();
+ itersDict.Clear ();
foreach (TeamTemplate template in provider.Templates) {
Pixbuf img;
TreeIter iter;
@@ -96,6 +100,7 @@ namespace LongoMatch.Gui.Panel
img = Gdk.Pixbuf.LoadFromResource ("logo.svg");
iter = teams.AppendValues (img, template.Name, template.TeamName);
+ itersDict.Add (template.Name, iter);
if (first || template.Name == templateName) {
templateIter = iter;
}
@@ -107,14 +112,26 @@ namespace LongoMatch.Gui.Panel
}
}
+ void SaveLoadedTeam () {
+ if (loadedTeam == null)
+ return;
+
+ provider.Update (loadedTeam);
+ /* The shield might have changed, update it just in case */
+ teamstreeview.Model.SetValue (itersDict[loadedTeam.Name], 0,
+ loadedTeam.Shield.Value);
+ }
+
void LoadTeam (string teamName) {
- if (loadedTeam != null && teamtemplateeditor1.Edited) {
- string msg = Catalog.GetString ("Do you want to save the current template");
- if (Config.GUIToolkit.QuestionMessage (msg, null, this)) {
- provider.Update (loadedTeam);
- } else {
- return;
- }
+ if (loadedTeam != null) {
+ if (teamtemplateeditor1.Edited) {
+ string msg = Catalog.GetString ("Do you want to save the current
template");
+ if (Config.GUIToolkit.QuestionMessage (msg, null, this)) {
+ SaveLoadedTeam ();
+ } else {
+ return;
+ }
+ }
}
try {
diff --git a/LongoMatch.GUI/gtk-gui/objects.xml b/LongoMatch.GUI/gtk-gui/objects.xml
index fc0bf91..29d7622 100644
--- a/LongoMatch.GUI/gtk-gui/objects.xml
+++ b/LongoMatch.GUI/gtk-gui/objects.xml
@@ -482,7 +482,11 @@
<property name="Edited" />
</itemgroup>
</itemgroups>
- <signals />
+ <signals>
+ <itemgroup label="TeamTemplateEditor Signals">
+ <signal name="TemplateSaved" />
+ </itemgroup>
+ </signals>
</object>
<object type="LongoMatch.Gui.Panel.ProjectsManagerPanel" palette-category="General" allow-children="false"
base-type="Gtk.Bin">
<itemgroups />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]