public static void SaveList(ListStore list, string path) { path = path + "streams.list"; File.Delete(path); for (int i = 0; i < list.IterNChildren(); i++) { TreeIter iter; list.GetIterFromString (out iter, i.ToString ()); File.AppendAllText(path, list.GetValue(iter, 0).ToString()); File.AppendAllText(path, " "); File.AppendAllText(path, list.GetValue(iter, 1).ToString()); File.AppendAllText(path, "\n"); } }
protected virtual void OnTreeviewrefCursorChanged(object sender, System.EventArgs e) { bool isSelect = treeviewref.Selection.CountSelectedRows() == 1; editAction1.Sensitive = isSelect && CanEdit; removeAction1.Sensitive = isSelect && CanDel; bool SelectFirst = false, SelectLast = false; bool Filtered = entryFilter.Text != ""; TreeIter iter, SelectIter; if (treeviewref.Selection.GetSelected(out SelectIter)) { TreePath SelectPath = RefListStore.GetPath(filter.ConvertIterToChildIter(SelectIter)); RefListStore.GetIterFirst(out iter); SelectFirst = RefListStore.GetPath(iter).Compare(SelectPath) == 0; RefListStore.IterNthChild(out iter, RefListStore.IterNChildren() - 1); SelectLast = RefListStore.GetPath(iter).Compare(SelectPath) == 0; } buttonOrdinalUp.Sensitive = isSelect && !Filtered && !SelectFirst; buttonOrdinalDown.Sensitive = isSelect && !Filtered && !SelectLast; buttonOk.Sensitive = isSelect; }
public void PopulateForm () { //for (int i = 0; i < comboboxDevices.Model.IterNChildren(); i++) // comboboxDevices.RemoveText(i); /* List<String> deviceNames = new List<string> (); foreach (LedController controller in Manager.Controllers) { deviceNames.Add (controller.DeviceVisibleName); } deviceNames.Sort (); */ string previousDeviceSerial = ""; if (comboboxDevices.Active >= 0) previousDeviceSerial = DeviceEntities[comboboxDevices.Active].Serial; ListStore store = new ListStore(typeof (string)); comboboxDevices.Model = store; DeviceEntities = Manager.GetOnlineDeviceList(); int previousDeviceIndex = -1; int index = -1; foreach (DeviceEntity entity in DeviceEntities) { store.AppendValues(entity.ToString()); index++; if (entity.ToString() == previousDeviceSerial) { previousDeviceIndex = index; } } SelectedController = null; if (store.IterNChildren() >= 1 && previousDeviceIndex == -1) { comboboxDevices.Active = 0; } else if (previousDeviceIndex >= 0) { comboboxDevices.Active = previousDeviceIndex; } else { UpdateFormComponents(); } }
static void rowsreordered_cb(IntPtr tree_model, IntPtr path_ptr, IntPtr iter_ptr, IntPtr new_order) { try { ListStore store = GLib.Object.GetObject(tree_model, false) as ListStore; TreePath path = GLib.Opaque.GetOpaque(path_ptr, typeof(TreePath), false) as TreePath; TreeIter iter = TreeIter.New(iter_ptr); int child_cnt = store.IterNChildren(); int[] child_order = new int [child_cnt]; Marshal.Copy(new_order, child_order, 0, child_cnt); store.OnRowsReordered(path, iter, child_order); } catch (Exception e) { GLib.ExceptionManager.RaiseUnhandledException(e, true); // NOTREACHED: above call doesn't return throw e; } }
/// <summary> /// Event Handler for Remove Button Clicked /// </summary> public void OnRemoveButtonClicked(object o, EventArgs args) { TreeModel tModel; Queue iterQueue; iterQueue = new Queue(); TreeSelection tSelect = SelTreeView.Selection; Array treePaths = tSelect.GetSelectedRows(out tModel); // remove compiler warning if (tModel != null) { tModel = null; } // We can't remove anything while getting the iters // because it will change the paths and we'll remove // the wrong stuff. foreach (TreePath tPath in treePaths) { TreeIter iter; if (SelTreeStore.GetIter(out iter, tPath)) { iterQueue.Enqueue(iter); } } // Now that we have all of the TreeIters, loop and // remove them all while (iterQueue.Count > 0) { TreeIter iter = (TreeIter)iterQueue.Dequeue(); MemberInfo member = (MemberInfo)SelTreeStore.GetValue(iter, 0); selectedUsers.Remove(member.UserID); SelTreeStore.Remove(ref iter); } if (SelTreeStore.IterNChildren() == 0) { SetResponseSensitive(ResponseType.Ok, false); } }
public ConnectDialog() : base(Gui.MainWindow.Window, "ConnectDialog") { store = new ListStore(typeof(object), typeof(string)); ipCombo.Model = store; ipCombo.TextColumn = 1; CellRendererPixbuf imageCell = new CellRendererPixbuf(); CellRendererText textCell = new CellRendererText(); ipCombo.Clear(); ipCombo.PackStart(imageCell, false); ipCombo.PackStart(textCell, true); ipCombo.SetCellDataFunc(imageCell, ShowImage); ipCombo.SetCellDataFunc(textCell, ShowText); ipCombo.WrapWidth = 3; ipCombo.Entry.ActivatesDefault = true; PopulateAddressCombo(); networksListStore = new ListStore(typeof(object)); networksListStore.AppendValues(new object()); foreach (Network network in Core.Networks) { networksListStore.AppendValues(network); } networksComboBox.Clear(); CellRendererText networkNameCell = new CellRendererText(); networksComboBox.PackStart(networkNameCell, false); networksComboBox.SetCellDataFunc(networkNameCell, new CellLayoutDataFunc(NetworkTextFunc)); networksComboBox.Model = networksListStore; networksComboBox.Changed += delegate { PopulateAddressCombo(); }; networksComboBox.Active = Math.Min(networksListStore.IterNChildren(), 1); notImage = Gui.LoadIcon(16, "dialog-warning"); localImage = Gui.LoadIcon(16, "stock_channel"); }
static void RowsReorderedSignalCallback(IntPtr arg0, IntPtr arg1, IntPtr arg2, IntPtr arg3, IntPtr gch) { Gtk.RowsReorderedArgs args = new Gtk.RowsReorderedArgs(); try { GLib.Signal sig = ((GCHandle)gch).Target as GLib.Signal; if (sig == null) { throw new Exception("Unknown signal GC handle received " + gch); } ListStore sender = GLib.Object.GetObject(arg0) as ListStore; args.Args = new object[3]; args.Args[0] = arg1 == IntPtr.Zero ? null : (Gtk.TreePath)GLib.Opaque.GetOpaque(arg1, typeof(Gtk.TreePath), false); args.Args[1] = Gtk.TreeIter.New(arg2); int child_cnt = sender.IterNChildren(); int[] new_order = new int [child_cnt]; Marshal.Copy(arg3, new_order, 0, child_cnt); args.Args[2] = new_order; Gtk.RowsReorderedHandler handler = (Gtk.RowsReorderedHandler)sig.Handler; handler(sender, args); } catch (Exception e) { GLib.ExceptionManager.RaiseUnhandledException(e, false); } }
private Widget BuildCombo(PipelineVariable variable) { ListStore model = new ListStore(typeof(string), typeof(string)); PipelineVariableComboBox box = new PipelineVariableComboBox(variable, model); TreeIter active_iter = TreeIter.Zero; box.Changed += OnComboChanged; if(variable.PossibleValuesCount > 0) { foreach(string key in variable.PossibleValuesKeys) { TreeIter iter = ComboAppend(model, variable, variable.PossibleValues[key].Display, key); if(variable.CurrentValue == key || (active_iter.Equals(TreeIter.Zero) && variable.DefaultValue == key)) { active_iter = iter; } } } else { double min = variable.MinValue; double max = variable.MaxValue; double step = variable.StepValue; double current = min; for(; current <= max; current += step) { ComboAppend(model, variable, current.ToString(), current.ToString()); } } if(active_iter.Equals(TreeIter.Zero)) { for(int i = 0, n = model.IterNChildren(); i < n; i++) { TreeIter iter; if(model.IterNthChild(out iter, i)) { string value = (string)model.GetValue(iter, 1); if(value == variable.CurrentValue) { active_iter = iter; break; } } } } CellRendererText text_renderer = new CellRendererText(); box.PackStart(text_renderer, true); box.AddAttribute(text_renderer, "text", 0); box.Model = model; if(active_iter.Equals(TreeIter.Zero)) { if(model.IterNthChild(out active_iter, 0)) { box.SetActiveIter(active_iter); } } else { box.SetActiveIter(active_iter); } return box; }
public static int CountRows(Gtk.ListStore ls) { return(ls.IterNChildren()); }
private void SharedConstructor() { fileListStore = new ListStore(typeof(string)); fileList.Model = fileListStore; TreeViewColumn theCol = fileList.AppendColumn("File Attachments", new CellRendererText(), "text", 0 ); theCol.Sizing = TreeViewColumnSizing.Autosize; networksListStore = new ListStore(typeof (object)); networksListStore.AppendValues(new object()); foreach (Network network in Core.Networks) { networksListStore.AppendValues (network); } networksComboBox.Clear (); CellRendererText networkNameCell = new CellRendererText (); networksComboBox.PackStart (networkNameCell, true); networksComboBox.SetCellDataFunc (networkNameCell, NetworkTextFunc); networksComboBox.Model = networksListStore; networksComboBox.Active = Math.Min(networksListStore.IterNChildren(), 1); }
private void SetupProviders() { providers = Daemon.GetProviders (); providerStore = new ListStore (typeof (string), typeof (string)); providerCombo.Model = providerStore; CellRendererText renderer = new CellRendererText (); providerCombo.PackStart (renderer, false); providerCombo.AddAttribute (renderer, "text", 0); foreach (Provider p in providers) { if (p.Plugin != "beagle") { providerStore.AppendValues (p.Name, p.Plugin); } } if (providerStore.IterNChildren () == 0) { providerRadio.Sensitive = false; providerCombo.Sensitive = false; specifyRadio.Active = true; providerStore.AppendValues ("None", "None"); providerCombo.Active = 0; } else { providerCombo.Active = 0; } beagleRadio.Sensitive = FindProvider ("beagle") != null; }
public JoinChatroomDialog(Window parent) : base(parent, "JoinChatroomDialog") { passwordEntry.Text = ""; networksListStore = new ListStore (typeof (object)); networksListStore.AppendValues (new object()); foreach (Network network in Core.Networks) { networksListStore.AppendValues (network); } roomListStore = new ListStore (typeof(string), typeof(ChatRoom)); CellRendererText textCell = new CellRendererText (); networkCombo.PackStart (textCell, true); networkCombo.SetCellDataFunc (textCell, new CellLayoutDataFunc (networkComboBox_TextFunc)); networkCombo.Model = networksListStore; roomNameCombo.Entry.Changed += roomNameCombo_Entry_Changed; roomNameCombo.Entry.ActivatesDefault = true; roomNameCombo.Entry.Text = "#"; var imageCell = new CellRendererPixbuf (); roomNameCombo.PackEnd(imageCell, false); roomNameCombo.SetCellDataFunc(imageCell, RoomComboImageFunc); roomNameCombo.Model = roomListStore; roomNameCombo.TextColumn = 0; if (networksListStore.IterNChildren() > 0) { networkCombo.Active = 1; roomNameCombo.Entry.GrabFocus(); roomNameCombo.Entry.SelectRegion(1,1); } else { networkCombo.Active = 0; } base.Dialog.Shown += delegate { roomNameCombo.Entry.SelectRegion (1,1); }; EnableDisableOkButton(); }