The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Settings Framework Adventures

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Settings Framework Adventures Posted: Jan 18, 2005 4:36 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Settings Framework Adventures
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

I ran across an interesting requirement today - I needed to enable/disable individual settings in the BottomFeeder settings tool. That tool is simply a user of the new settings framework created by Vassili. In a typical VW interface, enabling/disabling widgets isn't hard - you do something like this:


(self builder componentAt: #idOfWidgetHere) enable.

It gets trickier when the widget is in a subcanvas - the builder used to create the subcanvas isn't typically kept, and the widgets in it aren't tracked by the builder in the outer UI. Typically, one solves that by grabbing a copy of the builder used for the subcanvas and caching it. Each page of the settings tool, is a subcanvas, so I had to accomplish the same thing. Here's where I had to do some digging. In class SettingsManager, there's a method that swaps the pages:


pageSelected

	| page tree |
	page := self pageListHolder selection.
	page isNil ifTrue: [^self].
	tree := self pageListHolder list.
	((tree isExpandable: page) and: [(tree isExpanded: page) not])
		ifTrue: [tree expand: self pageListHolder selectionIndex].
	(self widgetAt: #GroupBox) label: 
		((TreeViewIndentedLabelAndIcon with: page label) icon: page listIcon).
		"This is the only kind of label with a sane icon positioning."
	page builder: nil.
	(self widgetAt: #Subcanvas)
		client: page 
		spec: page spec
		builder: self builder newSubBuilder.
	self updatePageSubcanvasScrollbar

The actual swapping happens in the #client:spec:builder: message send. So, to do what I needed to do, I changed that section as follows by overriding that method in my subclass:


	newBuilder := self builder newSubBuilder.
	(self widgetAt: #Subcanvas)
		client: page 
		spec: page spec
		builder: newBuilder.
	self updatePageSubcanvasScrollbar.
	self possiblyAdjustEnablementFor: newBuilder onPage: page

By holding a reference to the builder, I can call out to a new method and check which page we are on - and also check the applicable application state. From there, I can grab the relevant widgets and enable/disable them. Here's what that method looks like:


possiblyAdjustEnablementFor: newBuilder onPage: page
	"if we are in certain application states, disable some settings"

	RSS.RSSFeedManager default isUpdating ifFalse: [^self]. 
	page id = #(#rss #network) ifFalse: [^self]. 

	"This grabs each wrapper for the thread options and disables them if we are in the update cycle"
	#(#'-rss-network-runThreadedUpdates' #'-rss-network-shouldSpreadUpdates' #'-rss-network-shouldThrottleThreads') do: [:each |
		(newBuilder componentAt: each) disable]

Those ID's are not pretty - they are manufactured by the settings framework, and I figured out what they were with a breakpoint and an inspector. In any case, the method checks the application state and the page, and then toggles the appropriate settings based on those. In this case, I'm making sure that the threading/non-threading of updates cannot be mucked with while the update process is awake and running. In general, it looks like it's easy enough for any application to enable/disable settings options via this strategy.

Read: Settings Framework Adventures

Topic: The first Mac Rumor ever Previous Topic   Next Topic Topic: Agile Languages

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use