+1  A: 

The old way, simple but now being phased out, is GKSu. Here is the discussion on GKSu's future.

The new way is to use PolicyKit. I'm not quite sure how this works but I think you need to launch your app using the pkexec command.

UPDATE:

Looking at the example code on http://hal.freedesktop.org/docs/polkit/polkit-apps.html, it seems that you can use PolicyKit to obtain authorization for certain actions which are described by .policy files in /usr/share/polkit-1/actions. The action for executing a program as another user is org.freedesktop.policykit.exec. I can't seem to find an action for directly accessing block devices, but I have to admit, the PolicyKit documentation breaks my brain too.

So, perhaps the simplest course of action for you is to separate your disk-mangling code that requires privileges into a command-line utility, and run that from your GUI application using g_spawn_[a]sync() with pkexec. That way you wouldn't have to bother with requesting actions and that sort of thing. It's probably bad practice anyway to run your whole GUI application as root.

Another suggestion is to ask the author of PolicyKit (David Zeuthen) directly. Or try posting your question to the gtk-app-devel list.

ptomato
I've tried pkexec - unfortunately, it doesn't work in my case as I get the following error message: "Gtk-WARNING **: cannot open display:"--"man pkexec" explains why:“The environment that PROGRAM will run it, will be set to a minimal known and safe environment in order to avoid injecting code through LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID environment variable is set to the user id of the process invoking pkexec. As a result, pkexec will not allow you to run e.g. X11 applications as another user since the $DISPLAY environment variable is not set.”Darn.
Thomas Tempelmann
Hmm, I think the PolicyKit API allows you to achieve the same thing, but from within your program. I'm not sure though.
ptomato
SO did not mail me about your update, so I only see it now. Thanks for making the extra effort, I think with that information I can get ahead.
Thomas Tempelmann
Sure, I'm happy to go the extra mile for all that rep, they don't call it Crack Overflow for nothing ;-)
ptomato