1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" type="topic" style="task" id="weatherAutotools.js" xml:lang="es">
<info>
<link type="guide" xref="weatherApp.js#main" group="#last"/>
<revision version="0.1" date="2012-03-09" status="stub"/>
<credit type="author copyright">
<name>Susanna Huhtanen</name>
<email>ihmis.suski@gmail.com</email>
<years>2012</years>
</credit>
<desc/>
</info>
<title>Autotools e iconos</title>
<synopsis>
<p>En esta parte de la guía se construirán las «autotools» y los iconos necesarios para la aplicación del clima para que sea una parte integral de su escritorio. Para escribir y ejecutar todos los ejemplos de código necesita un editor de texto en el que escribir el código, una terminal y GNOME 3 o superior instalado en su equipo. En esta guía se verán las siguientes partes:</p>
<list>
<item><p><link xref="#autotools">Autotools</link></p></item>
<item><p><link xref="#icons">Iconos personalizados para su aplicación</link></p></item>
</list>
</synopsis>
<section id="autotools">
<title>Autotools y archivos necesarios</title>
<p>Tener más de un archivo en la carpeta complica un poco el uso de autotools. Necesita los archivos .desktop, autogen.sh, Makefile.am, configure.ac y un archivo nuevo: myapp.sh.in. Hackear el archivo de autotools es complicado. Puede encontrar más información en diferentes fuentes; <link href="http://en.wikipedia.org/wiki/GNU_build_system">este artículo de la wikipedia</link> proporciona una visión general de este tema.</p>
<list>
<item><p>weatherapp.desktop</p></item>
<item><p>weatherapp.sh.in</p></item>
<item><p>Makefile.am</p></item>
<item><p>configure.ac</p></item>
<item><p>autogen.sh</p></item>
</list>
<p>weatherapp.desktop</p>
<code mime="text/.desktop" style="numbered"><![CDATA[
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=Weather app
Comment=Weather showing application
Exec=weatherapp.sh
Icon=application-default-icon
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Utility;]]></code>
<p>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.</p>
<p>weatherapp.sh.in</p>
<code mime="text/sh.in" style="numbered"><![CDATA[
#!/bin/sh
export GJS_PATH=@bindir@
gjs @bindir@/weatherapp.js]]></code>
<p>This file is a template to the file Makefile will do to be run from .desktop.</p>
<p>Makefile.am</p>
<code mime="text/am" style="numbered"><![CDATA[
# The actual runnable program is set to the SCRIPTS primitive. Prefix bin_ tells where to copy this
bin_SCRIPTS = weatherapp.js geonames.js weatherapp.sh
# List of files to be distributed
EXTRA_DIST= \
$(bin_SCRIPTS) \
$(private_icons) \
$(NULL)
CLEANFILES =
# The desktop files
desktopdir = $(datadir)/applications
desktop_DATA =weatherapp.desktop
# convenience command for doing Makefile variable substitutions in non-Makefile
# files (scripts, service files, etc.)
do_subst = sed -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
-e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
-e 's|@localedir[@]|$(localedir)|g' \
-e 's|@bindir[@]|$(bindir)|g' \
-e 's|@libexecdir[@]|$(libexecdir)|g' \
-e 's|@pkglibdir[@]|$(pkglibdir)|g' \
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
-e 's|@have_libnotify[@]|$(HAVE_LIBNOTIFY)|g' \
-e 's|@have_libsoup[@]|$(HAVE_LIBSOUP)|g' \
-e 's|@have_cheese[@]|$(HAVE_CHEESE)|g'
weatherapp.sh: weatherapp.sh.in
$(AM_V_GEN) $(do_subst) $< > $@
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]]></code>
<p>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:</p>
<p>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.</p>
<p>EXTRA_DIST son los archivos que se deben distribuir</p>
<p>do_subst block is bits and pieces that need to be where they are</p>
<p>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 byt the install-icons: bit</p>
<p>configure.ac</p>
<code mime="text/ac" style="numbered"><![CDATA[
dnl This file is processed by autoconf to create a configure script
AC_INIT([Weather App], 1.0)
AM_INIT_AUTOMAKE([1.10 no-define foreign])
AC_CONFIG_FILES(Makefile)
AC_OUTPUT]]></code>
<p>autohen.sh</p>
<code mime="text/sh" style="numbered"><![CDATA[
#!/bin/sh
# This will run autoconf, automake, etc. for us
autoreconf --force --install]]></code>
</section>
<section id="icons">
<title>Iconos personalizados para su aplicación</title>
<p>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</p>
<p>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</p>
<p>appicondir=$(datadir)/icons/hicolor/scalable/apps</p>
<p>appicon_DATA=weather-icon.svg</p>
</section>
</page>
|