Entries Tagged as 'input method'

How to easily modify a program in Ubuntu (updated)?

Some time ago we talked about how to modify easily a pro­gram in Ubuntu. We gave as an example the modi­fic­a­tion of gucharmap; we got the deb source pack­age, made the change, com­piled, cre­ated new .deb files and installed them.

We go the same (well, sim­ilar) route here, by modi­fy­ing the gtk+ lib­rary (!!!). The pur­pose of the modi­fic­a­tion is to allow us to type, by default, all sort of inter­est­ing Uni­code char­ac­ters, includ­ing ⓣⓗⓘⓢ , ᾅᾷ, ṩ, and many more.

The result of this exer­cise is to create replace­ment .deb pack­ages for the gtk+ lib­rary that we are going to install in place of the system lib­rar­ies. Because these new lib­rar­ies will not be ori­ginal Ubuntu pack­ages, the update man­ager will be pes­ter­ing us to roll­back to the offi­cial gtk+ pack­ages. This is actu­ally good in case you want to switch back; you will have the enhanced func­tion­al­ity for as long as you post­pone that update.

There is a chance we might screw up our system, so please make backups, or have a few drinks first and come back. I take no respons­ib­il­ity if some­thing bad hap­pens on your system. If you are having any second thoughts, do not follow the next steps; use the safer altern­at­ive pro­ced­ure. You may try how­ever this guide just for the kicks; up to the dpkg com­mand below, no changes are being made to your system.

We use Ubuntu 7.10 here. This should work in other ver­sions, though your mileage may vary.

The com­pil­a­tion pro­ced­ure takes time (about 30 minutes) and space. Make sure you use a par­ti­tion with >2GB of free space. We are not going to use up 2GB (a bit less than 1GB), but it’s nice not to fill up partitions.

We are going to use the gen­eric instruc­tions on how to recom­pile a debian pack­age by ducea.

First of all, install the devel­op­ment packages,

sudo apt-get install devscripts build-essential

Next, we use the apt-​get source com­mand to get the source code of the GTK+ 2 library,

cd /home/ubuntu/bigpartition_over2GB/
apt-get source libgtk2.0-0

We then pull in any depend­en­cies that GTK+ may require. They are nor­mally about a dozen pack­ages, but we do not have to worry for the details.

apt-get build-dep libgtk2.0-0

At this stage we need to touch up the source code of GTK+ before we go into the com­pil­a­tion phase. Visit the bug report #321896 – Synch gdkkeysyms.h/gtkimcontextsimple.c with X.org 6.9/7.0 and down­load the patch (look under the Attach­ment sec­tion). You should get a file named gtk-​com​pose-​update.patch. If you have a look at the patch, you will notice that it expects to find the source of gtk+ in a dir­ect­ory called gtk+. Making a link solves the problem,

ln -s libgtk2.0-0 gtk+

We then attempt to apply the patch (per­form a dry run), just in case.

patch -p0 --dry-run < /tmp/gtk-compose-update.patch

If this does not show an error mes­sage, you can the com­mand again without the –dry-​run.

patch -p0 < /tmp/gtk-compose-update.patch

Finally, we are ready to build our fresh GTK+ library.

cd libgtk2.0-0
debuild -us -uc

This will take time to com­plete, so go and do some healthy cooking.

At the end of the com­pil­a­tion, if all went OK, you should have about a dozen .deb files cre­ated. These are one dir­ect­ory higher (do a “cd ..“). To install, use dpkg,

dpkg -i *.deb

If you have any other deb files in this dir­ect­ory, it’s good to move them away before run­ning the com­mand. If all went ok, the .deb files should install without a hitch.

The final step is to restart your system. To test the new sup­port, see the last sec­tion at this post. Use Fire­fox and Open​Of​fice.org to type those Uni­code characters.

If you man­aged to wade through all these steps, I would appre­ci­ate it if you could post a comment.

Good luck!