How to shrink the changes file?
Smalltalk condenseChanges
This will free up some space in the changes file at the cost of removing version history in your image.
Examples to build a GUI
UITheme exampleBasicControls.
UITheme exampleColorControls.
UITheme exampleDialogs.
UITheme exampleGroups.
UITheme exampleOtherControls.
UITheme exampleWindowWithToolbars.
Disabling features for more speed
The following statements can be run in a Pharo image to increase the speed of the IDE. The script selects the OBSystemBrowser (code browser without package view), it disables the virtual method categories, removes the annotation pane above the source code, and enables fast window dragging.
SystemBrowser default: OBSystemBrowserAdaptor.
Preferences disable: #dynamicProtocolActivation.
Preferences disable: #annotationPanes.
Preferences enable: #fastDragWindowForMorphic.
How to set demo mode
In Pharo 1.0
Preferences setDemoFonts
In Pharo 1.1
From the setting browser:
Style button (top button bar) then "load" then choose "DemoMode" or
DemoSettingStyle new load
Playing with fonts
The following script sets the fonts in Pharo. Feel free to change the font family names and sizes to what suits you best. You will have to reopen each window to see the change.
In Pharo 1.0
|font codeFont|
font := LogicalFont familyName: 'DejaVu Serif' pointSize: 10.
codeFont := LogicalFont familyName: 'DejaVu Sans Mono' pointSize: 9.
Preferences setListFontTo: font.
Preferences setMenuFontTo: font.
Preferences setCodeFontTo: codeFont.
Preferences setButtonFontTo: font.
Preferences setSystemFontTo: font.
font := LogicalFont familyName: 'DejaVu Serif' pointSize: 11.
Preferences setWindowTitleFontTo: font.
You can also set the fonts using the graphical interface in the Preferences menu.
In Pharo 1.1
|font codeFont|
font := LogicalFont familyName: 'DejaVu Serif' pointSize: 10.
codeFont := LogicalFont familyName: 'DejaVu Sans Mono' pointSize: 9.
StandardFonts listFont: font.
StandardFonts menuFont: font.
StandardFonts codeFont: codeFont.
StandardFonts buttonFont: font.
StandardFonts defaultFont: font.
font := LogicalFont familyName: 'DejaVu Serif' pointSize: 11.
StandardFonts windowTitleFont: font.
or
StandardFonts setFontsFromSpec:
#( #(#defaultFont: 'Bitmap DejaVu' 9 )
#(#codeFont: 'Bitmap DejaVu' 9 )
#(#listFont: 'Bitmap DejaVu' 9 )
#(#menuFont: 'Bitmap DejaVu' 9 )
#(#windowTitleFont: 'Bitmap DejaVu' 12 )
#(#balloonFont: 'Bitmap DejaVu' 10 )
#(#haloFont: 'Bitmap DejaVu' 10 )
#(#buttonFont: 'Bitmap DejaVu' 9 ) ).You can also set the fonts using the Settings tool: <world Menu>/System/Settings/Appearance/Standard fonts.
Double-buffering using Display and BitBlt
Compare these two:
1 to: 1000 do:[:i|
Display getCanvas line: i@0 to: i@500 width: 1 color: Color black.
].
vs. (after doing a restore display):
Display deferUpdates: true.
1 to: 1000 do:[:i|
Display getCanvas line: i@0 to: i@500 width: 1 color: Color black.
].
Display forceToScreen: Display boundingBox. "way too much but hey..."
(Submitted by Andreas Raab on the Squeak mailing list)
Knowing the list of modules
The #listLoadedModules are the plugins (internal and external) that your image has actually used since you last restarted it. When you inspect the list of loaded modules, you will notice either '(i)' or '(e)' to indicate whether the loaded module is an internal plugin or and external plugin.
SmalltalkImage current listLoadedModules
The available plugins are those that appear in #listBuiltinModules, plus any external plugins that the VM can find in shared libraries. It doesn't matter if they were loaded or not.
SmalltalkImage current listBuiltinModules
To load the FFI module
To install FFI in Pharo, evaluate:
Gofer new
squeaksource: 'MetacelloRepository';
package: 'ConfigurationOfFFI';
load.
((Smalltalk at: #ConfigurationOfFFI) project version: '1.3') load.
Searching for unsaved packages (advanced)
To refresh all the packages of your image and see which ones have not been saved, execute the following
|pharoRepository|
pharoRepository := MCWorkingCopyBrowser new repositories
detect: [:ea | (ea isKindOf: MCHttpRepository)
and: [ea locationWithTrailingSlash endsWith: 'Pharo/']].
UIManager default informUserDuring: [:bar |
MCWorkingCopyBrowser new workingCopies do: [:workingCopy| |repository patch|
bar value: workingCopy printString.
(workingCopy repositoryGroup repositories size = 1)
ifTrue: ["The working copy is only associated with the cache, that won''t help us, so choose the Pharo repository"
repository := pharoRepository]
ifFalse: ["Arbitrarily selects the last repository of this working copy"
repository := workingCopy repositoryGroup repositories last.
"If the choosen is PharoInbox then selects the Pharo repository"
(repository locationWithTrailingSlash endsWith: 'PharoInbox/')
ifTrue: [repository := pharoRepository]].
patch := workingCopy changesRelativeToRepository: repository.
patch isEmpty ifFalse: [workingCopy modified: true]]]
Why an object is not garbage collected?
To see pointers to that object
PointerExplorer openOn: anObject
Or you can do something like this (example with HandMorph):
HandMorph allInstancesDo: [:e | PointerExplorer openOn: e]
How to create a tab with an icon?
TabGroupMorph/TabSelectorMorph support arbitrary morphs as well as text labels.
An example:
|dialog|
dialog := (UITheme builder newPluggableDialogWindow: 'Example tabs')
useDefaultOKButton.
dialog contentMorph: (
dialog newTabGroup: {
(dialog newRow: {dialog newImage: MenuIcons smallFindIcon. dialog
newLabel: 'Page 1'})->
dialog newPanel.
'Page 2'->dialog newPanel}).
dialog model: nil.
World openModal: dialogHow to fix underscore assigment with RB ?
Since the refactoring engine and OmniBrowser has no overrides and cleanly loads into Pharo 1.0 and 1.1 images this can conveniently be done from the GUI.
Alternatively the following script works without GUI:
1. Load the code:
Gofer new
squeaksource: 'rb';
package: 'AST-Core';
package: 'Refactoring-Core';
load.2. Select the code (packages) you want to fix:
environment := BrowserEnvironment new
forPackageNames: #('PackageName1' 'PackageName2').3. Create the transformation rule:
rule := RBUnderscoreAssignmentRule new.
4. Perform the search:
SmalllintChecker runRule: rule onEnvironment: environment.
5. Perform the transformation:
change := CompositeRefactoryChange new
change changes: rule changes.
change execute
How to know the package of a class?
PackageOrganizer? default packageOfClass: aClass
How to reinitialize the font system?
FreeTypeFontProvider current updateFromSystem
Chinese Fonts
How to set the user to squeaksource.com Monticello Repositories
How to add a nice background wallpaper
Nice wallpaper (from Ubuntu) that fits well with the pharo logo, polymorph and seaside:
|form| form := (Form fromBinaryStream: (HTTPSocket httpGet: 'http://ubuntu.ecchi.ca/wallpapers/10.04/' , 'Maraetaibeforesunrise.jpg')). World backgroundImage: form layout: #scaled(contributed by Torsten)
<H1>How to get all package names(major category names)</H1>
(SystemOrganizer? allInstances anyOne categories asSet collect: [:each| each readStream upTo: $-]) asSortedCollection