[longomatch] Add a new editor for event types tags and groups
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a new editor for event types tags and groups
- Date: Fri, 3 Oct 2014 17:29:21 +0000 (UTC)
commit 399b273d9beb021dd4f0dcc05907d3b533b64bd4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Oct 3 19:10:42 2014 +0200
Add a new editor for event types tags and groups
LongoMatch.Core/Store/Tag.cs | 2 +-
LongoMatch.GUI/Gui/Component/DashboardWidget.cs | 13 +-
LongoMatch.GUI/Gui/Dialog/EventTypeTagsEditor.cs | 246 ++++++++++++++++++++
LongoMatch.GUI/LongoMatch.GUI.csproj | 2 +
LongoMatch.GUI/Makefile.am | 2 +
.../LongoMatch.Gui.Dialog.EventTypeTagsEditor.cs | 61 +++++
LongoMatch.GUI/gtk-gui/gui.stetic | 64 +++++
7 files changed, 383 insertions(+), 7 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Tag.cs b/LongoMatch.Core/Store/Tag.cs
index 3a5a21b..0d884ef 100644
--- a/LongoMatch.Core/Store/Tag.cs
+++ b/LongoMatch.Core/Store/Tag.cs
@@ -29,7 +29,7 @@ namespace LongoMatch.Core.Store
[Serializable]
public class Tag
{
- public Tag (string value, string grp="") {
+ public Tag (string value, string grp="Default") {
Group = grp;
Value = value;
}
diff --git a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
index c6b5133..c743d72 100644
--- a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
@@ -32,6 +32,7 @@ using LongoMatch.Drawing.Cairo;
using Mono.Unix;
using Image = LongoMatch.Core.Common.Image;
using LongoMatch.Gui.Helpers;
+using LongoMatch.Gui.Dialog;
namespace LongoMatch.Gui.Component
{
@@ -399,12 +400,12 @@ namespace LongoMatch.Gui.Component
void HandleAddNewTagEvent (DashboardButton taggerbutton)
{
- string res = MessagesHelpers.QueryMessage (this, Catalog.GetString ("Name"),
- Catalog.GetString ("New tag"));
- if (!string.IsNullOrEmpty (res)) {
- (taggerbutton as AnalysisEventButton).AnalysisEventType.Tags.Add (new Tag
(res));
- tagger.Refresh (null);
- }
+ AnalysisEventType evt = (taggerbutton as AnalysisEventButton).AnalysisEventType;
+ EventTypeTagsEditor dialog = new EventTypeTagsEditor ();
+ dialog.EventType = evt;
+ dialog.Run ();
+ dialog.Destroy ();
+ Edited = true;
}
void HandleResetField (object sender, EventArgs e)
diff --git a/LongoMatch.GUI/Gui/Dialog/EventTypeTagsEditor.cs
b/LongoMatch.GUI/Gui/Dialog/EventTypeTagsEditor.cs
new file mode 100644
index 0000000..f18eeeb
--- /dev/null
+++ b/LongoMatch.GUI/Gui/Dialog/EventTypeTagsEditor.cs
@@ -0,0 +1,246 @@
+//
+// 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 System.Linq;
+using Gtk;
+using LongoMatch.Core.Store;
+using Mono.Unix;
+using Misc = LongoMatch.Gui.Helpers.Misc;
+using System.Collections.Generic;
+
+namespace LongoMatch.Gui.Dialog
+{
+ public partial class EventTypeTagsEditor : Gtk.Dialog
+ {
+ const int COLS_PER_ROW = 5;
+ AnalysisEventType eventType;
+
+ public EventTypeTagsEditor ()
+ {
+ this.Build ();
+ }
+
+ public AnalysisEventType EventType {
+ set {
+ eventType = value;
+ LoadEventType (value);
+ }
+ get {
+ return eventType;
+ }
+ }
+
+ void LoadEventType (AnalysisEventType eventType)
+ {
+ Button newGroupButton;
+
+ var tagsByGroup = eventType.Tags.GroupBy (t => t.Group);
+
+ foreach (var tagsGroup in tagsByGroup) {
+ AddNewGroup (tagsGroup.Key, tagsGroup.ToList());
+ }
+ newGroupButton = CreateAddGroupButton ();
+ mainvbox.PackEnd (newGroupButton, false, true, 0);
+ mainvbox.ShowAll ();
+ }
+
+ Widget CreateTagsTable (TagsGroup g)
+ {
+ int i = 0;
+ uint rows, count;
+ Alignment alignment;
+ Table t;
+
+ count = (uint) g.tags.Count + 1;
+ rows = count / COLS_PER_ROW + 1;
+
+ alignment = new Alignment (0.5F, 0.5F, 1, 1);
+ alignment.LeftPadding = 20;
+ t = new Table (rows, COLS_PER_ROW, false);
+ t.RowSpacing = 2;
+ t.ColumnSpacing = 5;
+ foreach (Tag tag in g.tags) {
+ CreateTagBox (t, tag, i, g);
+ i++;
+ }
+ var addb = CreateAddTagButton (g);
+ InsertInTable (t, addb, i);
+ alignment.Add (t);
+ g.table = alignment;
+ return alignment;
+ }
+
+ void AddNewGroup (string name, List<Tag> tags)
+ {
+ TagsGroup g;
+ Widget t;
+ VBox vbox = new VBox (false, 5);
+ HBox hbox = new HBox (false, 5);
+
+ g = new TagsGroup (vbox, tags);
+ hbox.PackStart (GroupBox (name, g), false, true, 0);
+ t = CreateTagsTable (g);
+ vbox.PackStart (hbox, true, true, 0);
+ vbox.PackStart (t, true, true, 0);
+ vbox.PackEnd (new HSeparator(), true, true, 0);
+ vbox.ShowAll ();
+ mainvbox.PackStart (vbox, true, true, 0);
+ }
+
+ void RemoveGroup (TagsGroup g)
+ {
+ string msg = Catalog.GetString ("Do you want to remove this group and all its tags?");
+ if (Config.GUIToolkit.QuestionMessage (msg, null, this)) {
+ EventType.Tags.RemoveAll (g.tags.Contains);
+ mainvbox.Remove (g.container);
+ }
+ }
+
+ void RemoveTag (Tag tag, TagsGroup g)
+ {
+ string msg = Catalog.GetString ("Do you want to remove this tag?");
+ if (Config.GUIToolkit.QuestionMessage (msg, null, this)) {
+ EventType.Tags.Remove (tag);
+ g.tags.Remove (tag);
+ g.container.Remove (g.table);
+ CreateTagsTable (g);
+ g.container.PackStart (CreateTagsTable (g), true, true, 0);
+ g.container.ShowAll ();
+ }
+ }
+
+ void AddTag (TagsGroup g)
+ {
+ Tag t = new Tag(Catalog.GetString ("New tag"), g.nameEntry.Text);
+ EventType.Tags.Add (t);
+ g.tags.Add (t);
+ g.container.Remove (g.table);
+ CreateTagsTable (g);
+ g.container.PackStart (CreateTagsTable (g), true, true, 0);
+ g.container.ShowAll ();
+ }
+
+ Box GroupBox (string name, TagsGroup g)
+ {
+ HBox box = new HBox (false, 5);
+ Label l = new Label ();
+ Entry entry = new Entry (name);
+ Button b = RemoveButton ();
+
+ l.Markup = Catalog.GetString ("<b>Group name:</b>");
+ g.nameEntry = entry;
+ entry.Changed += (sender, e) => {
+ foreach (Tag t in g.tags) {
+ t.Group = entry.Text;
+ }
+ };
+ b.Clicked += (sender, e) => {
+ RemoveGroup (g);
+ };
+ box.PackStart (l, false, false, 0);
+ box.PackStart (entry, false, true, 0);
+ box.PackStart (b, false, false, 0);
+ return box;
+ }
+
+ Box CreateTagBox (Table t, Tag tag, int i, TagsGroup g)
+ {
+ HBox box = new HBox (false, 2);
+ Entry tagEntry = new Entry (tag.Value);
+ Button b = RemoveButton ();
+
+ b.Clicked += (sender, e) => {
+ RemoveTag (tag, g);
+ };
+
+ tagEntry.Changed += (o, e) => {
+ tag.Value = tagEntry.Text;
+ };
+
+ box.PackStart (tagEntry, true, true, 0);
+ box.PackStart (b, false, false, 0);
+ InsertInTable (t, box, i);
+ return box;
+ }
+
+ Button RemoveButton ()
+ {
+ Button b = new Button ();
+ Alignment a = new Alignment (0.5F, 0.5F, 0F, 0F);
+ Gtk.Image i = new Image (Misc.LoadIcon ("gtk-remove", 24));
+ a.Add (i);
+ b.Add (a);
+ return b;
+ }
+
+ Button CreateButton (string s, int size)
+ {
+ Button b = new Button ();
+ Gtk.Image i = new Image (Misc.LoadIcon ("gtk-add", size));
+ Label l = new Label (s);
+ HBox box = new HBox ();
+ box.PackStart (i, false, false, 5);
+ box.PackStart (l, false, false, 5);
+ b.Add (box);
+ return b;
+ }
+
+ Button CreateAddGroupButton ()
+ {
+ Button b = CreateButton (Catalog.GetString ("Add new group"), 48);
+ b.Clicked += (sender, e) => {
+ AddNewGroup (Catalog.GetString ("New group"), new List<Tag> ());
+ };
+ return b;
+ }
+
+ Button CreateAddTagButton (TagsGroup g)
+ {
+ Button b = CreateButton (Catalog.GetString ("Add new tag"), 24);
+ b.Clicked += (sender, e) => {
+ AddTag (g);
+ };
+ return b;
+ }
+
+ void InsertInTable (Table table, Widget widget, int position)
+ {
+ uint row_top, row_bottom, col_left, col_right;
+ row_top = (uint)(position / table.NColumns);
+ row_bottom = (uint)row_top + 1;
+ col_left = (uint)position % table.NColumns;
+ col_right = (uint)col_left + 1;
+ table.Attach (widget, col_left, col_right, row_top, row_bottom);
+ }
+
+ protected class TagsGroup
+ {
+ public List<Tag> tags;
+ public Box container;
+ public Entry nameEntry;
+ public Widget table;
+
+ public TagsGroup (Box container, List<Tag> tags)
+ {
+ this.container = container;
+ this.tags = tags;
+ }
+ }
+ }
+}
+
diff --git a/LongoMatch.GUI/LongoMatch.GUI.csproj b/LongoMatch.GUI/LongoMatch.GUI.csproj
index d11093c..734bf99 100644
--- a/LongoMatch.GUI/LongoMatch.GUI.csproj
+++ b/LongoMatch.GUI/LongoMatch.GUI.csproj
@@ -185,6 +185,8 @@
<Compile Include="gtk-gui\LongoMatch.Gui.Dialog.PlayEditor.cs" />
<Compile Include="Gui\Dialog\SubstitutionsEditor.cs" />
<Compile Include="gtk-gui\LongoMatch.Gui.Dialog.SubstitutionsEditor.cs" />
+ <Compile Include="Gui\Dialog\EventTypeTagsEditor.cs" />
+ <Compile Include="gtk-gui\LongoMatch.Gui.Dialog.EventTypeTagsEditor.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="gtk-gui\gui.stetic">
diff --git a/LongoMatch.GUI/Makefile.am b/LongoMatch.GUI/Makefile.am
index 652bf61..78a398a 100644
--- a/LongoMatch.GUI/Makefile.am
+++ b/LongoMatch.GUI/Makefile.am
@@ -47,6 +47,7 @@ SOURCES = Gui/Cairo.cs \
Gui/Dialog/EditCategoryDialog.cs \
Gui/Dialog/EndCaptureDialog.cs \
Gui/Dialog/EntryDialog.cs \
+ Gui/Dialog/EventTypeTagsEditor.cs \
Gui/Dialog/FramesCaptureProgressDialog.cs \
Gui/Dialog/HotKeySelectorDialog.cs \
Gui/Dialog/PlayEditor.cs \
@@ -119,6 +120,7 @@ SOURCES = Gui/Cairo.cs \
gtk-gui/LongoMatch.Gui.Dialog.EditCategoryDialog.cs \
gtk-gui/LongoMatch.Gui.Dialog.EndCaptureDialog.cs \
gtk-gui/LongoMatch.Gui.Dialog.EntryDialog.cs \
+ gtk-gui/LongoMatch.Gui.Dialog.EventTypeTagsEditor.cs \
gtk-gui/LongoMatch.Gui.Dialog.FramesCaptureProgressDialog.cs \
gtk-gui/LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs \
gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs \
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.EventTypeTagsEditor.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.EventTypeTagsEditor.cs
new file mode 100644
index 0000000..6bd98ce
--- /dev/null
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.EventTypeTagsEditor.cs
@@ -0,0 +1,61 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace LongoMatch.Gui.Dialog
+{
+ public partial class EventTypeTagsEditor
+ {
+ private global::Gtk.VBox mainvbox;
+ private global::Gtk.Button buttonOk;
+
+ protected virtual void Build ()
+ {
+ global::Stetic.Gui.Initialize (this);
+ // Widget LongoMatch.Gui.Dialog.EventTypeTagsEditor
+ this.Name = "LongoMatch.Gui.Dialog.EventTypeTagsEditor";
+ this.Title = global::Mono.Unix.Catalog.GetString ("Edit event tags");
+ this.Icon = global::Stetic.IconLoader.LoadIcon (this, "longomatch",
global::Gtk.IconSize.Menu);
+ this.TypeHint = ((global::Gdk.WindowTypeHint)(1));
+ this.WindowPosition = ((global::Gtk.WindowPosition)(4));
+ this.Modal = true;
+ this.Gravity = ((global::Gdk.Gravity)(5));
+ this.SkipPagerHint = true;
+ this.SkipTaskbarHint = true;
+ // Internal child LongoMatch.Gui.Dialog.EventTypeTagsEditor.VBox
+ global::Gtk.VBox w1 = this.VBox;
+ w1.Name = "dialog1_VBox";
+ w1.BorderWidth = ((uint)(2));
+ // Container child dialog1_VBox.Gtk.Box+BoxChild
+ this.mainvbox = new global::Gtk.VBox ();
+ this.mainvbox.Name = "mainvbox";
+ this.mainvbox.Spacing = 6;
+ w1.Add (this.mainvbox);
+ global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(w1 [this.mainvbox]));
+ w2.Position = 0;
+ w2.Expand = false;
+ // Internal child LongoMatch.Gui.Dialog.EventTypeTagsEditor.ActionArea
+ global::Gtk.HButtonBox w3 = this.ActionArea;
+ w3.Name = "dialog1_ActionArea";
+ w3.Spacing = 10;
+ w3.BorderWidth = ((uint)(5));
+ w3.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
+ // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
+ this.buttonOk = new global::Gtk.Button ();
+ this.buttonOk.CanDefault = true;
+ this.buttonOk.CanFocus = true;
+ this.buttonOk.Name = "buttonOk";
+ this.buttonOk.UseStock = true;
+ this.buttonOk.UseUnderline = true;
+ this.buttonOk.Label = "gtk-ok";
+ this.AddActionWidget (this.buttonOk, -5);
+ global::Gtk.ButtonBox.ButtonBoxChild w4 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w3
[this.buttonOk]));
+ w4.Expand = false;
+ w4.Fill = false;
+ if ((this.Child != null)) {
+ this.Child.ShowAll ();
+ }
+ this.DefaultWidth = 445;
+ this.DefaultHeight = 351;
+ this.Show ();
+ }
+ }
+}
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 550bc84..1f99dba 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -10910,4 +10910,68 @@ You can continue with the current capture, cancel it or save your project.
</widget>
</child>
</widget>
+ <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.EventTypeTagsEditor" design-size="445 351">
+ <property name="MemberName" />
+ <property name="Title" translatable="yes">Edit event tags</property>
+ <property name="Icon">stock:longomatch Menu</property>
+ <property name="TypeHint">Dialog</property>
+ <property name="WindowPosition">CenterOnParent</property>
+ <property name="Modal">True</property>
+ <property name="Gravity">Center</property>
+ <property name="SkipPagerHint">True</property>
+ <property name="SkipTaskbarHint">True</property>
+ <property name="Buttons">1</property>
+ <property name="HelpButton">False</property>
+ <child internal-child="VBox">
+ <widget class="Gtk.VBox" id="dialog1_VBox">
+ <property name="MemberName" />
+ <property name="BorderWidth">2</property>
+ <child>
+ <widget class="Gtk.VBox" id="mainvbox">
+ <property name="MemberName" />
+ <property name="Spacing">6</property>
+ <child>
+ <placeholder />
+ </child>
+ <child>
+ <placeholder />
+ </child>
+ <child>
+ <placeholder />
+ </child>
+ </widget>
+ <packing>
+ <property name="Position">0</property>
+ <property name="AutoSize">False</property>
+ <property name="Expand">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child internal-child="ActionArea">
+ <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
+ <property name="MemberName" />
+ <property name="Spacing">10</property>
+ <property name="BorderWidth">5</property>
+ <property name="Size">1</property>
+ <property name="LayoutStyle">End</property>
+ <child>
+ <widget class="Gtk.Button" id="buttonOk">
+ <property name="MemberName" />
+ <property name="CanDefault">True</property>
+ <property name="CanFocus">True</property>
+ <property name="UseStock">True</property>
+ <property name="Type">StockItem</property>
+ <property name="StockId">gtk-ok</property>
+ <property name="ResponseId">-5</property>
+ <property name="label">gtk-ok</property>
+ </widget>
+ <packing>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</stetic-interface>
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]