diff --git a/DMX-2.0/GestionCircuits.cs b/DMX-2.0/GestionCircuits.cs index 17c5e8d..28e6dd7 100644 --- a/DMX-2.0/GestionCircuits.cs +++ b/DMX-2.0/GestionCircuits.cs @@ -1,26 +1,23 @@ using System; +using System.Collections.Generic; namespace DMX2 { public partial class GestionCircuits : Gtk.Dialog { Gtk.ListStore ls; - public GestionCircuits () + public GestionCircuits (Gtk.Window parent) : base ("Circuits",parent,Gtk.DialogFlags.Modal) { + this.Build (); Gtk.TreeViewColumn nameCol = new Gtk.TreeViewColumn(); Gtk.CellRendererText nameCell = new Gtk.CellRendererText(); nameCol.Title = "Circuit"; nameCol.PackStart(nameCell,true); - nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( - new Gtk.TreeCellDataFunc(RenderCircuitName) - )); - + nameCol.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc( new Gtk.TreeCellDataFunc(RenderCircuitName) )); nameCell.Editable =true; nameCell.Edited += OnNameCellEdited; - this.listeCircuits.AppendColumn(nameCol); - ls = new Gtk.ListStore(typeof (Circuit)); this.listeCircuits.Model = ls; UpdateListeCircuits(); @@ -36,39 +33,59 @@ namespace DMX2 } - private void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { - Circuit c = tree_model.GetValue (iter, 0) as Circuit; - (cell as Gtk.CellRendererText).Text = c.Name; - } + private void RenderCircuitName(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) { + Circuit c = tree_model.GetValue (iter, 0) as Circuit; + (cell as Gtk.CellRendererText).Text = c.Name; + } protected void UpdateListeCircuits () { ls.Clear(); - foreach(Circuit c in Conduite.Courante.Circuits) + foreach(var c in Conduite.Courante.Circuits) ls.AppendValues(c); } protected void OnAddActionActivated (object sender, EventArgs e) { - Gtk.Dialog dlg = new Gtk.Dialog("Test", this, Gtk.DialogFlags.DestroyWithParent); - Gtk.VBox vb = new Gtk.VBox(); - var etry = new Gtk.Entry(); - dlg.Add(vb); - vb.Add(etry); - vb.Add(dlg.AddButton("Close",Gtk.ResponseType.Close)); + var dlg = new Gtk.Dialog ("Test", this, Gtk.DialogFlags.DestroyWithParent); + dlg.VBox.Add (new Gtk.Label ("Nombre de circuits :")); + var etry = new Gtk.Entry ("1"); + etry.ActivatesDefault=true; + dlg.VBox.Add (etry); + dlg.AddButton ("Close", Gtk.ResponseType.Close ).GrabDefault(); + dlg.VBox.ShowAll (); dlg.Run (); - dlg.Destroy(); - - Conduite.Courante.NouveauCircuit(); - UpdateListeCircuits(); - + int nb; + if (int.TryParse (etry.Text, out nb) && nb > 0) { + for (int i=0; i GetSelection() + { + Gtk.TreeIter iter; List selection = new List(); + foreach(var row in listeCircuits.Selection.GetSelectedRows()) + { + ls.GetIter (out iter, row); + selection.Add( ls.GetValue(iter,0) as Circuit); + } + return selection; + } + protected void OnResp (object o, Gtk.ResponseArgs args) { Hide (); diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index 7e8f502..9e8b11f 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -23,12 +23,8 @@ namespace DMX2 protected void OnCircuitsActionActivated (object sender, EventArgs e) { - GestionCircuits gc= new GestionCircuits(); - gc.Parent=this; + GestionCircuits gc= new GestionCircuits(this); gc.Run(); } - - - } } \ No newline at end of file diff --git a/DMX-2.0/gtk-gui/DMX2.GestionCircuits.cs b/DMX-2.0/gtk-gui/DMX2.GestionCircuits.cs index f19d280..d626191 100644 --- a/DMX-2.0/gtk-gui/DMX2.GestionCircuits.cs +++ b/DMX-2.0/gtk-gui/DMX2.GestionCircuits.cs @@ -28,6 +28,7 @@ namespace DMX2 this.Name = "DMX2.GestionCircuits"; this.Title = global::Mono.Unix.Catalog.GetString ("Circuits"); this.TypeHint = ((global::Gdk.WindowTypeHint)(1)); + this.WindowPosition = ((global::Gtk.WindowPosition)(4)); this.DestroyWithParent = true; this.Gravity = ((global::Gdk.Gravity)(10)); // Internal child DMX2.GestionCircuits.VBox @@ -88,7 +89,8 @@ namespace DMX2 } this.DefaultWidth = 400; this.DefaultHeight = 456; - this.Show (); + this.buttonOk.HasDefault = true; + this.Hide (); this.Response += new global::Gtk.ResponseHandler (this.OnResp); this.addAction.Activated += new global::System.EventHandler (this.OnAddActionActivated); this.removeAction.Activated += new global::System.EventHandler (this.OnRemoveActionActivated); diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index e07352e..7dfb032 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -327,8 +327,10 @@ + False Circuits Dialog + CenterOnParent True Static 1 @@ -396,6 +398,7 @@ True + True True True StockItem