[longomatch] Update cats when selected in the editor
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Update cats when selected in the editor
- Date: Mon, 7 Jul 2014 11:32:30 +0000 (UTC)
commit 9b25f9b22c228aee1ed60ad1ee9deee61086c5e7
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Jun 30 14:28:29 2014 +0200
Update cats when selected in the editor
.../Gui/Component/AnalysisTemplateEditor.cs | 35 ++++++++++-
LongoMatch.GUI/Gui/Component/ButtonsWidget.cs | 4 +
LongoMatch.GUI/Gui/Dialog/EntryDialog.cs | 6 ++
LongoMatch.GUI/Gui/Panel/SportsTemplatesPanel.cs | 1 +
...goMatch.Gui.Component.AnalysisTemplateEditor.cs | 63 ++++++++++++++++++-
LongoMatch.GUI/gtk-gui/gui.stetic | 35 ++++++++++-
LongoMatch.GUI/gtk-gui/objects.xml | 6 ++-
7 files changed, 141 insertions(+), 9 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/AnalysisTemplateEditor.cs
b/LongoMatch.GUI/Gui/Component/AnalysisTemplateEditor.cs
index 9cfb770..1108477 100644
--- a/LongoMatch.GUI/Gui/Component/AnalysisTemplateEditor.cs
+++ b/LongoMatch.GUI/Gui/Component/AnalysisTemplateEditor.cs
@@ -19,6 +19,8 @@ using System;
using LongoMatch.Store.Templates;
using LongoMatch.Common;
using LongoMatch.Gui.Helpers;
+using LongoMatch.Store;
+using Mono.Unix;
namespace LongoMatch.Gui.Component
{
@@ -27,19 +29,28 @@ namespace LongoMatch.Gui.Component
{
bool edited;
Categories template;
+ Category selectedCategory;
public AnalysisTemplateEditor ()
{
this.Build ();
buttonswidget.Mode = LongoMatch.Common.TagMode.Predifined;
+ buttonswidget.CategorySelected += HandleCategorySelected;
categoryproperties.Visible = false;
savebutton.Clicked += HandleSaveClicked;
+ deletebutton.Sensitive = false;
+ newbutton.Sensitive = false;
+ newbutton.Clicked += HandleNewClicked;
+ deletebutton.Clicked += HandleDeleteClicked;
}
-
+
public Categories Template {
set {
template = value;
+ categoryproperties.Template = value;
+ newbutton.Sensitive = true;
buttonswidget.UpdateCategories (value);
+ Edited = false;
}
}
@@ -52,10 +63,30 @@ namespace LongoMatch.Gui.Component
}
}
- void HandleCategorySelected (LongoMatch.Store.Category category)
+ void HandleDeleteClicked (object sender, EventArgs e)
+ {
+ string msg = Catalog.GetString ("Do you want to delete: ") +
+ selectedCategory.Name + "?";
+ if (Config.GUIToolkit.QuestionMessage (msg, null, this)) {
+ template.List.Remove (selectedCategory);
+ buttonswidget.UpdateCategories (template);
+ Edited = true;
+ }
+ }
+
+ void HandleNewClicked (object sender, EventArgs e)
+ {
+ template.AddDefaultItem (template.List.Count);
+ buttonswidget.UpdateCategories (template);
+ Edited = true;
+ }
+
+ void HandleCategorySelected (Category category)
{
categoryproperties.Visible = true;
+ deletebutton.Sensitive = true;
categoryproperties.Category = category;
+ selectedCategory = category;
}
void HandleSaveClicked (object sender, EventArgs e)
diff --git a/LongoMatch.GUI/Gui/Component/ButtonsWidget.cs b/LongoMatch.GUI/Gui/Component/ButtonsWidget.cs
index b322537..bb1dcc1 100644
--- a/LongoMatch.GUI/Gui/Component/ButtonsWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/ButtonsWidget.cs
@@ -34,6 +34,7 @@ namespace LongoMatch.Gui.Component
[System.ComponentModel.ToolboxItem(true)]
public partial class ButtonsWidget : Gtk.Bin
{
+ public event NewTagHandler CategorySelected;
TagMode tagMode;
Dictionary<ButtonTagger, Category> buttonsDic;
const int N_COLUMNS = 5;
@@ -89,6 +90,9 @@ namespace LongoMatch.Gui.Component
ButtonTagger b = new ButtonTagger (cat);
b.NewTag += (category) => {
Config.EventsBroker.EmitNewTag (category);
+ if (CategorySelected != null) {
+ CategorySelected (category);
+ }
};
b.NewTagStart += (category) => {
Config.EventsBroker.EmitNewTagStart (category);
diff --git a/LongoMatch.GUI/Gui/Dialog/EntryDialog.cs b/LongoMatch.GUI/Gui/Dialog/EntryDialog.cs
index 0595bba..dd5a333 100644
--- a/LongoMatch.GUI/Gui/Dialog/EntryDialog.cs
+++ b/LongoMatch.GUI/Gui/Dialog/EntryDialog.cs
@@ -56,6 +56,12 @@ namespace LongoMatch.Gui.Dialog
playersspinbutton.Value = value;
}
}
+
+ public string CountText {
+ set {
+ playerslabel.Text = value;
+ }
+ }
public bool ShowCount {
set {
diff --git a/LongoMatch.GUI/Gui/Panel/SportsTemplatesPanel.cs
b/LongoMatch.GUI/Gui/Panel/SportsTemplatesPanel.cs
index bcd6b63..1836181 100644
--- a/LongoMatch.GUI/Gui/Panel/SportsTemplatesPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/SportsTemplatesPanel.cs
@@ -165,6 +165,7 @@ namespace LongoMatch.Gui.Panel
dialog.TransientFor = (Gtk.Window)this.Toplevel;
dialog.ShowCount = true;
dialog.Text = Catalog.GetString("New team");
+ dialog.CountText = Catalog.GetString ("Categories:");
dialog.AvailableTemplates = provider.TemplatesNames;
while (dialog.Run() == (int)ResponseType.Ok) {
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.AnalysisTemplateEditor.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.AnalysisTemplateEditor.cs
index 8a01389..de90191 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.AnalysisTemplateEditor.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.AnalysisTemplateEditor.cs
@@ -10,6 +10,8 @@ namespace LongoMatch.Gui.Component
private global::LongoMatch.Gui.Component.CategoryProperties categoryproperties;
private global::Gtk.HButtonBox hbuttonbox2;
private global::Gtk.Button savebutton;
+ private global::Gtk.Button newbutton;
+ private global::Gtk.Button deletebutton;
protected virtual void Build ()
{
@@ -47,6 +49,7 @@ namespace LongoMatch.Gui.Component
// Container child vbox2.Gtk.Box+BoxChild
this.hbuttonbox2 = new global::Gtk.HButtonBox ();
this.hbuttonbox2.Name = "hbuttonbox2";
+ this.hbuttonbox2.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(1));
// Container child hbuttonbox2.Gtk.ButtonBox+ButtonBoxChild
this.savebutton = new global::Gtk.Button ();
this.savebutton.CanFocus = true;
@@ -63,7 +66,7 @@ namespace LongoMatch.Gui.Component
w5.Add (w6);
// Container child GtkHBox.Gtk.Container+ContainerChild
global::Gtk.Label w8 = new global::Gtk.Label ();
- w8.LabelProp = global::Mono.Unix.Catalog.GetString ("Save");
+ w8.LabelProp = global::Mono.Unix.Catalog.GetString ("Save template");
w8.UseUnderline = true;
w5.Add (w8);
w4.Add (w5);
@@ -72,10 +75,62 @@ namespace LongoMatch.Gui.Component
global::Gtk.ButtonBox.ButtonBoxChild w12 =
((global::Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox2 [this.savebutton]));
w12.Expand = false;
w12.Fill = false;
+ // Container child hbuttonbox2.Gtk.ButtonBox+ButtonBoxChild
+ this.newbutton = new global::Gtk.Button ();
+ this.newbutton.CanFocus = true;
+ this.newbutton.Name = "newbutton";
+ this.newbutton.UseUnderline = true;
+ // Container child newbutton.Gtk.Container+ContainerChild
+ global::Gtk.Alignment w13 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F);
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
+ global::Gtk.HBox w14 = new global::Gtk.HBox ();
+ w14.Spacing = 2;
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Image w15 = new global::Gtk.Image ();
+ w15.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-add",
global::Gtk.IconSize.Dialog);
+ w14.Add (w15);
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Label w17 = new global::Gtk.Label ();
+ w17.LabelProp = global::Mono.Unix.Catalog.GetString ("New category");
+ w17.UseUnderline = true;
+ w14.Add (w17);
+ w13.Add (w14);
+ this.newbutton.Add (w13);
+ this.hbuttonbox2.Add (this.newbutton);
+ global::Gtk.ButtonBox.ButtonBoxChild w21 =
((global::Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox2 [this.newbutton]));
+ w21.Position = 1;
+ w21.Expand = false;
+ w21.Fill = false;
+ // Container child hbuttonbox2.Gtk.ButtonBox+ButtonBoxChild
+ this.deletebutton = new global::Gtk.Button ();
+ this.deletebutton.CanFocus = true;
+ this.deletebutton.Name = "deletebutton";
+ this.deletebutton.UseUnderline = true;
+ // Container child deletebutton.Gtk.Container+ContainerChild
+ global::Gtk.Alignment w22 = new global::Gtk.Alignment (0.5F, 0.5F, 0F, 0F);
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
+ global::Gtk.HBox w23 = new global::Gtk.HBox ();
+ w23.Spacing = 2;
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Image w24 = new global::Gtk.Image ();
+ w24.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-delete",
global::Gtk.IconSize.Dialog);
+ w23.Add (w24);
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Label w26 = new global::Gtk.Label ();
+ w26.LabelProp = global::Mono.Unix.Catalog.GetString ("Delete category");
+ w26.UseUnderline = true;
+ w23.Add (w26);
+ w22.Add (w23);
+ this.deletebutton.Add (w22);
+ this.hbuttonbox2.Add (this.deletebutton);
+ global::Gtk.ButtonBox.ButtonBoxChild w30 =
((global::Gtk.ButtonBox.ButtonBoxChild)(this.hbuttonbox2 [this.deletebutton]));
+ w30.Position = 2;
+ w30.Expand = false;
+ w30.Fill = false;
this.vbox2.Add (this.hbuttonbox2);
- global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vbox2
[this.hbuttonbox2]));
- w13.Position = 1;
- w13.Expand = false;
+ global::Gtk.Box.BoxChild w31 = ((global::Gtk.Box.BoxChild)(this.vbox2
[this.hbuttonbox2]));
+ w31.Position = 1;
+ w31.Expand = false;
this.Add (this.vbox2);
if ((this.Child != null)) {
this.Child.ShowAll ();
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 6b5be49..3efae96 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -9185,17 +9185,48 @@ Click 2 players to swap them</property>
<child>
<widget class="Gtk.HButtonBox" id="hbuttonbox2">
<property name="MemberName" />
- <property name="Size">1</property>
+ <property name="Size">3</property>
+ <property name="LayoutStyle">Spread</property>
<child>
<widget class="Gtk.Button" id="savebutton">
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="Type">TextAndIcon</property>
<property name="Icon">stock:gtk-save Dialog</property>
- <property name="Label" translatable="yes">Save</property>
+ <property name="Label" translatable="yes">Save template</property>
+ <property name="UseUnderline">True</property>
+ </widget>
+ <packing>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Button" id="newbutton">
+ <property name="MemberName" />
+ <property name="CanFocus">True</property>
+ <property name="Type">TextAndIcon</property>
+ <property name="Icon">stock:gtk-add Dialog</property>
+ <property name="Label" translatable="yes">New category</property>
<property name="UseUnderline">True</property>
</widget>
<packing>
+ <property name="Position">1</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Gtk.Button" id="deletebutton">
+ <property name="MemberName" />
+ <property name="CanFocus">True</property>
+ <property name="Type">TextAndIcon</property>
+ <property name="Icon">stock:gtk-delete Dialog</property>
+ <property name="Label" translatable="yes">Delete category</property>
+ <property name="UseUnderline">True</property>
+ </widget>
+ <packing>
+ <property name="Position">2</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
diff --git a/LongoMatch.GUI/gtk-gui/objects.xml b/LongoMatch.GUI/gtk-gui/objects.xml
index 2759da1..72c5073 100644
--- a/LongoMatch.GUI/gtk-gui/objects.xml
+++ b/LongoMatch.GUI/gtk-gui/objects.xml
@@ -5,7 +5,11 @@
</object>
<object type="LongoMatch.Gui.Component.ButtonsWidget" palette-category="General" allow-children="false"
base-type="Gtk.Bin">
<itemgroups />
- <signals />
+ <signals>
+ <itemgroup label="ButtonsWidget Signals">
+ <signal name="CategorySelected" />
+ </itemgroup>
+ </signals>
</object>
<object type="LongoMatch.Gui.Component.NotesWidget" palette-category="General" allow-children="false"
base-type="Gtk.Bin">
<itemgroups />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]