|
Packit |
1470ea |
|
|
Packit |
1470ea |
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" type="topic" style="task" id="weatherAutotools.js" xml:lang="es">
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<link type="guide" xref="weatherApp.js#main" group="#last"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-03-09" status="stub"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Susanna Huhtanen</name>
|
|
Packit |
1470ea |
<email its:translate="no">ihmis.suski@gmail.com</email>
|
|
Packit |
1470ea |
<years>2012</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Daniel Mustieles</mal:name>
|
|
Packit |
1470ea |
<mal:email>daniel.mustieles@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2011 - 2017</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Nicolás Satragno</mal:name>
|
|
Packit |
1470ea |
<mal:email>nsatragno@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2012 - 2013</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Jorge González</mal:name>
|
|
Packit |
1470ea |
<mal:email>jorgegonz@svn.gnome.org</mal:email>
|
|
Packit |
1470ea |
<mal:years>2011</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Autotools e iconos</title>
|
|
Packit |
1470ea |
<synopsis>
|
|
Packit |
1470ea |
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:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item><link xref="#autotools"> Autotools</link> </item>
|
|
Packit |
1470ea |
<item><link xref="#icons">Iconos personalizados para su aplicación</link> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</synopsis>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="autotools">
|
|
Packit |
1470ea |
<title>Autotools y archivos necesarios</title>
|
|
Packit |
1470ea |
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.
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item>weatherapp.desktop </item>
|
|
Packit |
1470ea |
<item>weatherapp.sh.in </item>
|
|
Packit |
1470ea |
<item>Makefile.am </item>
|
|
Packit |
1470ea |
<item>configure.ac </item>
|
|
Packit |
1470ea |
<item>autogen.sh </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
weatherapp.desktop
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
[Desktop Entry]
|
|
Packit |
1470ea |
Version=1.0
|
|
Packit |
1470ea |
Encoding=UTF-8
|
|
Packit |
1470ea |
Name=Weather app
|
|
Packit |
1470ea |
Comment=Weather showing application
|
|
Packit |
1470ea |
Exec=weatherapp.sh
|
|
Packit |
1470ea |
Icon=application-default-icon
|
|
Packit |
1470ea |
Terminal=false
|
|
Packit |
1470ea |
Type=Application
|
|
Packit |
1470ea |
StartupNotify=true
|
|
Packit |
1470ea |
Categories=GNOME;GTK;Utility;
|
|
Packit |
1470ea |
Lo importante de este archivo es que la línea Exec hará que el archivo .desktop funcione sólo después de ejecutar el resto de makefiles. Weatherapp.sh es un pequeño script creado a partir de weatherapp.sh.in.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
weatherapp.sh.in
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
#!/bin/sh
|
|
Packit |
1470ea |
export GJS_PATH=@bindir@
|
|
Packit |
1470ea |
gjs @bindir@/weatherapp.js
|
|
Packit |
1470ea |
Este archivo es una plantilla que el Makefile creará para ejecutarlo desde el .desktop.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Makefile.am
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
# The actual runnable program is set to the SCRIPTS primitive. Prefix bin_ tells where to copy this
|
|
Packit |
1470ea |
bin_SCRIPTS = weatherapp.js geonames.js weatherapp.sh
|
|
Packit |
1470ea |
# List of files to be distributed
|
|
Packit |
1470ea |
EXTRA_DIST= \
|
|
Packit |
1470ea |
$(bin_SCRIPTS) \
|
|
Packit |
1470ea |
$(private_icons) \
|
|
Packit |
1470ea |
$(NULL)
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
CLEANFILES =
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
# The desktop files
|
|
Packit |
1470ea |
desktopdir = $(datadir)/applications
|
|
Packit |
1470ea |
desktop_DATA =weatherapp.desktop
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
# convenience command for doing Makefile variable substitutions in non-Makefile
|
|
Packit |
1470ea |
# files (scripts, service files, etc.)
|
|
Packit |
1470ea |
do_subst = sed -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
|
|
Packit |
1470ea |
-e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
|
|
Packit |
1470ea |
-e 's|@localedir[@]|$(localedir)|g' \
|
|
Packit |
1470ea |
-e 's|@bindir[@]|$(bindir)|g' \
|
|
Packit |
1470ea |
-e 's|@libexecdir[@]|$(libexecdir)|g' \
|
|
Packit |
1470ea |
-e 's|@pkglibdir[@]|$(pkglibdir)|g' \
|
|
Packit |
1470ea |
-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
|
|
Packit |
1470ea |
-e 's|@have_libnotify[@]|$(HAVE_LIBNOTIFY)|g' \
|
|
Packit |
1470ea |
-e 's|@have_libsoup[@]|$(HAVE_LIBSOUP)|g' \
|
|
Packit |
1470ea |
-e 's|@have_cheese[@]|$(HAVE_CHEESE)|g'
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
weatherapp.sh: weatherapp.sh.in
|
|
Packit |
1470ea |
$(AM_V_GEN) $(do_subst) $< > $@
|
|
Packit |
1470ea |
chmod +x $@
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
CLEANFILES += weatherapp.sh
|
|
Packit |
1470ea |
EXTRA_DIST += weatherapp.sh.in
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
#the application icon
|
|
Packit |
1470ea |
appicondir=$(datadir)/icons/hicolor/scalable/apps
|
|
Packit |
1470ea |
appicon_DATA=weather-icon.svg
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
#icons in the application
|
|
Packit |
1470ea |
NULL =
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
private_icons = \
|
|
Packit |
1470ea |
weather-clear.svg \
|
|
Packit |
1470ea |
weather-few-clouds.svg \
|
|
Packit |
1470ea |
weather-fog.svg \
|
|
Packit |
1470ea |
weather-icon.svg \
|
|
Packit |
1470ea |
weather-overcast.svg \
|
|
Packit |
1470ea |
weather-showers.svg \
|
|
Packit |
1470ea |
weather-showers-scattered.svg \
|
|
Packit |
1470ea |
weather-snow.svg \
|
|
Packit |
1470ea |
$(NULL)
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
install-icons:
|
|
Packit |
1470ea |
for icon in $(private_icons); do \
|
|
Packit |
1470ea |
mkdir -p $(DESTDIR)$(pkgdatadir)/icons/; \
|
|
Packit |
1470ea |
$(INSTALL_DATA) $(srcdir)/$$icon $(DESTDIR)$(pkgdatadir)/icons/; \
|
|
Packit |
1470ea |
done
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
install-data-local: install-icons
|
|
Packit |
1470ea |
Esto necesita más explicación. Comparado con el Makefile.am de HelloWorld, esto ha cambiado un poco. Eche un vistazo a los bloques nuevos.
|
|
Packit |
1470ea |
bin_scripts son los archivos necesarios para ejecutar la aplicación. En este caso, los dos primeros archivos son el programa en sí y el tercero es el script que lanza la aplicación.
|
|
Packit |
1470ea |
EXTRA_DIST son los archivos que se deben distribuir
|
|
Packit |
1470ea |
El bloque do_subst son partes que deben estar donde están
|
|
Packit |
1470ea |
después del comentario «#icons» en la aplicación, están todos los iconos usados por el programa. Para que sean útiles, debe instalar los iconos en los lugares correctos, y esto se hace con el bit «install-icons:»
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
configure.ac
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
dnl This file is processed by autoconf to create a configure script
|
|
Packit |
1470ea |
AC_INIT([Weather App], 1.0)
|
|
Packit |
1470ea |
AM_INIT_AUTOMAKE([1.10 no-define foreign])
|
|
Packit |
1470ea |
AC_CONFIG_FILES(Makefile)
|
|
Packit |
1470ea |
AC_OUTPUT
|
|
Packit |
1470ea |
autogen.sh
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
#!/bin/sh
|
|
Packit |
1470ea |
# This will run autoconf, automake, etc. for us
|
|
Packit |
1470ea |
autoreconf --force --install
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
<section id="icons">
|
|
Packit |
1470ea |
<title>Iconos personalizados para su aplicación</title>
|
|
Packit |
1470ea |
Cuando piense en iconos personalizados, una buena regla es: ¿espera ver un este icono en cualquier parte o es privado para su aplicación? En el primer caso (ej. iconos en el archivo .desktop que se muestran en GNOME Shell) necesita /usr/share/hicolor; si no, (ej. iconos del tiempo en su aplicación), necesita /usr/share/$application/bla/bla.
|
|
Packit |
1470ea |
Usando autotools debe hacer algunos cambios en sus archivos .desktop y Makefile.am. En el archivo .desktop, debe cambiar el nombre del icono a Icon=weather-icon. En el Makefile.am, debe añadir estas líneas al final del archivo
|
|
Packit |
1470ea |
#the application icon
|
|
Packit |
1470ea |
appicondir=$(datadir)/icons/hicolor/scalable/apps
|
|
Packit |
1470ea |
appicon_DATA=weather-icon.svg
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
</page>
|