Mono

Nested Grabs In GtkSharp

I ran across this while working on some complex GtkSharp grabbing behavior to mimic window focusing for a docking framework. Turns out there is a weird inconsistency in the way Gtk+ manages the grab stack. While the list of grabbed Widgets is indeed a stack, a flag on each Widget (Widget.HasGrab) is used to check if a Widget has the grab or not. The problem is that Grab.Add (which calls the Gtk+ method gtk_grab_add) never clears the flag for the currently grabbed Widget if you're nesting grabs. That means that every Widget in the grab stack will have Widget.HasGrab set to true. If you try to add a Widget to the grab stack and it's already in the stack (even if there are multiple other grabbed Widgets after it in the stack), it won't get added. Because the flag is set though, it will get removed at the first place it was in the stack on a call to Grab.Remove (gtk_grab_remove).

Read more...

Right-Click Context Menus In GtkSharp

To show a context menu in GtkSharp (or "popup" as they're called in Gtk land), you would normally add an event handler for Widget.PopupMenu, create or use a Menu instance, and then call Menu.Popup. The only problem is that for many widgets, the right-click doesn't trigger the Widget.PopupMenu event. This is fine for systems where there is no right mouse button or where a right-click isn't the customary way of initiating context menus. However, on systems where there is a user expectation that the way to open a context menu is through a right-click (such as Windows), we need some way to trigger one.

Read more...

Exporting a GtkSharp TreeView to CSV

All packaged up in nice little utility methods.

I recently had to create some functionality to export a TreeView widget to a CSV file for further analysis. Since I tend to think about generic behavior, I decided to code up a method that would take any arbitrary TreeView and perform the export operation. Luckily, the TreeView widget and the attached TreeModel both contain a lot of functionality for accessing the data and it's presentation. I decided that I wanted the exported CSV file to represent the perspective of the model as currently represented in the TreeView including column visibility and sort order. This led to the trickiest part of the process. Because a CellRenderer can be customized using cell data functions (such as those added by a call to TreeViewColumn.SetCellDataFunc), I had to pull the content to export from the CellRenderer as opposed to pulling directly from the TreeModel. Turns out there's a method to take the TreeIter from a TreeModel and apply it to all the CellRenderers in a given TreeViewColumn. Since I really only care about textual content, I decided to only export those columns that contain CellRendererText renderers.

Read more...

open source (18) ASP.NET (15) ASP.NET MVC (14) static site generator (9) programming (8) Azure (7) Wyam (7) Roslyn (7) NuGet (6) devops (5) .NET Compiler Platform (5) Razor (4) personal (4) Vue.js (4) Entity Framework (4) LINQ (4) database (4) KendoUI (4) KendoUI MVC (4) grid (4) csharp (3) scripting (3) meta (3) T4 (3) XML (3) Mono (3) GtkSharp (3) tools (2) Cake (2) msbuild (2) magic strings (2) Azure Cosmos DB (2) Azure Functions (2) LINQ to Entities (2) strings (2) algorithms (2) LINQPad (2) blog (2) CSS (2) export (2) CSV (2) HtmlHelper (2) Entity Framework Code First (2) Nxdb (2) XQuery (2) Blazor (1) WebAssembly (1) Netlify (1) FTP (1) documentation (1) configuration (1) DSL (1) enum (1) stdin (1) stream (1) console (1) cli (1) npm (1) node (1) microdependencies (1) collections (1) concurrent (1) HashSet (1) Twitter (1) Serilog (1) MiniProfiler (1) logging (1) OWIN (1) templating (1) design (1) web (1) JavaScript (1) API (1) IIS (1) debugging (1) LINQ to SQL (1) FluentBootstrap (1) Bootstrap (1) RazorDatabase (1) GitHub (1) AppVeyor (1) fluent interfaces (1) method chaining (1) style (1) conventions (1) PDF (1) Acrobat (1) Excel (1) checkbox (1) postback (1) icon fonts (1) icons (1) SQL (1) SQL Server (1) round robin (1) DotNet (1) Dictionary (1) MultiDictionary (1) data annotations (1) persistence (1) object persistence (1) NiceThreads (1) Threading (1) Monitor (1) ReaderWriterLockSlim (1) locking (1) ILocker (1) networkdays (1) weekdays (1) ButtonPressEvent (1) Context Menu (1) ContextMenuHelper (1) Menu (1) Popup (1) Popup Menu (1) CellRenderer (1) TreeModel (1) TreeView (1) TreeViewColumn (1)