Sunday, September 20, 2009

Extra Mouse click in GIMP on OS X

Found this tip while searching for something else about GIMP. The default setup for GIMP on OS X requires a user to click on any of the app windows (toolbox, image window, ..) twice to edit it. This setting eliminates that extra click.

http://www.macosxhints.com/article.php?story=20090817083346589

In summary -
X11 -> Preferences -> Windows -> 'Check' Click through inactive Windows


Many many thanks to the anonymous poster. This will eliminate a lot of wear and tear of my fingers.

Saturday, February 07, 2009

Programmatically Taking a Screenshot in iPhone

It took me some time to find the code for this. Thought I'd share it here. The following code takes a screen capture of the currently visible portions of a UITableView but its applicable to any view.

UIGraphicsBeginImageContext(self.tableView.bounds.size);
[self.tableView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
//UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
UIGraphicsEndImageContext();

The commented out line saves the photo to a the Photos application on the iPhone.

Saturday, March 22, 2008

Transparent bordered shell in SWT

I've wanted to get a transparent bordered shell in SWT ever since I saw the transparent bordered video shell in Leopard video quickview.

A shell with alpha support is coming in 3.4. However, I have not looked at the 3.4 material as yet and this sample was built on 3.3.

The shell can be used in the same way that the org.eclipse.swt.custom.PopupList class can be used except that you can place any controls you want and not just a List. Lets see how to do this -

In SWT, a Canvas control can have an alpha value. Thus, the base needs to be a canvas. First, create a control that extends the Canvas. Set the layout for this canvas to a FillLayout. This canvas will contain other controls. It is important to set the margin of the layout. This margin will be the width of your transparent border. Now, set an alpha value for the canvas. The alpha determines how transparent the border will be.

Image -
Now create or load a gradiented (is there such a word?) image. In the paintListener for the Canvas, draw this gradiented image. Because of the alpha on the canvas, the image will be semi-transparent. Now add any controls (typically a composite with controls within it) to the canvas and these will be drawn with a transparent border around them.

To get the real transparency, this canvas needs to be placed inside a shell created with the style SWT.NO_TRIM and SWT.ON_TOP. Also, the canvas needs to be created with the style SWT.NO_BACKGROUND. However, due to these styles, the shell cannot be really moved around. Thus, its useful where no movement is necessary - a transparent menu, infopopups, ...

Thus, to summarize,
1. A shell with styles SWT.NO_TRIM and SWT.ON_TOP contains
2. a canvas with style NO_BACKGROUND, a gradiented image, an alpha value, a margin (border width) contains
3. a control (composite) that is displayed within the canvas.

Saturday, February 23, 2008

Firefox Memory Consumption

I started noticing a performance issue with Firefox while filling out forms and opened Task Manager to see this.


Firefox - one window - four tabs (370 MB)

IE - one window - three tabs (20 MB)

Safari (webkit) - zero windows - don't know where those two processes have come from (121MB + 54 MB)


The second javaw.exe process (218 MB) is Eclipse 3.2 with a pretty huge workspace. The eclipse.exe(200MB) is an instance of Eclipse 3.3 with a relatively smaller workspace. Nice to see someone beating Eclipse in memory consumption :).





Thursday, February 14, 2008

RESTful JSON

In a recent project, I used a REST style interface(PHP) and GWT (Google Widget Toolkit). The first thought for a data exchange format was XML. However, on further rumination, the prospect of writing XML node iteration code was daunting. After having done the whole XML node iteration for multiple projects before this, I was feeling too lazy to do it all over again :). Thats when I thought of using JSON (Javascript Object Notation). The JSON programming model is much simpler to use than XML. The ease with which the data can be transformed into objects eliminates all the node iteration code. This is due to the multitude of libraries (including GWT) available for encoding/decoding the JSON format and the ease with which JSON can be converted to objects.  Finally, I ended up with a REST style interface returning JSON encoded data that gets decoded on the client by GWT. 

JSON seems to be a much simpler data exchange format while XML seems to more suited to storage of data. A good combination is probably an XML database (more flexible than an RDBMS) for storage and JSON for data exchange.

Wednesday, January 23, 2008

4GB iPhone - A Lower Priced iPhone

When Apple reduced the iPhone prices from 599 to 399, they also discontinued the 4GB iPhone and to exhaust their existing stock sold this model at 299. I don't have a whole lot of songs but was interested in the non-iPod related functionality (phone, maps, browser, touchscreen,...). Thus, for me, the price was in the sweet spot and 4GB of memory was just fine. One rarely buys iPod(iPhone) products without accessories (case, earphones,...). Thus, the phone is not really 299 but 299 + taxes + accessory cost.

I end up using the browser, maps, stocks, weather and notes more than the iPod functionality. Someone like me who does not have a whole lot of songs but is more interested in the constant connectivity and the non-iPod functionality would be an ideal candidate for the 4GB version of iPhone. Apple does sell other 4GB iPods - iPod Nano (which is $149). I think there is a market segment that would love to use the iPhone if Apple offered a lower price version - maybe ~ $275. The iPod Touch is great but does not have constant connectivity that an iPhone provides. Maybe once the 3G version is released, they could offer the EDGE model at a lower price. Only time will tell...

Thursday, July 13, 2006

Displaying Non-Resource Content Using the Common Navigator Framework

Introduction
This post discusses the procedure for displaying non-resource nodes in a CNF Viewer. Examples of non-resource nodes are database tables or servers.

Prerequisites
The article assumes that you have some familiarity with the Common Navigator Framework. If not there are some great articles by Michael Elder.

Define a View and a Viewer
Define a view and a viewer using the common navigator framework.


This definition also adds the content binding for displaying standard resource nodes in the project structure.

Our Content
Our content will consist of the class called Child which represents a non-resource child and a class called NRParent, which will form the parent of all Child classes in the project tree. Note that in a real world the Child class could be something like a database table.





Next a Content provider and a Label provider need to be defined for this content. The content provider is simple - if a parent is of type IProject, it contributes a NRParent instance, if a parent is of type NRParent, it provides some children of type Child and if it is of type Child, it just provides more children.

Here are the relevant code sections from the content provider and the label provider -






The point to note is that when the parent is of type IProject, is when you need to provide first level non-resource nodes to the project structure. Ofcourse you can provide non-resource nodes to a specific folder within a project too or even a file. In that case, check for the parent being of type IFolder or IFile respectively. I can't think of a specific use-case for it right now, but it is something that is possible.


Now add a navigatorContent extension that defines the content provider, the label provider and trigger point. Note the trigger point and the possible children elements.


Finally, add a viewerContentBinding to bind the above navigatorContent to the viewer.



That is it. Execute a Run configuration for the plugin and open the view to see the new non-resource nodes.

As suggested by Michael, the source code has been added as an attachment to bug 143127: [CommonNavigator] Examples

iPhone not connecting to macOS from Xcode

 After trying everything standard (re-pair, restart, reconnects), it turned out that VPN was enabled on my Mac.  Turn Off VPN to let Xcode f...