public void PopulateForm () { Gtk.TreeViewColumn serialColumn = new Gtk.TreeViewColumn (); serialColumn.Title = "Serial"; Gtk.TreeViewColumn nameColumn = new Gtk.TreeViewColumn (); nameColumn.Title = "Name"; Gtk.CellRendererText serialCell = new Gtk.CellRendererText (); Gtk.CellRendererText nameCell = new Gtk.CellRendererText (); serialColumn.PackStart (serialCell, false); serialColumn.SetCellDataFunc (serialCell, new Gtk.TreeCellDataFunc (RenderSerial)); nameColumn.PackEnd (nameCell, true); nameColumn.SetCellDataFunc (nameCell, new Gtk.TreeCellDataFunc (RenderName)); treeviewDevices.Model = DeviceListStore; treeviewDevices.AppendColumn (serialColumn); treeviewDevices.AppendColumn (nameColumn); List<String> deviceNames = new List<string> (); foreach (LedController controller in Manager.Controllers) { deviceNames.Add (controller.DeviceVisibleName); } deviceNames.Sort (); foreach (String name in deviceNames) { DeviceListStore.AppendValues(Manager.FindControllerBySerialNumber(name)); } UpdateFormComponents(); }
public HighlightingPanel () { this.Build (); var col = new TreeViewColumn (); var crpixbuf = new CellRendererPixbuf (); col.PackStart (crpixbuf, false); col.SetCellDataFunc (crpixbuf, ImageDataFunc); var crtext = new CellRendererText (); col.PackEnd (crtext, true); col.SetAttributes (crtext, "markup", 0); styleTreeview.AppendColumn (col); styleTreeview.Model = styleStore; styleTreeview.SearchColumn = -1; // disable the interactive search schemeName = DefaultSourceEditorOptions.Instance.ColorScheme; MonoDevelop.Ide.Gui.Styles.Changed += HandleThemeChanged; }
public HighlightingPanel () { this.Build (); var col = new TreeViewColumn (); var crpixbuf = new CellRendererPixbuf (); col.PackStart (crpixbuf, false); col.SetCellDataFunc (crpixbuf, (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) => { var isError = (bool)styleStore.GetValue (iter, 2); crpixbuf.Visible = isError; crpixbuf.Pixbuf = isError ? errorPixbuf.Value : null; }); var crtext = new CellRendererText (); col.PackEnd (crtext, true); col.SetAttributes (crtext, "markup", 0); styleTreeview.AppendColumn (col); styleTreeview.Model = styleStore; schemeName = DefaultSourceEditorOptions.Instance.ColorScheme; }
public EventsWidget() { this.Build(); Gtk.TreeViewColumn timeColumn = new Gtk.TreeViewColumn(); timeColumn.Title = "Time"; timeColumn.Resizable = true; Gtk.TreeViewColumn notificationColumn = new Gtk.TreeViewColumn(); notificationColumn.Title = "Notification"; notificationColumn.Resizable = true; Gtk.TreeViewColumn messageColumn = new Gtk.TreeViewColumn(); messageColumn.Title = "Message"; Gtk.CellRendererText timeCell = new Gtk.CellRendererText(); Gtk.CellRendererText notificationCell = new Gtk.CellRendererText(); Gtk.CellRendererText messageCell = new Gtk.CellRendererText(); timeColumn.PackEnd(timeCell, false); notificationColumn.PackEnd(notificationCell, false); messageColumn.PackEnd(messageCell, false); timeColumn.SetCellDataFunc(timeCell, new Gtk.TreeCellDataFunc(RenderTimeCell)); notificationColumn.SetCellDataFunc(notificationCell, new Gtk.TreeCellDataFunc(RenderNotificationCell)); messageColumn.SetCellDataFunc(messageCell, new Gtk.TreeCellDataFunc(RenderMessageCell)); treeviewEvents.AppendColumn(timeColumn); treeviewEvents.AppendColumn(notificationColumn); treeviewEvents.AppendColumn(messageColumn); EventListStore.SetSortFunc(0, delegate(TreeModel model, TreeIter a, TreeIter b) { TriggeredEvent s1 = (TriggeredEvent)model.GetValue(a, 0); TriggeredEvent s2 = (TriggeredEvent)model.GetValue(b, 0); return(DateTime.Compare(s1.TimeStamp, s2.TimeStamp)); }); EventListStore.SetSortColumnId(0, SortType.Descending); treeviewEvents.Model = EventListStore; RefreshTimer = GLib.Timeout.Add(5000, new GLib.TimeoutHandler(UpdateRows)); }
public ListTreeViewBase() { Selection.Mode = SelectionMode.Multiple; Selection.SelectFunction = SelectFunction; RowActivated += new RowActivatedHandler(OnTreeviewRowActivated); HeadersVisible = false; SetMenu(); ProjectIsLive = false; PlayListLoaded = false; nameColumn = new Gtk.TreeViewColumn(); nameColumn.Title = "Name"; nameCell = new Gtk.CellRendererText(); nameCell.Edited += OnNameCellEdited; Gtk.CellRendererPixbuf miniatureCell = new Gtk.CellRendererPixbuf(); nameColumn.PackStart(nameCell, true); nameColumn.PackEnd(miniatureCell, true); nameColumn.SetCellDataFunc(miniatureCell, new Gtk.TreeCellDataFunc(RenderMiniature)); nameColumn.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc(RenderName)); AppendColumn(nameColumn); }
public CustomPropertiesWidget (PListScheme scheme) { this.scheme = scheme = scheme ?? PListScheme.Empty; treeview = new PopupTreeView (this); treeview.HeadersClickable = true; this.PackStart (treeview, true, true, 0); ShowAll (); var keyRenderer = new CellRendererCombo (); keyRenderer.Editable = true; keyRenderer.Model = keyStore; keyRenderer.Mode = CellRendererMode.Editable; keyRenderer.TextColumn = 0; keyRenderer.Edited += delegate(object o, EditedArgs args) { TreeIter selIter; if (!treeStore.GetIterFromString (out selIter, args.Path)) return; if (args.NewText == (string)treeStore.GetValue (selIter, 0)) return; var obj = (PObject)treeStore.GetValue (selIter, 1); var dict = obj.Parent as PDictionary; if (dict == null) return; var key = scheme.Keys.FirstOrDefault (k => k.Identifier == args.NewText || k.Description == args.NewText); var newKey = key != null ? key.Identifier : args.NewText; dict.ChangeKey (obj, newKey, key == null || obj.TypeString == key.Type ? null : CreateNewObject (key.Type)); }; var col = new TreeViewColumn (); col.Resizable = true; col.Title = GettextCatalog.GetString ("Property"); col.PackStart (keyRenderer, true); col.SetCellDataFunc (keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; string id = (string)tree_model.GetValue (iter, 0) ?? ""; var obj = (PObject)tree_model.GetValue (iter, 1); if (obj == null) { renderer.Text = id; renderer.Editable = false; renderer.Sensitive = false; return; } var key = scheme.GetKey (id); renderer.Editable = !(obj.Parent is PArray); renderer.Sensitive = true; renderer.Text = key != null && ShowDescriptions ? GettextCatalog.GetString (key.Description) : id; }); treeview.AppendColumn (col); var iconSize = IconSize.Menu; col = new TreeViewColumn { MinWidth = 25, Resizable = true, Sizing = Gtk.TreeViewColumnSizing.Autosize }; var removeRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-remove", IconSize.Menu)); removeRenderer.Clicked += delegate { TreeIter iter; bool hasSelection = treeview.Selection.GetSelected (out iter); PObject obj = null; if (hasSelection) { obj = (PObject)treeStore.GetValue (iter, 1); obj.Remove (); } }; col.PackEnd (removeRenderer, false); col.SetCellDataFunc (removeRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { removeRenderer.Visible = treeview.Selection.IterIsSelected (iter) && !AddKeyNode.Equals (treeStore.GetValue (iter, 0)); }); var addRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-add", IconSize.Menu)); addRenderer.Clicked += delegate { Gtk.TreeIter iter = Gtk.TreeIter.Zero; if (!treeview.Selection.GetSelected (out iter)) return; PObject obj = null; if (treeStore.IterParent (out iter, iter)) obj = (PObject) treeStore.GetValue (iter, 1); obj = obj ?? nsDictionary; var newObj = new PString (""); if (obj is PArray) { var arr = (PArray) obj; arr.Add (newObj); } else if (obj is PDictionary) { string name = "newNode"; var dict = (PDictionary) obj; while (dict.ContainsKey (name)) name += "_"; dict.Add (name ,newObj); } else { return; } }; col.PackEnd (addRenderer, false); col.SetCellDataFunc (addRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { addRenderer.Visible = treeview.Selection.IterIsSelected (iter) && AddKeyNode.Equals (treeStore.GetValue (iter, 0)); }); treeview.AppendColumn (col); treeview.RowExpanded += delegate(object o, RowExpandedArgs args) { var obj = (PObject)treeStore.GetValue (args.Iter, 1); expandedObjects.Add (obj); }; treeview.RowCollapsed += delegate(object o, RowCollapsedArgs args) { var obj = (PObject)treeStore.GetValue (args.Iter, 1); expandedObjects.Remove (obj); }; var comboRenderer = new CellRendererCombo (); var typeModel = new ListStore (typeof (string)); typeModel.AppendValues ("Array"); typeModel.AppendValues ("Dictionary"); typeModel.AppendValues ("Boolean"); typeModel.AppendValues ("Data"); typeModel.AppendValues ("Date"); typeModel.AppendValues ("Number"); typeModel.AppendValues ("String"); comboRenderer.Model = typeModel; comboRenderer.Mode = CellRendererMode.Editable; comboRenderer.HasEntry = false; comboRenderer.TextColumn = 0; comboRenderer.Edited += delegate(object o, EditedArgs args) { TreeIter selIter; if (!treeStore.GetIterFromString (out selIter, args.Path)) return; PObject oldObj = (PObject)treeStore.GetValue (selIter, 1); if (oldObj != null && oldObj.TypeString != args.NewText) oldObj.Replace (CreateNewObject (args.NewText)); }; treeview.AppendColumn (GettextCatalog.GetString ("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; string id = (string)tree_model.GetValue (iter, 0) ?? ""; var key = scheme.GetKey (id); var obj = (PObject)tree_model.GetValue (iter, 1); if (obj == null) { renderer.Editable = false; renderer.Text = ""; return; } renderer.Editable = key == null; renderer.ForegroundGdk = Style.Text (renderer.Editable ? StateType.Normal : StateType.Insensitive); renderer.Text = obj.TypeString; }); var propRenderer = new CellRendererCombo (); propRenderer.Model = valueStore; propRenderer.Mode = CellRendererMode.Editable; propRenderer.TextColumn = 0; propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) { valueStore.Clear (); if (Scheme == null) return; TreeIter iter; if (!treeStore.GetIterFromString (out iter, args.Path)) return; var pObject = (PObject)treeStore.GetValue (iter, 1); if (pObject == null) return; var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null; if (key != null) { var descr = new List<string> (key.Values.Select (v => v.Description)); descr.Sort (); foreach (var val in descr) { valueStore.AppendValues (val); } } }; propRenderer.Edited += delegate(object o, EditedArgs args) { TreeIter iter; if (!treeStore.GetIterFromString (out iter, args.Path)) return; var pObject = (PObject)treeStore.GetValue (iter, 1); if (pObject == null) return; string newText = args.NewText; var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null; if (key != null) { foreach (var val in key.Values) { if (newText == val.Description) { newText = val.Identifier; break; } } } pObject.SetValue (newText); }; /* propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) { TreeIter iter; if (!treeStore.GetIterFromString (out iter, args.Path)) return; PObject obj = (PObject)treeStore.GetValue (iter, 1); if (obj is PBoolean) { ((PBoolean)obj).Value = !((PBoolean)obj).Value; propRenderer.StopEditing (false); } };*/ treeview.AppendColumn (GettextCatalog.GetString ("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; var obj = (PObject)tree_model.GetValue (iter, 1); if (obj == null) { renderer.Editable = false; renderer.Text = ""; return; } renderer.Editable = !(obj is PArray || obj is PDictionary || obj is PData); obj.RenderValue (this, renderer); }); treeview.EnableGridLines = TreeViewGridLines.Horizontal; treeview.Model = treeStore; }
public Toolbox(ServiceContainer parentServices) { this.parentServices = parentServices; //we need this service, so create it if not present toolboxService = parentServices.GetService (typeof (IToolboxService)) as ToolboxService; if (toolboxService == null) { toolboxService = new ToolboxService (); parentServices.AddService (typeof (IToolboxService), toolboxService); } #region Toolbar toolbar = new Toolbar (); toolbar.ToolbarStyle = ToolbarStyle.Icons; toolbar.IconSize = IconSize.SmallToolbar; base.PackStart (toolbar, false, false, 0); filterToggleButton = new ToggleToolButton (); filterToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar); filterToggleButton.Toggled += new EventHandler (toggleFiltering); toolbar.Insert (filterToggleButton, 0); catToggleButton = new ToggleToolButton (); catToggleButton.IconWidget = new Image (Stock.MissingImage, IconSize.SmallToolbar); catToggleButton.Toggled += new EventHandler (toggleCategorisation); toolbar.Insert (catToggleButton, 1); SeparatorToolItem sep = new SeparatorToolItem(); toolbar.Insert (sep, 2); filterEntry = new Entry(); filterEntry.WidthRequest = 150; filterEntry.Changed += new EventHandler (filterTextChanged); #endregion scrolledWindow = new ScrolledWindow (); base.PackEnd (scrolledWindow, true, true, 0); //Initialise model store = new ToolboxStore (); //initialise view nodeView = new NodeView (store); nodeView.Selection.Mode = SelectionMode.Single; nodeView.HeadersVisible = false; //cell renderers CellRendererPixbuf pixbufRenderer = new CellRendererPixbuf (); CellRendererText textRenderer = new CellRendererText (); textRenderer.Ellipsize = Pango.EllipsizeMode.End; //Main column with text, icons TreeViewColumn col = new TreeViewColumn (); col.PackStart (pixbufRenderer, false); col.SetAttributes (pixbufRenderer, "pixbuf", ToolboxStore.Columns.Icon, "visible", ToolboxStore.Columns.IconVisible, "cell-background-gdk", ToolboxStore.Columns.BackgroundColour); col.PackEnd (textRenderer, true); col.SetAttributes (textRenderer, "text", ToolboxStore.Columns.Label, "weight", ToolboxStore.Columns.FontWeight, "cell-background-gdk", ToolboxStore.Columns.BackgroundColour); nodeView.AppendColumn (col); //Initialise self scrolledWindow.VscrollbarPolicy = PolicyType.Automatic; scrolledWindow.HscrollbarPolicy = PolicyType.Never; scrolledWindow.WidthRequest = 150; scrolledWindow.AddWithViewport (nodeView); //selection events nodeView.NodeSelection.Changed += OnSelectionChanged; nodeView.RowActivated += OnRowActivated; //update view when toolbox service updated toolboxService.ToolboxChanged += new EventHandler (tbsChanged); Refresh (); //track expanded state of nodes nodeView.RowCollapsed += new RowCollapsedHandler (whenRowCollapsed); nodeView.RowExpanded += new RowExpandedHandler (whenRowExpanded); //set initial state filterToggleButton.Active = false; catToggleButton.Active = true; }
public MainWindow (): base (Gtk.WindowType.Toplevel) { if (!BlinkstickDeviceFinder.IsUnix()) { SetupSingleInstanceEvent(); } Build (); this.Title = "BlinkStick " + ApplicationVersion; log.Debug("Setting up controls"); Gtk.TreeViewColumn eventTitleColumn = new Gtk.TreeViewColumn (); eventTitleColumn.Title = "Name"; Gtk.TreeViewColumn eventTypeColumn = new Gtk.TreeViewColumn (); eventTypeColumn.Title = "Type"; Gtk.TreeViewColumn eventColorColumn = new Gtk.TreeViewColumn (); eventColorColumn.Title = "Color"; // Create the text cell that will display the artist name Gtk.CellRendererText eventTitleCell = new Gtk.CellRendererText (); Gtk.CellRendererText eventTypeCell = new Gtk.CellRendererText (); Gtk.CellRendererPixbuf eventColorCell = new Gtk.CellRendererPixbuf (); log.Debug ("Loading main form icon"); this.Icon = new global::Gdk.Pixbuf (global::System.IO.Path.Combine (global::System.AppDomain.CurrentDomain.BaseDirectory, "icon.png")); log.Debug( "Setting up treeview"); // Add the cell to the column eventColorColumn.PackStart (eventColorCell, false); eventTypeColumn.PackEnd (eventTypeCell, true); eventTitleColumn.PackEnd (eventTitleCell, true); // Tell the Cell Renderers which items in the model to display //eventTitleColumn.AddAttribute (eventTitleCell, "name", 0); eventTitleColumn.SetCellDataFunc (eventTitleCell, new Gtk.TreeCellDataFunc (RenderEventName)); eventTypeColumn.SetCellDataFunc (eventTypeCell, new Gtk.TreeCellDataFunc (RenderEventType)); eventColorColumn.SetCellDataFunc (eventColorCell, new Gtk.TreeCellDataFunc (RenderEventColor)); treeviewEvents.Model = EventListStore; treeviewEvents.AppendColumn (eventColorColumn); treeviewEvents.AppendColumn (eventTypeColumn); treeviewEvents.AppendColumn (eventTitleColumn); log.Debug("Updating buttons"); UpdateButtons (); log.Debug("Setting up notification manager"); Manager = new NotificationManager (); Manager.NotificationUpdated += HandleNotificationUpdated; Manager.Load (); Manager.UpdateControllers(); DeviceMonitor = new UsbMonitor(this.GdkWindow.Handle); DeviceMonitor.UsbDeviceAdded += (object sender, EventArgs e) => { Gtk.Application.Invoke (delegate { Manager.UpdateControllers(); if (testForm != null) { testForm.PopulateForm(); } }); }; DeviceMonitor.Start (); log.Debug("Adding notifications to the tree"); //Gtk.TreeIter customEventRoot = EventListStore.AppendValues(new TriggeredEvent("Custom")); foreach (CustomNotification e in Manager.Notifications) { //EventListStore.AppendValues(customEventRoot, e); EventListStore.AppendValues (e); } log.Debug("Starting notification manager"); Manager.Start (); log.Debug ("Building popup menu"); //Build Popup Menu for TrayIcon popupMenu = new Menu (); //Settings menu item ImageMenuItem menuItemSettings = new ImageMenuItem ("Settings"); menuItemSettings.Image = new Gtk.Image(Stock.Preferences, IconSize.Menu); menuItemSettings.Activated += ToggleMainWindow; popupMenu.Append(menuItemSettings); popupMenu.Append(new SeparatorMenuItem()); //Quit menu item ImageMenuItem menuItemQuit = new ImageMenuItem ("Quit"); menuItemQuit.Image = new Gtk.Image (Stock.Quit, IconSize.Menu); menuItemQuit.Activated += OnQuitActionActivated; popupMenu.Append (menuItemQuit); log.Debug("Showing popup menu"); popupMenu.ShowAll(); #if LINUX indicator = new ApplicationIndicator ("blinkstick", "icon", Category.ApplicationStatus, ExecutableFolder); indicator.Menu = popupMenu; indicator.Status = AppIndicator.Status.Active; #else log.Debug ("Setting up tray icon"); trayIcon = new StatusIcon (new Pixbuf (System.IO.Path.Combine(ExecutableFolder, "icon.ico"))); trayIcon.Tooltip = this.Title; trayIcon.Visible = true; // Show/Hide the window (even from the Panel/Taskbar) when the TrayIcon has been clicked. trayIcon.Activate += ToggleMainWindow; trayIcon.PopupMenu += delegate { popupMenu.ShowAll (); popupMenu.Popup (); }; #endif log.Debug("Initialization done"); }
public CustomPropertiesWidget (PListScheme scheme) { Scheme = scheme ?? PListScheme.Empty; CurrentTree = new Dictionary<PObject, PListScheme.SchemaItem> (); treeview = new PopupTreeView (this) { DoubleBuffered = true }; treeview.HeadersClickable = true; RefreshKeyStore (); PackStart (treeview, true, true, 0); FindOrAddNewEntry (TreeIter.Zero); ShowAll (); var keyRenderer = new CellRendererCombo (); keyRenderer.Editable = true; keyRenderer.Model = keyStore; keyRenderer.Mode = CellRendererMode.Editable; keyRenderer.TextColumn = 0; keyRenderer.EditingStarted += KeyRendererEditingStarted; keyRenderer.Edited += KeyRendererEditingFinished; var col = new TreeViewColumn (); col.Resizable = true; col.Title = GettextCatalog.GetString ("Property"); col.PackStart (keyRenderer, true); col.SetCellDataFunc (keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; string id = (string)tree_model.GetValue (iter, 0) ?? ""; var obj = (PObject)tree_model.GetValue (iter, 1); if (obj == null) { renderer.Text = id; renderer.Editable = false; renderer.Sensitive = false; return; } var key = (PListScheme.SchemaItem) tree_model.GetValue (iter, 2); var parentPArray = obj.Parent is PArray; renderer.Editable = !parentPArray; renderer.Sensitive = !parentPArray; if (parentPArray) renderer.Text = ""; else renderer.Text = key != null && ShowDescriptions ? key.Description : id; }); treeview.AppendColumn (col); col = new TreeViewColumn { MinWidth = 25, Resizable = false, Sizing = Gtk.TreeViewColumnSizing.Fixed }; var removeRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-remove", IconSize.Menu)); removeRenderer.Clicked += RemoveElement; col.PackEnd (removeRenderer, false); col.SetCellDataFunc (removeRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { removeRenderer.Visible = treeview.Selection.IterIsSelected (iter) && !AddKeyNode.Equals (treeStore.GetValue (iter, 0)); }); var addRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-add", IconSize.Menu)); addRenderer.Clicked += AddElement; col.PackEnd (addRenderer, false); col.SetCellDataFunc (addRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { addRenderer.Visible = treeview.Selection.IterIsSelected (iter) && AddKeyNode.Equals (treeStore.GetValue (iter, 0)); }); treeview.AppendColumn (col); treeview.RowActivated += delegate(object o, RowActivatedArgs args) { TreeIter iter; if (treeStore.GetIter (out iter, args.Path) && AddKeyNode.Equals (treeStore.GetValue (iter, 0))) AddElement (o, EventArgs.Empty); }; var comboRenderer = new CellRendererCombo (); var typeModel = new ListStore (typeof (string)); typeModel.AppendValues (PArray.Type); typeModel.AppendValues (PDictionary.Type); typeModel.AppendValues (PBoolean.Type); typeModel.AppendValues (PData.Type); typeModel.AppendValues (PData.Type); typeModel.AppendValues (PNumber.Type); typeModel.AppendValues (PString.Type); comboRenderer.Model = typeModel; comboRenderer.Mode = CellRendererMode.Editable; comboRenderer.HasEntry = false; comboRenderer.TextColumn = 0; comboRenderer.Edited += delegate(object o, EditedArgs args) { TreeIter selIter; if (!treeStore.GetIterFromString (out selIter, args.Path)) return; PObject oldObj = (PObject)treeStore.GetValue (selIter, 1); if (oldObj != null && oldObj.TypeString != args.NewText) oldObj.Replace (PObject.Create (args.NewText)); }; treeview.AppendColumn (GettextCatalog.GetString ("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; var value = (string) tree_model.GetValue (iter, 0); var obj = (PObject)tree_model.GetValue (iter, 1); var key = (PListScheme.SchemaItem)tree_model.GetValue (iter, 2); renderer.Editable = key == null && !AddKeyNode.Equals (value); renderer.ForegroundGdk = Style.Text (renderer.Editable ? StateType.Normal : StateType.Insensitive); renderer.Text = obj == null ? "" : obj.TypeString; }); var propRenderer = new CellRendererCombo (); propRenderer.Model = valueStore; propRenderer.Mode = CellRendererMode.Editable; propRenderer.TextColumn = 0; propRenderer.EditingStarted += PropRendererEditingStarted; propRenderer.Edited += PropRendererEditingFinished; treeview.AppendColumn (GettextCatalog.GetString ("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; var obj = (PObject)tree_model.GetValue (iter, 1); renderer.Sensitive = obj != null && !(obj is PDictionary || obj is PArray || obj is PData); renderer.Editable = renderer.Sensitive; if (!renderer.Sensitive) { renderer.Text = ""; return; } if (ShowDescriptions) { var identifier = (string) tree_model.GetValue (iter, 0); var values = PListScheme.AvailableValues (obj, CurrentTree); var item = values == null ? null : values.FirstOrDefault (v => v.Identifier == identifier); if (item != null && obj is IPValueObject) { // Ensure that we only display the Description if the items value matches the description/identifier. // For example when setting the Document Type Name we wish to display whatever identifer the user types // in and not the literal string 'Document Type Name'. However for somegthing like UISupportedDeviceOrientations // we can safely display the description 'iPhone' or 'iPad' and not hide important information. var actualValue = ((IPValueObject) obj).Value; if (actualValue != null && (actualValue.ToString () == item.Description || actualValue.ToString () == item.Identifier)) { renderer.Text = item.Description ?? item.Identifier; return; } } } switch (obj.TypeString) { case PDictionary.Type: renderer.Text = string.Format (GettextCatalog.GetPluralString ("({0} item)", "({0} items)", ((PDictionary)obj).Count), ((PDictionary)obj).Count); break; case PArray.Type: renderer.Text = string.Format (GettextCatalog.GetPluralString ("({0} item)", "({0} items)", ((PArray)obj).Count, ((PArray)obj).Count)); break; case PBoolean.Type: renderer.Text = ((PBoolean)obj).Value ? GettextCatalog.GetString ("Yes") : GettextCatalog.GetString ("No"); break; case PData.Type: renderer.Text = string.Format ("byte[{0}]", ((PData)obj).Value.Length); break; default: if (obj is IPValueObject) { renderer.Text = (((IPValueObject)obj).Value ?? "").ToString (); } else { renderer.Sensitive = false; renderer.Text = GettextCatalog.GetString ("Could not render {0}.", obj.GetType ().Name); } break; } }); treeview.EnableGridLines = TreeViewGridLines.Horizontal; treeview.Model = treeStore; }
private Gtk.Widget CreateWorkspaceView() { ScrolledWindow sw = new ScrolledWindow(); m_treeView = new Gtk.TreeView(); //first column has workspaceUnit but presents its friendly name, 2nd column displays type and 3rd displays value m_workspaceStore = new Gtk.ListStore(typeof(WorkspaceUnit), typeof(WorkspaceUnit), typeof(WorkspaceUnit)); m_treeView.Model = m_workspaceStore; //create columns with associated cell renderings CellRendererText nameRenderer = new CellRendererText(); TreeViewColumn nameColumn = m_treeView.AppendColumn("Name", nameRenderer); nameColumn.SetCellDataFunc(nameRenderer, new TreeCellDataFunc(RenderName)); CellRendererText typeRenderer = new CellRendererText(); TreeViewColumn typeColumn = m_treeView.AppendColumn("Type", typeRenderer); typeColumn.SetCellDataFunc(typeRenderer, new TreeCellDataFunc(RenderType)); TreeViewColumn valueColumn = new TreeViewColumn(); valueColumn.Title = "Value"; CellRendererPixbuf valueViewerIconCellRenderer = new CellRendererPixbuf(); CellRendererText valueTextRenderer = new CellRendererText(); valueViewerIconCellRenderer.Xalign = 0.0f; valueColumn.PackEnd(valueTextRenderer, true); valueColumn.PackStart(valueViewerIconCellRenderer, false); valueColumn.SetCellDataFunc(valueViewerIconCellRenderer, new TreeCellDataFunc(RenderViewerIcon)); valueColumn.SetCellDataFunc(valueTextRenderer, new TreeCellDataFunc(RenderValue)); m_treeView.AppendColumn(valueColumn); m_treeView.RowActivated += HandleRowActivated; sw.Add(m_treeView); sw.ShowAll(); return sw; }
public void Initialize() { log.Debug("Setting up treeview"); Gtk.TreeViewColumn enabledColumn = new Gtk.TreeViewColumn(); enabledColumn.Title = ""; Gtk.TreeViewColumn nameColumn = new Gtk.TreeViewColumn(); nameColumn.Title = "Name"; Gtk.TreeViewColumn blinkStickColumn = new Gtk.TreeViewColumn(); blinkStickColumn.Title = "BlinkStick"; Gtk.TreeViewColumn patternColumn = new Gtk.TreeViewColumn(); patternColumn.Title = "Pattern"; Gtk.CellRendererPixbuf enabledCell = new Gtk.CellRendererPixbuf(); Gtk.CellRendererText nameCell = new Gtk.CellRendererText(); Gtk.CellRendererText typeCell = new Gtk.CellRendererText(); Gtk.CellRendererText blinkStickCell = new Gtk.CellRendererText(); Gtk.CellRendererText patternCell = new Gtk.CellRendererText(); CellRendererPixbuf iconCell = new CellRendererPixbuf(); nameColumn.PackStart(iconCell, false); nameColumn.AddAttribute(iconCell, "pixbuf", 4); enabledColumn.PackEnd(enabledCell, false); blinkStickColumn.PackEnd(blinkStickCell, false); nameColumn.PackEnd(nameCell, true); patternColumn.PackEnd(patternCell, false); enabledColumn.SetCellDataFunc(enabledCell, new Gtk.TreeCellDataFunc(RenderEnabledCell)); nameColumn.SetCellDataFunc(nameCell, new Gtk.TreeCellDataFunc(RenderNameCell)); blinkStickColumn.SetCellDataFunc(blinkStickCell, new Gtk.TreeCellDataFunc(RenderBlinkStickCell)); patternColumn.SetCellDataFunc(patternCell, new Gtk.TreeCellDataFunc(RenderPatternCell)); treeviewEvents.AppendColumn(enabledColumn); treeviewEvents.AppendColumn(nameColumn); treeviewEvents.Columns[1].Expand = true; treeviewEvents.AppendColumn(patternColumn); if (this.ApplicationSettings.SingleBlinkStickMode) { DeleteColumnIndex = 5; } else { treeviewEvents.AppendColumn(blinkStickColumn); DeleteColumnIndex = 6; } treeviewEvents.AppendColumn("", new Gtk.CellRendererPixbuf(), "stock_id", 1); treeviewEvents.AppendColumn("", new Gtk.CellRendererPixbuf(), "stock_id", 2); treeviewEvents.AppendColumn("", new Gtk.CellRendererPixbuf(), "stock_id", 3); NotificationListStore.SetSortFunc(0, delegate(TreeModel model, TreeIter a, TreeIter b) { CustomNotification n1 = (CustomNotification)model.GetValue(a, 0); CustomNotification n2 = (CustomNotification)model.GetValue(b, 0); if (n1 == null || n2 == null) { return(0); } return(String.Compare(n1.Name, n2.Name)); }); NotificationListStore.SetSortColumnId(1, SortType.Ascending); treeviewEvents.Model = NotificationListStore; log.Debug("Adding notifications to the tree"); foreach (CustomNotification e in DataModel.Notifications) { NotificationListStore.AppendValues(e, "icon-dark-pencil-square-o", "icon-dark-clone", "icon-dark-trash", NotificationRegistry.FindIcon(e.GetType())); } }
private Gtk.Widget CreateWorkspaceView() { ScrolledWindow sw = new ScrolledWindow(); m_treeView = new Gtk.TreeView(); //first column has workspaceUnit but presents its friendly name, 2nd column displays type and 3rd displays value m_workspaceStore = new Gtk.ListStore(typeof(WorkspaceUnit), typeof(WorkspaceUnit), typeof(WorkspaceUnit)); m_treeView.Model = m_workspaceStore; //create columns with associated cell renderings CellRendererText nameRenderer = new CellRendererText(); TreeViewColumn nameColumn = m_treeView.AppendColumn("Name", nameRenderer); nameColumn.SetCellDataFunc(nameRenderer, new TreeCellDataFunc(RenderName)); CellRendererText typeRenderer = new CellRendererText(); TreeViewColumn typeColumn = m_treeView.AppendColumn("Type", typeRenderer); typeColumn.SetCellDataFunc(typeRenderer, new TreeCellDataFunc(RenderType)); TreeViewColumn valueColumn = new TreeViewColumn(); valueColumn.Title = "Value"; CellRendererPixbuf valueViewerIconCellRenderer = new CellRendererPixbuf(); CellRendererText valueTextRenderer = new CellRendererText(); valueViewerIconCellRenderer.Xalign = 0.0f; valueColumn.PackEnd(valueTextRenderer, true); valueColumn.PackStart(valueViewerIconCellRenderer, false); valueColumn.SetCellDataFunc(valueViewerIconCellRenderer, new TreeCellDataFunc(RenderViewerIcon)); valueColumn.SetCellDataFunc(valueTextRenderer, new TreeCellDataFunc(RenderValue)); m_treeView.AppendColumn(valueColumn); m_treeView.RowActivated += HandleRowActivated; // HERZUM SPRINT 3: TLAB-86 VBox vbox1 = new VBox(); sw.Add(m_treeView); vbox1.Add (sw); Box.BoxChild w1 = ((Box.BoxChild)(vbox1 [sw])); w1.Position = 0; baseline.CanFocus = false; Box.BoxChild w2 = ((Box.BoxChild)(vbox1 [baseline])); vbox1.Add (baseline); w2.Position = 2; w2.Expand = false; w2.Fill = false; vbox1.ShowAll (); return vbox1; //sw.Add(m_treeView); //sw.ShowAll(); //return sw; // END HERZUM SPRINT 3: TLAB-86 }