Code by Kevin, Programming, code, business, and other pursuits
Kevin Walzer, software developer.
Subscribe to RSS Feed
Get a syndicated feed of my weblog.
Site design: Skeleton
In a previous entry I outlined an update roadmap for my apps that focused on taking a step back from native UI integration and more on under-the-hood integration between my cross-platform development framework (Tcl/Tk) and OS X. I'm about done with applying this strategy to PacketStream. Because the changes to PacketStream are going to serve as a template for the rest of the app updates as well, I wanted to take some time to discuss them in detail.
Less native UI integration
I am moving away from the extensive wrapping of native widgets in favor of a modified approach that makes use of Tk's native foundation but also takes advantage of Tk's flexibility with configuring appearance. For instance, in place of a native NSToolbar that cannot be easily configured from Tk, I've opted for the standard Tk approach of setting up a group of toolbuttons within a frame using a custom font to display icons, and using Tk to style both the buttons and their tooltips. This is simpler to set up and also is snappier in performance; the NSToolbar approach was harder to configure, slower to load and, for some reason, subject to flickering, especially in displaying tooltips. Note that this approach still makes use of under-the-hood native integration; I had to write a custom library calling Core Text functions to load the icon font. But this approach has the advantage of allowing me to use font icons, which are resolution independent and naturally friendly to Retina displays, rather than native bitmaps, which are not Retina friendly without considerable rigamorole. Bottom line: My UI is now easier to set up, runs better, and supports emerging hardware features on the Mac platform (Retina support).
The screen shots below illustrate the older and newer layout of PacketStream.
Greater integration under the hood
I'm taking a step forward toward better integration under the hood. One good example on this is how I call external processes that need escalated privileges, such as running tcpdump (the network monitoring tool that powers PacketStream). If someone is launching tcpdump from the command line, they'll do so by calling "sudo tcpdump"; sudo is a command that gives "superuser" privileges to the user launching tcpdump. Native GUI apps use a somewhat different process that presents an "authorization" dialog to the user (such as a software installer); I have, however, been unable to get this approach to play nicely with the design of my Tcl apps, and so have resorted to presenting a dialog that calls for the user's password and pipes it under the hood to "sudo." This approach has served me well for several years, but as I have continued to research the question, I've come to the conclusion that using the user's "sudo" password in this fashion presents a security risk because the password is transmitted, under the hood, in plain text. I finally devised a solution that allows me to make use of the native authorization dialog based on the work of another Mac developer, Ian Waldham, and that's what I'm rolling out in my applications now. It's more secure, provides very clean integration, and, in my testing, allows my app to perform better as well. Bottom line: Improved under-the-hood integration provides better performance and security.
The screenshots below illustrate the older and newer, more secure, native authorization dialog.
More muted look and feel
One reason for moving away from wrapping of native widgets such as the NSToolbar is that they are not very configurable--it is hard to modify their appearance to keep up with evolving UI trends on the Mac. This may be subjective, but it matters; my apps making use of the native Cocoa toolbar look dated compared to other apps running on recent versions of OS X, which are more muted in color. It's not just a matter of changing icons; it's also matter of overall color schemes, the size of buttons and their layout, and more. Switching to a more Tk-centric approach (which uses native components such as Cocoa buttons and frames, but which does not lock you into structured Cocoa widgets such as the toolbar) gives me more flexibility to keep up with these UI styles. As a result, if you look at the screenshots above, you see a big difference in the old and new version of PacketStream. The old version is more authentically native, but now looks stuck in a time warp. The new version, while it looks somewhat less native in its overall layout, nonetheless does not look out of place because it picks up current styles with color, icon format, and more. Similarly, if you look at the icons below, you'll see a big difference in the old and new versions. Bottom line: It's important to use an app structure that lets you readily modify the general look of the app to keep up with evolving UI trends.
The screenshots below illustrate the older and newer, more muted, icon style.
I'm going to hold off on releasing the new version of PacketStream because I want it to be of a piece with my other apps; I'm hoping to have all of the new apps ready for release, along with a website makeover, early in 2014. But I wanted to give some concrete evidence of the direction these apps are taking. I'm happy with the progress thus far.