[longomatch/redesign3: 126/156] Add dialog to edit sub category tags



commit 55e6039ff51dfc5f27d0061b0589ec7bc300371b
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Apr 27 22:23:50 2011 +0200

    Add dialog to edit sub category tags

 LongoMatch/Gui/Dialog/SubCategoryTagsEditor.cs     |   91 +++++++++++
 .../LongoMatch.Gui.Dialog.SubCategoryTagsEditor.cs |  165 ++++++++++++++++++++
 2 files changed, 256 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch/Gui/Dialog/SubCategoryTagsEditor.cs b/LongoMatch/Gui/Dialog/SubCategoryTagsEditor.cs
new file mode 100644
index 0000000..c9330a7
--- /dev/null
+++ b/LongoMatch/Gui/Dialog/SubCategoryTagsEditor.cs
@@ -0,0 +1,91 @@
+// 
+//  Copyright (C) 2011 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.Collections.Generic;
+using Gtk;
+
+using LongoMatch.Store;
+
+namespace LongoMatch.Gui.Dialog
+{
+	public partial class SubCategoryTagsEditor : Gtk.Dialog
+	{
+		private TagSubCategory template;
+		private Dictionary<string, Widget>  tagsDict;
+		
+		public SubCategoryTagsEditor (TagSubCategory template)
+		{
+			this.Build ();
+			tagsDict = new Dictionary<string, Widget>();
+			addtagbutton.Clicked += OnAddTag;
+			tagentry.Activated += OnAddTag;
+			Template = template;
+		}
+		
+		public TagSubCategory Template {
+			set{
+				template = value;
+				nameentry.Text = template.Name;
+				foreach (string tag in template)
+					AddTag(tag, false);
+			}
+			get {
+				template.Name = nameentry.Text;
+				return template;
+			}
+		}
+		
+		private void RemoveTag (string tag) {
+			tagsbox.Remove(tagsDict[tag]);
+			tagsDict.Remove(tag);
+			template.Remove(tag);
+		}
+		
+		private void AddTag(string tag, bool update) {
+			HBox box;
+			Label label;
+			Button button;
+			
+			if (tagsDict.ContainsKey(tag))
+				return;
+			
+			box = new HBox();
+			label = new Label(tag);
+			label.Justify = Justification.Left;
+			button = new Button("gtk-delete");
+			button.Clicked += delegate {
+				RemoveTag(tag);
+			};
+			box.PackStart(label, true, false, 0);
+			box.PackStart(button, false, false, 0);
+			
+			tagsbox.PackStart(box, false, false, 0);
+			box.ShowAll();
+			
+			tagsDict.Add(tag, box);
+			if (update)
+				template.Add(tag);
+		}
+		
+		protected virtual void OnAddTag (object sender, System.EventArgs e)
+		{
+			AddTag(tagentry.Text, true);
+		}
+	}
+}
+
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.SubCategoryTagsEditor.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.SubCategoryTagsEditor.cs
new file mode 100644
index 0000000..f2d0501
--- /dev/null
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.SubCategoryTagsEditor.cs
@@ -0,0 +1,165 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace LongoMatch.Gui.Dialog
+{
+	public partial class SubCategoryTagsEditor
+	{
+		private global::Gtk.VBox vbox2;
+
+		private global::Gtk.HBox hbox2;
+
+		private global::Gtk.Label label1;
+
+		private global::Gtk.Entry nameentry;
+
+		private global::Gtk.ScrolledWindow scrolledwindow1;
+
+		private global::Gtk.VBox tagsbox;
+
+		private global::Gtk.HBox hbox1;
+
+		private global::Gtk.Entry tagentry;
+
+		private global::Gtk.Button addtagbutton;
+
+		private global::Gtk.Button buttonOk;
+
+		protected virtual void Build ()
+		{
+			global::Stetic.Gui.Initialize (this);
+			// Widget LongoMatch.Gui.Dialog.SubCategoryTagsEditor
+			this.Name = "LongoMatch.Gui.Dialog.SubCategoryTagsEditor";
+			this.Title = global::Mono.Unix.Catalog.GetString ("Edit sub category tags");
+			this.Icon = global::Gdk.Pixbuf.LoadFromResource ("longomatch.png");
+			this.WindowPosition = ((global::Gtk.WindowPosition)(1));
+			this.Modal = true;
+			this.Gravity = ((global::Gdk.Gravity)(5));
+			this.SkipPagerHint = true;
+			this.SkipTaskbarHint = true;
+			// Internal child LongoMatch.Gui.Dialog.SubCategoryTagsEditor.VBox
+			global::Gtk.VBox w1 = this.VBox;
+			w1.Name = "dialog1_VBox";
+			w1.BorderWidth = ((uint)(2));
+			// Container child dialog1_VBox.Gtk.Box+BoxChild
+			this.vbox2 = new global::Gtk.VBox ();
+			this.vbox2.Name = "vbox2";
+			this.vbox2.Spacing = 6;
+			// Container child vbox2.Gtk.Box+BoxChild
+			this.hbox2 = new global::Gtk.HBox ();
+			this.hbox2.Name = "hbox2";
+			this.hbox2.Spacing = 6;
+			// Container child hbox2.Gtk.Box+BoxChild
+			this.label1 = new global::Gtk.Label ();
+			this.label1.Name = "label1";
+			this.label1.LabelProp = global::Mono.Unix.Catalog.GetString ("Sub category name:");
+			this.hbox2.Add (this.label1);
+			global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.label1]));
+			w2.Position = 0;
+			w2.Expand = false;
+			w2.Fill = false;
+			// Container child hbox2.Gtk.Box+BoxChild
+			this.nameentry = new global::Gtk.Entry ();
+			this.nameentry.CanFocus = true;
+			this.nameentry.Name = "nameentry";
+			this.nameentry.Text = global::Mono.Unix.Catalog.GetString ("Goal type");
+			this.nameentry.IsEditable = true;
+			this.nameentry.InvisibleChar = 'â';
+			this.hbox2.Add (this.nameentry);
+			global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.nameentry]));
+			w3.Position = 1;
+			this.vbox2.Add (this.hbox2);
+			global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox2]));
+			w4.Position = 0;
+			w4.Expand = false;
+			w4.Fill = false;
+			// Container child vbox2.Gtk.Box+BoxChild
+			this.scrolledwindow1 = new global::Gtk.ScrolledWindow ();
+			this.scrolledwindow1.CanFocus = true;
+			this.scrolledwindow1.Name = "scrolledwindow1";
+			// Container child scrolledwindow1.Gtk.Container+ContainerChild
+			global::Gtk.Viewport w5 = new global::Gtk.Viewport ();
+			w5.ShadowType = ((global::Gtk.ShadowType)(0));
+			// Container child GtkViewport.Gtk.Container+ContainerChild
+			this.tagsbox = new global::Gtk.VBox ();
+			this.tagsbox.Name = "tagsbox";
+			this.tagsbox.Spacing = 6;
+			w5.Add (this.tagsbox);
+			this.scrolledwindow1.Add (w5);
+			this.vbox2.Add (this.scrolledwindow1);
+			global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.scrolledwindow1]));
+			w8.Position = 1;
+			// Container child vbox2.Gtk.Box+BoxChild
+			this.hbox1 = new global::Gtk.HBox ();
+			this.hbox1.Name = "hbox1";
+			this.hbox1.Spacing = 6;
+			// Container child hbox1.Gtk.Box+BoxChild
+			this.tagentry = new global::Gtk.Entry ();
+			this.tagentry.CanFocus = true;
+			this.tagentry.Name = "tagentry";
+			this.tagentry.Text = global::Mono.Unix.Catalog.GetString ("Penalty");
+			this.tagentry.IsEditable = true;
+			this.tagentry.InvisibleChar = 'â';
+			this.hbox1.Add (this.tagentry);
+			global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.tagentry]));
+			w9.Position = 0;
+			// Container child hbox1.Gtk.Box+BoxChild
+			this.addtagbutton = new global::Gtk.Button ();
+			this.addtagbutton.CanFocus = true;
+			this.addtagbutton.Name = "addtagbutton";
+			this.addtagbutton.UseUnderline = true;
+			// Container child addtagbutton.Gtk.Container+ContainerChild
+			global::Gtk.Alignment w10 = new global::Gtk.Alignment (0.5f, 0.5f, 0f, 0f);
+			// Container child GtkAlignment.Gtk.Container+ContainerChild
+			global::Gtk.HBox w11 = new global::Gtk.HBox ();
+			w11.Spacing = 2;
+			// Container child GtkHBox.Gtk.Container+ContainerChild
+			global::Gtk.Image w12 = new global::Gtk.Image ();
+			w12.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-add", global::Gtk.IconSize.Menu);
+			w11.Add (w12);
+			// Container child GtkHBox.Gtk.Container+ContainerChild
+			global::Gtk.Label w14 = new global::Gtk.Label ();
+			w14.LabelProp = global::Mono.Unix.Catalog.GetString ("Add tag");
+			w14.UseUnderline = true;
+			w11.Add (w14);
+			w10.Add (w11);
+			this.addtagbutton.Add (w10);
+			this.hbox1.Add (this.addtagbutton);
+			global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.addtagbutton]));
+			w18.Position = 1;
+			w18.Expand = false;
+			w18.Fill = false;
+			this.vbox2.Add (this.hbox1);
+			global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox1]));
+			w19.Position = 2;
+			w19.Expand = false;
+			w19.Fill = false;
+			w1.Add (this.vbox2);
+			global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(w1[this.vbox2]));
+			w20.Position = 0;
+			// Internal child LongoMatch.Gui.Dialog.SubCategoryTagsEditor.ActionArea
+			global::Gtk.HButtonBox w21 = this.ActionArea;
+			w21.Name = "dialog1_ActionArea";
+			w21.Spacing = 10;
+			w21.BorderWidth = ((uint)(5));
+			w21.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 w22 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w21[this.buttonOk]));
+			w22.Expand = false;
+			w22.Fill = false;
+			if ((this.Child != null)) {
+				this.Child.ShowAll ();
+			}
+			this.DefaultWidth = 272;
+			this.DefaultHeight = 304;
+			this.Show ();
+		}
+	}
+}



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