Susanna Huhtanen ihmis.suski@gmail.com 2012 Rafael Ferreira rafael.f.f1@gmail.com 2013 Autotools and Icons

In this part of the guide well construct the autotools and custom icons needed for weather application to be a seamless part of your desktop. To write and run all the code examples yourself, you need an editor to write code in, Terminal and GNOME 3 or higher installed into your computer. In this guide we we'll go through the following parts:

Autotools

Custom icons for your application

Autotools and necessary files

Having more than one file in your folder makes using autotools a bit tricky. You need the .desktop file, autogen.sh, Makefile.am, configure.ac and as a new file: myapp.sh.in file. Hacking the autotools file is a complicated field. More information can be found in many different sources, the wikipedia article provides a good overview on the subject.

weatherapp.desktop

weatherapp.sh.in

Makefile.am

configure.ac

autogen.sh

weatherapp.desktop

The thing to notice in this file is that the Exec line will make this .desktop file work only after running all the other makefiles. Weatherapp.sh is a small shell script created with the weatherapp.sh.in.

weatherapp.sh.in

This file is a template to the file Makefile will do to be run from .desktop.

Makefile.am

$@ chmod +x $@ CLEANFILES += weatherapp.sh EXTRA_DIST += weatherapp.sh.in #the application icon appicondir=$(datadir)/icons/hicolor/scalable/apps appicon_DATA=weather-icon.svg #icons in the application NULL = private_icons = \ weather-clear.svg \ weather-few-clouds.svg \ weather-fog.svg \ weather-icon.svg \ weather-overcast.svg \ weather-showers.svg \ weather-showers-scattered.svg \ weather-snow.svg \ $(NULL) install-icons: for icon in $(private_icons); do \ mkdir -p $(DESTDIR)$(pkgdatadir)/icons/; \ $(INSTALL_DATA) $(srcdir)/$$icon $(DESTDIR)$(pkgdatadir)/icons/; \ done install-data-local: install-icons]]>

This needs a bit more explaining. Compared to the HelloWorld Makefile.am this has changed quite a bit. Lets go through all the new blocks:

bin_scripts are the files that are needed to run your application. In thin case they are the first two files are the program itself and the third is the script that launches the application.

EXTRA_DIST are the files that are to be distributed

do_subst block is bits and pieces that need to be where they are

after the comment #icons in the application there are all the icons that are used by the program. For them to be useful you need to install the icons in correct places and that is done by the install-icons: bit

configure.ac

autogen.sh

Custom icons for your application

When thinking about custom icons a good rule of thumb is: do you expect to see that icon used elsewhere or is it private to your app? If the first (e.g. the icons in the desktop file that are shown by the shell) then you need /usr/share/hicolor, otherwise (e.g. the weather icons of your app) /usr/share/$application/bla/bla

Using autotools you have to make some changes to your .desktop and Makefile.am files. In the desktop file you change the Icon's name Icon=weather-icon. In the Makefile.am file you add these two lines to the end of your application #the application icon

appicondir=$(datadir)/icons/hicolor/scalable/apps

appicon_DATA=weather-icon.svg