Renaissance—A Cross-Platform Development Tool for Linux and Mac OS X
Under Mac OS X, we are sharing the main gsmarkup file with the GNUstep version of our application, so we now have to create the gsmarkup file used for our sample application menu, for Mac OS X. Doing so allows us to have a different menu for Mac OS X, which is required because the layout of menus under GNUstep (vertical) is different from the one on Mac OS X (horizontal). Create the file Cocoa-Menu.gsmarkup with the content shown in Listing 6.
Listing 6. Cocoa-Menu.gsmarkup
<gsmarkup> <objects> <menu type="main"> <menu title="TiffViewer" type="apple"> <menuItem title="Hide TiffViewer" key="h" action="hide:"/> <menuItem title="Quit TiffViewer" key="q" action="terminate:"/> </menu> <menu title="File"> <menuItem title="Load Image" action="loadImage:"/> </menu> </menu> </objects> </gsmarkup>
In Listing 6, we also define three menu items: Hide TiffViewer, Quit TiffViewer and Load Image. Contrary to GNUstep, we create the first two under the TiffViewer menu, to be displayed in bold (notice the type="apple") and the latter under the File menu. We do this because the menu disposition on Mac OS X is different from GNUstep, and we want to follow the HIG at least with regard to the menus.
Once the file has been created, we need to create the Mac OS X project file and build the application. To do so, start the Project Builder application and proceed with the following steps:
From the File menu, choose the New Project... menu item and select Cocoa Application. Click on the Next button.
Specify the project name (TiffViewer) and the project directory, then click on the Finish button.
Select the Classes node in the Groups & Files panel and then click on the Add Files... menu item from the Project menu. Add the AppController.m and ImageModel.m files. Those are the same files used under GNUstep.
Expand the Other Sources node and delete the main.m file. We don't need this file.
Expand the Resources node and double-click on MainMenu.nib. This launches Interface Builder. From Interface Builder's MainMenu.nib window, delete MainMenu and Window by clicking on the corresponding icons and choosing Delete from the Edit menu. Save everything and then quit Interface Builder. We need to do so because Renaissance can provide the application menu using our gsmarkup file.
Select the Resources node and add the Cocoa-Menu.gsmarkup and TiffViewer.gsmarkup files, as you did in Step 3.
Expand the Frameworks and Linked Frameworks nodes and click on the Add Frameworks... menu item from the Project menu. Add the Renaissance.framework located in the /Library/Frameworks directory.
Finally, from the Build menu in Project Builder, choose Build and Run. This compiles and launches the application.
As you have seen in this section, porting the application from GNUstep to Mac OS X is rather trivial. No code changes were required. As under GNUstep, you can load a TIFF file in the application and try to resize the window. You should see the image view automatically resizing both horizontally and vertically, as specified in the main gsmarkup file. You also should notice the Apple-style horizontal disposition of the application menu, as shown in Figure 2.
As said before, Renaissance eases localization. In order to show how, let's translate our simple TIFF viewer to the French language. Renaissance automatically knows what to translate and what to maintain. In our menu gsmarkup files, each of the menu items had a title. Renaissance automatically uses the title of UI elements as a key in the Localizable.strings files to get the right translated string. In order to translate our sample application, create a French.lproj directory inside the project's root directory. In that newly created directory, create the Localizable.strings file with the content shown in Listing 7.
- Readers' Choice Awards 2013
- A Plexible Pi
- Linux Kernel News - November 2013
- Advanced Hard Drive Caching Techniques
- Sublime Text: One Editor to Rule Them All?
- Mars Needs Women
- Raspberry Pi: the Perfect Home Server
- Tech Tip: Really Simple HTTP Server with Python
- December 2013 Issue of Linux Journal: Readers' Choice
- RSS Feeds
- Reply to comment | Linux Journal
18 min 53 sec ago
- rilakkuma onesie
2 hours 54 min ago
- flying squirrel onesie
2 hours 57 min ago
- animal onesies for adults
2 hours 59 min ago
- animal onesies
3 hours 9 sec ago
- stitch onesie
3 hours 52 sec ago
- totoro onesie
3 hours 2 min ago
- dinosaur onesie
3 hours 6 min ago
- pikachu onesie
3 hours 10 min ago
- While copy.com is nice, it's
8 hours 12 min ago