[longomatch] Allow deleting several categories at once
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Allow deleting several categories at once
- Date: Tue, 15 Jun 2010 22:46:25 +0000 (UTC)
commit b630996f6fc4972c6e75f7fca9ec2766dcf2b31f
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Jun 16 00:22:35 2010 +0200
Allow deleting several categories at once
LongoMatch/Gui/Component/ProjectTemplateWidget.cs | 54 +++++++++++++-------
LongoMatch/Gui/TreeView/CategoriesTreeView.cs | 25 ++++++---
LongoMatch/Handlers/Handlers.cs | 5 ++
...ngoMatch.Gui.Component.ProjectTemplateWidget.cs | 4 +-
.../LongoMatch.Gui.Dialog.TemplatesManager.cs | 2 +
LongoMatch/gtk-gui/gui.stetic | 4 +-
LongoMatch/gtk-gui/objects.xml | 16 +++---
7 files changed, 73 insertions(+), 37 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/ProjectTemplateWidget.cs b/LongoMatch/Gui/Component/ProjectTemplateWidget.cs
index c38a166..6584367 100644
--- a/LongoMatch/Gui/Component/ProjectTemplateWidget.cs
+++ b/LongoMatch/Gui/Component/ProjectTemplateWidget.cs
@@ -39,7 +39,7 @@ namespace LongoMatch.Gui.Component
private List<HotKey> hkList;
private Project project;
private Sections sections;
- private SectionsTimeNode selectedSection;
+ private List<SectionsTimeNode> selectedSections;
private bool edited = false;
public ProjectTemplateWidget()
@@ -112,28 +112,35 @@ namespace LongoMatch.Gui.Component
edited = true;
}
- private void RemoveSection(int index) {
+ private void RemoveSelectedSections() {
if (project!= null) {
MessageDialog dialog = new MessageDialog((Gtk.Window)this.Toplevel,DialogFlags.Modal,MessageType.Question,
ButtonsType.YesNo,true,
Catalog.GetString("You are about to delete a category and all the plays added to this category. Do you want to proceed?"));
- if (dialog.Run() == (int)ResponseType.Yes)
+ if (dialog.Run() == (int)ResponseType.Yes){
try {
- project.DeleteSection(index);
+ foreach (SectionsTimeNode tNode in selectedSections)
+ project.DeleteSection(sections.SectionsTimeNodes.IndexOf(tNode));
} catch {
MessagePopup.PopupMessage(this,MessageType.Warning,
- Catalog.GetString("You can't delete the last section"));
- dialog.Destroy();
- return;
+ Catalog.GetString("A template needs at least one category"));
}
+ }
dialog.Destroy();
sections=project.Sections;
} else {
- sections.RemoveSection(index);
+ foreach (SectionsTimeNode tNode in selectedSections){
+ Console.WriteLine (Sections.Count);
+ if (sections.Count == 1){
+ MessagePopup.PopupMessage(this,MessageType.Warning,
+ Catalog.GetString("A template needs at least one category"));
+ } else
+ sections.RemoveSection(sections.SectionsTimeNodes.IndexOf(tNode));
+ }
}
UpdateModel();
edited = true;
- selectedSection = null;
+ selectedSections = null;
ButtonsSensitive=false;
}
@@ -148,7 +155,7 @@ namespace LongoMatch.Gui.Component
private void EditSelectedSection() {
EditCategoryDialog dialog = new EditCategoryDialog();
- dialog.Section=selectedSection;
+ dialog.Section = selectedSections[0];
dialog.HotKeysList = hkList;
dialog.TransientFor = (Gtk.Window) Toplevel;
dialog.Run();
@@ -161,15 +168,15 @@ namespace LongoMatch.Gui.Component
}
protected virtual void OnNewAfter(object sender, EventArgs args) {
- AddSection(sections.SectionsTimeNodes.IndexOf(selectedSection)+1);
+ AddSection(sections.SectionsTimeNodes.IndexOf(selectedSections[0])+1);
}
protected virtual void OnNewBefore(object sender, EventArgs args) {
- AddSection(sections.SectionsTimeNodes.IndexOf(selectedSection));
+ AddSection(sections.SectionsTimeNodes.IndexOf(selectedSections[0]));
}
protected virtual void OnRemove(object sender, EventArgs args) {
- RemoveSection(sections.SectionsTimeNodes.IndexOf(selectedSection));
+ RemoveSelectedSections();
}
protected virtual void OnEdit(object sender, EventArgs args) {
@@ -181,16 +188,26 @@ namespace LongoMatch.Gui.Component
EditSelectedSection();
}
- protected virtual void OnSectionstreeview1SectionSelected(LongoMatch.TimeNodes.SectionsTimeNode tNode)
+ protected virtual void OnSectionstreeview1SectionsSelected (List<SectionsTimeNode> tNodesList)
{
- selectedSection = tNode;
- ButtonsSensitive = selectedSection != null;
+ selectedSections = tNodesList;
+ if (tNodesList.Count == 0)
+ ButtonsSensitive = false;
+ else if (tNodesList.Count == 1){
+ ButtonsSensitive = true;
+ }
+ else {
+ newprevbutton.Sensitive = false;
+ newafterbutton.Sensitive = false;
+ removebutton.Sensitive = true;
+ editbutton.Sensitive = false;
+ }
}
protected virtual void OnKeyPressEvent(object o, Gtk.KeyPressEventArgs args)
{
- if (args.Event.Key == Gdk.Key.Delete && selectedSection != null)
- RemoveSection(sections.SectionsTimeNodes.IndexOf(selectedSection));
+ if (args.Event.Key == Gdk.Key.Delete && selectedSections != null)
+ RemoveSelectedSections();
}
protected virtual void OnExportbuttonClicked (object sender, System.EventArgs e)
@@ -218,5 +235,6 @@ namespace LongoMatch.Gui.Component
}
dialog.Destroy();
}
+
}
}
diff --git a/LongoMatch/Gui/TreeView/CategoriesTreeView.cs b/LongoMatch/Gui/TreeView/CategoriesTreeView.cs
index 865b219..0f0f3aa 100644
--- a/LongoMatch/Gui/TreeView/CategoriesTreeView.cs
+++ b/LongoMatch/Gui/TreeView/CategoriesTreeView.cs
@@ -19,6 +19,7 @@
//
using System;
+using System.Collections.Generic;
using Gdk;
using Gtk;
using Mono.Unix;
@@ -28,19 +29,19 @@ using LongoMatch.TimeNodes;
namespace LongoMatch.Gui.Component
{
- public delegate void SectionHandler(SectionsTimeNode tNode);
[System.ComponentModel.Category("LongoMatch")]
[System.ComponentModel.ToolboxItem(true)]
public class CategoriesTreeView : Gtk.TreeView
{
public event SectionHandler SectionClicked;
- public event SectionHandler SectionSelected;
+ public event SectionsHandler SectionsSelected;
public CategoriesTreeView() {
RowActivated += OnTreeviewRowActivated;
- CursorChanged += OnCursorChanged;
+ Selection.Changed += OnSelectionChanged;
+ Selection.Mode = SelectionMode.Multiple;
Gtk.TreeViewColumn nameColumn = new Gtk.TreeViewColumn();
nameColumn.Title = Catalog.GetString("Name");
@@ -131,12 +132,20 @@ namespace LongoMatch.Gui.Component
(cell as Gtk.CellRendererText).Text = tNode.SortMethodString;
}
- protected virtual void OnCursorChanged(object o, System.EventArgs e) {
+ protected virtual void OnSelectionChanged(object o, System.EventArgs e) {
TreeIter iter;
- Selection.GetSelected(out iter);
- SectionsTimeNode tNode = (SectionsTimeNode) Model.GetValue(iter, 0);
- if (SectionSelected != null)
- SectionSelected(tNode);
+ List<SectionsTimeNode> list;
+ TreePath[] pathArray;
+
+ list = new List<SectionsTimeNode>();
+ pathArray = Selection.GetSelectedRows();
+
+ for (int i=0; i< pathArray.Length; i++){
+ Model.GetIterFromString (out iter, pathArray[i].ToString());
+ list.Add((SectionsTimeNode) Model.GetValue(iter, 0));
+ }
+ if (SectionsSelected != null)
+ SectionsSelected(list);
}
protected virtual void OnTreeviewRowActivated(object o, Gtk.RowActivatedArgs args)
diff --git a/LongoMatch/Handlers/Handlers.cs b/LongoMatch/Handlers/Handlers.cs
index 3206971..61ebd11 100644
--- a/LongoMatch/Handlers/Handlers.cs
+++ b/LongoMatch/Handlers/Handlers.cs
@@ -79,5 +79,10 @@ namespace LongoMatch.Handlers
public delegate void SnapshotSeriesHandler(MediaTimeNode tNode);
//A new version of the software exists
public delegate void NewVersionHandler(Version version, string URL);
+
+
+ public delegate void SectionHandler(SectionsTimeNode tNode);
+ public delegate void SectionsHandler(List<SectionsTimeNode> tNodesList);
+
}
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.ProjectTemplateWidget.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.ProjectTemplateWidget.cs
index c12ea69..3e0f0aa 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.ProjectTemplateWidget.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.ProjectTemplateWidget.cs
@@ -220,8 +220,8 @@ namespace LongoMatch.Gui.Component {
this.exportbutton.Hide();
this.Show();
this.KeyPressEvent += new Gtk.KeyPressEventHandler(this.OnKeyPressEvent);
- this.sectionstreeview1.SectionClicked += new LongoMatch.Gui.Component.SectionHandler(this.OnSectionstreeview1SectionClicked);
- this.sectionstreeview1.SectionSelected += new LongoMatch.Gui.Component.SectionHandler(this.OnSectionstreeview1SectionSelected);
+ this.sectionstreeview1.SectionClicked += new LongoMatch.Handlers.SectionHandler(this.OnSectionstreeview1SectionClicked);
+ this.sectionstreeview1.SectionsSelected += new LongoMatch.Handlers.SectionsHandler(this.OnSectionstreeview1SectionsSelected);
this.newprevbutton.Clicked += new System.EventHandler(this.OnNewBefore);
this.newafterbutton.Clicked += new System.EventHandler(this.OnNewAfter);
this.newafterbutton.Activated += new System.EventHandler(this.OnNewBefore);
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.TemplatesManager.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.TemplatesManager.cs
index 71f4cba..2180cbf 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.TemplatesManager.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.TemplatesManager.cs
@@ -177,6 +177,8 @@ namespace LongoMatch.Gui.Dialog {
this.hbox1.Add(this.teamtemplatewidget1);
Gtk.Box.BoxChild w33 = ((Gtk.Box.BoxChild)(this.hbox1[this.teamtemplatewidget1]));
w33.Position = 1;
+ w33.Expand = false;
+ w33.Fill = false;
this.hpaned1.Add(this.hbox1);
w1.Add(this.hpaned1);
Gtk.Box.BoxChild w35 = ((Gtk.Box.BoxChild)(w1[this.hpaned1]));
diff --git a/LongoMatch/gtk-gui/gui.stetic b/LongoMatch/gtk-gui/gui.stetic
index 8f87273..14887e3 100644
--- a/LongoMatch/gtk-gui/gui.stetic
+++ b/LongoMatch/gtk-gui/gui.stetic
@@ -1594,7 +1594,7 @@
<property name="MemberName" />
<property name="CanFocus">True</property>
<signal name="SectionClicked" handler="OnSectionstreeview1SectionClicked" />
- <signal name="SectionSelected" handler="OnSectionstreeview1SectionSelected" />
+ <signal name="SectionsSelected" handler="OnSectionstreeview1SectionsSelected" />
</widget>
</child>
</widget>
@@ -4066,6 +4066,8 @@ Hotkeys with a single key are also allowed with Ctrl+key.</property>
<packing>
<property name="Position">1</property>
<property name="AutoSize">True</property>
+ <property name="Expand">False</property>
+ <property name="Fill">False</property>
</packing>
</child>
</widget>
diff --git a/LongoMatch/gtk-gui/objects.xml b/LongoMatch/gtk-gui/objects.xml
index b68c8d7..dac8514 100644
--- a/LongoMatch/gtk-gui/objects.xml
+++ b/LongoMatch/gtk-gui/objects.xml
@@ -257,14 +257,6 @@
</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>
<object type="LongoMatch.Gui.Component.CategoryProperties" 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]