[longomatch/redesign2: 101/140] Make use of the templates service
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign2: 101/140] Make use of the templates service
- Date: Tue, 24 May 2011 22:04:35 +0000 (UTC)
commit 2b7a078fe7a9512b7a7a2b61d7ea3d7f6e0c4482
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Mar 30 22:28:08 2011 +0200
Make use of the templates service
LongoMatch/Gui/Component/CategoryProperties.cs | 76 ++++++++++++++++------
LongoMatch/Gui/Component/ProjectDetailsWidget.cs | 49 +++++++-------
2 files changed, 81 insertions(+), 44 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/CategoryProperties.cs b/LongoMatch/Gui/Component/CategoryProperties.cs
index e4f54dc..3255da1 100644
--- a/LongoMatch/Gui/Component/CategoryProperties.cs
+++ b/LongoMatch/Gui/Component/CategoryProperties.cs
@@ -19,10 +19,15 @@
//
using System;
+using System.Collections.Generic;
using Gdk;
using Gtk;
using Mono.Unix;
+
+using LongoMatch.Interfaces;
+using LongoMatch.Services;
using LongoMatch.Store;
+using LongoMatch.Store.Templates;
using LongoMatch.Gui.Dialog;
namespace LongoMatch.Gui.Component
@@ -37,32 +42,51 @@ namespace LongoMatch.Gui.Component
public event HotKeyChangeHandler HotKeyChanged;
- private Category stn;
+ private Category cat;
+ private ITemplateProvider<SubCategoryTemplate, string> subcategoriesTemplates;
+ private Dictionary<string, TagSubCategory> subCategories;
public CategoryProperties()
{
this.Build();
+ subcategoriesTemplates = MainClass.ts.SubCategoriesTemplateProvider;
+ LoadSubcategories();
}
+ private void LoadSubcategories() {
+ foreach (TagSubCategory subcat in subcategoriesTemplates.Templates) {
+ subCategories.Add(subcat.Name, subcat);
+ subcatcombobox.AppendText(subcat.Name);
+ }
+
+ /* We check here if the user already saved at least one category
+ * to hide the big helper button.*/
+ if (subCategories.Count != 0) {
+ newfirstbutton.Visible = false;
+ }
+ }
+
public Category Category {
set {
- stn = value;
+ cat = value;
UpdateGui();
}
get {
- return stn;
+ return cat;
}
}
private void UpdateGui() {
- if(stn != null) {
- nameentry.Text = stn.Name;
- timeadjustwidget1.SetTimeNode(stn);
- colorbutton1.Color = stn.Color;
- sortmethodcombobox.Active = (int)stn.SortMethod;
-
- if(stn.HotKey.Defined) {
- hotKeyLabel.Text = stn.HotKey.ToString();
+ if(cat != null) {
+ nameentry.Text = cat.Name;
+
+ lagtimebutton.Value = cat.Start.Seconds;
+ leadtimebutton.Value = cat.Stop.Seconds;
+ colorbutton1.Color = cat.Color;
+ sortmethodcombobox.Active = (int)cat.SortMethod;
+
+ if(cat.HotKey.Defined) {
+ hotKeyLabel.Text = cat.HotKey.ToString();
}
else hotKeyLabel.Text = Catalog.GetString("none");
}
@@ -72,40 +96,52 @@ namespace LongoMatch.Gui.Component
{
HotKeySelectorDialog dialog = new HotKeySelectorDialog();
dialog.TransientFor=(Gtk.Window)this.Toplevel;
- HotKey prevHotKey = stn.HotKey;
+ HotKey prevHotKey = cat.HotKey;
if(dialog.Run() == (int)ResponseType.Ok) {
- stn.HotKey=dialog.HotKey;
+ cat.HotKey=dialog.HotKey;
UpdateGui();
}
dialog.Destroy();
if(HotKeyChanged != null)
- HotKeyChanged(prevHotKey,stn);
+ HotKeyChanged(prevHotKey,cat);
}
protected virtual void OnColorbutton1ColorSet(object sender, System.EventArgs e)
{
- if(stn != null)
- stn.Color=colorbutton1.Color;
+ if(cat != null)
+ cat.Color=colorbutton1.Color;
}
protected virtual void OnTimeadjustwidget1LeadTimeChanged(object sender, System.EventArgs e)
{
- stn.Start = timeadjustwidget1.GetStartTime();
+ cat.Start = new Time{Seconds=(int)leadtimebutton.Value};
}
protected virtual void OnTimeadjustwidget1LagTimeChanged(object sender, System.EventArgs e)
{
- stn.Stop= timeadjustwidget1.GetStopTime();
+ cat.Stop = new Time{Seconds=(int)lagtimebutton.Value};
}
protected virtual void OnNameentryChanged(object sender, System.EventArgs e)
{
- stn.Name = nameentry.Text;
+ cat.Name = nameentry.Text;
}
protected virtual void OnSortmethodcomboboxChanged(object sender, System.EventArgs e)
{
- stn.SortMethodString = sortmethodcombobox.ActiveText;
+ cat.SortMethodString = sortmethodcombobox.ActiveText;
+ }
+
+ protected virtual void OnNewfirstbuttonClicked (object sender, System.EventArgs e)
+ {
+ }
+
+ protected virtual void OnAddbuttonClicked (object sender, System.EventArgs e)
+ {
+ }
+
+ protected virtual void OnNewbuttonClicked (object sender, System.EventArgs e)
+ {
}
}
}
diff --git a/LongoMatch/Gui/Component/ProjectDetailsWidget.cs b/LongoMatch/Gui/Component/ProjectDetailsWidget.cs
index 7bba332..92d26a8 100644
--- a/LongoMatch/Gui/Component/ProjectDetailsWidget.cs
+++ b/LongoMatch/Gui/Component/ProjectDetailsWidget.cs
@@ -550,40 +550,41 @@ namespace LongoMatch.Gui.Component
protected virtual void OnEditbuttonClicked(object sender, System.EventArgs e)
{
- ProjectTemplateEditorDialog ted = new ProjectTemplateEditorDialog();
- ted.TransientFor = (Window)Toplevel;
- ted.Categories = Categories;
- ted.Project = project;
- ted.CanExport = Use == ProjectType.EditProject;
- if(ted.Run() == (int)ResponseType.Apply) {
- Categories = ted.Categories;
- }
- ted.Destroy();
+ var editor = new TemplateEditorDialog<Categories, Category>();
+
+ editor.TransientFor = (Window)Toplevel;
+ editor.Template = Categories;
+ editor.InProject = true;
+ editor.CanExport = Use == ProjectType.EditProject;
+ if(editor.Run() == (int)ResponseType.Apply) {
+ Categories = editor.Template;
+ }
+ editor.Destroy();
OnEdited(this,null);
}
protected virtual void OnLocaltemplatebuttonClicked(object sender, System.EventArgs e) {
- TeamTemplateEditor tted = new TeamTemplateEditor();
- tted.TransientFor = (Window)Toplevel;
- tted.Title=Catalog.GetString("Local Team Template");
- tted.Template = LocalTeamTemplate;
+ var editor = new TemplateEditorDialog<TeamTemplate, Player>();
+ editor.TransientFor = (Window)Toplevel;
+ editor.Title=Catalog.GetString("Local Team Template");
+ editor.Template = LocalTeamTemplate;
- if(tted.Run() == (int)ResponseType.Apply) {
- LocalTeamTemplate = tted.Template;
+ if(editor.Run() == (int)ResponseType.Apply) {
+ LocalTeamTemplate = editor.Template;
}
- tted.Destroy();
+ editor.Destroy();
OnEdited(this,null);
}
protected virtual void OnVisitorbuttonClicked(object sender, System.EventArgs e) {
- TeamTemplateEditor tted = new TeamTemplateEditor();
- tted.TransientFor = (Window)Toplevel;
- tted.Title=Catalog.GetString("Visitor Team Template");
- tted.Template = VisitorTeamTemplate;
- if(tted.Run() == (int)ResponseType.Apply) {
- VisitorTeamTemplate = tted.Template;
- }
- tted.Destroy();
+ var editor = new TemplateEditorDialog<TeamTemplate, Player>();
+ editor.TransientFor = (Window)Toplevel;
+ editor.Title=Catalog.GetString("Visitor Team Template");
+ editor.Template = VisitorTeamTemplate;
+ if(editor.Run() == (int)ResponseType.Apply) {
+ VisitorTeamTemplate = editor.Template;
+ }
+ editor.Destroy();
OnEdited(this,null);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]