[longomatch] Enable subcat templates provider
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Enable subcat templates provider
- Date: Sun, 15 Jan 2012 23:04:18 +0000 (UTC)
commit 3ef5a41d25c0317fa5595c527931fb36e4a9fd1b
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Jan 2 22:34:31 2012 +0100
Enable subcat templates provider
LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs | 2 +-
.../Gui/Component/CategoriesTemplateEditor.cs | 7 ++++-
LongoMatch.GUI/Gui/Component/CategoryProperties.cs | 21 ++++++-------------
.../Gui/Component/PlaysListTreeWidget.cs | 17 +++++++++++++++-
.../Gui/Component/ProjectDetailsWidget.cs | 7 +++--
LongoMatch.GUI/Gui/Dialog/EditCategoryDialog.cs | 7 +++++-
LongoMatch.GUI/Gui/GUIToolkit.cs | 12 +++++++---
LongoMatch.Services/Services/ProjectsManager.cs | 2 +-
8 files changed, 48 insertions(+), 27 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index ff307e3..7646716 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -58,7 +58,7 @@ namespace LongoMatch.Interfaces.GUI
Project EditFakeProject(IDatabase db, Project project, ITemplatesService ts);
void OpenProjectsManager(Project openedProject, IDatabase db, ITemplatesService ts);
- void OpenCategoriesTemplatesManager(ICategoriesTemplatesProvider tp);
+ void OpenCategoriesTemplatesManager(ITemplatesService ts);
void OpenTeamsTemplatesManager(ITeamTemplatesProvider tp);
void ManageJobs(IRenderingJobsManager manager);
diff --git a/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs b/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs
index 8e607fb..97027be 100644
--- a/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs
+++ b/LongoMatch.GUI/Gui/Component/CategoriesTemplateEditor.cs
@@ -32,8 +32,10 @@ namespace LongoMatch.Gui.Component
CategoriesTreeView categoriestreeview;
List<HotKey> hkList;
GameUnitsEditor gameUnitsEditor;
+
+ ITemplatesService ts;
- public CategoriesTemplateEditorWidget (ITemplateProvider<Categories, Category> provider): base(provider)
+ public CategoriesTemplateEditorWidget (ITemplatesService ts): base(ts.CategoriesTemplateProvider)
{
hkList = new List<HotKey>();
categoriestreeview = new CategoriesTreeView();
@@ -46,6 +48,7 @@ namespace LongoMatch.Gui.Component
if (Config.useGameUnits) {
AddPage(gameUnitsEditor, "Game phases");
}
+ this.ts = ts;
}
public override Categories Template {
@@ -98,7 +101,7 @@ namespace LongoMatch.Gui.Component
}
protected override void EditSelected() {
- EditCategoryDialog dialog = new EditCategoryDialog();
+ EditCategoryDialog dialog = new EditCategoryDialog(ts);
dialog.Category = selected[0];
dialog.HotKeysList = hkList;
dialog.TransientFor = (Gtk.Window) Toplevel;
diff --git a/LongoMatch.GUI/Gui/Component/CategoryProperties.cs b/LongoMatch.GUI/Gui/Component/CategoryProperties.cs
index 081299b..38c2976 100644
--- a/LongoMatch.GUI/Gui/Component/CategoryProperties.cs
+++ b/LongoMatch.GUI/Gui/Component/CategoryProperties.cs
@@ -44,7 +44,7 @@ namespace LongoMatch.Gui.Component
public event HotKeyChangeHandler HotKeyChanged;
private Category cat;
- private ITemplateProvider<SubCategoryTemplate, string> subcategoriesTemplates;
+ private ISubcategoriesTemplatesProvider subcategoriesProvider;
private ListStore model;
public CategoryProperties()
@@ -56,23 +56,16 @@ namespace LongoMatch.Gui.Component
lagtimebutton.ValueChanged += OnLagTimeChanged;
}
- public ITemplateProvider<SubCategoryTemplate, string> Template {
- set {
- subcategoriesTemplates = value;
- }
- }
-
- public List<PlayerSubCategory> PlayerSubcategories{
- set{
- LoadSubcategories(value);
- }
+ public void LoadSubcategories(ITemplatesService ts) {
+ subcategoriesProvider = ts.SubCategoriesTemplateProvider;
+ LoadSubcategories(ts.PlayerSubcategories);
}
private void LoadSubcategories(List<PlayerSubCategory> playerSubcategories) {
model = new ListStore(typeof(string), typeof(ISubCategory));
model.AppendValues(Catalog.GetString("Create new..."), "");
- foreach (TagSubCategory subcat in subcategoriesTemplates.Templates) {
+ foreach (TagSubCategory subcat in subcategoriesProvider.Templates) {
Log.Debug("Adding tag subcategory: ", subcat.Name);
model.AppendValues(String.Format("[{0}] {1}",
Catalog.GetString("Tags"),
@@ -137,7 +130,7 @@ namespace LongoMatch.Gui.Component
}
private TagSubCategory EditSubCategoryTags (TagSubCategory template, bool checkName){
- SubCategoryTagsEditor se = new SubCategoryTagsEditor(template, subcategoriesTemplates.TemplatesNames);
+ SubCategoryTagsEditor se = new SubCategoryTagsEditor(template, subcategoriesProvider.TemplatesNames);
se.CheckName = checkName;
int ret = se.Run();
@@ -230,7 +223,7 @@ namespace LongoMatch.Gui.Component
model.AppendValues(String.Format("[{0}] {1}",Catalog.GetString("Tags"), template.Name),
template);
- subcategoriesTemplates.Save(template);
+ subcategoriesProvider.Save(template);
subcatcombobox.Active = 1;
return;
}
diff --git a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
index 843d1c2..14fd1d8 100644
--- a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
@@ -24,7 +24,9 @@ using Gtk;
using Mono.Unix;
using LongoMatch.Gui.Dialog;
using LongoMatch.Handlers;
+using LongoMatch.Interfaces;
using LongoMatch.Store;
+using LongoMatch.Store.Templates;
using LongoMatch.Common;
namespace LongoMatch.Gui.Component
@@ -44,6 +46,10 @@ namespace LongoMatch.Gui.Component
public event TagPlayHandler TagPlay;
public event RenderPlaylistHandler RenderPlaylistEvent;
+ ITemplatesService ts;
+ ISubcategoriesTemplatesProvider subcatProvider;
+ List<PlayerSubCategory> playersSubcat;
+
private Project project;
public PlaysListTreeWidget()
@@ -58,6 +64,15 @@ namespace LongoMatch.Gui.Component
treeview.TagPlay += OnTagPlay;
treeview.NewRenderingJob += OnNewRenderingJob;
}
+
+ public ITemplatesService TemplatesService
+ {
+ set {
+ this.ts = ts;
+ this.subcatProvider = ts.SubCategoriesTemplateProvider;
+ this.playersSubcat = ts.PlayerSubcategories;
+ }
+ }
public void RemovePlays(List<Play> plays) {
TreeIter iter, child;
@@ -160,7 +175,7 @@ namespace LongoMatch.Gui.Component
}
protected virtual void OnEditProperties(TimeNode tNode, object val) {
- EditCategoryDialog dialog = new EditCategoryDialog();
+ EditCategoryDialog dialog = new EditCategoryDialog(ts);
dialog.Category = tNode as Category;
dialog.Project = project;
dialog.Run();
diff --git a/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs b/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs
index 7118201..aae413d 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectDetailsWidget.cs
@@ -49,8 +49,9 @@ namespace LongoMatch.Gui.Component
Categories actualCategory;
TeamTemplate actualVisitorTeam;
TeamTemplate actualLocalTeam;
- ITemplateProvider<Categories, Category> tpc;
- ITemplateProvider<TeamTemplate, Player> tpt;
+
+ ICategoriesTemplatesProvider tpc;
+ ITeamTemplatesProvider tpt;
ITemplateWidget<Categories, Category> twc;
ITemplateWidget<TeamTemplate, Player> twt;
ProjectType useType;
@@ -81,7 +82,7 @@ namespace LongoMatch.Gui.Component
set {
tpc = value.CategoriesTemplateProvider;
tpt = value.TeamTemplateProvider;
- twc = new CategoriesTemplateEditorWidget(tpc);
+ twc = new CategoriesTemplateEditorWidget(value);
twt = new TeamTemplateEditorWidget(tpt);
FillCategories();
FillTeamsTemplate();
diff --git a/LongoMatch.GUI/Gui/Dialog/EditCategoryDialog.cs b/LongoMatch.GUI/Gui/Dialog/EditCategoryDialog.cs
index 989eadc..f2f296b 100644
--- a/LongoMatch.GUI/Gui/Dialog/EditCategoryDialog.cs
+++ b/LongoMatch.GUI/Gui/Dialog/EditCategoryDialog.cs
@@ -25,6 +25,10 @@ using LongoMatch.Gui.Component;
using LongoMatch.Gui;
using Mono.Unix;
+using LongoMatch.Store;
+using LongoMatch.Store.Templates;
+using LongoMatch.Interfaces;
+
namespace LongoMatch.Gui.Dialog
{
@@ -33,10 +37,11 @@ namespace LongoMatch.Gui.Dialog
{
private List<HotKey> hkList;
- public EditCategoryDialog()
+ public EditCategoryDialog(ITemplatesService ts)
{
this.Build();
timenodeproperties2.HotKeyChanged += OnHotKeyChanged;
+ timenodeproperties2.LoadSubcategories(ts);
}
public Category Category {
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index e05f0c3..da9af51 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -171,16 +171,18 @@ namespace LongoMatch.Gui
return project;
}
- public void OpenCategoriesTemplatesManager(ICategoriesTemplatesProvider tp)
+ public void OpenCategoriesTemplatesManager(ITemplatesService ts)
{
- var tManager = new TemplatesManager<Categories, Category> (tp, new CategoriesTemplateEditorWidget (tp));
+ var tManager = new TemplatesManager<Categories, Category> (ts.CategoriesTemplateProvider,
+ new CategoriesTemplateEditorWidget(ts));
tManager.TransientFor = mainWindow as Gtk.Window;
tManager.Show();
}
- public void OpenTeamsTemplatesManager(ITeamTemplatesProvider tp)
+ public void OpenTeamsTemplatesManager(ITeamTemplatesProvider teamProvider)
{
- var tManager = new TemplatesManager<TeamTemplate, Player>(tp, new TeamTemplateEditorWidget (tp));
+ var tManager = new TemplatesManager<TeamTemplate, Player> (teamProvider,
+ new TeamTemplateEditorWidget(teamProvider));
tManager.TransientFor = mainWindow as Gtk.Window;
tManager.Show();
}
@@ -267,6 +269,8 @@ namespace LongoMatch.Gui
}
if (type == ProjectType.CaptureProject)
captureSettings = npd.CaptureSettings;
+ else
+ captureSettings = new CaptureSettings();
npd.Destroy();
return project;
}
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index 0e1b491..ce2a2a6 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -374,7 +374,7 @@ namespace LongoMatch.Services
protected void OpenCategoriesTemplatesManager()
{
- guiToolkit.OpenCategoriesTemplatesManager (Core.TemplatesService.CategoriesTemplateProvider);
+ guiToolkit.OpenCategoriesTemplatesManager (Core.TemplatesService);
}
protected void OpenTeamsTemplatesManager()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]