commit 6f41cc29e2468215409bbb31f6225aed98b5da2f parent 7dc78f6e6294461a8cd71a20fe763756a0953d9f Author: Alexander Kojevnikov <alexander@kojevnikov.com> Date: Wed, 28 Apr 2010 19:11:11 +1000 Screw C, let's use Vala! Diffstat:
26 files changed, 288 insertions(+), 44 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -4,9 +4,14 @@ autom4te.cache compile config.* configure +data/spek.desktop +data/spek.desktop.in depcomp .deps install-sh +intltool-extract.in +intltool-merge.in +intltool-update.in libtool ltmain.sh Makefile @@ -15,9 +20,12 @@ Makefile.in.in missing mkinstalldirs omf.make +po/.intltool-merge-cache po/POTFILES po/stamp-it +src/*.c src/*.o +src/*.stamp src/spek stamp-h1 xmldocs.make diff --git a/Makefile.am b/Makefile.am @@ -1,7 +1,17 @@ -SUBDIRS = src po +# Makefile.am + +SUBDIRS = \ + data \ + src \ + vapi \ + po EXTRA_DIST = \ - HACKING - autogen.sh + intltool-extract.in \ + intltool-merge.in \ + intltool-update.in -CLEANFILES = *~ -\ No newline at end of file +DISTCLEANFILES = \ + intltool-extract \ + intltool-merge \ + intltool-update diff --git a/autogen.sh b/autogen.sh @@ -7,7 +7,7 @@ test -z "$srcdir" && srcdir=. PKG_NAME="spek" REQUIRED_AUTOMAKE_VERSION=1.7 -(test -f $srcdir/configure.ac \ +(test -f $srcdir/src/spek.vala \ && test -d $srcdir/src) || { echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" echo " top-level spek directory" @@ -18,4 +18,4 @@ which gnome-autogen.sh || { echo "You need to install gnome-common from the GNOME Git" exit 1 } -USE_GNOME2_MACROS=1 . gnome-autogen.sh +. gnome-autogen.sh diff --git a/configure.ac b/configure.ac @@ -1,27 +1,49 @@ -AC_INIT(spek, 0.1) -AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) +# configure.ac + +AC_INIT([spek], [0.1]) +AC_CONFIG_SRCDIR([src/spek.vala]) +AC_CONFIG_HEADERS([config.h]) + +AM_INIT_AUTOMAKE([no-dist-gzip dist-bzip2]) + +# Enable silent rules is available +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + AM_MAINTAINER_MODE AC_PROG_CC -AM_PROG_CC_C_O +AC_PROG_CC_STDC +AM_PROG_VALAC([0.7.0]) AC_PROG_INSTALL -AC_PROG_LIBTOOL +AC_PROG_INTLTOOL([0.35]) + +pkg_modules="gtk+-2.0 >= 2.14.0" +SPEK_PACKAGES="--pkg gtk+-2.0" +PKG_CHECK_MODULES(SPEK, [$pkg_modules]) +AC_SUBST(SPEK_CFLAGS) +AC_SUBST(SPEK_LIBS) +AC_SUBST(SPEK_PACKAGES) -dnl *************************************************************************** -dnl Internatinalization -dnl *************************************************************************** GETTEXT_PACKAGE=spek +AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["$GETTEXT_PACKAGE"], [Gettext Package]) AC_SUBST(GETTEXT_PACKAGE) -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name]) AM_GLIB_GNU_GETTEXT -IT_PROG_INTLTOOL([0.35.0]) -AM_PATH_GTK_2_0([2.10.0],,AC_MSG_ERROR([Gtk+ 2.10.0 or higher required.])) +AM_GLIB_GNU_GETTEXT -AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ - Makefile - src/Makefile - po/Makefile.in + Makefile + data/spek.desktop.in + data/Makefile + data/icons/Makefile + data/icons/16x16/Makefile + data/icons/22x22/Makefile + data/icons/24x24/Makefile + data/icons/32x32/Makefile + data/icons/48x48/Makefile + data/icons/scalable/Makefile + po/Makefile.in + src/Makefile + vapi/Makefile ]) AC_OUTPUT \ No newline at end of file diff --git a/data/Makefile.am b/data/Makefile.am @@ -0,0 +1,14 @@ +# Makefile.am + +SUBDIRS = icons + +desktopdir = $(datadir)/applications +desktop_in_files = spek.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) +@INTLTOOL_DESKTOP_RULE@ + +EXTRA_DIST = \ + $(desktop_in_files) + +CLEANFILES = \ + $(desktop_DATA) diff --git a/data/icons/16x16/Makefile.am b/data/icons/16x16/Makefile.am @@ -0,0 +1,14 @@ +# Makefile.am + +themedir = $(datadir)/icons/hicolor +size = 16x16 +context = apps + +iconsdir = $(themedir)/$(size)/$(context) + +icons_DATA = \ + spek.png + +EXTRA_DIST = \ + $(icons_DATA) + diff --git a/data/icons/16x16/spek.png b/data/icons/16x16/spek.png Binary files differ. diff --git a/data/icons/22x22/Makefile.am b/data/icons/22x22/Makefile.am @@ -0,0 +1,14 @@ +# Makefile.am + +themedir = $(datadir)/icons/hicolor +size = 22x22 +context = apps + +iconsdir = $(themedir)/$(size)/$(context) + +icons_DATA = \ + spek.png + +EXTRA_DIST = \ + $(icons_DATA) + diff --git a/data/icons/22x22/spek.png b/data/icons/22x22/spek.png Binary files differ. diff --git a/data/icons/24x24/Makefile.am b/data/icons/24x24/Makefile.am @@ -0,0 +1,14 @@ +# Makefile.am + +themedir = $(datadir)/icons/hicolor +size = 24x24 +context = apps + +iconsdir = $(themedir)/$(size)/$(context) + +icons_DATA = \ + spek.png + +EXTRA_DIST = \ + $(icons_DATA) + diff --git a/data/icons/24x24/spek.png b/data/icons/24x24/spek.png Binary files differ. diff --git a/data/icons/32x32/Makefile.am b/data/icons/32x32/Makefile.am @@ -0,0 +1,14 @@ +# Makefile.am + +themedir = $(datadir)/icons/hicolor +size = 32x32 +context = apps + +iconsdir = $(themedir)/$(size)/$(context) + +icons_DATA = \ + spek.png + +EXTRA_DIST = \ + $(icons_DATA) + diff --git a/data/icons/32x32/spek.png b/data/icons/32x32/spek.png Binary files differ. diff --git a/data/icons/48x48/Makefile.am b/data/icons/48x48/Makefile.am @@ -0,0 +1,14 @@ +# Makefile.am + +themedir = $(datadir)/icons/hicolor +size = 48x48 +context = apps + +iconsdir = $(themedir)/$(size)/$(context) + +icons_DATA = \ + spek.png + +EXTRA_DIST = \ + $(icons_DATA) + diff --git a/data/icons/48x48/spek.png b/data/icons/48x48/spek.png Binary files differ. diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am @@ -0,0 +1,16 @@ +# Makefile.am + +SUBDIRS = 16x16 22x22 24x24 32x32 48x48 scalable + +gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor + +install-data-hook: update-icon-cache +uninstall-hook: update-icon-cache +update-icon-cache: + @-if test -z "$(DESTDIR)"; then \ + echo "Updating GTK+ icon cache."; \ + $(gtk_update_icon_cache); \ + else \ + echo "*** Icon cache not updated. After (un)install, run this:"; \ + echo "*** $(gtk_update_icon_cache)"; \ + fi diff --git a/data/icons/scalable/Makefile.am b/data/icons/scalable/Makefile.am @@ -0,0 +1,13 @@ +# Makefile.am + +themedir = $(datadir)/icons/hicolor +size = scalable +context = apps + +iconsdir = $(themedir)/$(size)/$(context) + +icons_DATA = \ + spek.svg + +EXTRA_DIST = \ + $(icons_DATA) diff --git a/data/icons/scalable/spek.svg b/data/icons/scalable/spek.svg @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + version="1.1" + width="280" + height="280" + id="svg2"> + <defs + id="defs4" /> + <g + transform="translate(0,-772.36218)" + id="layer1"> + <g + transform="matrix(1.0033597,0,0,0.95445541,-84.6288,726.1841)" + id="g5214"> + <path + d="m 148,49.28125 c -11.99467,0 -21.71875,12.21817 -21.71875,27.28125 0,0.68473 0.023,1.359186 0.0625,2.03125 l -40.3125,230.28125 43.15625,0 4.0625,-23.21875 188.0625,0 40.25,-236.375 -212.15625,0 0,0.0625 C 148.9456,49.307097 148.46804,49.28125 148,49.28125 z" + id="rect3594" + style="fill:#f9e689;fill-opacity:1;stroke:#000000;stroke-width:1.02186584;stroke-opacity:1" /> + <path + d="m 106.5625,286.59375 c -11.994674,0 -21.71875,12.21817 -21.71875,27.28125 0,15.06308 9.724076,27.25 21.71875,27.25 1.20071,0 2.38353,-0.10841 3.53125,-0.34375 l 0,0.4375 212.15625,0 -1.03125,-54.5625 -212.125,0 0,0.125 c -0.83135,-0.12133 -1.67398,-0.1875 -2.53125,-0.1875 z" + id="path3590" + style="fill:#c5c5c5;fill-opacity:1;stroke:#000000;stroke-width:1.02186584;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" /> + <rect + width="236.14818" + height="57.336876" + x="-2213.9961" + y="-2289.0808" + transform="matrix(-0.16720778,0.98592168,0.00326554,-0.99999467,0,0)" + id="rect3601" + style="fill:#dbdbdb;fill-opacity:1;stroke:#000000;stroke-width:2.52341509;stroke-opacity:1" /> + </g> + <text + x="81.701401" + y="897.75659" + id="text3605" + xml:space="preserve" + style="font-size:48px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans Mono;-inkscape-font-specification:Bitstream Vera Sans Mono Bold"><tspan + x="81.701401" + y="897.75659" + id="tspan3607">Vala</tspan></text> + </g> +</svg> diff --git a/data/spek.desktop.in.in b/data/spek.desktop.in.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Type=Application +Version=1.0 +_Name=Spek +_GenericName=Spectrogram Viewer +_Comment=Spectrogram viewer +Exec=sampala +Icon=sampala +Terminal=false +Categories=Audio +StartupNotify=true diff --git a/po/POTFILES.in b/po/POTFILES.in @@ -1,3 +1,3 @@ -# List of source files containing translatable strings. - -src/main.c +[encoding: UTF-8] +data/spek.desktop.in.in +src/spek.vala diff --git a/po/POTFILES.skip b/po/POTFILES.skip @@ -0,0 +1 @@ +data/spek.desktop.in diff --git a/src/Makefile.am b/src/Makefile.am @@ -1,9 +1,18 @@ bin_PROGRAMS = spek spek_SOURCES = \ - main.c + spek.vala -spek_CPPFLAGS = @GTK_CFLAGS@ -spek_LDADD = @GTK_LIBS@ +INCLUDES = \ + -include config.h \ + $(SPEK_CFLAGS) \ + -DLOCALEDIR=\""$(localedir)"\" \ + -DPKGDATADIR=\""$(pkgdatadir)"\" \ + -DPKGLIBDIR=\""$(pkglibdir)"\" -CLEANFILES = *~ +VALAFLAGS = \ + --vapidir=$(srcdir)/../vapi --pkg config \ + @SPEK_PACKAGES@ + +spek_LDADD = \ + $(SPEK_LIBS) diff --git a/src/main.c b/src/main.c @@ -1,16 +0,0 @@ -#include <gtk/gtk.h> - -gint -main (gint argc, gchar *argv[]) -{ - GtkWidget *window = NULL; - gtk_init (&argc, &argv); - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_size_request (window, 400, 300); - gtk_container_set_border_width (GTK_CONTAINER (window), 10); - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (gtk_main_quit), NULL); - gtk_widget_show (window); - gtk_main (); - return 0; -} diff --git a/src/spek.vala b/src/spek.vala @@ -0,0 +1,19 @@ +public class Main { + public static int main (string[] args) { + Intl.bindtextdomain( Config.GETTEXT_PACKAGE, Config.LOCALEDIR ); + Intl.bind_textdomain_codeset( Config.GETTEXT_PACKAGE, "UTF-8" ); + Intl.textdomain( Config.GETTEXT_PACKAGE ); + + Gtk.init (ref args); + + var window = new Gtk.Window (Gtk.WindowType.TOPLEVEL); + window.set_default_size (300, 200); + window.destroy += Gtk.main_quit; + window.add (new Gtk.Label ("Hello World!")); + window.show_all (); + + Gtk.main (); + return 0; + } +} + diff --git a/vapi/Makefile.am b/vapi/Makefile.am @@ -0,0 +1,5 @@ +noinst_DATA = \ + config.vapi + +EXTRA_DIST = \ + $(noinst_DATA) diff --git a/vapi/config.vapi b/vapi/config.vapi @@ -0,0 +1,17 @@ +[CCode (prefix = "", lower_case_cprefix = "", cheader_filename = "config.h")] +namespace Config +{ + /* Package information */ + public const string PACKAGE_NAME; + public const string PACKAGE_STRING; + public const string PACKAGE_VERSION; + + /* Gettext package */ + public const string GETTEXT_PACKAGE; + + /* Configured paths - these variables are not present in config.h, they are + * passed to underlying C code as cmd line macros. */ + public const string LOCALEDIR; /* /usr/local/share/locale */ + public const string PKGDATADIR; /* /usr/local/share/sampala */ + public const string PKGLIBDIR; /* /usr/local/lib/sampala */ +}