[longomatch] Add support for creating and deleting periods



commit 5f8297401934dcf5431a252507b6ec040146941e
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Oct 14 13:40:47 2014 +0200

    Add support for creating and deleting periods

 LongoMatch.Drawing/CanvasObjects/TimelineObject.cs |   52 ++++++++++--
 LongoMatch.Drawing/Widgets/PlaysTimeline.cs        |   45 ++++++-----
 LongoMatch.Drawing/Widgets/TimersTimeline.cs       |   35 +++++----
 LongoMatch.GUI/Gui/Component/ProjectPeriods.cs     |   82 +++++++-------------
 LongoMatch.GUI/Gui/Component/Timeline.cs           |   13 +++-
 LongoMatch.GUI/Gui/Menu/PeriodsMenu.cs             |   83 ++++++++++++++++++++
 LongoMatch.GUI/LongoMatch.GUI.csproj               |    1 -
 LongoMatch.GUI/Makefile.am                         |    1 +
 .../LongoMatch.Gui.Component.ProjectPeriods.cs     |    1 +
 9 files changed, 209 insertions(+), 104 deletions(-)
---
diff --git a/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs 
b/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
index 9eec3ad..22cb284 100644
--- a/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
@@ -50,9 +50,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                
                protected override void Dispose (bool disposing)
                {
-                       foreach (TimeNodeObject tn in nodes) {
-                               tn.Dispose ();
-                       }
+                       ClearObjects ();
                        selectionBorderL.Dispose ();
                        selectionBorderR.Dispose ();
                        base.Dispose (disposing);
@@ -109,7 +107,22 @@ namespace LongoMatch.Drawing.CanvasObjects
                        
                        to = nodes.FirstOrDefault (n => n.TimeNode == node);
                        if (to != null) {
-                               to.RedrawEvent -= HandleRedrawEvent;
+                               RemoveObject (to, true);
+                       }
+               }
+
+               protected void ClearObjects () {
+                       foreach (TimeNodeObject tn in nodes) {
+                               RemoveObject (tn, false);
+                       }
+                       nodes.Clear ();
+               }
+
+               protected void RemoveObject (TimeNodeObject to, bool full)
+               {
+                       to.RedrawEvent -= HandleRedrawEvent;
+                       to.Dispose ();
+                       if (full) {
                                nodes.Remove (to);
                        }
                }
@@ -256,11 +269,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                        ShowLine = showLine;
                        LineColor = lineColor;
        
-                       foreach (Timer t in timers) {
-                               foreach (TimeNode tn in t.Nodes) {
-                                       AddTimeNode (t, tn);
-                               }
-                       }
+                       ReloadPeriods (timers);
                }
 
                Color LineColor {
@@ -288,6 +297,23 @@ namespace LongoMatch.Drawing.CanvasObjects
                        return nodes.FirstOrDefault (n => n.TimeNode == tn) != null;
                }
 
+               public void AddTimer (Timer timer)
+               {
+                       foreach (TimeNode tn in timer.Nodes) {
+                               AddTimeNode (timer, tn);
+                       }
+                       ReDraw ();
+               }
+
+               public void RemoveTimer (Timer timer)
+               {
+                       TimerTimeNodeObject to = (TimerTimeNodeObject) nodes.FirstOrDefault (t => (t as 
TimerTimeNodeObject).Timer == timer);
+                       if (to != null) {
+                               RemoveObject (to, true);
+                       }
+                       ReDraw ();
+               }
+
                public void AddTimeNode (Timer t, TimeNode tn)
                {
                        TimerTimeNodeObject to = new TimerTimeNodeObject (t, tn);
@@ -300,6 +326,14 @@ namespace LongoMatch.Drawing.CanvasObjects
                        AddNode (to);
                }
 
+               public void ReloadPeriods (List<Timer> timers)
+               {
+                       ClearObjects ();
+                       foreach (Timer t in timers) {
+                               AddTimer (t);
+                       }
+               }
+
                protected override void DrawBackground (IDrawingToolkit tk, Area area)
                {
                        double linepos;
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index 60717f1..9a308d3 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -39,7 +39,6 @@ namespace LongoMatch.Drawing.Widgets
                double secondsPerPixel;
                Time duration;
                TimelineEvent loadedEvent;
-               TimerTimeline periodsTimeline;
                Dictionary<TimelineObject, object> timelineToFilter;
                Dictionary<EventType, CategoryTimeline> eventsTimelines;
 
@@ -50,7 +49,7 @@ namespace LongoMatch.Drawing.Widgets
                        secondsPerPixel = 0.1;
                        Accuracy = Constants.TIMELINE_ACCURACY;
                        SelectionMode = MultiSelectionMode.MultipleWithModifier;
-                       SingleSelectionObjects.Add (typeof (TimerTimeNodeObject));
+                       SingleSelectionObjects.Add (typeof(TimerTimeNodeObject));
                }
 
                protected override void Dispose (bool disposing)
