[longomatch/redesign: 80/82] Add manager for subcategories
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign: 80/82] Add manager for subcategories
- Date: Mon, 14 Mar 2011 00:23:33 +0000 (UTC)
commit 95fd4db350f3f3768959f32c3ec84d1ed8be2efe
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Mar 13 20:39:56 2011 +0100
Add manager for subcategories
LongoMatch/Gui/Dialog/SubCategoriesManager.cs | 101 +++++++++++
.../LongoMatch.Gui.Dialog.SubCategoriesManager.cs | 189 ++++++++++++++++++++
2 files changed, 290 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch/Gui/Dialog/SubCategoriesManager.cs b/LongoMatch/Gui/Dialog/SubCategoriesManager.cs
new file mode 100644
index 0000000..decde75
--- /dev/null
+++ b/LongoMatch/Gui/Dialog/SubCategoriesManager.cs
@@ -0,0 +1,101 @@
+//
+// 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;
+using LongoMatch.Store.Templates;
+using LongoMatch.Common;
+
+namespace LongoMatch.Gui.Dialog
+{
+ public partial class SubCategoriesManager : Gtk.Dialog
+ {
+ private ListStore store;
+ private List<SubCategory> selectedSubCategories;
+ private Dictionary<SubCategory, string> catsDict;
+
+ public SubCategoriesManager ()
+ {
+ this.Build ();
+ catsDict = new Dictionary<SubCategory, string>();
+ subcategoriestreeview1.SubCategoryClicked += OnSubCategoryClicked;
+ subcategoriestreeview1.SubCategoriesSelected += OnSubCategoriesSelected;
+
+ LoadSubcategories();
+ UpdateModel();
+ }
+
+ private void UpdateModel(){
+ store = new Gtk.ListStore(typeof(string));
+ foreach (SubCategory subCat in catsDict.Keys)
+ store.AppendValues(subCat);
+ subcategoriestreeview1.Model = store;
+ }
+
+ private void LoadSubcategories()
+ {
+ string[] allFiles = System.IO.Directory.GetFiles(MainClass.TemplatesDir(),
+ "*."+Constants.SUBCAT_EXT);
+
+ foreach(string filePath in allFiles) {
+ try {
+ SubCategory subCat = SubCategory.Load(filePath);
+ catsDict.Add(subCat, filePath);
+ } catch (Exception ex) {
+ Log.Warning("Error loading subcategories template " + filePath);
+ Log.Exception(ex);
+ }
+ }
+ }
+
+ protected virtual void OnSubCategoryClicked (SubCategory subCat)
+ {
+ }
+
+ protected virtual void OnSubCategoriesSelected (List<SubCategory> list)
+ {
+ removebutton.Sensitive = true;
+ editbutton.Sensitive = list.Count == 1;
+ }
+
+ protected virtual void OnEdit (object sender, System.EventArgs e)
+ {
+ /* FIXME: Launch dialog editor */
+ }
+
+ protected virtual void OnNew (object sender, System.EventArgs e)
+ {
+ /* FIXME: Launch dialog editor */
+ }
+ protected virtual void OnDelete (object sender, System.EventArgs e)
+ {
+ foreach (SubCategory subcat in selectedSubCategories){
+ try {
+ System.IO.File.Delete(catsDict[subcat]);
+ } catch (Exception ex) {
+ Log.Warning ("Error deleting subcategory " + catsDict[subcat]);
+ Log.Exception(ex);
+ }
+ catsDict.Remove(subcat);
+ }
+ UpdateModel();
+ }
+ }
+}
+
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.SubCategoriesManager.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.SubCategoriesManager.cs
new file mode 100644
index 0000000..7863c0e
--- /dev/null
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Dialog.SubCategoriesManager.cs
@@ -0,0 +1,189 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace LongoMatch.Gui.Dialog
+{
+ public partial class SubCategoriesManager
+ {
+ private global::Gtk.HBox hbox2;
+
+ private global::Gtk.ScrolledWindow GtkScrolledWindow;
+
+ private global::LongoMatch.Gui.TreeView.SubCategoriesTreeView subcategoriestreeview1;
+
+ private global::Gtk.VBox vbox2;
+
+ private global::Gtk.Button newprevbutton;
+
+ private global::Gtk.Button removebutton;
+
+ private global::Gtk.Button editbutton;
+
+ private global::Gtk.HSeparator hseparator1;
+
+ private global::Gtk.Button buttonCancel;
+
+ protected virtual void Build ()
+ {
+ global::Stetic.Gui.Initialize (this);
+ // Widget LongoMatch.Gui.Dialog.SubCategoriesManager
+ this.Name = "LongoMatch.Gui.Dialog.SubCategoriesManager";
+ this.Title = global::Mono.Unix.Catalog.GetString ("Sub categories editor");
+ this.Icon = global::Gdk.Pixbuf.LoadFromResource ("longomatch.png");
+ 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.SubCategoriesManager.VBox
+ global::Gtk.VBox w1 = this.VBox;
+ w1.Name = "dialog1_VBox";
+ w1.BorderWidth = ((uint)(2));
+ // Container child dialog1_VBox.Gtk.Box+BoxChild
+ this.hbox2 = new global::Gtk.HBox ();
+ this.hbox2.Name = "hbox2";
+ this.hbox2.Spacing = 6;
+ // Container child hbox2.Gtk.Box+BoxChild
+ this.GtkScrolledWindow = new global::Gtk.ScrolledWindow ();
+ this.GtkScrolledWindow.Name = "GtkScrolledWindow";
+ this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
+ // Container child GtkScrolledWindow.Gtk.Container+ContainerChild
+ this.subcategoriestreeview1 = new global::LongoMatch.Gui.TreeView.SubCategoriesTreeView ();
+ this.subcategoriestreeview1.CanFocus = true;
+ this.subcategoriestreeview1.Name = "subcategoriestreeview1";
+ this.GtkScrolledWindow.Add (this.subcategoriestreeview1);
+ this.hbox2.Add (this.GtkScrolledWindow);
+ global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.GtkScrolledWindow]));
+ w3.Position = 0;
+ // Container child hbox2.Gtk.Box+BoxChild
+ this.vbox2 = new global::Gtk.VBox ();
+ this.vbox2.Name = "vbox2";
+ this.vbox2.Spacing = 6;
+ // Container child vbox2.Gtk.Box+BoxChild
+ this.newprevbutton = new global::Gtk.Button ();
+ this.newprevbutton.TooltipMarkup = "Insert a new category before the selected one";
+ this.newprevbutton.CanFocus = true;
+ this.newprevbutton.Name = "newprevbutton";
+ this.newprevbutton.UseUnderline = true;
+ // Container child newprevbutton.Gtk.Container+ContainerChild
+ global::Gtk.Alignment w4 = new global::Gtk.Alignment (0.5f, 0.5f, 0f, 0f);
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
+ global::Gtk.HBox w5 = new global::Gtk.HBox ();
+ w5.Spacing = 2;
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Image w6 = new global::Gtk.Image ();
+ w6.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-new", global::Gtk.IconSize.Menu);
+ w5.Add (w6);
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Label w8 = new global::Gtk.Label ();
+ w8.LabelProp = global::Mono.Unix.Catalog.GetString ("New sub category");
+ w8.UseUnderline = true;
+ w5.Add (w8);
+ w4.Add (w5);
+ this.newprevbutton.Add (w4);
+ this.vbox2.Add (this.newprevbutton);
+ global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.newprevbutton]));
+ w12.Position = 0;
+ w12.Expand = false;
+ w12.Fill = false;
+ // Container child vbox2.Gtk.Box+BoxChild
+ this.removebutton = new global::Gtk.Button ();
+ this.removebutton.TooltipMarkup = "Remove the selected category";
+ this.removebutton.Sensitive = false;
+ this.removebutton.CanFocus = true;
+ this.removebutton.Name = "removebutton";
+ this.removebutton.UseUnderline = true;
+ // Container child removebutton.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-delete", global::Gtk.IconSize.Menu);
+ w14.Add (w15);
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Label w17 = new global::Gtk.Label ();
+ w17.LabelProp = global::Mono.Unix.Catalog.GetString ("Remove");
+ w17.UseUnderline = true;
+ w14.Add (w17);
+ w13.Add (w14);
+ this.removebutton.Add (w13);
+ this.vbox2.Add (this.removebutton);
+ global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.removebutton]));
+ w21.Position = 1;
+ w21.Expand = false;
+ w21.Fill = false;
+ // Container child vbox2.Gtk.Box+BoxChild
+ this.editbutton = new global::Gtk.Button ();
+ this.editbutton.TooltipMarkup = "Edit the selected category";
+ this.editbutton.Sensitive = false;
+ this.editbutton.CanFocus = true;
+ this.editbutton.Name = "editbutton";
+ this.editbutton.UseUnderline = true;
+ // Container child editbutton.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-edit", global::Gtk.IconSize.Menu);
+ w23.Add (w24);
+ // Container child GtkHBox.Gtk.Container+ContainerChild
+ global::Gtk.Label w26 = new global::Gtk.Label ();
+ w26.LabelProp = global::Mono.Unix.Catalog.GetString ("Edit");
+ w26.UseUnderline = true;
+ w23.Add (w26);
+ w22.Add (w23);
+ this.editbutton.Add (w22);
+ this.vbox2.Add (this.editbutton);
+ global::Gtk.Box.BoxChild w30 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.editbutton]));
+ w30.Position = 2;
+ w30.Expand = false;
+ w30.Fill = false;
+ // Container child vbox2.Gtk.Box+BoxChild
+ this.hseparator1 = new global::Gtk.HSeparator ();
+ this.hseparator1.Name = "hseparator1";
+ this.vbox2.Add (this.hseparator1);
+ global::Gtk.Box.BoxChild w31 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hseparator1]));
+ w31.Position = 3;
+ w31.Expand = false;
+ w31.Fill = false;
+ this.hbox2.Add (this.vbox2);
+ global::Gtk.Box.BoxChild w32 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.vbox2]));
+ w32.Position = 1;
+ w32.Expand = false;
+ w32.Fill = false;
+ w1.Add (this.hbox2);
+ global::Gtk.Box.BoxChild w33 = ((global::Gtk.Box.BoxChild)(w1[this.hbox2]));
+ w33.Position = 0;
+ // Internal child LongoMatch.Gui.Dialog.SubCategoriesManager.ActionArea
+ global::Gtk.HButtonBox w34 = this.ActionArea;
+ w34.Name = "dialog1_ActionArea";
+ w34.Spacing = 10;
+ w34.BorderWidth = ((uint)(5));
+ w34.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
+ // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
+ this.buttonCancel = new global::Gtk.Button ();
+ this.buttonCancel.CanDefault = true;
+ this.buttonCancel.CanFocus = true;
+ this.buttonCancel.Name = "buttonCancel";
+ this.buttonCancel.UseStock = true;
+ this.buttonCancel.UseUnderline = true;
+ this.buttonCancel.Label = "gtk-quit";
+ this.AddActionWidget (this.buttonCancel, 0);
+ global::Gtk.ButtonBox.ButtonBoxChild w35 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w34[this.buttonCancel]));
+ w35.Expand = false;
+ w35.Fill = false;
+ if ((this.Child != null)) {
+ this.Child.ShowAll ();
+ }
+ this.DefaultWidth = 489;
+ this.DefaultHeight = 309;
+ this.hseparator1.Hide ();
+ this.Show ();
+ this.newprevbutton.Clicked += new global::System.EventHandler (this.OnNew);
+ this.editbutton.Clicked += new global::System.EventHandler (this.OnEdit);
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]