From: Michael Cronenworth Date: Wed, 9 Dec 2009 07:04:08 +0000 (-0600) Subject: Initial commit. X-Git-Tag: rel-0-9-0~4 X-Git-Url: http://vcs.maemo.org/git/?p=stopish;a=commitdiff_plain;h=3bb16a033558cb0f642f206597f4af8fd6a71a94 Initial commit. --- 3bb16a033558cb0f642f206597f4af8fd6a71a94 diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..2b65655 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,113 @@ +# +# This file is part of stopish +# +# Copyright 2009 Michael Cronenworth +# + +# The icons + +icondir = $(datadir)/icons/hicolor + +install-data-local: + i=stopish; \ + $(mkinstalldirs) $(DESTDIR)$(icondir)/16x16/hildon; \ + $(mkinstalldirs) $(DESTDIR)$(icondir)/26x26/hildon; \ + $(mkinstalldirs) $(DESTDIR)$(icondir)/40x40/hildon; \ + $(mkinstalldirs) $(DESTDIR)$(icondir)/scalable/hildon; \ + $(INSTALL_DATA) $(srcdir)/$$i.16.png $(DESTDIR)$(icondir)/16x16/hildon/$$i.png; \ + $(INSTALL_DATA) $(srcdir)/$$i.26.png $(DESTDIR)$(icondir)/26x26/hildon/$$i.png; \ + $(INSTALL_DATA) $(srcdir)/$$i.40.png $(DESTDIR)$(icondir)/40x40/hildon/$$i.png; \ + $(INSTALL_DATA) $(srcdir)/$$i.64.png $(DESTDIR)$(icondir)/scalable/hildon/$$i.png; + +uninstall-local: + i=stopish; \ + rm $(DESTDIR)$(icondir)/16x16/hildon/$$i.png; \ + rm $(DESTDIR)$(icondir)/26x26/hildon/$$i.png; \ + rm $(DESTDIR)$(icondir)/40x40/hildon/$$i.png; \ + rm $(DESTDIR)$(icondir)/scalable/hildon/$$i.png; + +# The program + +bin_PROGRAMS = stopish + +stopish_SOURCES = stopish.c + +stopish_CFLAGS = $(GTK_CFLAGS) $(OSSO_CFLAGS) +stopish_LDADD = $(GTK_LIBS) $(OSSO_LIBS) $(DESKTOP_LIBS) + +desktopdir = $(datadir)/applications/hildon +desktop_DATA = stopish.desktop + +servicedir = $(datadir)/dbus-1/services +service_DATA = com.nokia.stopish.service + +# The shared library + +#lib_LTLIBRARIES = libhelloworld.la + +#include_HEADERS = libhelloworld.h + +#libhelloworld_la_SOURCES = libhelloworld.c \ + #libhelloworld.h +#libhelloworld_la_CFLAGS = $(GTK_CFLAGS) +#libhelloworld_la_LIBADD = $(GTK_LIBS) + +# The control panel applet + +#libcpdir = $(libdir)/hildon-control-panel +#libcp_LTLIBRARIES = libhelloworld-cp.la + +#libhelloworld_cp_la_SOURCES = hello-world-applet.c +#libhelloworld_cp_la_CFLAGS = $(GTK_CFLAGS) $(OSSO_CFLAGS) +#libhelloworld_cp_la_LDFLAGS = -module -avoid-version +#libhelloworld_cp_la_LIBADD = $(GTK_LIBS) libhelloworld.la + +#controlpaneldir = $(datadir)/applications/hildon-control-panel +#controlpanel_DATA = hello-world-cp.desktop + +# The status menu plugin + +#libsmdir = `pkg-config libhildondesktop-1 --variable=hildondesktoplibdir` +#libsm_LTLIBRARIES = libhelloworld-sm.la +#datsmdir = `pkg-config libhildondesktop-1 --variable=hildonstatusmenudesktopentrydir` +#datsm_DATA = hello-world-sm.desktop + +#libhelloworld_sm_la_SOURCES = hello-world-statusmenu.c +#libhelloworld_sm_la_CFLAGS = $(GTK_CFLAGS) $(OSSO_CFLAGS) $(DESKTOP_CFLAGS) +#libhelloworld_sm_la_LDFLAGS = -module -avoid-version +#libhelloworld_sm_la_LIBADD = libhelloworld.la $(GTK_LIBS) + +# The Home plugin + +#libhhdir = `pkg-config osso-af-settings --variable=hildondesktoplibdir` +#dathhdir = $(datadir)/applications/hildon-home +#libhh_LTLIBRARIES = libhelloworld-home.la +#dathh_DATA = stopish.desktop + +#libhelloworld_home_la_SOURCES = hello-world-home.c +#libhelloworld_home_la_CFLAGS = $(GTK_CFLAGS) $(OSSO_CFLAGS) $(DESKTOP_CFLAGS) +#libhelloworld_home_la_LDFLAGS = -module -avoid-version +#libhelloworld_home_la_LIBADD = $(GTK_LIBS) libhelloworld.la + +# The locale + +# The gstreamer plugin + +# The backup/restore configuration + +EXTRA_DIST = \ + autogen.sh \ + make-package \ + debian/changelog \ + debian/compat \ + debian/copyright \ + debian/control \ + debian/rules \ + stopish.desktop \ + com.nokia.stopish.service \ + stopish.26.png \ + stopish.40.png \ + stopish.64.png + +deb: + ./make-package $(PACKAGE) $(VERSION) diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..d6b2ae6 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -x +aclocal-1.7 +autoconf +libtoolize +automake-1.7 --add-missing --foreign diff --git a/com.nokia.stopish.service b/com.nokia.stopish.service new file mode 100644 index 0000000..b27ca87 --- /dev/null +++ b/com.nokia.stopish.service @@ -0,0 +1,4 @@ +# Sample service description file +[D-BUS Service] +Name=com.nokia.stopish +Exec=/usr/bin/stopish diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..709f174 --- /dev/null +++ b/configure.ac @@ -0,0 +1,21 @@ +AC_INIT(stopish, 1.0) +AC_CONFIG_SRCDIR(Makefile.am) +AM_INIT_AUTOMAKE + +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_LIBTOOL + +PKG_CHECK_MODULES(GTK, gtk+-2.0) +AC_SUBST(GTK_LIBS) +AC_SUBST(GTK_CFLAGS) + +PKG_CHECK_MODULES(OSSO, libosso >= 1) +AC_SUBST(OSSO_LIBS) +AC_SUBST(OSSO_CFLAGS) + +PKG_CHECK_MODULES(DESKTOP, libhildondesktop-1) +AC_SUBST(DESKTOP_LIBS) +AC_SUBST(DESKTOP_CFLAGS) + +AC_OUTPUT([ Makefile]) diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..edfd004 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +stopish (1.0) unstable; urgency=low + + * Initial Release. + + -- Michael Cronenworth Tue, 08 Dec 2000 22:48:40 -0600 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..5c9d17f --- /dev/null +++ b/debian/control @@ -0,0 +1,26 @@ +Source: stopish +Section: misc +Priority: optional +Maintainer: Michael Cronenworth +Build-Depends: debhelper (>= 4.0.0), libgtk2.0-dev, libosso-dev (>= 1), libhildondesktop1-dev, hildon-control-panel-dev, osso-af-settings +Standards-Version: 3.7.2 + +Package: stopish +Architecture: any +Depends: ${shlibs:Depends}, hildon-desktop, libgtk2.0-bin +Description: A stopwatch when you need to keep track of the length of + an important event. +XB-Maemo-Icon-26: + iVBORw0KGgoAAAANSUhEUgAAABoAAAAZCAAAAAAKtWG8AAAACXBIWXMAAAAnAAAAJwEqCZFP + AAAAB3RJTUUH1QkMEgEBuF+MPAAAACF0RVh0Q29tbWVudABKUEVHOmdudS1oZWFkLmpwZyAy + NzZ4MjYxjzmxCgAAAi9JREFUKM9dkd9LU2Ecxp/37HU/nFub02Zty9K0lc5FYWJBUCBeRD+o + y6j/IoIuoj8hgi6DgqAroSAk+gWSIuZVTU1nuDM3tzl1O3PNc3a29/12cSyoy+/zfD+fm4cR + QJWdPXgiCgMAECNVF72t4ICZmEmxmn9ooN8FAEV1gnmr/VeCHDKd9USHlIAecAIAfPJmM5l5 + br/NkdS16KAHtFdccndTLuAcBaKmVslxMkoIeUAFdT4hr00IfvUGR8fxjU2dw1VK3AG0z4/V + qjI59j05R7cUHHLYHVyW01GC+fFhPayFR/p6JlefHLyI5fnrLVzhzfxi+MW7B+N29Wx2mr9f + y73O19+E3G1MzmZeenxLr7rW3sYHybbz6XLft6ep0PDwOdujtt3Dxer9ASbj+pTdF04mzwRT + sfOdo5zDf5L7XBcA+BfVES/8P0zn+NbRkA0govzSHBElhDR0SXJ6VYpsk4gYAagXurH9q8sJ + kXKFChm30XTEAQ4AxUhjVcQkseV68Eu8UzutAAAjwFgo1S+VI6i0VtX0GHnyXre1AVFj29gS + X4nkuiYqZTH1QRIRkQKABxyK0l4mFt5gXl+hEbOG4wAAGDi2IjpYx2xEW8mdsjIQERGtCVrf + kCTMjCnTlo8U6yFUQLi+1RA/n92dYZYPjCy2xPy1vcIJRdUHbPu+fYq110w3p6JN7hL+rcC6 + WhiOqMmFXuP/Ci0KuMuZLd2b/5OwvzwAamrlWs+B/es340gXFARK7DMAAAAASUVORK5CYII= diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..56a4660 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,22 @@ +Copyright (C) 2009 Michael Cronenworth + +This maemo code example is licensed under a following MIT-style license. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..61bad97 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,3 @@ +#! /bin/sh + +gtk-update-icon-cache -f /usr/share/icons/hicolor diff --git a/debian/rules b/debian/rules new file mode 100644 index 0000000..c63f373 --- /dev/null +++ b/debian/rules @@ -0,0 +1,95 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +configure: configure-stamp +configure-stamp: + test -e ./configure || ./autogen.sh + dh_testdir + # Add here commands to configure the package. + CFLAGS="$(CFLAGS)" ./configure --prefix=/usr --disable-static + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) distclean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package + $(MAKE) install DESTDIR=$(CURDIR)/debian/stopish + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs +# dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo +# dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_python + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/debian/stopish.install b/debian/stopish.install new file mode 100644 index 0000000..aab0749 --- /dev/null +++ b/debian/stopish.install @@ -0,0 +1,2 @@ +usr/bin/stopish +usr/share/applications/hildon-home diff --git a/stopish.16.png b/stopish.16.png new file mode 100644 index 0000000..de47095 Binary files /dev/null and b/stopish.16.png differ diff --git a/stopish.26.png b/stopish.26.png new file mode 100644 index 0000000..777f652 Binary files /dev/null and b/stopish.26.png differ diff --git a/stopish.40.png b/stopish.40.png new file mode 100644 index 0000000..1a69bd6 Binary files /dev/null and b/stopish.40.png differ diff --git a/stopish.64.png b/stopish.64.png new file mode 100644 index 0000000..9efc044 Binary files /dev/null and b/stopish.64.png differ diff --git a/stopish.c b/stopish.c new file mode 100644 index 0000000..c1fd229 --- /dev/null +++ b/stopish.c @@ -0,0 +1,208 @@ +// stopish.c +// +// Copyright 2009 Michael Cronenworth +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +// MA 02110-1301, USA. + + +#include +#include +#include + +#include +#include + +static GtkWidget *timerLabel = NULL; +static int stopishMode = 0; // 0 = Start, 1 = Stop +static int timerHandle = -1; +static int timerStartTime = 0; +static int timeTicks = 0; + +//Prototypes +gint dbus_callback( const gchar *interface, const gchar *method, + GArray *arguments, gpointer data, osso_rpc_t *retval ); +GtkWindow *stopish_new( void ); +static void start_cb( GtkButton* button, gpointer data ); +static void close_cb( GtkButton* button, gpointer data ); +static gint timeout_cb( gpointer data ); +static int current_time( void ); + + +int main( int argc, char *argv[] ) +{ + osso_context_t *ctxt; + osso_return_t ret; + GtkWindow *window; + + //printf( "stopish: starting up\n" ); + + ctxt = osso_initialize( "com.nokia.stopish", PACKAGE_VERSION, TRUE, NULL ); + if ( ctxt == NULL ) { + fprintf( stderr, "osso_initialize failed.\n" ); + exit( 1 ); + } + + gtk_init( &argc, &argv ); + + window = stopish_new( ); + + ret = osso_rpc_set_default_cb_f( ctxt, dbus_callback, window ); + if ( ret != OSSO_OK ) { + fprintf( stderr, "osso_rpc_set_default_cb_f failed: %d.\n", ret ); + exit( 1 ); + } + + gtk_main( ); + + return 0; +} + + +gint dbus_callback( const gchar *interface, const gchar *method, + GArray *arguments, gpointer data, osso_rpc_t *retval ) +{ + //printf( "stopish dbus: %s, %s\n", interface, method ); + + if ( !strcmp( method, "top_application" ) ) + gtk_window_present( GTK_WINDOW( data ) ); + + retval->type = DBUS_TYPE_INVALID; + + return OSSO_OK; +} + + +GtkWindow *stopish_new( void ) +{ + GtkWidget *window, *hBox, *label, *button; + GtkWidget *vBox, *vBox0; + + window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); + + gtk_container_set_border_width( GTK_CONTAINER( window ), 20 ); + + gtk_window_set_title( GTK_WINDOW( window ), "Stopish" ); + + g_signal_connect( G_OBJECT( window ), "destroy", + G_CALLBACK( close_cb ), window ); + + vBox = gtk_vbox_new( FALSE, 10 ); + + label = gtk_label_new( "Stopish - The Stopwatch" ); + gtk_box_pack_start( GTK_BOX( vBox ), label, FALSE, FALSE, 0 ); + + hBox = gtk_hbox_new( FALSE, 10 ); + + // stop watch area + timerLabel = gtk_label_new( NULL ); + gtk_label_set_markup( GTK_LABEL( timerLabel ), "00:00:00.0" ); + gtk_container_add( GTK_CONTAINER( hBox ), timerLabel ); + + // button area + vBox0 = gtk_vbox_new( FALSE, 10 ); + + // close button + button = gtk_button_new( ); + label = gtk_label_new( "Start" ); + gtk_container_add( GTK_CONTAINER( button ), label ); + g_signal_connect( G_OBJECT( button ), "clicked", + G_CALLBACK( start_cb ), label ); + gtk_box_pack_start( GTK_BOX( vBox0 ), button, FALSE, FALSE, 0 ); + + // start stopwatch button + button = gtk_button_new_with_label( "Close" ); + g_signal_connect( G_OBJECT( button ), "clicked", + G_CALLBACK( close_cb ), window ); + gtk_box_pack_start( GTK_BOX( vBox0 ), button, FALSE, FALSE, 0 ); + + gtk_container_add( GTK_CONTAINER( hBox ), vBox0 ); + + gtk_container_add( GTK_CONTAINER( vBox ), hBox ); + + gtk_container_add( GTK_CONTAINER( window ), vBox ); + + gtk_widget_show_all( window ); + + return GTK_WINDOW( window ); +} + + +static void start_cb( GtkButton* button, gpointer data ) +{ + if ( stopishMode == 0 ) { + // set label text and add timer handle + gtk_label_set_text( GTK_LABEL( data ), "Stop" ); + stopishMode = 1; + timerHandle = g_timeout_add( 100, timeout_cb, NULL ); + timerStartTime = current_time( ) - timeTicks; + } + else { + // set label text and remove timer handle + gtk_label_set_text( GTK_LABEL( data ), "Start" ); + stopishMode = 0; + timerStartTime = 0; + timeTicks = 0; + gtk_label_set_markup( GTK_LABEL( timerLabel ), + "00:00:00.0" ); + g_source_remove( timerHandle ); + } +} + + +static void close_cb( GtkButton* button, gpointer data ) +{ + // destroy main window and exit gtk main loop + gtk_widget_destroy( GTK_WIDGET( data ) ); + gtk_main_quit( ); +} + + +static gint timeout_cb( gpointer data ) +{ + static char timeBuffer[64]; + int h, m, s, ss, currentTime; + + // get current time + currentTime = current_time( ); + + // calculate time format + timeTicks = ( currentTime - timerStartTime ); + ss = timeTicks % 10; + s = timeTicks / 10; + m = s / 60; + s = s % 60; + h = m / 60; + m = m % 60; + + // print to screen + sprintf( timeBuffer, "%.02d:%.02d:%.02d.%.1d", h, m, s, ss); + gtk_label_set_markup( GTK_LABEL( timerLabel ), timeBuffer ); + + return TRUE; +} + + +static int current_time( void ) +{ + struct timeval tv; + int s, us; + + gettimeofday( &tv, NULL ); + s = tv.tv_sec % 100000; + us = tv.tv_usec / 100000; + + return ( s * 10 + us ); +} diff --git a/stopish.desktop b/stopish.desktop new file mode 100644 index 0000000..a6602fb --- /dev/null +++ b/stopish.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Name=Stopish +Exec=/usr/bin/stopish +Icon=stopish +X-Window-Icon=tn-bookmarks-link +X-HildonDesk-ShowInToolbar=true +X-Osso-Service=com.nokia.stopish +X-Osso-Type=application/x-executable +Terminal=false diff --git a/stopwatch_shading_hi.png b/stopwatch_shading_hi.png new file mode 100644 index 0000000..b8b5a26 Binary files /dev/null and b/stopwatch_shading_hi.png differ