LinuxSoftware

Coding and tramping in Aotearoa / New Zealand

Car insurance

Aug 18

My homebrew is almost drinkable

, david, Monday, 7:27 pm

beer The beer which I brewed back in June is almost drinkable. It’s still a bit yeasty, but is definitely alcoholic.


Aug 17

T-Shirts don't last forever ☹

, , , , , , david, Sunday, 10:55 pm

tshirts
You can tell my favourite T-shirts by their holey tattered appearance, but even for me these shirts are looking scruffy. Unlike a friend who creatively turned his old t-shirts into a patchwork quilt, these are destined for the rag bin ☹.

Nova ScotiaThis t-shirt is from Nova Scotia is from when I was living in Toronto, and took a trip to see the ocean. Saw the Endeavour replica in Halifax before driving up to Cape Breton Island. Was in Fall, on the Canadian Thanksgiving (which is a month before the American one) spectacular with forests of brillant colour. Stayed at a B&B in Inverness which was found for me by the campsite operator when I couldn’t find a bed there. Visited Alexander Graham Bell’s home. Had a great time. Nova Scotia is a place I’d like to go back to one day.

Museum, Vancouver This one is also from when I was living in Canada and visited the Museum of Anthropology at UBC in Vancouver. Was passing through on a visit home to Auckland. I really liked that design, I’ve even looked at trying to buy a replacement, but it seems they don’t sell it anymore. Must find out who the artist is. The design is signed, but it’s hard to make the signature out.

Tim Finn, Bic Runga & Dave Dobbyn, Together in Concert I went and saw Tim, Bic and Dave at their Together in Concert show in 2000. To me this is about when Kiwi music started to get a new lease of life. Was a good night out anyway.

Genève My sister brought this t-shirt back for me from the International Red Cross/Red Crescent museum in Genève. Our mother was very involved in the Red Cross/Red Crescent movement.

cd /pub; more beer Geeks everywhere understood this shirt. It can be hard to explain it in a bar though. It does mix the /pub directory from FTP sites in with standard shell commands. Basically though it says “go to the pub, drink more beer”.


Aug 16

How to participate in the Linux community

david, Saturday, 6:53 pm

A guide by Jonathan Corbet, executive editor of lwn.net and Linux developer.


Aug 12

Handling window close in an X11 app

, , , david, Tuesday, 10:31 am

When a user clicks the close button [x] on our X11 application we want it to pop a a dialog asking “do you really want to quit?”. This is a plain X app. No fancy GTK or QT widgets here. So how to catch the “window is being closed” message?

The answer is to tell the Window Manager we are interested in these event by calling XSetWMProtocols and registering a WM_DELETE_WINDOW message with it. Then we’ll get a client message from the Window Manager if someone tries to close the window, and it won’t close it, it’ll leave that us up to us. Here’s an example….

// example.cpp
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <iostream>

int main()
{
   Display* display = XOpenDisplay(NULL);
   Window window = XCreateSimpleWindow(display,
                                       DefaultRootWindow(display),
                                       0, 0,
                                       500, 400,
                                       0,
                                       0, 0);

   // register interest in the delete window message
   Atom wmDeleteMessage = XInternAtom(display, "WM_DELETE_WINDOW", False);
   XSetWMProtocols(display, window, &wmDeleteMessage, 1);

   std::cout << "Starting up..." << std::endl;
   XMapWindow(display, window);

   while (true) {
      XEvent event;
      XNextEvent(display, &event);

      if (event.type == ClientMessage &&
          event.xclient.data.l[0] == wmDeleteMessage) {
         std::cout << "Shutting down now!!!" << std::endl;
         break;
      }
   }

   XCloseDisplay(display);
   return 0;
}

Compile with g++ example.cpp -o example -lX11


Aug 11

Drawing a square

, , , , , , david, Monday, 7:08 pm

This blog post is a survey of the graphics programs available on Linux. A friend complained how hard it is to even draw a square with the Gimp. My suggestion is there are better tools for drawing and the Gimp is better left to image manipulation.

So what tools are there for drawing a square?

inkscape

Inkscape has got to be the most popular free drawing tool. Inkscape is an Open Source vector graphics editor, with capabilities similar to Illustrator using the standard Scalable Vector Graphics (SVG) file format.

To draw a square in Inkscape: Click on the rectangles tool (or push F4), and while holding down Ctrl (to keep the ratio right) draw your square. We want a black empty square so now we need to edit the Fill and Stroke. Click on the Fill colour in the bottom left corner and the Fill and Stroke dialog will pop up. Select X for no Fill. Change to the Stroke paint tab and select black for the stroke. On the Stroke style tab you can select the width of the stroke. (On my screen the black stroke looked kind of grey until I zoomed in (+) on it.)

oodraw

OpenOffice.org comes with a basic drawing tool, oodraw. This might be all you need if you are working with oowrite and just want to add a simple diagram.

To draw a square in oodraw: Click on the rectangle tool and while holding down Ctrl+Shift draw your square. Right-click the square, select Area | Fill: None | ok. The line colour defaults to black, but if you want to change it just right-click (must be on the outline now) and choose Line, then change the colour.

tuxpaint

For the child in all of us Tux Paint is fun to play with. The truth is it is actually harder to create a neat drawing in Tux Paint than in Inkscape. But then having fun is the point, not neat drawings to illustrate the report to your boss. Children might like this app too.

To draw a square in Tux Paint: First select the shapes tool on the left, then the open square shape on the right. Select how big you want your square and what crazy angle you want it on.

Xara Xtreme looked cool when it was open-sourced, but doesn’t seem to have gone anywhere fast. (I may be out of date on this.) Wikipedia says “The port is still in its first stages and, while usable, currently lacks major features.”

dia

Dia is a GTK+ based diagram creation program. It is similar to Visio, but unfortunately doesn’t match it. For basic diagrams though Dia is useful.

Getting a bit off topic. I have found the cpp->dia (aka cpp2dia) tool very useful for reverse engineering UML diagrams from existing C++ source. Pity it hasn’t been updated since 2003.

To draw a square in Dia: Click on the box tool and draw your square. There is no keypress I am aware of to to force the ratio to be a square. After you’ve drawn it though you can right click on the shape and edit its properties.

But what if you really want to draw a square using the Gimp?

For example you may have a photo and want to draw attention to a region in it.

First I’d suggest you create a new transparent layer for your square Layer | New Layer. This lets you work on your square without it messing up the rest of your image.

You may also find it useful to drag out guides from the rulers to mark the boundaries of your square.

gimp-05

Method One: Use the Gfig plugin
Updated: Thanks to Penguin Pete we’ve learnt there is a gfig plugin which can draw all kinds of shapes under the menu Filters | Render | Gfig. Use the rectangle tool to create the square and move single point tool to adjust its size. I didn’t find a way of maintain the square ratio, but you can use snap to grid to help with that.

gimp-03

Method Two: Use the Rectangular Select and Bucket Fill Tool draw a solid square
Use the rectangle select tool to select the region, then use the bucket fill tool to paint the square. This could then be used as a background, e.g. for some text.

gimp-04

Method Three: Use Select Invert and layer transparency to create a square “window”
Select the area we want to highlight with the rectangle select tool again, but this time choose the menu item Select | Invert to select everything outside the window. Now use the bucket fill tool to paint this area white. Then the cool bit: wind down the layer’s Opacity in the layer options until the layer underneath is visible, but the selected area is still highlighted.


« Previous PageNext Page »