r1632 - in trunk/src/target/OM-2007/applications: . openmoko-calculator openmoko-calculator/data openmoko-calculator/po openmoko-calculator/src

mickey at sita.openmoko.org mickey at sita.openmoko.org
Mon Apr 2 20:54:50 CEST 2007


Author: mickey
Date: 2007-04-02 20:54:48 +0200 (Mon, 02 Apr 2007)
New Revision: 1632

Added:
   trunk/src/target/OM-2007/applications/openmoko-calculator/
   trunk/src/target/OM-2007/applications/openmoko-calculator/AUTHORS
   trunk/src/target/OM-2007/applications/openmoko-calculator/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-calculator/README
   trunk/src/target/OM-2007/applications/openmoko-calculator/configure.ac
   trunk/src/target/OM-2007/applications/openmoko-calculator/data/
   trunk/src/target/OM-2007/applications/openmoko-calculator/data/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop
   trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.png
   trunk/src/target/OM-2007/applications/openmoko-calculator/openmoko-calculator.pro
   trunk/src/target/OM-2007/applications/openmoko-calculator/po/
   trunk/src/target/OM-2007/applications/openmoko-calculator/po/Calculator.pot
   trunk/src/target/OM-2007/applications/openmoko-calculator/po/Makefile.in.in
   trunk/src/target/OM-2007/applications/openmoko-calculator/po/fr.po
   trunk/src/target/OM-2007/applications/openmoko-calculator/src/
   trunk/src/target/OM-2007/applications/openmoko-calculator/src/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.c
   trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.h
Log:
initial import of openmoko-calculator 0.0.3 courtesy Rodolphe Ortalo <rodolphe.ortalo at free.fr>


