[longomatch] Move SortMethodType Enum to Common
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Move SortMethodType Enum to Common
- Date: Sun, 30 May 2010 23:18:50 +0000 (UTC)
commit e4276c3b07273573470f88c0294cb5ee850b1840
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun May 30 20:40:16 2010 +0200
Move SortMethodType Enum to Common
LongoMatch/Common/Enums.cs | 7 +++++
LongoMatch/Gui/Component/CategoryProperties.cs | 4 +-
LongoMatch/Gui/TreeView/CategoriesTreeView.cs | 2 +-
LongoMatch/Gui/TreeView/PlaysTreeView.cs | 29 +++++++++++----------
LongoMatch/IO/SectionsReader.cs | 2 +-
LongoMatch/IO/SectionsWriter.cs | 2 +-
LongoMatch/Time/SectionsTimeNode.cs | 33 ++++++++++-------------
LongoMatch/gtk-gui/objects.xml | 16 ++++++------
8 files changed, 49 insertions(+), 46 deletions(-)
---
diff --git a/LongoMatch/Common/Enums.cs b/LongoMatch/Common/Enums.cs
index ebcb45d..b8d260e 100644
--- a/LongoMatch/Common/Enums.cs
+++ b/LongoMatch/Common/Enums.cs
@@ -40,4 +40,11 @@ namespace LongoMatch.Common
Predifined,
Free
}
+
+ public enum SortMethodType{
+ SortByName = 0,
+ SortByStartTime = 1,
+ SortByStopTime = 2,
+ SortByDuration = 3
+ }
}
diff --git a/LongoMatch/Gui/Component/CategoryProperties.cs b/LongoMatch/Gui/Component/CategoryProperties.cs
index 5978da2..41354e3 100644
--- a/LongoMatch/Gui/Component/CategoryProperties.cs
+++ b/LongoMatch/Gui/Component/CategoryProperties.cs
@@ -60,7 +60,7 @@ namespace LongoMatch.Gui.Component
nameentry.Text = stn.Name;
timeadjustwidget1.SetTimeNode(stn);
colorbutton1.Color = stn.Color;
- sortmethodcombobox.Active = (int)stn.SortingMethod;
+ sortmethodcombobox.Active = (int)stn.SortMethod;
if (stn.HotKey.Defined) {
hotKeyLabel.Text = stn.HotKey.ToString();
@@ -106,7 +106,7 @@ namespace LongoMatch.Gui.Component
protected virtual void OnSortmethodcomboboxChanged (object sender, System.EventArgs e)
{
- stn.SortingMethodString = sortmethodcombobox.ActiveText;
+ stn.SortMethodString = sortmethodcombobox.ActiveText;
}
}
}
diff --git a/LongoMatch/Gui/TreeView/CategoriesTreeView.cs b/LongoMatch/Gui/TreeView/CategoriesTreeView.cs
index 88f914a..865b219 100644
--- a/LongoMatch/Gui/TreeView/CategoriesTreeView.cs
+++ b/LongoMatch/Gui/TreeView/CategoriesTreeView.cs
@@ -128,7 +128,7 @@ namespace LongoMatch.Gui.Component
{
SectionsTimeNode tNode = (SectionsTimeNode) Model.GetValue(iter, 0);
- (cell as Gtk.CellRendererText).Text = tNode.SortingMethodString;
+ (cell as Gtk.CellRendererText).Text = tNode.SortMethodString;
}
protected virtual void OnCursorChanged(object o, System.EventArgs e) {
diff --git a/LongoMatch/Gui/TreeView/PlaysTreeView.cs b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
index 2a606bc..9a2e467 100644
--- a/LongoMatch/Gui/TreeView/PlaysTreeView.cs
+++ b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
@@ -25,6 +25,7 @@ using Gtk;
using Mono.Unix;
using LongoMatch.Handlers;
using LongoMatch.TimeNodes;
+using LongoMatch.Common;
namespace LongoMatch.Gui.Component
{
@@ -234,15 +235,15 @@ namespace LongoMatch.Gui.Component
sortByDuration.Activated += OnSortActivated;
}
- private void SetupSortMenu(SectionsTimeNode.SortMethod sortMethod){
+ private void SetupSortMenu(SortMethodType sortMethod){
switch (sortMethod) {
- case SectionsTimeNode.SortMethod.BY_NAME:
+ case SortMethodType.SortByName:
sortByName.Active = true;
break;
- case SectionsTimeNode.SortMethod.BY_START_TIME:
+ case SortMethodType.SortByStartTime:
sortByStart.Active = true;
break;
- case SectionsTimeNode.SortMethod.BY_STOP_TIME:
+ case SortMethodType.SortByStopTime:
sortByStop.Active = true;
break;
default:
@@ -302,14 +303,14 @@ namespace LongoMatch.Gui.Component
tna = model.GetValue (a, 0)as TimeNode;
tnb = model.GetValue (b, 0) as TimeNode;
- switch(category.SortingMethod){
- case(SectionsTimeNode.SortMethod.BY_NAME):
+ switch(category.SortMethod){
+ case(SortMethodType.SortByName):
return String.Compare(tna.Name, tnb.Name);
- case(SectionsTimeNode.SortMethod.BY_START_TIME):
+ case(SortMethodType.SortByStartTime):
return (tna.Start - tnb.Start).MSeconds;
- case(SectionsTimeNode.SortMethod.BY_STOP_TIME):
+ case(SortMethodType.SortByStopTime):
return (tna.Stop - tnb.Stop).MSeconds;
- case(SectionsTimeNode.SortMethod.BY_DURATION):
+ case(SortMethodType.SortByDuration):
return (tna.Duration - tnb.Duration).MSeconds;
default:
return 0;
@@ -396,7 +397,7 @@ namespace LongoMatch.Gui.Component
menu.Popup();
}
else{
- SetupSortMenu((selectedTimeNode as SectionsTimeNode).SortingMethod);
+ SetupSortMenu((selectedTimeNode as SectionsTimeNode).SortMethod);
categoriesMenu.Popup();
}
}
@@ -418,13 +419,13 @@ namespace LongoMatch.Gui.Component
category = GetValueFromPath(Selection.GetSelectedRows()[0]) as SectionsTimeNode;
if (sender == sortByName)
- category.SortingMethod = SectionsTimeNode.SortMethod.BY_NAME;
+ category.SortMethod = SortMethodType.SortByName;
else if (sender == sortByStart)
- category.SortingMethod = SectionsTimeNode.SortMethod.BY_START_TIME;
+ category.SortMethod = SortMethodType.SortByName;
else if (sender == sortByStop)
- category.SortingMethod = SectionsTimeNode.SortMethod.BY_STOP_TIME;
+ category.SortMethod = SortMethodType.SortByStopTime;
else
- category.SortingMethod = SectionsTimeNode.SortMethod.BY_DURATION;
+ category.SortMethod = SortMethodType.SortByDuration;
// Redorder plays
Model.SetSortFunc(0, SortFunction);
}
diff --git a/LongoMatch/IO/SectionsReader.cs b/LongoMatch/IO/SectionsReader.cs
index b601473..bb647e1 100644
--- a/LongoMatch/IO/SectionsReader.cs
+++ b/LongoMatch/IO/SectionsReader.cs
@@ -88,7 +88,7 @@ namespace LongoMatch.IO
name = GetName(i);
if (name != null) {
tn = new SectionsTimeNode(name, GetStartTime(i), GetStopTime(i), GetHotKey(i), GetColor(i));
- tn.SortingMethodString = GetSortMethod(i);
+ tn.SortMethodString = GetSortMethod(i);
sections.AddSection(tn);
}
else tryNext=false;
diff --git a/LongoMatch/IO/SectionsWriter.cs b/LongoMatch/IO/SectionsWriter.cs
index aea8596..bc546f3 100644
--- a/LongoMatch/IO/SectionsWriter.cs
+++ b/LongoMatch/IO/SectionsWriter.cs
@@ -92,7 +92,7 @@ namespace LongoMatch.IO
sb.Append(String.Format("<add key=\"Blue{0}\" value=\"{1}\" />",i,tn.Color.Blue));
sb.Append(String.Format("<add key=\"Modifier{0}\" value=\"{1}\" />",i,(int)(tn.HotKey.Modifier)));
sb.Append(String.Format("<add key=\"Key{0}\" value=\"{1}\" />",i,(int)(tn.HotKey.Key)));
- sb.Append(String.Format("<add key=\"SortMethod{0}\" value=\"{1}\" />",i,tn.SortingMethodString));
+ sb.Append(String.Format("<add key=\"SortMethod{0}\" value=\"{1}\" />",i,tn.SortMethodString));
i++;
}
sb.Append("</configuration>");
diff --git a/LongoMatch/Time/SectionsTimeNode.cs b/LongoMatch/Time/SectionsTimeNode.cs
index b02b3ab..8ef5353 100644
--- a/LongoMatch/Time/SectionsTimeNode.cs
+++ b/LongoMatch/Time/SectionsTimeNode.cs
@@ -22,6 +22,7 @@ using System;
using System.Runtime.Serialization;
using Gdk;
using Mono.Unix;
+using LongoMatch.Common;
namespace LongoMatch.TimeNodes
{
@@ -33,16 +34,10 @@ namespace LongoMatch.TimeNodes
[Serializable]
public class SectionsTimeNode:TimeNode, ISerializable
{
- public enum SortMethod{
- BY_NAME = 0,
- BY_START_TIME = 1,
- BY_STOP_TIME = 2,
- BY_DURATION = 3
- }
private HotKey hotkey;
private Gdk.Color color;
- private SortMethod sortMethod;
+ private SortMethodType sortMethod;
#region Constructors
@@ -68,7 +63,7 @@ namespace LongoMatch.TimeNodes
{
this.hotkey = hotkey;
this.color = color;
- this.sortMethod = SortMethod.BY_NAME;
+ this.sortMethod = SortMethodType.SortByName;
}
// this constructor is automatically called during deserialization
@@ -114,14 +109,14 @@ namespace LongoMatch.TimeNodes
//// <value>
/// Sort method used to sort plays for this category
/// </value>
- public SortMethod SortingMethod{
+ public SortMethodType SortMethod{
get{
// New in 0.15.5
try{
return sortMethod;
}
catch{
- return SortMethod.BY_NAME;
+ return SortMethodType.SortByName;
}
}
set{
@@ -129,16 +124,16 @@ namespace LongoMatch.TimeNodes
}
}
- public string SortingMethodString{
+ public string SortMethodString{
get{
switch (sortMethod){
- case SortMethod.BY_NAME:
+ case SortMethodType.SortByName:
return Catalog.GetString("Sort by name");
- case SortMethod.BY_START_TIME:
+ case SortMethodType.SortByStartTime:
return Catalog.GetString("Sort by start time");
- case SortMethod.BY_STOP_TIME:
+ case SortMethodType.SortByStopTime:
return Catalog.GetString("Sort by stop time");
- case SortMethod.BY_DURATION:
+ case SortMethodType.SortByDuration:
return Catalog.GetString("Sort by duration");
default:
return Catalog.GetString("Sort by name");
@@ -146,13 +141,13 @@ namespace LongoMatch.TimeNodes
}
set{
if (value == Catalog.GetString("Sort by start time"))
- sortMethod = SortMethod.BY_START_TIME;
+ sortMethod = SortMethodType.SortByStartTime;
else if (value == Catalog.GetString("Sort by stop time"))
- sortMethod = SortMethod.BY_STOP_TIME;
+ sortMethod = SortMethodType.SortByStopTime;
else if (value == Catalog.GetString("Sort by duration"))
- sortMethod = SortMethod.BY_DURATION;
+ sortMethod = SortMethodType.SortByDuration;
else
- sortMethod = SortMethod.BY_NAME;
+ sortMethod = SortMethodType.SortByName;
}
}
// this method is automatically called during serialization
diff --git a/LongoMatch/gtk-gui/objects.xml b/LongoMatch/gtk-gui/objects.xml
index 6a0f9ab..7d23639 100644
--- a/LongoMatch/gtk-gui/objects.xml
+++ b/LongoMatch/gtk-gui/objects.xml
@@ -174,14 +174,6 @@
<itemgroups />
<signals />
</object>
- <object type="LongoMatch.Gui.Component.ProjectTemplateWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
- <itemgroups>
- <itemgroup label="ProjectTemplateWidget Properties">
- <property name="Edited" />
- </itemgroup>
- </itemgroups>
- <signals />
- </object>
<object type="LongoMatch.Gui.Component.PlaysListTreeWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
<itemgroups />
<signals>
@@ -273,4 +265,12 @@
</itemgroup>
</signals>
</object>
+ <object type="LongoMatch.Gui.Component.ProjectTemplateWidget" palette-category="LongoMatch" allow-children="false" base-type="Gtk.Bin">
+ <itemgroups>
+ <itemgroup label="ProjectTemplateWidget Properties">
+ <property name="Edited" />
+ </itemgroup>
+ </itemgroups>
+ <signals />
+ </object>
</objects>
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]