@@ -94,6 +93,11 @@ namespace LongoMatch.Drawing.Widgets
                        }
                }
 
+               public TimerTimeline PeriodsTimeline {
+                       get;
+                       set;
+               }
+
                public void LoadPlay (TimelineEvent play)
                {
                        if (play == this.loadedEvent) {
@@ -146,7 +150,7 @@ namespace LongoMatch.Drawing.Widgets
                void AddTimeline (TimelineObject tl, object filter)
                {
                        AddObject (tl);
-                       timelineToFilter[tl] = filter;
+                       timelineToFilter [tl] = filter;
                        if (tl is CategoryTimeline) {
                                eventsTimelines [filter as EventType] = tl as CategoryTimeline;
                        } 
@@ -157,18 +161,18 @@ namespace LongoMatch.Drawing.Widgets
                        TimelineObject tl;
                        int i = 0;
 
-                       tl = new TimerTimeline (project.Periods.Select (p => p as Timer).ToList(),
+                       tl = new TimerTimeline (project.Periods.Select (p => p as Timer).ToList (),
                                                true, true, false, duration,
                                                i * StyleConf.TimelineCategoryHeight,
                                                Utils.ColorForRow (i), Config.Style.PaletteBackgroundDark);
                        AddTimeline (tl, null);
-                       periodsTimeline = tl as TimerTimeline;
+                       PeriodsTimeline = tl as TimerTimeline;
                        i++;
 
                        foreach (Timer t in project.Timers) {
-                               tl = new TimerTimeline (new List<Timer> {t}, false, true, false, duration,
-                               i * StyleConf.TimelineCategoryHeight,
-                               Utils.ColorForRow (i), Config.Style.PaletteBackgroundDark);
+                               tl = new TimerTimeline (new List<Timer> { t }, false, true, false, duration,
+                                                       i * StyleConf.TimelineCategoryHeight,
+                                                       Utils.ColorForRow (i), 
Config.Style.PaletteBackgroundDark);
                                AddTimeline (tl, t);
                        }
                                                
@@ -187,7 +191,7 @@ namespace LongoMatch.Drawing.Widgets
                {
                        int i = 0;
                        foreach (TimelineObject timeline in Objects) {
-                               if (playsFilter.IsVisible (timelineToFilter[timeline])) {
+                               if (playsFilter.IsVisible (timelineToFilter [timeline])) {
                                        timeline.OffsetY = i * timeline.Height;
                                        timeline.Visible = true;
                                        timeline.BackgroundColor = Utils.ColorForRow (i);
@@ -201,10 +205,10 @@ namespace LongoMatch.Drawing.Widgets
 
                void ShowTimersMenu (Point coords)
                {
-                       if (coords.Y >= periodsTimeline.OffsetY &&
-                               coords.Y < periodsTimeline.OffsetY + periodsTimeline.Height) {
-                               Timer t = Selections.FirstOrDefault.Select (p => (p.Drawable as 
TimerTimeNodeObject).Timer);
-                               if (ShowTimerMenuEvent != nul) {
+                       if (coords.Y >= PeriodsTimeline.OffsetY &&
+                               coords.Y < PeriodsTimeline.OffsetY + PeriodsTimeline.Height) {
+                               Timer t = Selections.Select (p => (p.Drawable as 
TimerTimeNodeObject).Timer).FirstOrDefault ();
+                               if (ShowTimerMenuEvent != null) {
                                        ShowTimerMenuEvent (t, Utils.PosToTime (coords, SecondsPerPixel));
                                }
                        } else {
@@ -215,7 +219,8 @@ namespace LongoMatch.Drawing.Widgets
                        }
                }
 
-               void ShowPlaysMenu (Point coords) {
+               void ShowPlaysMenu (Point coords)
+               {
                        EventType ev = null;
                        List<TimelineEvent> plays;
                        
@@ -261,19 +266,17 @@ namespace LongoMatch.Drawing.Widgets
                        }
                }
 
-               protected override void StopMove ()
+               protected override void StopMove (bool moved)
                {
                        widget.SetCursor (CursorType.Arrow);
                }
 
                protected override void ShowMenu (Point coords)
                {
-                       if (Selections.Count > 0) {
-                               if (Selections.Last ().Drawable is PlayObject) {
-                                       ShowPlaysMenu (coords);
-                               } else {
-                                       ShowTimersMenu (coords);
-                               }
+                       if (Selections.Count > 1 && Selections.Last ().Drawable is PlayObject) {
+                               ShowPlaysMenu (coords);
+                       } else {
+                               ShowTimersMenu (coords);
                        }
                }
 
diff --git a/LongoMatch.Drawing/Widgets/TimersTimeline.cs b/LongoMatch.Drawing/Widgets/TimersTimeline.cs
index 31791af..80949ae 100644
--- a/LongoMatch.Drawing/Widgets/TimersTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/TimersTimeline.cs
@@ -16,6 +16,7 @@ namespace LongoMatch.Drawing.Widgets
                public event ShowTimerMenuHandler ShowTimerMenuEvent;
 
                double secondsPerPixel;
+               TimerTimeline timertimeline;
                Time duration;
                Dictionary <Timer, TimerTimeline> timers;
 
@@ -28,18 +29,24 @@ namespace LongoMatch.Drawing.Widgets
 
                public void LoadPeriods (List<Period> periods, Time duration)
                {
-                       LoadTimers (periods.Select (p => p as Timer).ToList (), duration, false);
+                       LoadTimers (periods.Select (p => p as Timer).ToList (), duration);
                }
 
-               public void LoadTimers (List<Timer> timers, Time duration, bool splitTimers = true)
+               public void LoadTimers (List<Timer> timers, Time duration)
                {
                        ClearObjects ();
                        this.timers = new Dictionary<Timer, TimerTimeline> ();
                        this.duration = duration;
-                       FillCanvas (timers, splitTimers);
+                       FillCanvas (timers);
                        widget.ReDraw ();
                }
 
+               public TimerTimeline TimerTimeline {
+                       get {
+                               return timertimeline;
+                       }
+               }
+
                public Time CurrentTime {
                        set {
                                foreach (TimerTimeline tl in timers.Values) {
@@ -72,20 +79,16 @@ namespace LongoMatch.Drawing.Widgets
                        }
                }
 
-               void FillCanvas (List<Timer> timers, bool splitTimers)
+               void FillCanvas (List<Timer> timers)
                {
-                       if (!splitTimers) {
-                               widget.Height = Constants.TIMER_HEIGHT;
-                               TimerTimeline tl = new TimerTimeline (timers, true, true, true, duration, 0,
-                                                                     Config.Style.PaletteBackground,
-                                                                     Config.Style.PaletteBackgroundLight);
-                               foreach (Timer t in timers) {
-                                       this.timers [t] = tl;
-                               }
-                               AddObject (tl);
-                       } else {
-                               widget.Height = timers.Count * Constants.TIMER_HEIGHT;
+                       widget.Height = Constants.TIMER_HEIGHT;
+                       timertimeline = new TimerTimeline (timers, true, true, true, duration, 0,
+                                                          Config.Style.PaletteBackground,
+                                                          Config.Style.PaletteBackgroundLight);
+                       foreach (Timer t in timers) {
+                               this.timers [t] = timertimeline;
                        }
+                       AddObject (timertimeline);
                        Update ();
                }
 
@@ -118,7 +121,7 @@ namespace LongoMatch.Drawing.Widgets
                                TimeNodeChanged (tn, moveTime);
                        }
                }
-               
+
                protected override void ShowMenu (Point coords)
                {
                        if (ShowTimerMenuEvent != null) {
diff --git a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
index f6ba571..11def2c 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
@@ -21,20 +21,20 @@ using System.Collections.Generic;
 using LongoMatch.Drawing.Widgets;
 using LongoMatch.Drawing.Cairo;
 using Mono.Unix;
-using LongoMatch.Gui.Helpers;
 using LongoMatch.Core.Common;
-using Gtk;
+using LongoMatch.Gui.Menus;
 
 namespace LongoMatch.Gui.Component
 {
        [System.ComponentModel.ToolboxItem(true)]
        public partial class ProjectPeriods : Gtk.Bin
        {
-               TimersTimeline timersTimenline;
+               TimersTimeline timersTimeline;
                Timerule timerule;
                Time duration;
                Project project;
-               
+               PeriodsMenu menu;
+
                public ProjectPeriods ()
                {
                        this.Build ();
@@ -43,23 +43,24 @@ namespace LongoMatch.Gui.Component
                        playerbin2.Tick += HandleTick;
                        playerbin2.ShowControls = false;
                        timerule = new Timerule (new WidgetWrapper (drawingarea1));
-                       timersTimenline = new TimersTimeline (new WidgetWrapper (drawingarea2));
+                       timersTimeline = new TimersTimeline (new WidgetWrapper (drawingarea2));
                        drawingarea1.HeightRequest = LongoMatch.Drawing.Constants.TIMERULE_HEIGHT;
                        drawingarea2.HeightRequest = LongoMatch.Drawing.Constants.TIMER_HEIGHT;
-                       timersTimenline.TimeNodeChanged += HandleTimeNodeChanged;
-                       timersTimenline.ShowTimerMenuEvent += HandleShowTimerMenuEvent;
+                       timersTimeline.TimeNodeChanged += HandleTimeNodeChanged;
+                       timersTimeline.ShowTimerMenuEvent += HandleShowTimerMenuEvent;
                        scrolledwindow2.Hadjustment.ValueChanged += HandleValueChanged;
                        synclabel.Markup = String.Format ("{0} {1} {2}", "<b>⬇  ",
-                                                       Catalog.GetString ("Synchronize the game periods"),
-                                                       "  ⬇</b>");
+                                                         Catalog.GetString ("Synchronize the game periods"),
+                                                         "  ⬇</b>");
                        LongoMatch.Gui.Helpers.Misc.SetFocus (this, false);
+                       menu = new PeriodsMenu ();
                }
 
                protected override void OnDestroyed ()
                {
                        playerbin2.Destroy ();
                        timerule.Dispose ();
-                       timersTimenline.Dispose ();
+                       timersTimeline.Dispose ();
                        base.OnDestroyed ();
                }
 
@@ -85,30 +86,31 @@ namespace LongoMatch.Gui.Component
                                playerbin2.Open (value.Description.FileSet);
                                
                                foreach (string s in gamePeriods) {
-                                       Period period = new Period {Name = s};
+                                       Period period = new Period { Name = s };
                                        period.StartTimer (start);
                                        period.StopTimer (start + pDuration);
                                        periods.Add (period);
                                        start += pDuration;
                                }
                                value.Periods = periods;
-                               timersTimenline.LoadPeriods (periods, duration);
+                               timersTimeline.LoadPeriods (periods, duration);
                        }
                }
-               
-               void SetZoom () {
+
+               void SetZoom ()
+               {
                        if (duration != null) {
-                               double spp = (double) duration.Seconds / drawingarea1.Allocation.Width;
-                               int secondsPerPixel = (int) Math.Ceiling (spp);
+                               double spp = (double)duration.Seconds / drawingarea1.Allocation.Width;
+                               int secondsPerPixel = (int)Math.Ceiling (spp);
                                timerule.SecondsPerPixel = secondsPerPixel;
-                               timersTimenline.SecondsPerPixel = secondsPerPixel;
+                               timersTimeline.SecondsPerPixel = secondsPerPixel;
                        }
                }
-               
+
                void HandleTick (Time currentTime)
                {
                        timerule.CurrentTime = currentTime;
-                       timersTimenline.CurrentTime = currentTime;
+                       timersTimeline.CurrentTime = currentTime;
                        drawingarea1.QueueDraw ();
                        drawingarea2.QueueDraw ();
                }
@@ -125,52 +127,24 @@ namespace LongoMatch.Gui.Component
                        timerule.Scroll = scrolledwindow2.Hadjustment.Value;
                        drawingarea1.QueueDraw ();
                }
-               
+
                void HandleZooomActivated (object sender, EventArgs e)
                {
                        if (sender == zoomoutbutton) {
                                timerule.SecondsPerPixel ++;
-                               timersTimenline.SecondsPerPixel ++;
+                               timersTimeline.SecondsPerPixel ++;
                        } else {
                                timerule.SecondsPerPixel = Math.Max (1, timerule.SecondsPerPixel - 1);
-                               timersTimenline.SecondsPerPixel = Math.Max (1, 
timersTimenline.SecondsPerPixel - 1);
+                               timersTimeline.SecondsPerPixel = Math.Max (1, timersTimeline.SecondsPerPixel 
- 1);
                        }
-                       drawingarea1.QueueDraw();
-                       drawingarea2.QueueDraw();
+                       drawingarea1.QueueDraw ();
+                       drawingarea2.QueueDraw ();
                }
-               
+
                void HandleShowTimerMenuEvent (Timer timer, Time time)
                {
-                       Menu menu = new Menu ();
-                       MenuItem additem = new MenuItem (Catalog.GetString ("Add period"));
-                       additem.Activated += (sender, e) => {
-                               string periodname = Config.GUIToolkit.QueryMessage (Catalog.GetString 
("Period name"), null,
-                                                                                   (project.Periods.Count + 
1).ToString(),
-                                                                                   this);
-                               if (periodname != null) {
-                                       project.Dashboard.GamePeriods.Add (periodname);
-                                       Period p = new Period {Name = periodname};
-                                       p.Nodes.Add (new TimeNode {
-                                               Name = periodname,
-                                               Start = new Time {Seconds = time.Seconds - 10},
-                                               Stop = new Time {Seconds = time.Seconds + 10}});
-                                       project.Periods.Add (p);
-                                       timersTimenline.LoadPeriods (project.Periods, duration);
-                               }
-                       };
-                       menu.Add (additem);
-                       if (timer != null) {
-                               MenuItem delitem = new MenuItem (Catalog.GetString ("Delete period"));
-                               delitem.Activated += (sender, e) => {
-                                       project.Periods.Remove (timer as Period);
-                                       timersTimenline.LoadPeriods (project.Periods, duration);
-                               };
-                               menu.Add (delitem);
-                       }
-                       menu.ShowAll ();
-                       menu.Popup ();
+                       menu.ShowMenu (project, timer, time, timersTimeline.TimerTimeline);
                }
-               
        }
 }
 
diff --git a/LongoMatch.GUI/Gui/Component/Timeline.cs b/LongoMatch.GUI/Gui/Component/Timeline.cs
index ff13e7e..091ab25 100644
--- a/LongoMatch.GUI/Gui/Component/Timeline.cs
+++ b/LongoMatch.GUI/Gui/Component/Timeline.cs
@@ -18,12 +18,9 @@
 using System;
 using LongoMatch.Drawing.Widgets;
 using LongoMatch.Core.Store;
-using LongoMatch.Core.Handlers;
 using LongoMatch.Core.Common;
 using System.Collections.Generic;
-using LongoMatch.Core.Interfaces;
 using LongoMatch.Drawing.Cairo;
-using LongoMatch.Drawing;
 using Gtk;
 using Mono.Unix;
 using LongoMatch.Gui.Menus;
@@ -43,6 +40,7 @@ namespace LongoMatch.Gui.Component
                Time currentTime, nextCurrentTime;
                PlaysMenu menu;
                Project project;
+               PeriodsMenu periodsmenu;
 
                public Timeline ()
                {
@@ -69,6 +67,8 @@ namespace LongoMatch.Gui.Component
                        zoomoutimage.Pixbuf = LongoMatch.Gui.Helpers.Misc.LoadIcon ("longomatch-zoom-out", 
14);
                        zoominimage.HeightRequest = zoomoutimage.HeightRequest = focusscale.HeightRequest = 
16;
                        menu = new PlaysMenu ();
+                       periodsmenu = new PeriodsMenu ();
+                       
                }
 
                protected override void OnDestroyed ()
@@ -114,6 +114,7 @@ namespace LongoMatch.Gui.Component
                        timerule.Duration = project.Description.FileSet.GetAngle 
(MediaFileAngle.Angle1).Duration;
                        timeline.ShowMenuEvent += HandleShowMenu;
                        timeline.ShowTimersMenuEvent += HandleShowTimersMenu;
+                       timeline.ShowTimerMenuEvent += HandleShowTimerMenuEvent;
                        QueueDraw ();
                }
 
@@ -201,6 +202,12 @@ namespace LongoMatch.Gui.Component
                        m.ShowAll ();
                        m.Popup ();
                }
+               
+               void HandleShowTimerMenuEvent (Timer timer, Time time)
+               {
+                       periodsmenu.ShowMenu (project, timer, time, timeline.PeriodsTimeline);
+               }
+
        }
 }
 
diff --git a/LongoMatch.GUI/Gui/Menu/PeriodsMenu.cs b/LongoMatch.GUI/Gui/Menu/PeriodsMenu.cs
new file mode 100644
index 0000000..52f9947
--- /dev/null
+++ b/LongoMatch.GUI/Gui/Menu/PeriodsMenu.cs
@@ -0,0 +1,83 @@
+//
+//  Copyright (C) 2014 Andoni Morales Alastruey
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using Gtk;
+using LongoMatch.Core.Store;
+using Mono.Unix;
+using LongoMatch.Drawing.CanvasObjects;
+
+namespace LongoMatch.Gui.Menus
+{
+       public class PeriodsMenu: Gtk.Menu
+       {
+               MenuItem additem, delitem;
+               Timer timer;
+               Time time;
+               Project project;
+               TimerTimeline timertimeline;
+
+               public PeriodsMenu ()
+               {
+                       CreateMenu ();
+               }
+
+               public void ShowMenu (Project project, Timer timer, Time time,
+                                     TimerTimeline timertimeline)
+               {
+                       this.timer = timer;
+                       this.time = time;
+                       this.project = project;
+                       this.timertimeline = timertimeline;
+                       delitem.Visible = project != null && timer != null;
+                       Popup ();
+               }
+               
+               void CreateMenu ()
+               {
+                       additem = new MenuItem (Catalog.GetString ("Add period"));
+                       additem.Activated += (sender, e) => {
+                               string periodname = Config.GUIToolkit.QueryMessage (Catalog.GetString 
("Period name"), null,
+                                                                                   (project.Periods.Count + 
1).ToString(),
+                                                                                   this);
+                               if (periodname != null) {
+                                       project.Dashboard.GamePeriods.Add (periodname);
+                                       Period p = new Period {Name = periodname};
+                                       p.Nodes.Add (new TimeNode {
+                                               Name = periodname,
+                                               Start = new Time {Seconds = time.Seconds - 10},
+                                               Stop = new Time {Seconds = time.Seconds + 10}});
+                                       project.Periods.Add (p);
+                                       if (timertimeline != null) {
+                                               timertimeline.AddTimer (p);
+                                       }
+                               }
+                       };
+                       Add (additem);
+                       delitem = new MenuItem (Catalog.GetString ("Delete period"));
+                       delitem.Activated += (sender, e) => {
+                               project.Periods.Remove (timer as Period);
+                               if (timertimeline != null) {
+                                       timertimeline.RemoveTimer (timer);
+                               }
+                       };
+                       Add (delitem);
+                       ShowAll ();
+               }
+       }
+}
+
diff --git a/LongoMatch.GUI/LongoMatch.GUI.csproj b/LongoMatch.GUI/LongoMatch.GUI.csproj
index 8205188..ca99c66 100644
--- a/LongoMatch.GUI/LongoMatch.GUI.csproj
+++ b/LongoMatch.GUI/LongoMatch.GUI.csproj
@@ -190,7 +190,6 @@
     <Compile Include="Gui\Component\MediaFileSetSelection.cs" />
     <Compile Include="gtk-gui\LongoMatch.Gui.Component.MediaFileSetSelection.cs" />
     <Compile Include="Gui\Menu\PeriodsMenu.cs" />
-    <Compile Include="gtk-gui\LongoMatch.Gui.Menu.PeriodsMenu.cs" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="gtk-gui\gui.stetic">
diff --git a/LongoMatch.GUI/Makefile.am b/LongoMatch.GUI/Makefile.am
index cef6626..6ae53c0 100644
--- a/LongoMatch.GUI/Makefile.am
+++ b/LongoMatch.GUI/Makefile.am
@@ -63,6 +63,7 @@ SOURCES = Gui/Cairo.cs \
        Gui/GUIToolkit.cs \
        Gui/GtkGlue.cs \
        Gui/MainWindow.cs \
+       Gui/Menu/PeriodsMenu.cs \
        Gui/Menu/PlaysMenu.cs \
        Gui/Panel/NewProjectPanel.cs \
        Gui/Panel/OpenProjectPanel.cs \
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
index bbff674..49acab1 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
@@ -115,6 +115,7 @@ namespace LongoMatch.Gui.Component
                        this.scrolledwindow2 = new global::Gtk.ScrolledWindow ();
                        this.scrolledwindow2.HeightRequest = 50;
                        this.scrolledwindow2.CanFocus = true;
+                       this.scrolledwindow2.Name = "scrolledwindow2";
                        // Container child scrolledwindow2.Gtk.Container+ContainerChild
                        global::Gtk.Viewport w23 = new global::Gtk.Viewport ();
                        w23.ShadowType = ((global::Gtk.ShadowType)(0));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]