[longomatch] Fix selection and scroll adding new events to the list
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Fix selection and scroll adding new events to the list
- Date: Tue, 11 Nov 2014 17:59:42 +0000 (UTC)
commit 71f8c1a965e3a5d79230e8fbd00452711c31f691
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Nov 10 17:45:56 2014 +0100
Fix selection and scroll adding new events to the list
.../Gui/Component/PlaysListTreeWidget.cs | 93 ++++++++++----------
LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs | 9 ++
...LongoMatch.Gui.Component.PlaysListTreeWidget.cs | 18 ++---
LongoMatch.GUI/gtk-gui/gui.stetic | 18 ++---
LongoMatch.Services/Services/EventsManager.cs | 2 +-
5 files changed, 68 insertions(+), 72 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
index e646608..cd8cd55 100644
--- a/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/PlaysListTreeWidget.cs
@@ -17,7 +17,6 @@
//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
//
-
using System;
using System.Collections.Generic;
using Gtk;
@@ -28,8 +27,6 @@ using LongoMatch.Gui.Dialog;
namespace LongoMatch.Gui.Component
{
-
-
[System.ComponentModel.Category("LongoMatch")]
[System.ComponentModel.ToolboxItem(true)]
public partial class PlaysListTreeWidget : Gtk.Bin
@@ -38,15 +35,15 @@ namespace LongoMatch.Gui.Component
Project project;
Dictionary<EventType, TreeIter> itersDic;
- public PlaysListTreeWidget()
+ public PlaysListTreeWidget ()
{
- this.Build();
+ this.Build ();
treeview.EditProperties += OnEditProperties;
treeview.NewRenderingJob += OnNewRenderingJob;
itersDic = new Dictionary<EventType, TreeIter> ();
Config.EventsBroker.EventLoadedEvent += HandlePlayLoaded;
}
-
+
protected override void OnDestroyed ()
{
Config.EventsBroker.EventLoadedEvent -= HandlePlayLoaded;
@@ -54,60 +51,58 @@ namespace LongoMatch.Gui.Component
}
public EventsFilter Filter {
- set{
+ set {
treeview.Filter = value;
}
}
- public void RemovePlays(List<TimelineEvent> plays) {
+ public void RemovePlays (List<TimelineEvent> plays)
+ {
TreeIter iter, child;
TreeStore model;
List<TreeIter> removeIters;
- if(project == null)
+ if (project == null)
return;
- removeIters = new List<TreeIter>();
+ removeIters = new List<TreeIter> ();
model = (TreeStore)treeview.Model;
- model.GetIterFirst(out iter);
+ model.GetIterFirst (out iter);
/* Scan all the tree and store the iter of each play
* we need to delete, but don't delete it yet so that
* we don't alter the tree */
do {
- if(!model.IterHasChild(iter))
+ if (!model.IterHasChild (iter))
continue;
- model.IterChildren(out child, iter);
+ model.IterChildren (out child, iter);
do {
- TimelineEvent play = (TimelineEvent) model.GetValue(child,0);
- if(plays.Contains(play)) {
- removeIters.Add(child);
+ TimelineEvent play = (TimelineEvent)model.GetValue (child, 0);
+ if (plays.Contains (play)) {
+ removeIters.Add (child);
}
} while(model.IterNext(ref child));
} while(model.IterNext(ref iter));
/* Remove the selected iters now */
- for(int i=0; i < removeIters.Count; i++) {
- iter = removeIters[i];
- model.Remove(ref iter);
+ for (int i=0; i < removeIters.Count; i++) {
+ iter = removeIters [i];
+ model.Remove (ref iter);
}
}
- public void AddPlay(TimelineEvent play) {
- TreeIter categoryIter;
+ public void AddPlay (TimelineEvent play)
+ {
+ TreePath path;
- if(project == null)
+ if (project == null)
return;
- var cat = play.EventType;
- var model = (TreeStore)treeview.Model;
- categoryIter = itersDic[cat];
- var playIter = model.AppendValues(categoryIter,play);
- var playPath = model.GetPath(playIter);
- treeview.Selection.UnselectAll();
- treeview.ExpandToPath(playPath);
- treeview.ScrollToCell (playPath, null, true, 0, 0);
- treeview.Selection.SelectIter(playIter);
+ path = treeview.AddEvent (play, itersDic [play.EventType]);
+ treeview.ExpandToPath (path);
+ treeview.SetCursor (path, null, false);
+ var cellRect = treeview.GetBackgroundArea (path, null);
+ treeview.ScrollToPoint (cellRect.X, Math.Max (cellRect.Y, 0));
}
public Project Project {
@@ -133,27 +128,28 @@ namespace LongoMatch.Gui.Component
itersDic.Clear ();
- foreach(EventType evType in project.EventTypes) {
- iter = dataFileListStore.AppendValues(evType);
- itersDic.Add(evType, iter);
+ foreach (EventType evType in project.EventTypes) {
+ iter = dataFileListStore.AppendValues (evType);
+ itersDic.Add (evType, iter);
}
var queryPlaysByCategory = project.PlaysGroupedByEventType;
- foreach(var playsGroup in queryPlaysByCategory) {
+ foreach (var playsGroup in queryPlaysByCategory) {
EventType cat = playsGroup.Key;
- if(!itersDic.ContainsKey(cat))
+ if (!itersDic.ContainsKey (cat))
continue;
- foreach(TimelineEvent play in playsGroup) {
- dataFileListStore.AppendValues(itersDic[cat], play);
+ foreach (TimelineEvent play in playsGroup) {
+ dataFileListStore.AppendValues (itersDic [cat], play);
}
}
return dataFileListStore;
}
- protected virtual void OnEditProperties(EventType eventType) {
+ protected virtual void OnEditProperties (EventType eventType)
+ {
EditCategoryDialog dialog = new EditCategoryDialog (project, eventType);
- dialog.Run();
- dialog.Destroy();
+ dialog.Run ();
+ dialog.Destroy ();
}
protected virtual void OnNewRenderingJob (object sender, EventArgs args)
@@ -161,23 +157,24 @@ namespace LongoMatch.Gui.Component
Playlist playlist;
TreePath[] paths;
- playlist = new Playlist();
- paths = treeview.Selection.GetSelectedRows();
+ playlist = new Playlist ();
+ paths = treeview.Selection.GetSelectedRows ();
- foreach(var path in paths) {
+ foreach (var path in paths) {
TreeIter iter;
PlaylistPlayElement element;
- treeview.Model.GetIter(out iter, path);
- element = new PlaylistPlayElement (treeview.Model.GetValue(iter, 0) as
TimelineEvent,
+ treeview.Model.GetIter (out iter, path);
+ element = new PlaylistPlayElement (treeview.Model.GetValue (iter, 0) as
TimelineEvent,
project.Description.FileSet);
playlist.Elements.Add (element);
}
Config.EventsBroker.EmitRenderPlaylist (playlist);
}
-
- void HandlePlayLoaded (TimelineEvent play) {
+
+ void HandlePlayLoaded (TimelineEvent play)
+ {
treeview.QueueDraw ();
}
}
diff --git a/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs b/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
index f1593b0..b9db7de 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlaysTreeView.cs
@@ -62,6 +62,15 @@ namespace LongoMatch.Gui.Component
}
}
+ public TreePath AddEvent (TimelineEvent evt, TreeIter evtTter)
+ {
+ TreeIter childIter = childModel.AppendValues (evtTter, evt);
+ TreePath childPath = childModel.GetPath (childIter);
+ TreePath path = modelSort.ConvertChildPathToPath (
+ modelFilter.ConvertChildPathToPath (childPath));
+ return path;
+ }
+
private void SetCategoriesMenu ()
{
Gtk.Action editProp, sortMenu;
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.PlaysListTreeWidget.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.PlaysListTreeWidget.cs
index d27d6d5..0d87f45 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.PlaysListTreeWidget.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.PlaysListTreeWidget.cs
@@ -4,7 +4,7 @@ namespace LongoMatch.Gui.Component
{
public partial class PlaysListTreeWidget
{
- private global::Gtk.ScrolledWindow scrolledwindow1;
+ private global::Gtk.ScrolledWindow GtkScrolledWindow;
private global::LongoMatch.Gui.Component.PlaysTreeView treeview;
protected virtual void Build ()
@@ -14,20 +14,16 @@ namespace LongoMatch.Gui.Component
global::Stetic.BinContainer.Attach (this);
this.Name = "LongoMatch.Gui.Component.PlaysListTreeWidget";
// Container child
LongoMatch.Gui.Component.PlaysListTreeWidget.Gtk.Container+ContainerChild
- this.scrolledwindow1 = new global::Gtk.ScrolledWindow ();
- this.scrolledwindow1.CanFocus = true;
- this.scrolledwindow1.Name = "scrolledwindow1";
- // Container child scrolledwindow1.Gtk.Container+ContainerChild
- global::Gtk.Viewport w1 = new global::Gtk.Viewport ();
- w1.ShadowType = ((global::Gtk.ShadowType)(0));
- // Container child GtkViewport.Gtk.Container+ContainerChild
+ this.GtkScrolledWindow = new global::Gtk.ScrolledWindow ();
+ this.GtkScrolledWindow.Name = "GtkScrolledWindow";
+ this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
+ // Container child GtkScrolledWindow.Gtk.Container+ContainerChild
this.treeview = new global::LongoMatch.Gui.Component.PlaysTreeView ();
this.treeview.CanFocus = true;
this.treeview.Name = "treeview";
this.treeview.Colors = false;
- w1.Add (this.treeview);
- this.scrolledwindow1.Add (w1);
- this.Add (this.scrolledwindow1);
+ this.GtkScrolledWindow.Add (this.treeview);
+ this.Add (this.GtkScrolledWindow);
if ((this.Child != null)) {
this.Child.ShowAll ();
}
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index d48b965..5204dc1 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -93,21 +93,15 @@ Sort by competition</property>
<widget class="Gtk.Bin" id="LongoMatch.Gui.Component.PlaysListTreeWidget" design-size="300 300">
<property name="MemberName" />
<child>
- <widget class="Gtk.ScrolledWindow" id="scrolledwindow1">
+ <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow">
<property name="MemberName" />
- <property name="CanFocus">True</property>
+ <property name="ShadowType">In</property>
<child>
- <widget class="Gtk.Viewport" id="GtkViewport">
+ <widget class="LongoMatch.Gui.Component.PlaysTreeView" id="treeview">
<property name="MemberName" />
- <property name="ShadowType">None</property>
- <child>
- <widget class="LongoMatch.Gui.Component.PlaysTreeView" id="treeview">
- <property name="MemberName" />
- <property name="CanFocus">True</property>
- <property name="ShowScrollbars">True</property>
- <property name="Colors">False</property>
- </widget>
- </child>
+ <property name="CanFocus">True</property>
+ <property name="ShowScrollbars">True</property>
+ <property name="Colors">False</property>
</widget>
</child>
</widget>
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index cccf2cd..8a9a327 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -265,8 +265,8 @@ namespace LongoMatch.Services
play.Stop.MSeconds = Math.Min (player.StreamLength.MSeconds,
play.Stop.MSeconds);
}
- analysisWindow.AddPlay (play);
filter.Update ();
+ analysisWindow.AddPlay (play);
if (projectType == ProjectType.FileProject) {
player.Play ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]