From: Michael Cronenworth Date: Thu, 10 Dec 2009 01:30:07 +0000 (-0600) Subject: Use separate directories for data and source. X-Git-Tag: rel-0-9-0~3 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=33b937bc88719b46e83874ffe3d748033721ebb8;p=stopish Use separate directories for data and source. --- diff --git a/Makefile.am b/Makefile.am index 2b65655..e931b7e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,110 +4,12 @@ # 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 + debian/changelog \ + debian/compat \ + debian/copyright \ + debian/control \ + debian/rules -deb: - ./make-package $(PACKAGE) $(VERSION) +SUBDIRS = src data diff --git a/autogen.sh b/autogen.sh index d6b2ae6..cf956ac 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,7 @@ #!/bin/sh set -x -aclocal-1.7 -autoconf -libtoolize -automake-1.7 --add-missing --foreign +libtoolize --automake --copy --force +aclocal +autoconf --force +automake --add-missing --copy --force-missing --foreign diff --git a/com.nokia.stopish.service b/com.nokia.stopish.service deleted file mode 100644 index b27ca87..0000000 --- a/com.nokia.stopish.service +++ /dev/null @@ -1,4 +0,0 @@ -# Sample service description file -[D-BUS Service] -Name=com.nokia.stopish -Exec=/usr/bin/stopish diff --git a/configure.ac b/configure.ac index 709f174..7192714 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,21 @@ -AC_INIT(stopish, 1.0) -AC_CONFIG_SRCDIR(Makefile.am) -AM_INIT_AUTOMAKE +AC_INIT(Makefile.am) +AM_INIT_AUTOMAKE(stopish, 0.9) AC_PROG_CC AC_PROG_INSTALL AC_PROG_LIBTOOL +# Option to enable debugging +AC_ARG_ENABLE(debug, + [AC_HELP_STRING([ --enable-debug],[Debugging (default=no)])], + [with_debug=yes], [with_debug=no]) + +if test "x$with_debug" == "xyes" ; then + CFLAGS="$CFLAGS -ggdb -O0 -DDEBUG -Wall " +else + CFLAGS="$CFLAGS -O2 -Wall " +fi + PKG_CHECK_MODULES(GTK, gtk+-2.0) AC_SUBST(GTK_LIBS) AC_SUBST(GTK_CFLAGS) @@ -18,4 +28,19 @@ PKG_CHECK_MODULES(DESKTOP, libhildondesktop-1) AC_SUBST(DESKTOP_LIBS) AC_SUBST(DESKTOP_CFLAGS) -AC_OUTPUT([ Makefile]) +# Application icon install directories +icon_16x16dir=$datadir/icons/hicolor/16x16/hildon +icon_26x26dir=$datadir/icons/hicolor/26x26/hildon +icon_40x40dir=$datadir/icons/hicolor/40x40/hildon +icon_scalabledir=$datadir/icons/hicolor/scalable/hildon +AC_SUBST(icon_16x16dir) +AC_SUBST(icon_26x26dir) +AC_SUBST(icon_40x40dir) +AC_SUBST(icon_scalabledir) + +# Produce output files +AC_OUTPUT( + Makefile \ + src/Makefile \ + data/Makefile +) diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..7d7b586 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,25 @@ +# +# This file is part of stopish +# +# Copyright 2009 Michael Cronenworth +# + +# The icons + +icondir = $(datadir)/icons/hicolor + +icon_16x16_DATA = icons/16x16/stopish.png +icon_26x26_DATA = icons/26x26/stopish.png +icon_40x40_DATA = icons/40x40/stopish.png +icon_scalable_DATA = icons/scalable/stopish.png + +# The data files + +desktopdir = $(datadir)/applications/hildon +desktop_DATA = stopish.desktop + +servicedir = $(datadir)/dbus-1/services +service_DATA = com.nokia.stopish.service + +EXTRA_DIST = $(service_DATA) $(desktop_DATA) \ + $(icon_16x16_DATA) $(icon_26x26_DATA) $(icon_40x40_DATA) $(icon_scalable_DATA) diff --git a/data/com.nokia.stopish.service b/data/com.nokia.stopish.service new file mode 100644 index 0000000..b27ca87 --- /dev/null +++ b/data/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/data/icons/16x16/stopish.png b/data/icons/16x16/stopish.png new file mode 100644 index 0000000..de47095 Binary files /dev/null and b/data/icons/16x16/stopish.png differ diff --git a/data/icons/26x26/stopish.png b/data/icons/26x26/stopish.png new file mode 100644 index 0000000..777f652 Binary files /dev/null and b/data/icons/26x26/stopish.png differ diff --git a/data/icons/40x40/stopish.png b/data/icons/40x40/stopish.png new file mode 100644 index 0000000..1a69bd6 Binary files /dev/null and b/data/icons/40x40/stopish.png differ diff --git a/data/icons/scalable/stopish.png b/data/icons/scalable/stopish.png new file mode 100644 index 0000000..9efc044 Binary files /dev/null and b/data/icons/scalable/stopish.png differ diff --git a/data/stopish.desktop b/data/stopish.desktop new file mode 100644 index 0000000..85fa1b7 --- /dev/null +++ b/data/stopish.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=0.9 +Type=Application +Name=Stopish +Exec=/usr/bin/stopish +Icon=stopish +X-Window-Icon=stopish +X-Window-Icon-Dimmed=stopish +X-Osso-Service=com.nokia.stopish +X-Osso-Type=application/x-executable diff --git a/data/stopwatch_shading_hi.png b/data/stopwatch_shading_hi.png new file mode 100644 index 0000000..b8b5a26 Binary files /dev/null and b/data/stopwatch_shading_hi.png differ diff --git a/debian/changelog b/debian/changelog index edfd004..e712a1d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,5 @@ -stopish (1.0) unstable; urgency=low +stopish (0.9) unstable; urgency=low * Initial Release. - -- Michael Cronenworth Tue, 08 Dec 2000 22:48:40 -0600 - + -- Michael Cronenworth Tue, 09 Dec 2000 18:53:10 -0600 diff --git a/debian/compat b/debian/compat index b8626c4..7ed6ff8 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -4 +5 diff --git a/debian/control b/debian/control index 5c9d17f..cc084ea 100644 --- a/debian/control +++ b/debian/control @@ -6,21 +6,15 @@ Build-Depends: debhelper (>= 4.0.0), libgtk2.0-dev, libosso-dev (>= 1), libhildo Standards-Version: 3.7.2 Package: stopish +Section: user/office 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= + +Package: stopish-dbg +Section: user/office +Architecture: any +Depends: stopish (= ${Source-Version}) +Description: A stopwatch when you need to keep track of the length of + an important event. This package contains debug symbols. diff --git a/debian/copyright b/debian/copyright index 56a4660..5f715f4 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,14 +1,8 @@ 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: + This software is licensed under the GPLv3 license. + You should have received a copy of the GNU General Public License + along with this program. If not, see . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. diff --git a/debian/stopish.install b/debian/stopish.install index aab0749..fc78353 100644 --- a/debian/stopish.install +++ b/debian/stopish.install @@ -1,2 +1,2 @@ usr/bin/stopish -usr/share/applications/hildon-home +usr/share/* diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..9d7cd3d --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,14 @@ +# +# This file is part of stopish +# +# Copyright 2009 Michael Cronenworth +# + +# The program + +bin_PROGRAMS = stopish + +stopish_SOURCES = stopish.c + +stopish_CFLAGS = $(GTK_CFLAGS) $(OSSO_CFLAGS) +stopish_LDADD = $(GTK_LIBS) $(OSSO_LIBS) $(DESKTOP_LIBS) diff --git a/src/stopish.c b/src/stopish.c new file mode 100644 index 0000000..c1fd229 --- /dev/null +++ b/src/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.16.png b/stopish.16.png deleted file mode 100644 index de47095..0000000 Binary files a/stopish.16.png and /dev/null differ diff --git a/stopish.26.png b/stopish.26.png deleted file mode 100644 index 777f652..0000000 Binary files a/stopish.26.png and /dev/null differ diff --git a/stopish.40.png b/stopish.40.png deleted file mode 100644 index 1a69bd6..0000000 Binary files a/stopish.40.png and /dev/null differ diff --git a/stopish.64.png b/stopish.64.png deleted file mode 100644 index 9efc044..0000000 Binary files a/stopish.64.png and /dev/null differ diff --git a/stopish.c b/stopish.c deleted file mode 100644 index c1fd229..0000000 --- a/stopish.c +++ /dev/null @@ -1,208 +0,0 @@ -// 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 deleted file mode 100644 index a6602fb..0000000 --- a/stopish.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[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 deleted file mode 100644 index b8b5a26..0000000 Binary files a/stopwatch_shading_hi.png and /dev/null differ