Added: trunk/src/target/OM-2007/applications/openmoko-calculator/AUTHORS
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/AUTHORS	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/AUTHORS	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,3 @@
+Rodolphe Ortalo <rodolphe.ortalo at free.fr>
+Michael 'Mickey' Lauer <mlauer at vanille-media.de>
+Tony Guan <tonyguan at fic-sh.com.cn>

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/Makefile.am	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/Makefile.am	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,2 @@
+AUTOMAKE_OPTIONS=foreign
+SUBDIRS = src data po
\ No newline at end of file

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/README
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/README	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/README	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,11 @@
+Simple calculator, started based on the OpenMoko Finger Application
+example and the OpenMoko regular dialer UI, in the hope that it would
+be useful.
+
+Notes:
+ * Pango markup is used currently to manage font size for the display
+of for button labels, maybe styles would be more appropriate.
+
+Thanks for your attention,
+
+Rodolphe <rodolphe.ortalo at free.fr>

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/configure.ac
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/configure.ac	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/configure.ac	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,32 @@
+AC_PREREQ(2.53)
+AC_INIT(openmoko-calculator, 0.0.3, rodolphe.ortalo at free.fr)
+AM_INIT_AUTOMAKE()
+AC_CONFIG_SRCDIR(src/calc-main.c)
+AM_CONFIG_HEADER(config.h)
+AM_MAINTAINER_MODE
+
+AC_ISC_POSIX
+AC_PROG_CC
+AC_STDC_HEADERS
+AC_PROG_LIBTOOL
+
+dnl i18n support
+GETTEXT_PACKAGE=Calculator
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext package])
+AC_SUBST(GETTEXT_PACKAGE)
+ALL_LINGUAS="fr"
+AM_GLIB_GNU_GETTEXT
+
+# base deps
+PKG_CHECK_MODULES(OPENMOKO, openmoko-libs >= 0.0.1,,
+                 AC_MSG_ERROR([*** Required OpenMoko Libraries >= 0.0.1 not installed ***]))
+LIBS="$LIBS $GTK_LIBS $OPENMOKO_LIBS"
+CFLAGS="$CFLAGS $OPENMOKO_CFLAGS"
+
+# output stuff
+AC_OUTPUT([
+Makefile
+src/Makefile
+po/Makefile.in
+data/Makefile
+])

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/data/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/data/Makefile.am	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/data/Makefile.am	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,17 @@
+#
+# misc. data files
+#
+# None yet
+# dist_pkgdata_DATA = 
+
+#
+# desktop integration: .desktop file
+#
+desktopdir = $(datadir)/applications
+dist_desktop_DATA = openmoko-calculator.desktop
+
+#
+# desktop integration: application icon
+#
+appicondir = $(datadir)/icons
+dist_appicon_DATA = openmoko-calculator.png

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=OpenMoko Calculator
+Comment=Simple finger calculator
+Encoding=UTF-8
+Version=1.0
+Type=Application
+Exec=openmoko-calculator
+Icon=openmoko-calculator.png
+Terminal=false
+SingleInstance=true
+StartupNotify=true

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/openmoko-calculator.pro
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/openmoko-calculator.pro	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/openmoko-calculator.pro	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,10 @@
+TEMPLATE = app
+DEPENDPATH += src
+INCLUDEPATH += . src
+
+# Input
+HEADERS += src/calc-main.h
+SOURCES += src/calc-main.c
+
+MOKOCONFIG = mokoui
+include ( $(OPENMOKODIR)/devel/qmake/openmoko-include.pro )

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/po/Calculator.pot
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/po/Calculator.pot	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/po/Calculator.pot	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,39 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL at ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-03-24 13:52+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
+"Language-Team: LANGUAGE <LL at li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: src/calc-main.c:87
+msgid "Clear All"
+msgstr ""
+
+#: src/calc-main.c:87
+msgid "Clear"
+msgstr ""
+
+#: src/calc-main.c:91
+msgid "<big><b>.</b></big>"
+msgstr ""
+
+#. application object
+#. MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
+#: src/calc-main.c:349
+msgid "Calculator"
+msgstr ""
+
+#: src/calc-main.c:356
+msgid "Close"
+msgstr ""

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/po/Makefile.in.in
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/po/Makefile.in.in	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/po/Makefile.in.in	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,269 @@
+# Makefile for program source directory in GNU NLS utilities package.
+# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper at gnu.ai.mit.edu>
+#
+# This file file be copied and used freely without restrictions.  It can
+# be used in projects which are not available under the GNU Public License
+# but which still want to provide support for the GNU gettext functionality.
+# Please note that the actual code is *not* freely available.
+#
+# - Modified by Owen Taylor <otaylor at redhat.com> to use GETTEXT_PACKAGE
+#   instead of PACKAGE and to look for po2tbl in ./ not in intl/
+#
+# - Modified by jacob berkman <jacob at ximian.com> to install
+#   Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
+
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+
+SHELL = /bin/sh
+ at SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+datadir = @datadir@
+libdir = @libdir@
+localedir = $(libdir)/locale
+gnulocaledir = $(datadir)/locale
+gettextsrcdir = $(datadir)/glib-2.0/gettext/po
+subdir = po
+
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
+
+CC = @CC@
+GENCAT = @GENCAT@
+GMSGFMT = @GMSGFMT@
+MSGFMT = @MSGFMT@
+XGETTEXT = @XGETTEXT@
+MSGMERGE = msgmerge
+
+DEFS = @DEFS@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+
+INCLUDES = -I.. -I$(top_srcdir)/intl
+
+COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
+
+SOURCES = 
+POFILES = @POFILES@
+GMOFILES = @GMOFILES@
+DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
+$(POFILES) $(GMOFILES) $(SOURCES)
+
+POTFILES = \
+
+CATALOGS = @CATALOGS@
+CATOBJEXT = @CATOBJEXT@
+INSTOBJEXT = @INSTOBJEXT@
+
+.SUFFIXES:
+.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
+
+.c.o:
+	$(COMPILE) $<
+
+.po.pox:
+	$(MAKE) $(GETTEXT_PACKAGE).pot
+	$(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*.pox
+
+.po.mo:
+	$(MSGFMT) -o $@ $<
+
+.po.gmo:
+	file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
+	  && rm -f $$file && $(GMSGFMT) -c -o $$file $<
+
+.po.cat:
+	sed -f ../intl/po2msg.sed < $< > $*.msg \
+	  && rm -f $@ && $(GENCAT) $@ $*.msg
+
+
+all: all- at USE_NLS@
+
+all-yes: $(CATALOGS)
+all-no:
+
+$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
+	$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --directory=$(top_srcdir) \
+	  --add-comments --keyword=_ --keyword=N_ \
+          --flag=g_strdup_printf:1:c-format \
+          --flag=g_string_printf:2:c-format \
+          --flag=g_string_append_printf:2:c-format \
+          --flag=g_error_new:3:c-format \
+          --flag=g_set_error:4:c-format \
+          --flag=g_markup_printf_escaped:1:c-format \
+          --flag=g_log:3:c-format \
+          --flag=g_print:1:c-format \
+          --flag=g_printerr:1:c-format \
+          --flag=g_printf:1:c-format \
+          --flag=g_fprintf:2:c-format \
+          --flag=g_sprintf:2:c-format \
+          --flag=g_snprintf:3:c-format \
+          --flag=g_scanner_error:2:c-format \
+          --flag=g_scanner_warn:2:c-format \
+	  --files-from=$(srcdir)/POTFILES.in \
+	&& test ! -f $(GETTEXT_PACKAGE).po \
+	   || ( rm -f $(srcdir)/$(GETTEXT_PACKAGE).pot \
+		&& mv $(GETTEXT_PACKAGE).po $(srcdir)/$(GETTEXT_PACKAGE).pot )
+
+install: install-exec install-data
+install-exec:
+install-data: install-data- at USE_NLS@
+install-data-no: all
+install-data-yes: all
+	if test -r "$(MKINSTALLDIRS)"; then \
+	  $(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
+	else \
+	  $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
+	fi
+	@catalogs='$(CATALOGS)'; \
+	for cat in $$catalogs; do \
+	  cat=`basename $$cat`; \
+	  case "$$cat" in \
+	    *.gmo) destdir=$(gnulocaledir);; \
+	    *)     destdir=$(localedir);; \
+	  esac; \
+	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+	  dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
+	  if test -r "$(MKINSTALLDIRS)"; then \
+	    $(MKINSTALLDIRS) $$dir; \
+	  else \
+	    $(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
+	  fi; \
+	  if test -r $$cat; then \
+	    $(INSTALL_DATA) $$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+	    echo "installing $$cat as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
+	  else \
+	    $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+	    echo "installing $(srcdir)/$$cat as" \
+		 "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
+	  fi; \
+	  if test -r $$cat.m; then \
+	    $(INSTALL_DATA) $$cat.m $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+	    echo "installing $$cat.m as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
+	  else \
+	    if test -r $(srcdir)/$$cat.m ; then \
+	      $(INSTALL_DATA) $(srcdir)/$$cat.m \
+		$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+	      echo "installing $(srcdir)/$$cat as" \
+		   "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
+	    else \
+	      true; \
+	    fi; \
+	  fi; \
+	done
+	if test "$(PACKAGE)" = "glib"; then \
+	  if test -r "$(MKINSTALLDIRS)"; then \
+	    $(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
+	  else \
+	    $(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
+	  fi; \
+	  $(INSTALL_DATA) $(srcdir)/Makefile.in.in \
+			  $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
+	else \
+	  : ; \
+	fi
+
+# Define this as empty until I found a useful application.
+installcheck:
+
+uninstall:
+	catalogs='$(CATALOGS)'; \
+	for cat in $$catalogs; do \
+	  cat=`basename $$cat`; \
+	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+	  rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+	  rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+	  rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
+	  rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
+	done
+	if test "$(PACKAGE)" = "glib"; then \
+	  rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
+	fi
+
+check: all
+
+dvi info tags TAGS ID:
+
+mostlyclean:
+	rm -f core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp
+	rm -fr *.o
+
+clean: mostlyclean
+
+distclean: clean
+	rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
+
+maintainer-clean: distclean
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+	rm -f $(GMOFILES)
+
+distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir)
+dist distdir: update-po $(DISTFILES)
+	dists="$(DISTFILES)"; \
+	for file in $$dists; do \
+	  ln $(srcdir)/$$file $(distdir) 2> /dev/null \
+	    || cp -p $(srcdir)/$$file $(distdir); \
+	done
+
+update-po: Makefile
+	$(MAKE) $(GETTEXT_PACKAGE).pot
+	tmpdir=`pwd`; \
+	cd $(srcdir); \
+	catalogs='$(CATALOGS)'; \
+	for cat in $$catalogs; do \
+	  cat=`basename $$cat`; \
+	  lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
+	  echo "$$lang:"; \
+	  if $(MSGMERGE) $$lang.po $(GETTEXT_PACKAGE).pot -o $$tmpdir/$$lang.new.po; then \
+	    if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
+	      rm -f $$tmpdir/$$lang.new.po; \
+            else \
+	      if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
+	        :; \
+	      else \
+	        echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
+	        rm -f $$tmpdir/$$lang.new.po; \
+	        exit 1; \
+	      fi; \
+	    fi; \
+	  else \
+	    echo "msgmerge for $$cat failed!"; \
+	    rm -f $$tmpdir/$$lang.new.po; \
+	  fi; \
+	done
+
+# POTFILES is created from POTFILES.in by stripping comments, empty lines
+# and Intltool tags (enclosed in square brackets), and appending a full
+# relative path to them
+POTFILES: POTFILES.in
+	( if test 'x$(srcdir)' != 'x.'; then \
+	    posrcprefix='$(top_srcdir)/'; \
+	  else \
+	    posrcprefix="../"; \
+	  fi; \
+	  rm -f $@-t $@ \
+	    && (sed -e '/^#/d' 						\
+		    -e "s/^\[.*\] +//" 					\
+		    -e '/^[ 	]*$$/d' 				\
+		    -e "s at .*@	$$posrcprefix& \\\\@" < $(srcdir)/$@.in	\
+		| sed -e '$$s/\\$$//') > $@-t \
+	    && chmod a-w $@-t \
+	    && mv $@-t $@ )
+
+Makefile: Makefile.in.in ../config.status POTFILES
+	cd .. \
+	  && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
+	       $(SHELL) ./config.status
+
+# Tell versions [3.59,3.63) of GNU make not to export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/po/fr.po
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/po/fr.po	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/po/fr.po	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,39 @@
+# Template translation file.
+# Copyright (C) 2007 Rodolphe Ortalo
+# This file is distributed under the same license as the openmoko-calculator package.
+# Rodolphe Ortalo <rodolphe.ortalo at free.fr>, 2007
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: openmoko-calculator 0.0.2\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2007-03-24 13:52+0100\n"
+"PO-Revision-Date: 2007-03-23 21:34+0100\n"
+"Last-Translator: ortalo <rodolphe.ortalo at free.fr>\n"
+"Language-Team: French <traduc at traduc.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#: src/calc-main.c:87
+msgid "Clear All"
+msgstr "RAZ"
+
+#: src/calc-main.c:87
+msgid "Clear"
+msgstr "Effacer"
+
+#: src/calc-main.c:91
+msgid "<big><b>.</b></big>"
+msgstr "<big><b>,</b></big>"
+
+#. application object
+#. MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance());
+#: src/calc-main.c:349
+msgid "Calculator"
+msgstr "Calculatrice"
+
+#: src/calc-main.c:356
+msgid "Close"
+msgstr "Fermer"

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/src/Makefile.am	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/src/Makefile.am	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,9 @@
+localedir = $(datadir)/locale
+
+AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" -DLOCALEDIR=\"$(localedir)\"
+AM_CFLAGS =  @OPENMOKO_CFLAGS@ -Wall -std=c99 -pedantic
+
+bin_PROGRAMS = openmoko-calculator
+
+openmoko_calculator_SOURCES = calc-main.c calc-main.h
+

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.c	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.c	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,384 @@
+/*
+ *  Calculator -- OpenMoko simple Calculator
+ *
+ *  Authored by Rodolphe Ortalo <rodolphe.ortalo at free.fr>
+ *
+ *  Copyright (C) 2007 Rodolphe Ortalo
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2 of the license.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date$) [$Author$]
+ */
+
+#include "calc-main.h"
+
+#include <stdio.h>
+#include <math.h>
+
+#include <libmokoui/moko-application.h>
+#include <libmokoui/moko-finger-tool-box.h>
+#include <libmokoui/moko-finger-window.h>
+#include <libmokoui/moko-finger-wheel.h>
+
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkmenu.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtk.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#define BOOL short unsigned int
+
+/* state of calculator */
+typedef struct {
+  double last_operand;
+  double current_operand;
+  double (*func)(const double,const double);
+  BOOL decimal_point;
+  unsigned short int n_digits;
+  unsigned short int n_fractional;
+} calc_state;
+
+enum operation {
+  notimplemented,
+  backspace, clearall, clear,
+  zero, one, two, three, four, five, six, seven, eight, nine, ten,
+  add, sub, mult, div, equal, minus, point } ;
+
+/*
+ * functions for operations
+ */
+static double noop_func (const double a, const double b) { return a; }
+static double add_func  (const double a, const double b) { return a+b; }
+static double sub_func  (const double a, const double b) { return a-b; }
+static double mult_func (const double a, const double b) { return a*b; }
+static double div_func  (const double a, const double b) { return a/b; }
+
+/*
+ * Internal variables
+ */
+static calc_state the_state = { .last_operand = 0.0,
+				.current_operand = 0.0,
+				.func = &add_func,
+				.decimal_point = FALSE,
+				.n_digits = 0,
+				.n_fractional = 0, };
+static GtkWidget* displayed_label;
+
+#define CALC_ROWS 5
+#define CALC_COLS 4
+static const gchar *label[CALC_ROWS][CALC_COLS] = {
+    {N_("Clear All"), N_("Clear"), "<big><b>/</b></big>", "<big><b>*</b></big>" },
+    {"<big><b>7</b></big>", "<big><b>8</b></big>", "<big><b>9</b></big>", "<big><b>+</b></big>"},
+    {"<big><b>4</b></big>", "<big><b>5</b></big>", "<big><b>6</b></big>", "<big><b>-</b></big>"},
+    {"<big><b>1</b></big>", "<big><b>2</b></big>", "<big><b>3</b></big>", "<big><b>=</b></big>"},
+    {"<big><b>0</b></big>", N_("<big><b>.</b></big>"), "<big><b>+</b></big>/<big><b>-</b></big>", "none"},
+  };
+static enum operation ops[CALC_ROWS][CALC_COLS] = {
+    { clearall, clear, div, mult},
+    { seven, eight, nine, add},
+    { four, five, six, sub},
+    { one, two, three, equal},
+    { zero, point, minus, notimplemented},
+  };
+#if 1
+gchar *wnames[CALC_ROWS][CALC_COLS] = {
+  {"mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-dialer", "mokofingerbutton-dialer"},
+  {"mokofingerbutton-dialer", "mokofingerbutton-dialer", "mokofingerbutton-dialer", "mokofingerbutton-dialer"},
+  {"mokofingerbutton-dialer", "mokofingerbutton-dialer", "mokofingerbutton-dialer", "mokofingerbutton-dialer"},
+  {"mokofingerbutton-dialer", "mokofingerbutton-dialer", "mokofingerbutton-dialer", "mokofingerbutton-big"},
+  {"mokofingerbutton-dialer", "mokofingerbutton-dialer", "mokofingerbutton-dialer", "none"},
+};
+#else
+/* Alternative styling - more flashy */
+gchar *wnames[CALC_ROWS][CALC_COLS] = {
+  {"mokofingerbutton-black", "mokofingerbutton-black", "mokofingerbutton-orange", "mokofingerbutton-orange"},
+  {"mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-orange"},
+  {"mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-orange"},
+  {"mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-black"},
+  {"mokofingerbutton-orange", "mokofingerbutton-orange", "mokofingerbutton-orange", "none"},
+};
+#endif
+
+/*
+ * Signal function and static helpers
+ */
+#define MAX_DISPLAY_CHARS 10
+#define MAX_DISPLAY_MARKUP (MAX_DISPLAY_CHARS+80)
+static gchar dispstring[MAX_DISPLAY_MARKUP+1];
+
+static void update_display(const double v)
+{
+  if (the_state.n_digits == 0) {
+    /* We are certainly displaying a computation result */
+    /* Manually build the display string ala %g */
+    double value = v;
+    int expof10;
+
+    expof10 = (int) log10((value>=0.)?(value):(-value));
+    value *= pow(10,-expof10);
+    if (expof10 >= MAX_DISPLAY_CHARS)
+      snprintf(dispstring,MAX_DISPLAY_MARKUP,"<span font_desc=\"48\" >%.*g <small>e</small><sup><big>%d</big></sup></span>",(MAX_DISPLAY_CHARS-2),value,expof10);
+    else
+      snprintf(dispstring,MAX_DISPLAY_MARKUP,"<span font_desc=\"48\" >%.*g</span>",MAX_DISPLAY_CHARS,v);
+  } else {
+    /* We display entered value including trailing 0s */
+    if (the_state.decimal_point == TRUE)
+      snprintf(dispstring,MAX_DISPLAY_MARKUP,"<span font_desc=\"48\" >%#.*f</span>",the_state.n_fractional,v);
+    else
+      snprintf(dispstring,MAX_DISPLAY_MARKUP,"<span font_desc=\"48\" >%.*f</span>",the_state.n_fractional,v);
+  }
+#if 1
+  calc_debug("cur = %.12lf  last = %.12lf", the_state.current_operand, the_state.last_operand);
+  calc_debug("n_digits = %i  n_fractional = %i  dec_point = %i", the_state.n_digits, the_state.n_fractional, the_state.decimal_point);
+  calc_debug(dispstring);
+#endif
+	  
+  gtk_label_set_markup(GTK_LABEL(displayed_label), dispstring);
+}
+
+static void update_state_for_digit(const int v)
+{
+  if (the_state.func == &noop_func) {
+    /* renew a fresh calc */
+    the_state.last_operand = 0.0;
+    the_state.func = &add_func;
+  }
+  if (the_state.n_digits < MAX_DISPLAY_CHARS) {
+    the_state.n_digits++;
+    if (the_state.decimal_point == FALSE) {
+      the_state.current_operand *= 10.0;
+      the_state.current_operand += v
+	* (the_state.current_operand ? (the_state.current_operand / fabs(the_state.current_operand)) : 1.0);
+    } else {
+      the_state.n_fractional++;
+      the_state.current_operand += (v * pow(0.1,the_state.n_fractional))
+	* (the_state.current_operand ? (the_state.current_operand / fabs(the_state.current_operand)) : 1.0);
+    }
+  }
+  update_display(the_state.current_operand);
+}
+static void update_state_for_operation(double (*nextfunc)(const double,const double))
+{
+  the_state.last_operand = (*(the_state.func))(the_state.last_operand,the_state.current_operand);
+  the_state.current_operand = 0.0;
+  the_state.func = nextfunc;
+  the_state.decimal_point = FALSE;
+  the_state.n_digits = 0;
+  the_state.n_fractional = 0;
+  update_display(the_state.last_operand);
+}
+
+void calc_button_pressed( GtkButton* button, enum operation *k)
+{
+  calc_debug( "openmoko-calculator: button pressed" );
+  switch (*k) {
+  case zero:
+    update_state_for_digit(0);
+    break;
+  case one:
+    update_state_for_digit(1);
+    break;
+  case two:
+    update_state_for_digit(2);
+    break;
+  case three:
+    update_state_for_digit(3);
+    break;
+  case four:
+    update_state_for_digit(4);
+    break;
+  case five:
+    update_state_for_digit(5);
+    break;
+  case six:
+    update_state_for_digit(6);
+    break;
+  case seven:
+    update_state_for_digit(7);
+    break;
+  case eight:
+    update_state_for_digit(8);
+    break;
+  case nine:
+    update_state_for_digit(9);
+    break;
+  case minus:
+    the_state.current_operand *= -1;
+    update_display(the_state.current_operand);
+    break;
+  case point:
+    the_state.decimal_point = TRUE;
+    update_display(the_state.current_operand);
+    break;
+  case clearall:
+    the_state.last_operand = 0.0;
+    the_state.func = &add_func;
+  case clear:
+    the_state.current_operand = 0.0;
+    the_state.decimal_point = FALSE;
+    the_state.n_digits = 0;
+    the_state.n_fractional = 0;
+    update_display(the_state.current_operand);
+    break;
+  case add:
+    update_state_for_operation(&add_func);
+    break;
+  case sub:
+    update_state_for_operation(&sub_func);
+    break;
+  case mult:
+    update_state_for_operation(&mult_func);
+    break;
+  case div:
+    update_state_for_operation(&div_func);
+    break;
+#if 0
+    /* Not implemented to win one button slot and display a bigger = button */
+  case backspace:
+    break;
+#endif
+  case equal:
+    update_state_for_operation(&noop_func);
+    break;
+  case notimplemented:
+    g_debug("openmoko-calculator: operation not-implemented");
+    break;
+  default:
+    g_debug("openmoko-calculator: unknown operation (%i)!", *k);
+    break;
+  }
+}
+
+/*
+ * Convenience static function
+ */
+static GtkTable* calc_panel_init (void)
+{
+
+  GtkTable *table;
+  int i, j;
+
+  table = GTK_TABLE(gtk_table_new (CALC_ROWS, CALC_COLS, TRUE));
+  gtk_table_set_row_spacings(table, 10);
+  gtk_table_set_col_spacings(table, 10);
+
+  for (j = 0; j < CALC_COLS; j++)
+    for (i = 0; i < CALC_ROWS; i++)
+    {
+      GtkButton* button = GTK_BUTTON(gtk_button_new());
+      GtkWidget* blabel = gtk_label_new(NULL);
+      gtk_label_set_markup(GTK_LABEL(blabel),gettext(label[i][j]));
+      gtk_container_add(GTK_CONTAINER(button),blabel);
+
+      g_signal_connect (G_OBJECT(button), "clicked", G_CALLBACK(calc_button_pressed),&(ops[i][j]));
+      /* TODO: Check if this changes the aspect */
+      gtk_widget_set_name(GTK_WIDGET(button), wnames[i][j]);
+
+      if ((j == (CALC_COLS-1)) && (i == (CALC_ROWS-2))) {
+	/* Last button spans two cells vertically */
+	gtk_table_attach_defaults (table, GTK_WIDGET(button),
+				   j, j + 1, i, i + 2);
+	i++;
+      } else {
+	gtk_table_attach_defaults (table, GTK_WIDGET(button),
+				   j, j + 1, i, i + 1);	
+      }
+      gtk_widget_set_size_request (GTK_WIDGET(button), 20, 20);
+    }
+  return table;
+}
+
+/*
+ * Command line options definition
+ */
+static GOptionEntry entries[] = 
+{
+  /* No options right now except the default ones from GTK */
+  { NULL }
+};
+
+
+/*
+ * Main
+ */
+int main( int argc, char** argv )
+{
+    GtkHBox* hbox;
+    GtkVBox* vbox;
+    GtkTable* table;
+
+    calc_debug( "openmoko-calculator starting up" );
+    /* Initialize GTK+ */
+    gtk_init( &argc, &argv );
+    if (argc != 1)
+      {
+	/* Add init code. */
+	GError *error = NULL;
+	GOptionContext *context = g_option_context_new ("");
+	
+	g_option_context_add_main_entries (context, entries, NULL);
+	g_option_context_add_group (context, gtk_get_option_group (TRUE));
+	g_option_context_parse (context, &argc, &argv, &error);
+	
+	g_option_context_free (context);
+      }
+	
+    setlocale (LC_ALL, "");
+    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+    textdomain (GETTEXT_PACKAGE);
+
+    /* application object */
+    /* MokoApplication* app = MOKO_APPLICATION(moko_application_get_instance()); */
+    g_set_application_name( _("Calculator") );
+
+    /* main window */
+    MokoFingerWindow* window = MOKO_FINGER_WINDOW(moko_finger_window_new());
+
+    /* application menu */
+    GtkMenu* appmenu = GTK_MENU(gtk_menu_new());
+    GtkMenuItem* closeitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label( _("Close") ));
+    g_signal_connect( G_OBJECT(closeitem), "activate", G_CALLBACK(gtk_main_quit), NULL );
+    gtk_menu_shell_append( GTK_MENU_SHELL(appmenu), GTK_WIDGET(closeitem) );
+    moko_finger_window_set_application_menu( window, appmenu );
+
+    /* connect close event */
+    g_signal_connect( G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL );
+
+    /* contents */
+    hbox = GTK_HBOX(gtk_hbox_new(TRUE, 10)); /* The hbox is just to get some border space...! */
+    vbox = GTK_VBOX(gtk_vbox_new(FALSE, 10));
+
+    displayed_label = gtk_label_new("123");
+    gtk_misc_set_alignment(GTK_MISC(displayed_label), 1, 0);
+    update_display(0.0);
+    GtkWidget *eventbox1 = gtk_event_box_new ();
+    gtk_widget_set_name (eventbox1, "gtkeventbox-black");
+    gtk_container_add (GTK_CONTAINER (eventbox1), displayed_label);
+    gtk_box_pack_start( GTK_BOX(vbox), eventbox1, FALSE, FALSE, 10);
+
+    table = calc_panel_init();
+    gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(table), TRUE, TRUE, 10);
+
+    gtk_box_pack_start( GTK_BOX(hbox), GTK_WIDGET(vbox), TRUE, TRUE, 10);
+    moko_finger_window_set_contents(window, GTK_WIDGET(hbox));
+    
+    /* show everything and run main loop */
+    gtk_widget_show_all( GTK_WIDGET(window) );
+    calc_debug( "calculator entering main loop" );
+    gtk_main();
+    calc_debug( "calculator left main loop" );
+
+    return 0;
+}


Property changes on: trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.h	2007-04-02 17:49:52 UTC (rev 1631)
+++ trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.h	2007-04-02 18:54:48 UTC (rev 1632)
@@ -0,0 +1,38 @@
+/*
+ *  Calculator -- OpenMoko simple Calculator
+ *
+ *  Authored by Rodolphe Ortalo <rodolphe.ortalo at free.fr>
+ *
+ *  Copyright (C) 2007 Rodolphe Ortalo
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Public License as published by
+ *  the Free Software Foundation; version 2.1 of the license.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Public License for more details.
+ *
+ *  Current Version: $Rev$ ($Date$) [$Author$]
+ */
+
+#ifndef CALC_MAIN_H
+#define CALC_MAIN_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#undef CALCULATOR_DEBUG
+
+/*
+ * calc_debug functions
+ */
+#ifdef CALCULATOR_DEBUG
+#define calc_debug(...) g_debug(__VA_ARGS__)
+#else
+#define calc_debug(...)
+#endif
+
+#endif /* CALC_MAIN_H */


Property changes on: trunk/src/target/OM-2007/applications/openmoko-calculator/src/calc-main.h
___________________________________________________________________
Name: svn:eol-style
   + native





More information about the commitlog mailing list