Showing posts with label 3.4.1. Show all posts
Showing posts with label 3.4.1. Show all posts

10 June 2012

184. Fixing Gnome screenshot (3.4.1) in Debian Wheezy by patching and compiling

Approach
Putting a hold on gnome-screenshot forever will likely prevent gnome from upgrading properly since I'd suspect it's a required dependency.

Clarification: this fix restores the original behaviour. gnome-screenshot --interactive is NOT an acceptable solution. This guide restores gnome-screenshot to it's good old functional state.

So, time to build our own gnome-screenshot -- but one which actually works in a reasonable way. The gnome-screenshot cockup is just another sign that something is clearly amiss with the way gnome is being developed. And this, if true, is another truly idiotic 'feature' -- turn gnome into windows? Most of us left for a reason...

Anyway, linux is still sane though -- if we don't like something we're not entirely up a creek, which will buy us a bit more time while we're getting ready to move to xmonad  -- or for debian to move away from not making downstreams changes to gnome.

We have two options:
Either look here: http://git.gnome.org/browse/gnome-screenshot/commit/?id=3bbc1e158fd58ec7f4f984f6d3c15ec95e65a035&ignorews=1 and try to come up with your own way of reverting the crippling.

Or use the ubuntu patches as a guide: http://packages.ubuntu.com/precise/gnome-screenshot

Normally you shouldn't mix ubuntu and debian packages, and we won't: we'll be compiling our own package, but using the work done by the ubuntu maintainers.

In particular, look at this: http://archive.ubuntu.com/ubuntu/pool/main/g/gnome-screenshot/gnome-screenshot_3.4.1-0ubuntu1.debian.tar.gz

Look in the debian/patches directory and you'll find the ubuntu_interative_screenshots.patch

Building:
sudo apt-get install libgtk-3-dev libcanberra-gtk3-dev intltool
wget http://ftp.de.debian.org/debian/pool/main/g/gnome-screenshot/gnome-screenshot_3.4.1.orig.tar.xz
tar xvf gnome-screenshot_3.4.1.orig.tar.xz
cd gnome-screenshot-3.4.1/src

You can wget http://archive.ubuntu.com/ubuntu/pool/main/g/gnome-screenshot/gnome-screenshot_3.4.1-0ubuntu1.debian.tar.gz and untar it to look at the debian/patches/ubuntu_interactive_screenshots.patch, which what we do below is based on:

In the ubuntu patch there's a test to see whether unity is used. We'll do it a bit cruder -- we'll just make sure the condition is always true by testing for 0<1.


Edit src/screenshot-application.c and change the part in red

130 static void
131 save_pixbuf_handle_error (ScreenshotApplication *self,
132                           GError *error)
133 {
134   if (screenshot_config->interactive)
135     {
136       ScreenshotDialog *dialog = self->priv->dialog;
137       GtkWidget *toplevel = screenshot_dialog_get_toplevel (dialog);
138 
139       screenshot_dialog_set_busy (dialog, FALSE);
to

134   if (0 < 1)

Also, change

348   screenshot_play_sound_effect ("screen-capture", _("Screenshot taken"));
349 
350   if (screenshot_config->interactive)
351     {
352       self->priv->dialog = screenshot_dialog_new (self->priv->screenshot, self->priv->save_uri);
353       toplevel = screenshot_dialog_get_toplevel (self->priv->dialog);
354       gtk_widget_show (toplevel);
to


350   if (0 < 1 )

Time to build!
./configure --prefix=${HOME}/.gsc --program-suffix=.debugged
make
make install

Note: the install prefix here works fine for a single-user desktop. If you want everyone to be able to use our shiny new gnome-screenshot, put everything in /usr/bin instead.

We now have a working gnome screenshot in ~/.gsc that behaves as intended.
tree -L 2 -d
.
|-- bin
`-- share
    |-- applications
    |-- GConf
    |-- glib-2.0
    |-- gnome-screenshot
    |-- locale
    `-- man


 However, we need to make sure our fixed gnome-screenshot gets invoked.

In Gnome Shell 3.2.X
sudo apt-get install gconf-editor
Start gconf-editor
go to /apps/metacity/keybinding_commands/command_screenshot
change to e.g.  /home/verahill/.gsc/bin/gnome-screenshot.debugged
Also, change command_window_screenshot to
/home/verahill/.gsc/bin/gnome-screenshot.debugged --window

Note: defining Print/Alt+print keyboard shortcuts the 'gnome-shell' way (i.e. via system-settings) doesn't seem to work in gnome 3.2. Conversely, doing it the gconf-editor way in gnome 3.4 doesn't work.


In Gnome Shell 3.4.X
Go to System Settings, Keyboard, Shortcuts
Disable the automatically defined shortcuts for gnome-screenshot

And add your own under custom shortcuts:




Done! 
Unless you want to add to PATH in which case you can put this in your ~/.bashrc:
export PATH=$PATH:${HOME}/.gsc/bin




Note: If it's still not working, try to launch from the terminal. If you get
(gnome-screenshot.debugged:7493): GLib-GIO-ERROR **: Settings schema 'org.gnome.gnome-screenshot' does not contain a key named 'auto-save-directory'
Trace/breakpoint trap
it's because you had the old, good gnome-screenshot. 
sudo su
echo "gnome-screenshot install"|dpkg --set-selections
exit
sudo apt-get install gnome-screenshot

Now try
gsettings get org.gnome.gnome-screenshot auto-save-directory
which should be empty.

gsettings set org.gnome.gnome-screenshot auto-save-directory '/home/verahill/Pictures'

Finally, make sure to re-set your keybindings.



Links to this post:
http://qfox.nl/notes/153