From 3e6a8fc7afe096e2f06424a314cc07c044a862e3 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Tue, 28 May 2013 22:23:05 -0400 Subject: [PATCH] Version 1.0.0 with cairo anti-alias --- ChangeLog | 5 +- Makefile.am | 2 - NEWS | 6 +- config/acx_pthread.m4 | 226 ----------------- configure.ac | 22 +- doc/hvclock.man | 19 +- pixmaps/hvclock.xpm | 213 ---------------- pixmaps/wmaker-tile-60x60.xpm | 137 ++++++++++ src/Makefile.am | 25 +- src/calendar.c | 177 ------------- src/calendar.h | 27 -- src/clock.c | 461 +++++++++++++++++++++++++++++----- src/clock.h | 5 +- src/common.h | 9 +- src/dockapp.c | 294 +++------------------- src/dockapp.h | 28 +-- src/hvclock.c | 140 +---------- src/hvclock.h | 1 + src/options.c | 33 +-- src/xevents.c | 137 ---------- src/xevents.h | 31 --- 21 files changed, 640 insertions(+), 1358 deletions(-) delete mode 100644 config/acx_pthread.m4 delete mode 100644 pixmaps/hvclock.xpm create mode 100644 pixmaps/wmaker-tile-60x60.xpm delete mode 100644 src/calendar.c delete mode 100644 src/calendar.h delete mode 100644 src/xevents.c delete mode 100644 src/xevents.h diff --git a/ChangeLog b/ChangeLog index 41699b8..d5c744f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ +2009-12-20 Hugo Villeneuve + * Anti-aliased clock using Cairo + 2009-11-20 Hugo Villeneuve * Indentation as per Linux Kernel Coding Style * Added GPL header to all source files @@ -8,6 +11,6 @@ 2006-08-22 Hugo Villeneuve * Removed unnecessary calls to gdk-pixbuf functions and dropped any gdk-pixbuf dependencies. - + 2005-04-12 Hugo Villeneuve * Added project to subversion diff --git a/Makefile.am b/Makefile.am index ba93f8f..82b402c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,6 @@ SUBDIRS = src doc ## we want these in the dist tarball EXTRA_DIST = autogen.sh \ - $(ac_aux_dir)/acx_pthread.m4 \ pixmaps ACLOCAL = aclocal -I $(ac_aux_dir) @@ -20,4 +19,3 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config-h.in \ $(ac_aux_dir)/install-sh $(ac_aux_dir)/missing \ $(ac_aux_dir)/mkinstalldirs $(ac_aux_dir)/config.guess \ $(ac_aux_dir)/config.sub $(ac_aux_dir)/ltmain.sh - diff --git a/NEWS b/NEWS index d9d6134..307d581 100644 --- a/NEWS +++ b/NEWS @@ -1,10 +1,10 @@ -2009-11-20: hvclock-1.0.0 has been released. +2009-12-20: hvclock-1.0.0 has been released. Cleanup of code and added seconds hand as runtime option. + Anti-aliased clock using cairo. 2006-08-22: hvclock-0.2.0 has been released. Removed gdk-pixbuf stuff. 2005-07-05: hvclock-0.1.0 has been released. - This is the initial release - + This is the initial release. diff --git a/config/acx_pthread.m4 b/config/acx_pthread.m4 deleted file mode 100644 index b3c966b..0000000 --- a/config/acx_pthread.m4 +++ /dev/null @@ -1,226 +0,0 @@ -dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -dnl -dnl This macro figures out how to build C programs using POSIX -dnl threads. It sets the PTHREAD_LIBS output variable to the threads -dnl library and linker flags, and the PTHREAD_CFLAGS output variable -dnl to any special C compiler flags that are needed. (The user can also -dnl force certain compiler flags/libs to be tested by setting these -dnl environment variables.) -dnl -dnl Also sets PTHREAD_CC to any special C compiler that is needed for -dnl multi-threaded programs (defaults to the value of CC otherwise). -dnl (This is necessary on AIX to use the special cc_r compiler alias.) -dnl -dnl If you are only building threads programs, you may wish to -dnl use these variables in your default LIBS, CFLAGS, and CC: -dnl -dnl LIBS="$PTHREAD_LIBS $LIBS" -dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -dnl CC="$PTHREAD_CC" -dnl -dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute -dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE -dnl to that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -dnl -dnl ACTION-IF-FOUND is a list of shell commands to run if a threads -dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands -dnl to run it if it is not found. If ACTION-IF-FOUND is not specified, -dnl the default action will define HAVE_PTHREAD. -dnl -dnl Please let the authors know if this macro fails on any platform, -dnl or if you have any other suggestions or comments. This macro was -dnl based on work by SGJ on autoconf scripts for FFTW (www.fftw.org) -dnl (with help from M. Frigo), as well as ac_pthread and hb_pthread -dnl macros posted by AFC to the autoconf macro repository. We are also -dnl grateful for the helpful feedback of numerous users. -dnl -dnl @version $Id: acx_pthread.m4,v 1.3 2002/12/12 23:15 ac-archive-0.5.39 $ -dnl @author Steven G. Johnson and Alejandro Forero Cuervo - -AC_DEFUN([ACX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_SAVE -AC_LANG_C -acx_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) - AC_MSG_RESULT($acx_pthread_ok) - if test x"$acx_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all. - -acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# pthread: Linux, etcetera -# --thread-safe: KAI C++ - -case "${host_cpu}-${host_os}" in - *solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthread or - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" - ;; -esac - -if test x"$acx_pthread_ok" = xno; then -for flag in $acx_pthread_flags; do - - case $flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $flag]) - PTHREAD_CFLAGS="$flag" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$flag]) - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], - [acx_pthread_ok=yes]) - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - AC_MSG_RESULT($acx_pthread_ok) - if test "x$acx_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$acx_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Detect AIX lossage: threads are created detached by default - # and the JOINABLE attribute has a nonstandard name (UNDETACHED). - AC_MSG_CHECKING([for joinable pthread attribute]) - AC_TRY_LINK([#include ], - [int attr=PTHREAD_CREATE_JOINABLE;], - ok=PTHREAD_CREATE_JOINABLE, ok=unknown) - if test x"$ok" = xunknown; then - AC_TRY_LINK([#include ], - [int attr=PTHREAD_CREATE_UNDETACHED;], - ok=PTHREAD_CREATE_UNDETACHED, ok=unknown) - fi - if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then - AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok, - [Define to the necessary symbol if this constant - uses a non-standard name on your system.]) - fi - AC_MSG_RESULT(${ok}) - if test x"$ok" = xunknown; then - AC_MSG_WARN([we do not know how to create joinable pthreads]) - fi - - AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no - case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; - esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - # More AIX lossage: must compile with cc_r - AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) -else - PTHREAD_CC="$CC" -fi - -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_CC) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$acx_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) - : -else - acx_pthread_ok=no - $2 -fi -AC_LANG_RESTORE -])dnl ACX_PTHREAD diff --git a/configure.ac b/configure.ac index 6ff6abc..b28ebc6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,12 +1,13 @@ # configure.ac -- Process this file with autoconf to produce configure. dnl Initialization stuff. -AC_INIT(hvclock, 0.2.0) +AC_INIT(hvclock, 1.0.0) AC_CONFIG_AUX_DIR(config) AC_CONFIG_SRCDIR(src/hvclock.c) AM_CONFIG_HEADER(config.h:config-h.in) dnl Checking if the NEWS file has been updated to reflect the current version. AM_INIT_AUTOMAKE(check-news) +AM_SILENT_RULES([yes]) dnl Testing the C compiler. AC_PROG_CC @@ -26,11 +27,6 @@ AC_TYPE_SIZE_T dnl Basic CFLAGS values CFLAGS="${CFLAGS} -Wall" -dnl Checking for POSIX threads library. -ACX_PTHREAD(CC="${PTHREAD_CC}" CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}" dnl - LIBS="${PTHREAD_LIBS} ${LIBS}", dnl - echo "Can't find POSIX threads library"; exit 1 ) - dnl Trying to locate the X window system's includes and libraries, and sets the dnl variables x_includes and x_libraries to their locations. Also adds the dnl required include flags to X_CFLAGS and required linking flags to X_LIBS. @@ -42,16 +38,10 @@ dnl Checking for X11 library. AC_CHECK_LIB(X11, XOpenDisplay, LIBS="${LIBS} -lX11", echo "Can't find X11 library" ; exit 1, "${X_LIBS}") -dnl Checking for Xpm library and headers. -AC_CHECK_HEADERS(X11/xpm.h, ,echo "Can't find header file for library Xpm" ; exit 1) -AC_CHECK_LIB(Xpm, XpmCreatePixmapFromXpmImage, LIBS="${LIBS} -lXpm", - echo "Can't find Xpm library" ; exit 1, "${X_LIBS}") - -dnl Checking for Xext library and headers. -AC_CHECK_HEADERS(X11/extensions/shape.h, , -echo "Can't find header file for library Xext" ; exit 1) -AC_CHECK_LIB(Xext, XShapeCombineMask, LIBS="${LIBS} -lXext", - echo "Can't find Xext library" ; exit 1, "${X_LIBS}") +dnl Checks for Gtk+-2.0 +PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.8, CFLAGS="${CFLAGS} -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED") +AC_SUBST(GTK_CFLAGS) +AC_SUBST(GTK_LIBS) AC_CHECK_HEADERS(math.h, ,dnl echo "Can't find header file for math library" ; exit 1) diff --git a/doc/hvclock.man b/doc/hvclock.man index b8d7842..829e9d0 100644 --- a/doc/hvclock.man +++ b/doc/hvclock.man @@ -1,4 +1,4 @@ -.TH HVCLOCK 1 "April 2005" "hvclock" "User's Manual" +.TH HVCLOCK 1 "December 2009" "hvclock" "User's Manual" .SH NAME hvclock \- Dockable analog clock and calendar @@ -8,7 +8,7 @@ hvclock \- Dockable analog clock and calendar [\fIOPTION\fR]... .SH DESCRIPTION -\fBhvclock\fR is a dockable analog clock and calendar application (DockApps) +\fBhvclock\fR is a dockable analog clock and calendar application (dockapp) for the WindowMaker window manager. The interface is kept very simple. To switch between calendar view and @@ -18,22 +18,31 @@ clock view, single-click on the clock or calendar image. .TP \fB\-d\fR -Display debugging messages. +display debugging messages. .TP .BI \-display " host" : display -Specifies the host and screen to be used by \fBhvclock\fR. By default this +specifies the host and screen to be used by \fBhvclock\fR. By default this is obtained from the environment variable .SB DISPLAY. .TP .BI \-geometry " geometry" .RB ( *geometry ) -Specifies the initial geometry of the window. +specifies the initial geometry of the window. .TP \fB\-h\fR display usage and exit + +.TP +\fB\-n\fR +disable dockapp mode + +.TP +\fB\-s\fR +display seconds hand + .TP \fB\-v\fR output version information and exit diff --git a/pixmaps/hvclock.xpm b/pixmaps/hvclock.xpm deleted file mode 100644 index 2f4fcd2..0000000 --- a/pixmaps/hvclock.xpm +++ /dev/null @@ -1,213 +0,0 @@ -/* XPM */ -static char * hvclock_xpm[] = { -"223 148 62 1", -" c None", -". c #EFEEB3", -"+ c #D4D39F", -"@ c #9F9E77", -"# c #BAB98B", -"$ c #4F4F3B", -"% c #1B1B14", -"& c #000000", -"* c #353528", -"= c #6A6A50", -"- c #A4A1B4", -"; c #9C9DB4", -"> c #A49DB4", -", c #9C9DAC", -"' c #9C99AC", -") c #9499A4", -"! c #9C95AC", -"~ c #9495A4", -"{ c #9491A4", -"] c #8B919C", -"^ c #948DA4", -"/ c #8B8D9C", -"( c #8B899C", -"_ c #838994", -": c #8B859C", -"< c #838594", -"[ c #838194", -"} c #7B818B", -"| c #7B7D8B", -"1 c #A49DAC", -"2 c #A499AC", -"3 c #9C91AC", -"4 c #837D94", -"5 c #9495AC", -"6 c #9C99A4", -"7 c #9C95A4", -"8 c #FFFFFF", -"9 c #7B798B", -"0 c #858463", -"a c #CCCCCC", -"b c #666666", -"c c #7F7F7F", -"d c #A499B4", -"e c #737983", -"f c #B2B2B2", -"g c #7B758B", -"h c #737583", -"i c #737183", -"j c #6A717B", -"k c #736D83", -"l c #6A6D7B", -"m c #626573", -"n c #626173", -"o c #5A616A", -"p c #62616A", -"q c #5A6173", -"r c #999999", -"s c #5A5D6A", -"t c #5A596A", -"u c #525D62", -"v c #525962", -"w c #525562", -" ...................................................... .................. ............ ", -" ....+@................................................ .....#$%&&*=+..... .......*&&&. ", -" ----;->;>,;',''')!'~!~~{~{{{]{^]^///(/((_(:_:<<<<[<[}[[|[||| ----;->;>,;',''')!'~!~~{~{{{]{^]^///(/((_(:_:<<<<[<[}[[|[||| ....@&................................................ ....$&&&&&&&%@.... ......@&&&&. ", -" --->-1,,,,2,''''!'~~~~3~{&&&&&&&&&&&/((((:_<<<:<[<[[[[|}||4| --->-1,,,,2,''''!'~~~~3~{&&&&&&&&&&&/((((:_<<<:<[<[[[[|}||4| ....@&..#@#..@+@#..@+.##..@@+.+@#@##..@+.............. ...=&&&&&&&&&&#... .....+%&&&&. ", -" -->-,;>,>',''''56~575&&&&&888888888&&&&&:_<:<:<[<[[}[|}4|4|9 -->-,;>,>',''''56~575&&&&&888888888&&&&&:_<:<:<[<[[}[|}4|4|9 ....@&.0%$&=.&%$&0.&@.$$.***&#@&*00%.#&+.............. ..+&&&&&&&&&&&*... ....@%&&&&&. ", -" ->-,>1,,',''''565!&&&&8888888aba8888888&&&&<-,>1,,',''''565!&&&&8888888aba8888888&&&&<,;,d,''''565&&&8888888888b&b8888888888&&&[<[}[[|[||4|9|9 ;-,>,;,d,''''565&&&8888888888b&b8888888888&&&[<[}[[|[||4|9|9 .00.@&.0%*%$.&@.$$.&@.$$.$&$&@@&...*0*0............... ..&&&&0....*&&&=.. .=%&&&&&&&&. ", -" -1;1;1',''''565&&888888888888aba888888888888&&[[[}|[||||9|99 -1;1;1',''''565&&888888888888aba888888888888&&[[[}|[||||9|99 .=%@$%.&0.*$.&@.$$.&0+%$@&++&@@&...@*&+............... .#&&&&+....0&&&%.. .&&&&&%&&&&. ", -" >,>,,',''''~'&&&88888888888888888888888888888&&&[|[||||9|99e >,>,,',''''~'&&&88888888888888888888888888888&&&[|[||||9|99e .+*&%@.=&%$*.&@.$$.0&%*$+*&**0@&....&$................ .@&&&&.....@&&&&.. .&&&&0@&&&&. ", -" ;,,,d,''''~'&&88aba888888888&8f&&f88888888aba88&&[||||9|99e9 ;,,,d,''''~'&&88aba888888888&8f&&f88888888aba88&&[||||9|99e9 ...................................+&@................ .=&&&$......&&&&#. .&&%#.@&&&&. ", -" >,>',''''~'&&888b&b88888888&&8&88&88888888b&b888&&|||9|99e9e >,>',''''~'&&888b&b88888888&&8&88&88888888b&b888&&|||9|99e9e ..................................@&$................. .$&&&$......&&&&@. .*0...@&&&&. ", -" ,,',''''~&&&8888ab8888888888&888&&88888888aba8888&&&9|9999eg ,,',''''~&&&8888ab8888888888&888&&88888888aba8888&&&9|9999eg ...................................................... .$&&&$......&&&&@. ......@&&&&. ", -" ;2,''''~'&88888888&88&888888&8f&f88888888&888888888&|999eege ;2,''''~'&88888888&88&888888&8f&f88888888&888888888&|999eege .+@@@@+......##....................................... .$&&&$......&&&&@. ......@&&&&. ", -" ',''''~'&&8888888&&8&&888888&8&888888888&&888888888&&99e9geh ',''''~'&&8888888&&8&&888888&8&888888888&&888888888&&99e9geh .@&&&&@......$$....................................... .$&&&$......&&&&@. ......@&&&&. ", -" ,''''5'&&888888888&88&888888&8&&&&8888888&8888888888&&e9hehh ,''''5'&&888888888&88&888888&8&&&&8888888&8888888888&&e9hehh .@&......@#..$$#@..##@###.+@..#@#..@#@#@..##.......... .$&&&$......&&&&@. ......@&&&&. ", -" ''''56&&8888888888&88&8888888888888888888&88888888888&&h9hgh ''''56&&8888888888&88&8888888888888888888&88888888888&&h9hgh .@&@@@.+%**$.$%*%%.$&$#$$.@&.0%$&=.&%$+&#.%0.......... .$&&&$......&&&&@. ......@&&&&. ", -" '''565&88888888888&88&8888888888888888888&888888888888&9chhh '''565&88888888888&88&8888888888888888888&888888888888&9chhh .@&&&&.=*@@&#$*.+&@$*..$$.@&.+++*$.&0..*0+&+.......... .@&&&%.....#&&&&.. ......@&&&&. ", -" ''565&&88888888888&88&8888888888888888888&888888888888&&hhhi ''565&&88888888888&88&8888888888888888888&888888888888&&hhhi .@&....$%$$$#$$..&@$$..$$.@&.0%*%$.&@..0*0*........... .@&&&&.....@&&&&.. ......@&&&&. ", -" )!65&&8aba88888888888888888888888888888888888888888aba8&&hih )!65&&8aba88888888888888888888888888888888888888888aba8&&hih .@&....0%++#.$%+@&+$$..$*.$&.&0.*$.&@...&*0........... ..&&&&@....$&&&$.. ......@&&&&. ", -" !'~!&88b&b88888888888888888888888888888888888888888b&b88&ihi !'~!&88b&b88888888888888888888888888888888888888888b&b88&ihi .@&.....=&&*+$*%&0.$$..#%&$&.=&%$*.&@...$&............ ..*&&&%+..@&&&&0.. ......@&&&&. ", -" '~5&&88ab8&8f&&f8888888888888888888888888888888f&&8aba88&&ij '~5&&88ab8&8f&&f8888888888888888888888888888888f&&8aba88&&ij ........................................*$............ ..0&&&&&$*&&&&%... ......@&&&&. ", -" ~~7&88888&&8&88&8888888888888888888888888888888&88&888888&ji ~~7&88888&&8&88&8888888888888888888888888888888&88&888888&ji .......................................&%+............ ...*&&&&&&&&&&0... ......@&&&&. ", -" !~5&888888&8&88&888888888888888888888888888888888&&888888&ij !~5&888888&8&88&888888888888888888888888888888888&&888888&ij ...................................................... ...+%&&&&&&&&$.... ......@&&&&. ", -" ~~&&888888&8&88&8888888888888888888888888888888f&f8888888&&k ~~&&888888&8&88&8888888888888888888888888888888f&f8888888&&k .+@@..#@#................##........................... .....=&&&&&%0..... ......@&&&&. ", -" ~3&8888888&8&88&8888888888888888888888888888888&8888888888&j ~3&8888888&8&88&8888888888888888888888888888888&8888888888&j .@&&..$&$................$$........................... .......#@@#....... ............ ", -" {~&8888888&8f&&f8888888888888888888888888888888&&&&8888888&l {~&8888888&8f&&f8888888888888888888888888888888&&&&8888888&l .@&*@.&*$..@@+.+@#@..@@..$$#@......................... .................. ............ ", -" ~{&8888888888888888888888888888888888888888888888888888888&l ~{&8888888888888888888888888888888888888888888888888888888&l .@&==#%$$.***&#@&*0+%**%+$%*%*........................ ", -" {&&8888888888888888888888888888888888888888888888888888888&& {&&8888888888888888888888888888888888888888888888888888888&& .@&#$@$$$.#.#&@@&+.=*..#.$*.@&........................ ................. ................. ", -" {&888888888888888888888888888888888888888888888888888888888& {&888888888888888888888888888888888888888888888888888888888& .@&.&$@$$.$&$&@@&..$$....$$.@&........................ ....+=*&&&*=+.... .....@$&&&*0..... ", -" {&888888888888888888888888888888888888888888888888888888888& {&888888888888888888888888888888888888888888888888888888888& .@&.$%.$$@&++&@@&..0%++=+$$.@&........................ ...0&&&&&&&&&@... ...+*&&&&&&&%+... ", -" ]&88888f&&f888888888888888888888888888888888888888&&&f88888& ]&88888f&&f88888888888888888ab&ba88888888888888888&&&f88888& .@&.0*.$$+*&**0@&...=&&=.$$.@&........................ ..0&&&&&&&&&&&@.. ...%&&&&&&&&&%+.. ", -" {&8aba8&88&888888888888888888888888888888888888888888&8aba8& {&8aba8&88&88888888888888888b&&&b88888888888888888888&8aba8& ...................................................... .+&&&&&&&&&&&&&+. ..0&&&&&&&&&&&*.. ", -" ^&8b&b8&88&8888888888888888888888888888888888888888&&&8b&b8& ^&8b&b8&88&88888888888888888&&&&&888888888888888888&&&8b&b8& ...................................................... .=&&&&$+.+$&&&&0. ..%&&&&@.+*&&&&+. ", -" ]&8aba8f&&&888888888888888888888888888888888888888888&8aba8& ]&8aba8f&&&88888888888888888b&&&b88888888888888888888&8aba8& ...................................................... .*&&&*.....%&&&$. .+&&&&0...+&&&&@. ", -" ^&88888888&888888888888888888888888888888888888888&88&88888& ^&88888888&88888888888888888ab&ba88888888888888888&88&88888& ...+@+............+@.##............................... .&&&&0.....$&&&$. .+0$$&.....&&&&@. ", -" /&88888c&&f888888888888888888888888888888888888888f&&f88888& /&88888c&&f888888888888888888888888888888888888888f&&f88888& ...*&$............#$.$$............................... ...+@+.....$&&&$. ..........+&&&&+. ", -" /&888888888888888888888888888888888888888888888888888888888& /&888888888888888888888888888888888888888888888888888888888& ..+&$&+.+@+@+.+@#@+@.$$............................... ...........&&&&@. ..........$&&&*.. ", -" /&&8888888888888888888888888888888888888888888888888888888&& /&&8888888888888888888888888888888888888888888888888888888&& ..0&.&0.@&**&+@&*0@&.$$............................... ..........0&&&&.. .......#$&&&&%+.. ", -" (/&8888888888888888888888888888888888888888888888888888888&m (/&8888888888888888888888888888888888888888888888888888888&m ..*$.=*.@&+.*=@&+.@&.$$............................... .........@&&&&=.. .......@&&&&*+... ", -" /(&8888888888888888888888888888888888888888888888888888888&m /(&8888888888888888888888888888888888888888888888888888888&m .+&&&&&+@&..$$@&..@&.$$............................... ........@&&&&%... .......=&&&&%=... ", -" ((&88888888f&&f888888888888888888888888888888888&&88888888&m ((&88888888f&&f888888888888888888888888888888888&&88888888&m .0%@@@%0@&@+%0@&..@&.$$............................... .......@&&&&&+... .......$$$&&&&%+. ", -" ((&&8888888&88&88888888888888888888888888888888&8&8888888&&m ((&&8888888&88&88888888888888888888888888888888&8&8888888&&m .*=...=*@&$&$.@&..@&.$$............................... ......@&&&&&@.... ..........+%&&&=. ", -" _(:&8888888&&&&8888888888888888888888888888888&88&8888888&mn _(:&8888888&&&&8888888888888888888888888888888&88&8888888&mn ........@&............................................ .....@&&&&%#..... ...........#&&&&+ ", -" (:_&8888888&88&8888888888888888888888888888888&&&&&888888&nm (:_&8888888&88&8888888888888888888888888888888&&&&&888888&nm ........@&............................................ ....@&&&&%+...... ............&&&&@ ", -" :_<&&88aba8&88&8888888888888888888888888888888888&8aba88&&mo :_<&&88aba8&88&8888888888888888888888888888888888&8aba88&&mo ...................................................... ...@&&&&%+....... .0$$%$......&&&&@ ", -" _<:<&88b&b8f&&f8888888888888888888888888888888888&8b&b88&mon _<:<&88b&b8f&&f8888888888888888888888888888888888&8b&b88&mon .+@@..#@#............................................. ..+%&&&%+........ .=&&&&+....@&&&&# ", -" :<<<&&8aba88888888888888888888888888888888888888888aba8&&ono :<<<&&8aba88888888888888888888888888888888888888888aba8&&ono .@&&..$&$............................................. ..*&&&&=@@@@@@@#. .#&&&&$...+%&&&&. ", -" <<:<[&&88888888888&&&&88888888888888888&&&&88888888888&&pnon <<:<[&&88888888888&&&&88888888888888888&&&&88888888888&&pnon .@&*@.&*$..@@+.##..@+................................. .#&&&&&&&&&&&&&$. ..*&&&&&$$&&&&&=. ", -" <:<[<[&88888888888&88&88888888888888888&88888888888888&pqono <:<[<[&88888888888&88&88888888888888888&88888888888888&pqono .@&==#%$$.***�%.#&+................................. .*&&&&&&&&&&&&&$. ..#&&&&&&&&&&&%.. ", -" <<[<[[&&888888888888&r88888888888888888&&&88888888888&&qpnos <<[<[[&&888888888888&r88888888888888888&&&88888888888&&qpnos .@&#$@$$$.#.#&@+&+0*.................................. .&&&&&&&&&&&&&&$. ...@&&&&&&&&&*+.. ", -" <[<[}[[&&8888888888r&8888888f&&c8888888888&888888888&&qpqoso <[<[}[[&&8888888888r&8888888f&&c8888888888&888888888&&qpqoso .@&.&$@$$.$&$&@.*0*0.................................. @&&&&&&&&&&&&&&$. ....+$&&&&&%0.... ", -" [<[[[}|[&&888888888&88888888&8888888888&88&88888888&&opqpsps [<[[[}|[&&888888888&88888888&8888888888&88&88888888&&opqpsps .@&.$%.$$@&++&@.@*&+.................................. ................. .......@@@+...... ", -" <[[}[|[||&888888888&88888888&&&f88888888&&888888888&onqpsoss <[[}[|[||&888888888&88888888&&&f88888888&&888888888&onqpsoss .@&.0*.$$+*&**0..&$................................... ................. ................. ", -" [[}[|[|||&&&8888aba888888888&88&8888888888aba8888&&&nopsosss [[}[|[|||&&&8888aba888888888&88&8888888888aba8888&&&nopsosss ................+&@................................... ", -" }[[|[||||9|&&888b&b888888888&88&8888888888b&b888&&ononsqssss }[[|[||||9|&&888b&b888888888&88&8888888888b&b888&&ononsqssss ...............@&$.................................... ................... .................. ", -" [[|[||||9|99&&88aba888888888f&&f8888888888aba88&&ononsosssst [[|[||||9|99&&88aba888888888f&&f8888888888aba88&&ononsosssst ...................................................... ..........#$$$0.... ....#$$$$$$$$$$$.. ", -" [|}||||9|999e&&&88888888888888888888888888888&&&qpqpsosssstu [|}||||9|999e&&&88888888888888888888888888888&&&qpqpsosssstu ....+@................................................ ..........%&&&$.... ....$&&&&&&&&&&&.. ", -" |}4|4|9|999e9h9&&888888888888aba888888888888&&pqpqpsqsssstut |}4|4|9|999e9h9&&888888888888aba888888888888&&pqpqpsqsssstut ....@&................................................ .........=&&&&$.... ....*&&&&&&&&&&&.. ", -" [||||9|999e9h9hh&&&8888888888b&b8888888888&&&pqpqpsosssstutv [||||9|999e9h9hh&&&8888888888b&b8888888888&&&pqpqpsosssstutv ....@&.##.+@.###@...+@+............................... ........#&&&&&$.... ....&&&&&&&&&&&&.. ", -" ||4|9|99e9egehhhhi&&&&8888888aba8888888&&&&mononososssstutvt ||4|9|99e9egehhhhi&&&&8888888aba8888888&&&&mononososssstutvt ....@&.$$.@&.$%*%*.@&$%@.............................. .......+%&&&&&$.... ...#&&&&$$$$$$$$.. ", -" |4|9|99e9egehghhihiji&&&&&888888888&&&&&mnmononospsssstutvtv |4|9|99e9egehghhihiji&&&&&888888888&&&&&mnmononospsssstutvtv ....@&.$$.@&.$*.@&.%=@=%.............................. .......$&&&&&&$.... ...0&&&&.......... ", -" ||9|99e9egehhhhihijijkjll&&&&&&&&&&&mmmmnmononososssstutvtvw ||9|99e9egehhhhihijijkjll&&&&&&&&&&&mmmmnmononososssstutvtvw .00.@&.$$.@&.$$.@&.&*$$$.............................. ......@&&&&&&&$.... ...$&&&$.......... ", -" .=%@$%.$*.$&.$$.@&.*$.#+.............................. .....+%&&%*&&&$.... ...%&&&=.@@#...... ", -" .+*&%@.#%&$&.$$.@&.+*&&=.............................. .....$&&&@$&&&$.... ...&&&&*&&&&%0.... ", -" .......................................................... ...................................................... ....@&&&$.$&&&$.... ..@&&&&&&&&&&&$... ", -" ...@@+.................+@................................. ...................................................... ...+%&&%..$&&&$.... ..=&&&&&&&&&&&&=.. ", -" ..%&&&#................@&................................. ............................................................ ...................................................... ...*&&&#..$&&&$.... ..$&&&&&$$%&&&&&#. ", -" .@&#.=0.##.+@.###@...#@@&..#@#.+@..##..................... ............................................................ ....+@.......##....................................... ..0&&&=...$&&&$.... ..&&&&$+...0&&&&=. ", -" .#&%=+..$$.@&.$%*%*.=&$%&.0%$&=+&#.%0..................... ............................................................ ....@&.......$$....................................... .+&&&%....$&&&$.... ....+@......*&&&%. ", -" ..#*&&0.$$.@&.$*.@&.&0.0&.+++*$.*0+&+..................... ............................................................ ....@&.##.+@.$$+@..##................................. .$&&&*$$$$%&&&%$$0. ............@&&&&. ", -" .##.+=&.$$.@&.$$.@&.&@.@&.0%*%$.0*0*...................... ............................................................ ....@&.$$.@&.$$+&#.%0................................. .$&&&&&&&&&&&&&&&$. ............@&&&&. ", -" .0&0@$%.$*.$&.$$.@&.*$.$&.&0.*$..&*0...................... ............................................................ ....@&.$$.@&.$$.*0+&+................................. .$&&&&&&&&&&&&&&&$. .#$$%*......0&&&&. ", -" ..=&&*@.#%&$&.$$.@&.#%&$&.=&%$*..$&....................... ............................................................ .00.@&.$$.@&.$$.0*0*.................................. .$&&&&&&&&&&&&&&&$. .+&&&&+.....*&&&$. ", -" .................................*$....................... ............................................................ .=%@$%.$*.$&.$$..&*0.................................. .#@@@@@@@@*&&&*@@#. ..%&&&%+...$&&&&0. ", -" ................................&%+....................... ............................................................ .+*&%@.#%&$&.$$..$&................................... ..........$&&&$.... ..0&&&&&$$%&&&&%.. ", -" .......................................................... ............................................................ .................*$................................... ..........$&&&$.... ...*&&&&&&&&&&&#.. ", -" .......................................................... ............................................................ ................&%+................................... ..........$&&&$.... ...+%&&&&&&&&&@... ", -" .+@@..#@#................##............................... ............................................................ ...................................................... ..........$&&&$.... .....=%&&&&&$+.... ", -" .@&&..$&$................$$............................... ............................................................ ...+@+................................................ ................... .......#@@@....... ", -" .@&*@.&*$..#@+..@+@#...@#$$..@@+.##..@+................... ............................................................ ...*&$..........................+*.................... ................... .................. ", -" .@&==#%$$.$%$&@.&%$&0.%%*%$.***�%.#&+................... ............................................................ ..+&$&+.+@..@+.+@+@++@..@+.+@@..=&@................... ", -" .@&#$@$$$#&+.0%.&0.$$@&+.*$.#.#&@+&+0*.................... ............................................................ ..0&.&0.@&..&@#&**&@@&..&@+&$%*.*&$................... .................. ................. ", -" .@&.&$@$$@&..@&.&@.$$@&..$$.$&$&@.*0*0.................... ............................................................ ..*$.=*.@&..&@$*.+&@@&..&@@&0#+.@&.................... ......0$&&&$0..... .$$$$$$$$$$$$$$$. ", -" .@&.$%.$$+&@.$*.&@.$$+&@+%$@&++&@.@*&+.................... ............................................................ .+&&&&&+@&..&@$$..&@@&..&@.=%&$.@&.................... ....+%&&&&&&&$.... .&&&&&&&&&&&&&&&. ", -" .@&.0*.$$.@%&*+.&@.$$.0&%*$+*&**0..&$..................... ............................................................ .0%@@@%0@&+@&@=%+@&@@&+@&@#=.0&.@&.................... ...+%&&&&&&&&&$... .&&&&&&&&&&&&&&&. ", -" ..................................+&@..................... ............................................................ .*=...=*.*&$&@+*&=&@.*&$&@+*&&@.+%&................... ...%&&&&&&&&&&&#.. .&&&&&&&&&&&&&&&. ", -" .................................@&$...................... ............................................................ ..............#0.+&#.................................. ..0&&&&0..0&&&&=.. .$$$$$$$$$$&&&&@. ", -" .......................................................... ............................................................ ...............*&&=................................... ..*&&&0....$&&&%.. ..........$&&&0.. ", -" .......................................................... ............................................................ ...................................................... .+&&&&.....#$@@@.. .........@&&&$... ", -" .#@@@@#.....................##............................ ............................................................ ...@@+...............................+@............... .@&&&$............ ........+&&&&+... ", -" .$&&&&$.....................$$............................ ............................................................ ..%&&&#.............@=...............@&............... .0&&&$..@@@....... ........$&&&0.... ", -" ...$$..+@..@+..@#...#@#...@#$$..@@+.##..@+................ ............................................................ .@&#.=0..+@+..@+@#.+**#.+@+..@+@#.@+.@&+@+...@#..##@#. .$&&&@0%&&&&=+.... .......#&&&%..... ", -" ...$$..@&..&@+%**$.0%$&0.%%*%$.***�%.#&+................ ............................................................ .#&%=+..@&$%@.&%$&0#%%0@&$%@.&**&**&+@&**&#+%**$.$&$#. .$&&&%&&&&&&&%+... .......*&&&0..... ", -" ...$$..@&..&@=*@@&#$%@#.@&+.*$.#.#&@+&+0*................. ............................................................ ..#*&&0.%=@=%.&0.0%.$$.%=@=%.&0.&0.&@@&+.*$=*@@&#$*... .$&&&&&&&&&&&&%+.. ......#&&&%...... ", -" ...$$..@&..&@$%$$$#+$&&@@&..$$.$&$&@.*0*0................. ............................................................ .##.+=&.&*$$$.&@.@&.$$.&*$$$.&@.&@.&@@&..$$$%$$$#$$... .$&&&&&%$$&&&&&=.. ......$&&&=...... ", -" ...$$..@&+@&@0%++#.0@.*$+&@+%$@&++&@.@*&+................. ............................................................ .0&0@$%.*$.#+.&$.$*.$$.*$.#+.&@.&@.&@@&@+%00%++#.$$... .$&&&&$...+%&&&&.. .....+&&&&+...... ", -" ...$$...*&$&@.=&&*+@%&%+.0&%*$+*&**0..&$.................. ............................................................ ..=&&*@.+*&&=.&$&%+.@&$+*&&=.&@.&@.&@@&$&*..=&&*+$$... .$&&&%.....#&&&&#. .....0&&&*....... ", -" .....................................+&@.................. ............................................................ ..............&@...................................... .@&&&$......&&&&@. .....*&&&0....... ", -" ....................................@&$................... ............................................................ ..............&@...................................... .@&&&$......&&&&@. .....&&&&#....... ", -" .......................................................... ............................................................ ...................................................... ..&&&&+....#&&&&#. ....@&&&&........ ", -" .......................................................... ............................................................ ...+@@..................##............................ ..$&&&$+..+*&&&&.. ....=&&&*........ ", -" .@+..@#..##.........##.....................+@............. ............................................................ ..=&&&%@.......@=.......$$............................ ..#&&&&&$$&&&&&=.. ....$&&&$........ ", -" .*=.#&%..%0.........$$.....................@&............. ............................................................ .#&0.+$%..+@#.+**#.+@#..$$#@...+@+..@#@+.............. ...$&&&&&&&&&&%+.. ....%&&&0........ ", -" .$$.=*&+.&@.+@+...@#$$.@+@#...#@...+@@...#@@&..#@#.+@..##. ............................................................ .$*...+&@@&$%$#%%0@&$%$.$%*%%.@&$%@.&%$............... ....$&&&&&&&&%+... ....&&&&@........ ", -" .@&.*0*@@&.@&$%@.%%*%$.&%$&0.$%$%++&$%*.=&$%&.0%$&=+&#.%0. ............................................................ .$$....&@%0.++.$$.%0.+&#$*.+&@%=@=%.&0................ .....0%&&&&&=+.... ....&&&&@........ ", -" .+&+&#=$0*.%=@=%@&+.*$.&0.$$#&@@*=@&0#+.&0.0&.+++*$.*0+&+. ............................................................ .=%...#&#&@....$$.&@..&@$$..&@&*$$$.&@................ .......#@@#....... ................. ", -" ..%$&.@&$$.&*$$$@&..$$.&@.$$@&$$$0.=%&$.&@.@&.0%*%$.0*0*.. ............................................................ .+&*@0%*.*$.@0.$$.*$.@&+$%+@&+*$.#+.&@................ .................. ................. ", -" ..$%$..&%@.*$.#++&@+%$.&@.$$+&@.@.#=.0&.*$.$&.&0.*$..&*0.. ............................................................ ..#*&&=+.+*&%@.@&$+*&%@.$*%&0.+*&&=.&@................ ", -" ..0&@..$&+.+*&&=.0&%*$.&@.$$.@%&%@+*&&@.#%&$&.=&%$*..$&... ............................................................ ...................................................... .................. .................. ", -" .....................................................*$... ............................................................ ...................................................... .....@$%&&&$0+.... .....0$&&&$0...... ", -" ....................................................&%+... ............................................................ ...................................................... ...+*&&&&&&&&%@... ...+%&&&&&&&*+.... ", -" .......................................................... ............................................................ .+@#..##...........................@+................. ...%&&&&&&&&&&&#.. ..+%&&&&&&&&&%+... ", -" .......................................................... ............................................................ .@&%..$$...........................&@................. ..=&&&&*@@=&&&&%.. ..*&&&&&&&&&&&$... ", -" .#@@@@#+@.......................+@........................ ............................................................ .@&%0.$$..#@+.+@..##..@#..###@.##..&@@#...#@..+@#@.... ..%&&&*....0&&&&#. .#&&&&*#.+=&&&&#.. ", -" .$&&&&$@&.......................@&........................ ............................................................ .@&0%.$$.$%$&@#&+.*=+%**$.$%$&%$&0.&%$&=.$%$%+@&*0.... ..&&&&@.....&&&&@. .0&&&&+....=&&&=.. ", -" ...$$..@&+@+.+@..@++@#@.+@@...#@@&..#@#.+@..##............ ............................................................ .@&.%0$$#&+.0%.*@.&+=*@@&#$*.$*.$$.&0.0&#&@@*=@&+..... ..&&&&@.....&&&&@. .$&&&$.....+&&&%.. ", -" ...$$..@&**&+@&..&@@&*0+&$%*.=&$%&.0%$&=+&#.%0............ ............................................................ .@&.0%$$@&..@&.0*@*.$%$$$#$$.$$.$$.&@.@&@&$$$0@&...... ..*&&&=....#&&&&.. .$&&&$......&&&&.. ", -" ...$$..@&+.&@@&..&@@&+.@&0#+.&0.0&.+++*$.*0+&+............ ............................................................ .@&..%&$+&@.$*.+&*0.0%++#.$$.$$.$$.&$.$*+&@.@.@&...... ..#&&&&0..#%&&&=.. .$&&&*.....+&&&&#. ", -" ...$$..@&..&@@&..&@@&...=%&$.&@.@&.0%*%$.0*0*............. ............................................................ .@&..0&$.@%&*+..$&...=&&*+$$.$$.$$.&$&%#.@%&%@@&...... ...@&&&&&&&&&&$... .0&&&&@....$&&&&@. ", -" ...$$..@&..&@@&+@&@@&..#=.0&.*$.$&.&0.*$..&*0............. ............................................................ ...................................................... ....+%&&&&&&&@.... .+&&&&&=@@*&&&&&@. ", -" ...$$..@&..&@.*&$&@@&..+*&&@.#%&$&.=&%$*..$&.............. ............................................................ ...................................................... ...#%&&&&&&&&&0... ..=&&&&&&&&&&&&&@. ", -" ..........................................*$.............. ............................................................ ...................................................... ..+&&&&*@@=&&&&0.. ...$&&&&&&&&&&&&@. ", -" .........................................&%+.............. ............................................................ .+@@@@............................+@.................. ..*&&&*....0&&&&+. ....=&&&&&&=$&&&@. ", -" .......................................................... ............................................................ .@&&&&%+..........................@&.................. .+&&&&#.....%&&&0. .....+0$$=+.%&&&#. ", -" .......................................................... ............................................................ .@&..+%$..#@....@@...+@+..@+@#.@+.@&+@+...@#..##@#.... .@&&&&......$&&&$. ............&&&&.. ", -" .+@@@@+....+@....+@....................................... ............................................................ .@&...@&.$%$%++%**%+@&$%@.&**&**&+@&**&#+%**$.$&$#.... .@&&&&......$&&&$. ....+@.....#&&&%.. ", -" .@&&&&@....#$....@&....................................... .@&...@&#&@@*==*..#.%=@=%.&0.&0.&@@&+.*$=*@@&#$*...... .@&&&&#.....%&&&$. .@&&&&+....=&&&=.. ", -" .@&....+@#@+@..#@@&..#@#.+@..##........................... .@&...0%@&$$$0$$....&*$$$.&@.&@.&@@&..$$$%$$$#$$...... ..&&&&=....#&&&&@. ..&&&&$...@&&&&#.. ", -" .@&@@@.@&*0@&.=&$%&.0%$&=+&#.%0........................... .@&@@0&=+&@.@.0%++=+*$.#+.&@.&@.&@@&@+%00%++#.$$...... ..$&&&&=+.#%&&&%.. ..*&&&&%$*&&&&*... ", -" .@&&&&.@&+.@&.&0.0&.+++*$.*0+&+........................... .@&&&&=..@%&%@.=&&=.+*&&=.&@.&@.&@@&$&*..=&&*+$$...... ..+%&&&&&&&&&&&@.. ..#&&&&&&&&&&%+... ", -" .@&....@&..@&.&@.@&.0%*%$.0*0*............................ ...................................................... ...+%&&&&&&&&&0... ...=&&&&&&&&%+.... ", -" .@&....@&..@&.*$.$&.&0.*$..&*0............................ ...................................................... ....+=&&&&&&*#.... ....@%&&&&&=+..... ", -" .@&....@&..@&.#%&$&.=&%$*..$&............................. .......#@@@....... ......#@@#........ ", -" ...........................*$............................. .................. .................. ", -" ..........................&%+............................. ", -" .......................................................... ", -" .......................................................... ", -" ...@@+........................+@.......................... ", -" ..%&&&#.......@=..............@&.......................... ", -" .@&#.=0..#@#.+**###.+@.##@#.#@@&..#@#.+@..##.............. ", -" .#&%=+..0%$&=#%%0$$.@&.$&$#=&$%&.0%$&=+&#.%0.............. ", -" ..#*&&0.+++*$.$$.$$.@&.$*..&0.0&.+++*$.*0+&+.............. ", -" .##.+=&.0%*%$.$$.$$.@&.$$..&@.@&.0%*%$.0*0*............... ", -" .0&0@$%.&0.*$.$$.$*.$&.$$..*$.$&.&0.*$..&*0............... ", -" ..=&&*@.=&%$*.@&$#%&$&.$$..#%&$&.=&%$*..$&................ ", -" ........................................*$................ ", -" .......................................&%+................ ", -" .......................................................... "}; diff --git a/pixmaps/wmaker-tile-60x60.xpm b/pixmaps/wmaker-tile-60x60.xpm new file mode 100644 index 0000000..08685da --- /dev/null +++ b/pixmaps/wmaker-tile-60x60.xpm @@ -0,0 +1,137 @@ +/* XPM */ +static const char *wmaker_tile_60x60_xpm[] = { +"60 60 74 1", +" c None", +". c #A4A1B4", +"+ c #9C9DB4", +"@ c #A49DB4", +"# c #9C9DAC", +"$ c #9C99AC", +"% c #9499A4", +"& c #9C95AC", +"* c #9495A4", +"= c #9491A4", +"- c #8B919C", +"; c #948DA4", +"> c #8B8D9C", +", c #8B899C", +"' c #838994", +") c #8B859C", +"! c #838594", +"~ c #838194", +"{ c #7B818B", +"] c #7B7D8B", +"^ c #A49DAC", +"/ c #A499AC", +"( c #9C91AC", +"_ c #837D94", +": c #9495AC", +"< c #9C99A4", +"[ c #9C95A4", +"} c #9C91A4", +"| c #7B798B", +"1 c #A499B4", +"2 c #8B91A4", +"3 c #94919C", +"4 c #9491AC", +"5 c #8B8DA4", +"6 c #737983", +"7 c #948D9C", +"8 c #7B758B", +"9 c #737583", +"0 c #83899C", +"a c #8B8594", +"b c #83859C", +"c c #737183", +"d c #6A717B", +"e c #83818B", +"f c #736D83", +"g c #7B8194", +"h c #837D8B", +"i c #6A6D7B", +"j c #73798B", +"k c #7B7983", +"l c #7B7583", +"m c #7B7D94", +"n c #6A697B", +"o c #626973", +"p c #73758B", +"q c #73717B", +"r c #6A7183", +"s c #626573", +"t c #6A6D83", +"u c #736D7B", +"v c #6A657B", +"w c #62697B", +"x c #6A6973", +"y c #62657B", +"z c #6A6573", +"A c #626173", +"B c #5A616A", +"C c #62616A", +"D c #5A6173", +"E c #5A5D6A", +"F c #5A596A", +"G c #525D62", +"H c #525962", +"I c #525562", +"....+.@+@#+$#$$$%&$*&**=*===-=;-;>>>,>,,',)')!!!!~!~{~~]~]]]", +"...@.^####/#$$$$&$****(*=====;->>>;,>,,,,)'!!!)!~!~~~~]{]]_]", +"..@.#+@#@$#$$$$:<*:[:}*====-;->;>;,>,,,')'!)!)!~!~~{~]{_]_]|", +".@.#@^##$#$$$$:<:&**=*====-;-;>>>,>,,,')')!!!!~!~~{~]~]]]]|]", +"+.#@#+#1#$$$$:<:[**(*===23;-;>>;,>,,',)')!!)!~!~{~~]~]]_]|]|", +".^+^+^$#$$$$:<:[:*4*====35-;>>>,>,,,,!')!!!!~!~~~{]~]]]]|]||", +"@#@##$#$$$$*$*&**=*====-;-;>>>,>,,,')')!!!!~!~~{~]~]]]]|]||6", +"+###1#$$$$*$*&**4*===32;-;>>>,>,,,')')!!!!~!~~{~]~]]]]|]||6|", +"@#@$#$$$$*$*&**=*====27-;>>>,>,,,')')!!!!~!~~{~]~]]]]|]||6|6", +"##$#$$$$*$*&**=*====3;-;>>>,>,,,,)')!!!!~!~~~~]~]]]]|]||||68", +"+/#$$$$*$*&**=*====35-;>>>,>,,,,!')!!!!~!~~~{]~]]]]|]|||6686", +"$#$$$$*$*&**=*====353;>>>,>,,,,!,)!!!!~!~~~{_~]]]]|]|||6|869", +"#$$$$:$*&**=*=====535>>>,>,,,,!,!!!!!~!~~~{_{]]]]|]|||6|9699", +"$$$$:<*&**=*=====>357>7,>,,,,!,!)!)!~!~~~{_{_]_]|]|||6|9|989", +"$$$:<:&**=*=====>=57>>,>,,,,!,!)!!!~!~~~{_{_]]]|]|||6|9|9999", +"$$:<:[**=*=====>=>7>>,>,,,0a0ab!!!~!~~{~]~]]]]|]||6|6869999c", +"%&<:[:*4*=====>=>;>5,>,,,0a0ab!a!~!~~{~]~]]_]|]||6|6869899c9", +"&$*&**=*=====>=>;>>,>,,,0a0ab!!!~!~~{~]~]]]]|]||6|6869999c9c", +"$*:**4*====35357>>,>,,,')')!!!!~!~~{~]~]]]]|]||6|6869999c9cd", +"**[*(*====35357>5,>,,,')')!!b!~!~~{~]~]]]]|]||6|6869999c9cdc", +"&*:=*====35357>>,>,,,')')!!!!~!~~{~]~]]]]|]||6|6869999c9cdcd", +"**}*===32;-;>>>,>,,,')')!!!!~!~~e~]~]]]]|]||||6869999c9cccdf", +"*(*====27-;>>7,>,,,')')!!!!~!~~eg]~]]]]|]|||66869999c9ccddfd", +"=*====-;-;>>>,>,,,')')!!!!~!~~egh~]]]]|]|||6|869999c9ccdcfdi", +"*===23;-;>>>,>,,,0)')!!!!~!~~~ghg]]]]|]|||6|969999c9ccdcidii", +"====35-;>>>,>,,,0a')!!!!~!~~~{hgh]h]|]|||6|9|9899c9ccdcicifi", +"===-;-;>>>,>,,,0a0)!!!!~!~~~{_gh]]]|]|||6|9|9999c9ccdciciiii", +"==-;-;>>>,>,,,,a0a!!!!~!~~~{_{h]]]|]||jkjlj9999c9cdcdfdiiiii", +"-=;-;>>>,>,,,,!0ab!b!~!~~~{_{_]m]|]||jkjlj9l99c9cdcdfdifiiin", +"=;-;>>>,>,,,,!,ab!!!~!~~~{_{_]]]|]||jkjlj9999c9cdcdfdiiiiini", +";->>>>,>,,,,!,!b!!!~!~~eghgh]]]|]||6|6869999c9cdcdfdiiiiinio", +"->;>;,>,,,,!,!)!a!~!~~eghgh]m]|]||6|6869p99c9cdcdfdiiiiinion", +";>>>,>,,,,!,!)!!!~!~~eghgh]]]|]||6|6869999c9cdcdfdiiiiiniono", +">>;,>,,,')')!!!!~!~~{~]~]]]]|]||6|6869999c9cqcdfdiiiiininnon", +">;,>,,,')')!!)!~!~~{~]~]]h]|]||6|6869999c9cqrdfdiiiiininoons", +">,>,,,')')!!!!~!~~{~]~]]]]|]||6|6869999c9cqrqfdiiiiininonnso", +",>,,',)')!!!!~!~~{~]~]]]]|]||j|6869999c9ccrqtdiiiiininonosos", +">,,,,!')!!!!~!~~{~]~]]]]|]||jk6869999c9ccdqtqiuiiininonovovs", +",,,')')!!!!~!~~{~]~]]]]|]||jkj869999c9ccdctqiiiiininonovosss", +",,')')!!!!~!~~~~]~]]]]|]|||kjl69999c9ccdciqiiiiiniwxwxyossss", +"',)')!!!!~!~~~{]~]]]]|]|||6jlj9p99c9ccdcicitiiiniwxwxyozsssA", +",)')!!!!~!~~~{_~]]]]|]|||6|lj9999c9ccdciciiiiiniwxwxyossssAs", +")'!!!!!~!~~~{_{]]]]|]|||6|9j9999c9cqrqtqiiiiiniononsossssAsB", +"'!)!)!~!~~~{_{_]_]|]|||6|9|9l99c9cqrqtqitiiiniononsoysssAsBA", +")!!!!~!~~~{_{_]]]|]|||6|9|9999c9cqrqtqiiiiiniononsossssAsBAB", +"!!)!~!~~{~]~]]]]|]||6|6869999c9cdcdfdiiiiiniononsossssAsCABA", +"!)!~!~~{~]~]]_]|]||6|6869899c9cdcdfdiuiiiniononsossssAsCDBAB", +"!!~!~~{~]~]]]]|]||6|6869999c9cdcdfdiiiiiniononsossssAsCDCABE", +"!~!~{~~]~]]]]|]||6|6869999c9cdcdfdiiiiiniwnonsossssAsADCDBEB", +"~!~~~{]~]]]]|]||6|6869999c9cdcdfdiiiiiniwxonsossssAsABCDCECE", +"!~~{~]~]]]]|]||6|6869999c9cdcdfdiiiiiniwxwnsossssAsABADCEBEE", +"~~{~]~]]]]|]||||6869999c9cccdfdiiiiininxwxsossssAsABABCEBEEE", +"{~~]~]]]]|]|||66869999c9ccddfdiiiiininowxyoysssAsABABAEDEEEE", +"~~]~]]]]|]|||6|869999c9ccdcfdiiiiininonxyossssAsABABAEBEEEEF", +"~]{]]]]|]|||6|969999c9ccdcidiiiiininonoyossssAsCDCDCEBEEEEFG", +"]{_]_]|]|||6|9|9899c9ccdcicifiiininonovozsssAsCDCDCEDEEEEFGF", +"~]]]]|]|||6|9|9999c9ccdciciiiiininonovossssAsCDCDCEBEEEEFGFH", +"]]_]|]||6|6869999c9cdcdfdiiiiiniononsossssAsBABABEBEEEEFGFHF", +"]_]|]||6|6869899c9cdcdfdifiiiniononsovsssAsBABABECEEEEFGFHFH", +"]]|]||6|6869999c9cdcdfdiiiiiniononsossssAsBABABEBEEEEFGFHFHI"}; diff --git a/src/Makefile.am b/src/Makefile.am index 76d2179..04ac8c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,29 +1,26 @@ # This file is processed by GNU automake to generate Makefile.in -INCLUDES = -I$(top_srcdir)/pixmaps +INCLUDES = -I$(top_srcdir) \ + -I$(top_srcdir)/pixmaps \ + $(GTK_CFLAGS) bin_PROGRAMS = hvclock -hvclock_SOURCES = hvclock.c hvclock.h clock.c clock.h calendar.c calendar.h \ - options.c options.h xevents.c xevents.h dockapp.c dockapp.h \ +hvclock_SOURCES = hvclock.c hvclock.h clock.c clock.h \ + options.c options.h dockapp.c dockapp.h \ common.h +hvclock_LDADD = $(GTK_LIBS) + # These headers will be included in the distribution tarball, but will not be # installed by 'make install' noinst_HEADERS = -CLEANFILES = *~ +# we want these in the dist tarball +EXTRA_DIST = + +CLEANFILES = *~ DISTCLEANFILES = .deps/*.P MAINTAINERCLEANFILES = Makefile.in - -# This rule is used to bypass the default rule which is generated by Automake, in order -# to get rid of all the cluttered informations that are displayed by Make before -# calling the compiler like in the following example: -# source='programming.c' object='programming.o' libtool=no \ -# depfile='.deps/programming.Po' tmpdepfile='.deps/programming.TPo' \ -# depmode=gcc3 /bin/sh ../config/depcomp \ -# gcc -DHAVE_CONFIG_H -I. -I. -I.. -c `test -f 'main.c' || echo './'`main.c -.c.o: - $(COMPILE) -c $< diff --git a/src/calendar.c b/src/calendar.c deleted file mode 100644 index 56244fe..0000000 --- a/src/calendar.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * calendar.c -- functions for displaying calendar - * - * Copyright (C) 2005 Hugo Villeneuve - * - * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#if STDC_HEADERS -# include -#elif HAVE_STRINGS_H -# include -#else -# error "Needs or " -#endif - -#include -#include -#include - -#include "common.h" -#include "dockapp.h" -#include "xevents.h" -#include "options.h" -#include "calendar.h" - -#define CALENDAR_BACKGROUND_SRC_X 64 -#define CALENDAR_BACKGROUND_SRC_Y 64 - -#define WEEKDAYS_BASE_X 3 -#define WEEKDAYS_BASE_Y 65 -#define WEEKDAYS_HEIGHT 10 -#define WEEKDAYS_DELTA_Y 12 - -#define MONTHS_BASE_X 130 -#define MONTHS_BASE_Y 1 -#define MONTHS_HEIGHT 10 -#define MONTHS_DELTA_Y 11 - -#define NUMBERS_SRC_X 184 -#define NUMBERS_SRC_Y 0 -#define NUMBERS_DELTA_X 20 -#define NUMBERS_DELTA_Y 27 - -static const int number_widths[] = { - 18, /* 0 */ - 12, /* 1 */ - 17, /* 2 */ - 17, /* 3 */ - 19, /* 4 */ - 18, /* 5 */ - 18, /* 6 */ - 17, /* 7 */ - 18, /* 8 */ - 18 /* 9 */ -}; - -static const int months_widths[] = { - 39, /* January */ - 43, /* February */ - 29, /* March */ - 22, /* April */ - 20, /* May */ - 23, /* June */ - 20, /* July */ - 34, /* August */ - 52, /* September */ - 39, /* October */ - 49, /* November */ - 49 /* December */ -}; - -static const int days_widths[] = { - 36, /* Sunday */ - 38, /* Monday */ - 41, /* Tueday */ - 56, /* Wednesday */ - 45, /* Thursday */ - 30, /* Friday */ - 43 /* Saturday */ -}; - -static int DisplayDigit(int digit, int dest_x, int dest_y) -{ - int src_x, src_y; - - if ((digit % 2) == 0) - src_x = NUMBERS_SRC_X; /* First column */ - else - src_x = NUMBERS_SRC_X + NUMBERS_DELTA_X; /* Second column */ - - src_y = NUMBERS_SRC_Y + ((digit / 2) * NUMBERS_DELTA_Y); - - copyXPMArea(src_x, src_y, number_widths[digit], - NUMBERS_DELTA_Y - 1, dest_x, dest_y); - - return dest_x + number_widths[digit] + 1; -} - -static int GetNumberWidth(int number) -{ - int first, second; - int width; - - first = number / 10; - second = number % 10; - - if (first == 0) - width = number_widths[second]; - else - width = number_widths[first] + number_widths[second]; - - return width; -} - -void UpdateCalendar(void) -{ - struct tm *time_struct; - time_t curtime; - int x, y; - int day_of_month; - int day_of_week; - int month; - - curtime = time(CurrentTime); - time_struct = localtime(&curtime); - day_of_month = time_struct->tm_mday; - day_of_week = time_struct->tm_wday; - month = time_struct->tm_mon; - - /* Blanking the calendar area. */ - copyXPMArea(CALENDAR_BACKGROUND_SRC_X, CALENDAR_BACKGROUND_SRC_Y, - 64, 64, 0, 0); - - /* Displaying weekday. */ - x = (64 - days_widths[day_of_week]) / 2; - y = 6; - copyXPMArea(WEEKDAYS_BASE_X, - WEEKDAYS_BASE_Y + WEEKDAYS_DELTA_Y * day_of_week, - days_widths[day_of_week], WEEKDAYS_HEIGHT, x, y); - - /* Displaying month. */ - x = (64 - months_widths[month]) / 2; - y += WEEKDAYS_DELTA_Y + 1; - copyXPMArea(MONTHS_BASE_X, MONTHS_BASE_Y + MONTHS_DELTA_Y * month, - months_widths[month], MONTHS_HEIGHT, x, y); - - /* x is the position of the first digit. */ - x = (64 - GetNumberWidth(day_of_month)) / 2; - y += MONTHS_DELTA_Y + 2; - - if ((day_of_month / 10) != 0) - x = DisplayDigit(day_of_month / 10, x, y); - - (void) DisplayDigit(day_of_month % 10, x, y); - - RedrawWindow(); -} diff --git a/src/calendar.h b/src/calendar.h deleted file mode 100644 index 54ac164..0000000 --- a/src/calendar.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * calendar.h - * - * Copyright (C) 2005 Hugo Villeneuve - * - * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef CALENDAR_H -#define CALENDAR_H 1 - -void -UpdateCalendar(void); - -#endif /* CALENDAR_H */ diff --git a/src/clock.c b/src/clock.c index c07c173..ef835ad 100644 --- a/src/clock.c +++ b/src/clock.c @@ -3,6 +3,9 @@ * * Copyright (C) 2005 Hugo Villeneuve * + * Based on EggClockFace + * (c) 2005, Davyd Madeley + * * 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 @@ -25,6 +28,7 @@ # include "config.h" #endif +#include #include #include #include @@ -35,89 +39,428 @@ #else # error "Needs or " #endif - #include #include #include +#include #include "common.h" -#include "dockapp.h" -#include "xevents.h" -#include "options.h" -#include "hvclock.h" #include "clock.h" +#include "hvclock.h" +#include "dockapp.h" + +/* Constants */ +#define CLOCK_MODE 0 +#define CALENDAR_MODE 1 + +/* All ratios are relatives to clock diameter */ + +#define HAND_HOURS_LENGTH_RATIO 0.55 +#define HAND_MINUTES_LENGTH_RATIO 0.80 +#define HAND_SECONDS_LENGTH1_RATIO 0.80 /* Main hand */ +#define HAND_SECONDS_LENGTH2_RATIO 0.30 /* Small hand on opposite side */ + +#define HAND_HOURS_WIDTH_RATIO 0.100 +#define HAND_MINUTES_WIDTH_RATIO 0.070 +#define HAND_SECONDS_WIDTH_RATIO 0.040 + +#define CENTER_CIRCLE_OUTER_RADIUS_RATIO 0.100 +#define CENTER_CIRCLE_INNER_RADIUS_RATIO 0.030 + +#define CLOCK_DIGITS_FONTS_SIZE_RATIO 0.30 + +#define CALENDAR_FONTS_SIZE 8.0 + +/* Manual tweak for '11' oclock position */ +#define ELEVENTH_OCLOCK_FIRST_DIGIT_XOFFSET 1.99 +#define TENTH_OCLOCK_FIRST_DIGIT_XOFFSET 1.75 -#define SIZE 64 -#define HAND_WIDTH_HOURS_MINUTES 2 -#define HAND_WIDTH_SECONDS 1 -#define HAND_LENGTH_HOURS 16 -#define HAND_LENGTH_MINUTES 25 -#define HAND_LENGTH_SECONDS HAND_LENGTH_MINUTES -#define HAND_LENGTH_SECONDS_NEG 7 +/* Offset between digits of '10', '11' and '12' oclock positions */ +#define SECOND_DIGIT_XOFFSET 1.0 -static void draw_hand(double angle, int hand_length, int negative_hand_length, - int hand_width) +#define DIGITS_POSITION_RATIO 0.73 /* Position of digits from center */ +#define DIGITS_DOTS_POSITION_RATIO 0.92 /* Position of small hours dots */ + +/* Radius of small dots near each digit */ +#define DIGITS_DOTS_RADIUS_RATIO 0.04 + +struct hvclock_gtk_t { + GtkDrawingArea parent; +}; + +struct hvclock_gtk_class_t { + GtkDrawingAreaClass parent_class; +}; + +typedef struct hvclock_gtk_t HvClock; +typedef struct hvclock_gtk_class_t HvClockClass; + +#define HVCLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), hvclock_get_type(), \ + HvClock)) + +G_DEFINE_TYPE(HvClock, hvclock, GTK_TYPE_DRAWING_AREA); + +/* Starting mode is clock mode */ +static int hvclock_mode = CLOCK_MODE; + +static void +draw_clock_background(GtkWidget *clock, cairo_t *cr) { - int start_x, start_y, end_x, end_y; + gint center_x, center_y; + double angle = M_PI / 3; /* Starting angle at '12' oclock position */ + double radius, radius_numbers, radius_dots; + int digit; + + center_x = clock->allocation.width / 2; + center_y = clock->allocation.height / 2; + + /* Clock face radius */ + radius = MIN(clock->allocation.width / 2, clock->allocation.height / 2) + - 1; + + /* Position of digits as a radius ratio */ + radius_numbers = radius * DIGITS_POSITION_RATIO; + + /* Position of small hours dots as a radius ratio */ + radius_dots = radius * DIGITS_DOTS_POSITION_RATIO; + + cairo_save(cr); - XSetLineAttributes(dockapp.display, dockapp.NormalGC, hand_width, - LineSolid, CapRound, JoinRound); + cairo_select_font_face(cr, "serif", CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); - start_x = SIZE / 2; /* Center of clock */ - start_y = start_x; + cairo_set_font_size(cr, radius * CLOCK_DIGITS_FONTS_SIZE_RATIO); - end_x = start_x + (int) ((double) hand_length * sin(angle)); - end_y = start_y - (int) ((double) hand_length * cos(angle)); + /* Draw clock background and outer rim */ + cairo_set_line_width(cr, 1.5); + cairo_arc(cr, center_x, center_y, radius, 0, 2 * M_PI); + cairo_set_source_rgb(cr, 1, 1, 1); + cairo_fill_preserve(cr); /* White background */ + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_stroke(cr); /* Black rim */ - if (negative_hand_length) { - start_x -= (int) ((double) negative_hand_length * sin(angle)); - start_y += (int) ((double) negative_hand_length * cos(angle)); + /* Draw clock tick marks on outer circle */ + for (digit = 1; digit <= 12; digit++) { + double xx, yy; + double text_start_x, text_start_y; + double first_digit_xoffset = 0; + char hours[3]; + cairo_text_extents_t extents; + int divisor; + + sprintf(hours, "%d", digit); /* Convert digit to string */ + hours[1] = 0; /* Make sure to have only first digit */ + + /* Get digit dimensions */ + cairo_text_extents(cr, hours, &extents); + + if (digit <= 9) { + divisor = 2; + } else { + divisor = 1; + + /* Manual tweak for '10' and '11' oclock position */ + if (digit == 11) + first_digit_xoffset = + ELEVENTH_OCLOCK_FIRST_DIGIT_XOFFSET; + else if (digit == 10) + first_digit_xoffset = + TENTH_OCLOCK_FIRST_DIGIT_XOFFSET; + + } + + xx = extents.width / divisor + extents.x_bearing; + yy = extents.height / 2 + extents.y_bearing; + + text_start_x = center_x + radius_numbers * cos(angle) - xx + + first_digit_xoffset; + text_start_y = center_y - radius_numbers * sin(angle) - yy; + + cairo_move_to(cr, text_start_x, text_start_y); + cairo_show_text(cr, hours); + + if (digit > 9) { + /* Second digit */ + sprintf(hours, "%d", digit - 10); + + cairo_text_extents(cr, hours, &extents); + + text_start_x += xx - SECOND_DIGIT_XOFFSET; + + cairo_move_to(cr, text_start_x, text_start_y); + cairo_show_text(cr, hours); + } + + /* Draw small dot for each digit */ + cairo_arc(cr, center_x + radius_dots * cos(angle), + center_y + radius_dots * sin(angle), + radius * DIGITS_DOTS_RADIUS_RATIO, 0, 2 * M_PI); + cairo_fill(cr); + + angle -= M_PI / 6; /* Angle for next digit */ + if (angle < 0) + angle = 11 * M_PI / 6; /* '4' oclock position */ } - XDrawLine(dockapp.display, dockapp.xpm_icon.image, - dockapp.NormalGC, start_x, start_y, end_x, end_y); + cairo_restore(cr); } -void UpdateClock(void) +static void +draw_clock_hands(GtkWidget *clock, cairo_t *cr) { - static int old_hour; - static int old_minute; - static int old_second; - struct tm *time_struct; - time_t curtime; - double angle; - - curtime = time(NULL); - time_struct = localtime(&curtime); - - /* Do not update each second if the seconds hand is not displayed. */ - if ((time_struct->tm_hour == old_hour) && - (time_struct->tm_min == old_minute) && - (time_struct->tm_sec == old_second)) - return; + gint center_x, center_y; + double angle = M_PI / 3; /* Starting angle at '12' oclock position */ + double radius, length; + int hours, minutes, seconds; + double sin_x, cos_y; + time_t now; /* Current system time */ + struct tm *ts; + + /* Get the current time */ + now = time(NULL); + + /* Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */ + ts = localtime(&now); + + center_x = clock->allocation.width / 2; + center_y = clock->allocation.height / 2; + + /* Clock face radius */ + radius = MIN(clock->allocation.width / 2, clock->allocation.height / 2) + - 1; + + cairo_save(cr); - /* Blanking the clock area. */ - copyXPMArea(64, 0, SIZE, SIZE, 0, 0); + hours = ts->tm_hour; + minutes = ts->tm_min; - /* Draw hours hand */ - angle = (M_PI / 6.0) * (double) time_struct->tm_hour + - (M_PI / 360.0) * (double) time_struct->tm_min; - draw_hand(angle, HAND_LENGTH_HOURS, 0, HAND_WIDTH_HOURS_MINUTES); + cairo_set_source_rgb(cr, 0.15, 0.15, 0.15); + cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); - /* Draw minutes hand, 60 minutes = 2PI */ - angle = (M_PI / 30.0) * (double) time_struct->tm_min; - draw_hand(angle, HAND_LENGTH_MINUTES, 0, HAND_WIDTH_HOURS_MINUTES); + /* hour hand: + * the hour hand is rotated 30 degrees (pi/6 r) per hour + + * 1/2 a degree (pi/360 r) per minute + */ + angle = M_PI / 6 * hours + M_PI / 360 * minutes; + cairo_set_line_width(cr, radius * HAND_HOURS_WIDTH_RATIO); + cairo_move_to(cr, center_x, center_y); + length = radius * HAND_HOURS_LENGTH_RATIO; + cairo_line_to(cr, center_x + length * sin(angle), + center_y + length * -cos(angle)); + cairo_stroke(cr); + /* minute hand: + * the minute hand is rotated 6 degrees (pi/30 r) per minute + */ + angle = M_PI / 30 * minutes; + cairo_move_to(cr, center_x, center_y); + cairo_set_line_width(cr, radius * HAND_MINUTES_WIDTH_RATIO); + length = radius * HAND_MINUTES_LENGTH_RATIO; + cairo_line_to(cr, center_x + length * sin(angle), + center_y + length * -cos(angle)); + cairo_stroke(cr); + + /* seconds hand: + * operates identically to the minute hand + */ if (hvclock_infos.show_seconds) { - /* Draw seconds hand, 60 seconds = 2PI */ - angle = (M_PI / 30.0) * (double) time_struct->tm_sec; - draw_hand(angle, HAND_LENGTH_SECONDS, HAND_LENGTH_SECONDS_NEG, - HAND_WIDTH_SECONDS); + seconds = ts->tm_sec; + angle = M_PI / 30 * seconds; + cairo_set_line_width(cr, radius * HAND_SECONDS_WIDTH_RATIO); + sin_x = sin(angle); + cos_y = cos(angle); + length = radius * HAND_SECONDS_LENGTH2_RATIO; + cairo_move_to(cr, center_x - length * sin_x, + center_y - length * -cos_y); + length = radius * HAND_SECONDS_LENGTH1_RATIO; + cairo_line_to(cr, center_x + length * sin_x, + center_y + length * -cos_y); + cairo_stroke(cr); } - RedrawWindow(); + /* Draw clock center circle */ + cairo_arc(cr, center_x, center_y, + radius * CENTER_CIRCLE_OUTER_RADIUS_RATIO, + 0, 2 * M_PI); + cairo_fill(cr); + + /* Draw clock center smaller circle */ + cairo_set_source_rgb(cr, 0.6, 0.6, 0.6); + cairo_arc(cr, center_x, center_y, + radius * CENTER_CIRCLE_INNER_RADIUS_RATIO, + 0, 2 * M_PI); + cairo_fill(cr); + + cairo_restore(cr); +} + +static void +draw_calendar(GtkWidget *clock, cairo_t *cr) +{ + gint center_x, center_y; + char str[32]; + double x, y; + cairo_text_extents_t extents; + time_t now; /* Current system time */ + struct tm *ts; - old_hour = time_struct->tm_hour; - old_minute = time_struct->tm_min; - old_second = time_struct->tm_sec; + center_x = clock->allocation.width / 2; + center_y = clock->allocation.height / 2; + + cairo_save(cr); + + cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); + cairo_set_font_size(cr, CALENDAR_FONTS_SIZE); + cairo_set_source_rgb(cr, 0, 0, 0); + + /* Get the current time */ + now = time(NULL); + + /* Format and print the time, "ddd yyyy-mm-dd hh:mm:ss zzz" */ + ts = localtime(&now); + + /* Weekday */ + strftime(str, 256, "%A", ts); + /* Get text dimensions */ + cairo_text_extents(cr, str, &extents); + x = center_x - extents.width / 2; + cairo_move_to(cr, x, 11); + cairo_show_text(cr, str); + + strftime(str, 256, "%B", ts); + /* Get text dimensions */ + cairo_text_extents(cr, str, &extents); + x = center_x - extents.width / 2; + cairo_move_to(cr, x, 25); + cairo_show_text(cr, str); + + /* Day of month */ + cairo_set_font_size(cr, 30); + strftime(str, 256, "%d", ts); + /* Get text dimensions */ + cairo_text_extents(cr, str, &extents); + x = center_x - extents.width / 2; + y = clock->allocation.height - 7; + cairo_move_to(cr, x, y); + cairo_show_text(cr, str); + + cairo_restore(cr); +} + +static gboolean +hvclock_expose(GtkWidget *clock, GdkEventExpose *event) +{ + cairo_t *cr; + + /* Get a cairo_t */ + cr = gdk_cairo_create(clock->window); + + if (hvclock_infos.dockapp_mode == true) { + gdk_cairo_set_source_pixbuf(cr, dockapp.background_pixbuf, + 0, 0); + cairo_paint(cr); + } + + cairo_rectangle(cr, + event->area.x, event->area.y, + event->area.width, event->area.height); + cairo_clip(cr); + + if (hvclock_mode == CLOCK_MODE) { + draw_clock_background(clock, cr); + draw_clock_hands(clock, cr); + } else + draw_calendar(clock, cr); + + cairo_destroy(cr); + + return TRUE; +} + +static void +hvclock_redraw_canvas(HvClock *clock) +{ + GtkWidget *widget; + GdkRegion *region; + + widget = GTK_WIDGET(clock); + + if (!widget->window) + return; + + region = gdk_drawable_get_clip_region(widget->window); + /* redraw the cairo canvas completely by exposing it */ + gdk_window_invalidate_region(widget->window, region, TRUE); + gdk_window_process_updates(widget->window, TRUE); + + gdk_region_destroy(region); +} + +static gboolean +hvclock_button_release(GtkWidget *clock, GdkEventButton *event) +{ + if (hvclock_infos.debug) + printf("%s: button released\n", PACKAGE); + + /* single-click --> changing viewing mode */ + if (hvclock_mode == CLOCK_MODE) { + hvclock_mode = CALENDAR_MODE; + if (hvclock_infos.debug) + printf("%s: switching to calendar mode\n", PACKAGE); + } else { + hvclock_mode = CLOCK_MODE; + if (hvclock_infos.debug) + printf("%s: switching to clock mode\n", PACKAGE); + } + + /* Update clock/calendar... */ + hvclock_redraw_canvas(HVCLOCK(clock)); + + return FALSE; +} + +static void +hvclock_class_init(struct hvclock_gtk_class_t *class) +{ + GObjectClass *obj_class; + GtkWidgetClass *widget_class; + + obj_class = G_OBJECT_CLASS(class); + widget_class = GTK_WIDGET_CLASS(class); + + /* GtkWidget signals */ + widget_class->expose_event = hvclock_expose; + widget_class->button_release_event = hvclock_button_release; +} + +static gboolean +hvclock_update(gpointer data) +{ + HvClock *clock; + + clock = HVCLOCK(data); + + hvclock_redraw_canvas(clock); + + return TRUE; /* keep running this event */ +} + +static void +hvclock_init(HvClock *clock) +{ + gtk_widget_add_events(GTK_WIDGET(clock), GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK); + + hvclock_update(clock); + + /* update the clock once a second */ + g_timeout_add(1000, hvclock_update, clock); +} + +GtkWidget * +hvclock_widget_new(void) +{ + return g_object_new(hvclock_get_type(), NULL); } diff --git a/src/clock.h b/src/clock.h index 035cf4d..e9e8cd0 100644 --- a/src/clock.h +++ b/src/clock.h @@ -21,7 +21,8 @@ #ifndef CLOCK_H #define CLOCK_H 1 -void -UpdateClock(void); +#include + +GtkWidget *hvclock_widget_new(void); #endif /* CLOCK_H */ diff --git a/src/common.h b/src/common.h index 6ee78e0..8338342 100644 --- a/src/common.h +++ b/src/common.h @@ -21,6 +21,7 @@ #ifndef COMMON_H #define COMMON_H 1 +#include #include #include #include @@ -31,11 +32,6 @@ # define EXIT_FAILURE 1 #endif -#ifndef FALSE -# define FALSE 0 -# define TRUE 1 -#endif - /* Returns TRUE if the strings 'a' and 'b' are equal. */ #define STREQ(a, b) (strcmp((a), (b)) == 0) @@ -45,7 +41,4 @@ inline void ErrorLocation(const char *file, int line); -void * -xmalloc(size_t size, const char *filename, int line_number); - #endif /* COMMON_H */ diff --git a/src/dockapp.c b/src/dockapp.c index 644eceb..70d2486 100644 --- a/src/dockapp.c +++ b/src/dockapp.c @@ -30,290 +30,60 @@ #include #include #include -#include -#include -#include +#include +#include #include "common.h" +#include "clock.h" +#include "hvclock.h" #include "dockapp.h" - -#define XLIB_FAILURE 0 -#define XLIB_SUCCESS 1 - -/* Specifies the border width */ -#define BWIDTH 1 +#include "wmaker-tile-60x60.xpm" /* Width and height in pixels of Window Maker icons. */ #define ICON_SIZE 64 -static void CreateIconFromXpmData(char *pixmap_data[]) -{ - int status; - - dockapp.xpm_icon.attributes.valuemask |= - (XpmReturnPixels | XpmReturnExtensions); - - /* - * Using the XPM library to read XPM data from the array in the included - * XPM file. The 'shapemask' Pixmap variable is set to an additional - * 1-bit deep pixmap that can then be used as a shape mask for the - * XShapeCombineMask() function. - */ - status = XpmCreatePixmapFromData(dockapp.display, dockapp.root_win, - pixmap_data, - &dockapp.xpm_icon.image, - &dockapp.xpm_icon.shapemask, - &dockapp.xpm_icon.attributes); - if (status != XpmSuccess) { - fprintf(stderr, "%s: XpmCreatePixmapFromData() failed\n", - PACKAGE); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } -} - -static Pixel GetColor(char *name) -{ - int status; - int res; - XColor color; - XWindowAttributes attributes; - - status = XGetWindowAttributes(dockapp.display, dockapp.root_win, - &attributes); - if (status == XLIB_FAILURE) { - fprintf(stderr, "%s: XGetWindowAttributes() failed\n", - PACKAGE); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } - - color.pixel = 0; - res = - (int) XParseColor(dockapp.display, attributes.colormap, name, - &color); - if (res == FALSE) { - fprintf(stderr, "%s: Can't parse %s.\n", PACKAGE, name); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } - - res = - (int) XAllocColor(dockapp.display, attributes.colormap, - &color); - if (res == FALSE) { - fprintf(stderr, "%s: Can't allocate %s.\n", PACKAGE, name); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } - - return color.pixel; -} - -static void flush_expose(Window win) -{ - XEvent dummy; - int res = TRUE; - - while (res != FALSE) { - res = - (int) XCheckTypedWindowEvent(dockapp.display, win, - Expose, &dummy); - } -} - -void RedrawWindow(void) -{ - flush_expose(dockapp.iconwin); - - (void) XCopyArea(dockapp.display, dockapp.xpm_icon.image, - dockapp.iconwin, dockapp.NormalGC, 0, 0, - dockapp.xpm_icon.attributes.width, - dockapp.xpm_icon.attributes.height, 0, 0); - - flush_expose(dockapp.win); - - (void) XCopyArea(dockapp.display, dockapp.xpm_icon.image, - dockapp.win, dockapp.NormalGC, 0, 0, - dockapp.xpm_icon.attributes.width, - dockapp.xpm_icon.attributes.height, 0, 0); -} - -void -copyXPMArea(int x, int y, unsigned int sx, unsigned int sy, int dx, int dy) -{ - (void) XCopyArea(dockapp.display, dockapp.xpm_icon.image, - dockapp.xpm_icon.image, dockapp.NormalGC, x, y, - sx, sy, dx, dy); -} +/* Specifies the border width */ +#define BWIDTH 2 /******************************************************************************* * New window creation and initialization for a Dockable Application ******************************************************************************/ void -InitDockAppWindow(int argc, char *argv[], char *pixmap_data[], - char *display_arg, char *geometry_arg) +dockapp_init(int argc, char *argv[], char *display_arg, char *geometry_arg) { - XGCValues gcv; - XSizeHints size_hints; + GtkWidget *window; + GtkWidget *clock; XWMHints wm_hints; - int status; - int gravity = 0; /* Used to store the gravity value returned by - * XWMGeometry, but not used. */ - char *app_name = "hvclock"; - - /* Opening a connection to the X server. */ - dockapp.display = XOpenDisplay(display_arg); - if (dockapp.display == NULL) { - fprintf(stderr, "%s: Can't open display: %s\n", PACKAGE, - XDisplayName(display_arg)); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } - - dockapp.screen = DefaultScreen(dockapp.display); - dockapp.root_win = RootWindow(dockapp.display, dockapp.screen); - dockapp.d_depth = DefaultDepth(dockapp.display, dockapp.screen); - - /* Create a window to hold the stuff */ - size_hints.flags = USSize | USPosition; - size_hints.x = 0; - size_hints.y = 0; - - /* - * Constructing window's geometry information. - * XWMGeometry() returns an 'int', but Xlib documentation doesn't - * explain it's meaning. - */ - XWMGeometry(dockapp.display, dockapp.screen, geometry_arg, NULL, - BWIDTH, &size_hints, &size_hints.x, &size_hints.y, - &size_hints.width, &size_hints.height, &gravity); - - size_hints.width = ICON_SIZE; - size_hints.height = ICON_SIZE; - dockapp.back_pix = GetColor("white"); - dockapp.fore_pix = GetColor("black"); - dockapp.win = - XCreateSimpleWindow(dockapp.display, dockapp.root_win, - size_hints.x, size_hints.y, - (unsigned int) size_hints.width, - (unsigned int) size_hints.height, BWIDTH, - dockapp.fore_pix, dockapp.back_pix); + gtk_init(&argc, &argv); - dockapp.iconwin = XCreateSimpleWindow(dockapp.display, dockapp.win, - size_hints.x, size_hints.y, - (unsigned int) size_hints. - width, - (unsigned int) size_hints. - height, BWIDTH, - dockapp.fore_pix, - dockapp.back_pix); + if (hvclock_infos.dockapp_mode == true) + dockapp.background_pixbuf = + gdk_pixbuf_new_from_xpm_data(wmaker_tile_60x60_xpm); - /* Configuring Client to Window Manager Communications. */ + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), ICON_SIZE, ICON_SIZE); - /* - * WM_NORMAL_HINTS property: size hints for a window in it's normal - * state. - * Replaces the size hints for the WM_NORMAL_HINTS property on the - * specified window. - */ - XSetWMNormalHints(dockapp.display, dockapp.win, &size_hints); + clock = hvclock_widget_new(); + gtk_container_add(GTK_CONTAINER(window), clock); - /* Setting the WM_CLASS property. */ - { - XClassHint wm_class; + g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); - /* - * The res_name member contains the application name. - * The res_class member contains the application class. - * The name set in this property may differ from the name set as - * WM_NAME. That is, WM_NAME specifies what should be displayed - * in the title bar and, therefore, can contain temporal - * information (for example, the name of a file currently in an - * editor's buffer). On the other hand, the name specified as - * part of WM_CLASS is the formal name of the application that - * should be used when retrieving the application's resources - * from the resource database. - */ - wm_class.res_name = app_name; - wm_class.res_class = app_name; - (void) XSetClassHint(dockapp.display, dockapp.win, - &wm_class); - } - - /* Setting the WM_NAME property. - This specifies what should be displayed in the title bar (usually the - application name). */ - { - XTextProperty text_prop; + gtk_container_set_border_width(GTK_CONTAINER(window), BWIDTH); - const int string_count = 1; + gtk_widget_show_all(window); - status = - XStringListToTextProperty(&app_name, string_count, - &text_prop); - if (status == 0) { - fprintf(stderr, - "%s: XStringListToTextProperty() failed\n", - PACKAGE); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } + if (hvclock_infos.dockapp_mode == true) { + /* Dockapp specific initialization */ + wm_hints.flags = StateHint | IconWindowHint | IconPositionHint | + WindowGroupHint; + wm_hints.initial_state = WithdrawnState; + wm_hints.icon_window = GDK_WINDOW_XWINDOW(clock->window); + wm_hints.icon_x = 0; + wm_hints.icon_y = 0; + wm_hints.window_group = GDK_WINDOW_XWINDOW(window->window); - XSetWMName(dockapp.display, dockapp.win, &text_prop); - - /* Freing the storage for the value field. */ - (void) XFree(text_prop.value); + XSetWMHints(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window->window), + &wm_hints); } - - /* WM_HINTS --> Additional hints set by the client for use by the Window - Manager. */ - /* XWMHints wm_hints; */ - - /* WithdrawnState, NormalState or IconicState. Must be set to - * WithdrawnState for DockApp. */ - wm_hints.flags = StateHint | IconWindowHint | IconPositionHint | - WindowGroupHint; - wm_hints.initial_state = WithdrawnState; /* Withdrawn, Normal */ - wm_hints.icon_window = dockapp.iconwin; - wm_hints.icon_x = size_hints.x; - wm_hints.icon_y = size_hints.y; - wm_hints.window_group = dockapp.win; - (void) XSetWMHints(dockapp.display, dockapp.win, &wm_hints); - - /* Sets the WM_COMMAND property. This sets the command and arguments - used to invoke the application. */ - (void) XSetCommand(dockapp.display, dockapp.win, argv, argc); - - /* ... */ - (void) XSelectInput(dockapp.display, dockapp.win, - ButtonPressMask | ExposureMask | - ButtonReleaseMask | PointerMotionMask | - StructureNotifyMask); - - (void) XSelectInput(dockapp.display, dockapp.iconwin, - ButtonPressMask | ExposureMask | - ButtonReleaseMask | PointerMotionMask | - StructureNotifyMask); - - /* Create GC for drawing */ - gcv.foreground = dockapp.fore_pix; - gcv.background = dockapp.back_pix; - gcv.graphics_exposures = 0; - dockapp.NormalGC = XCreateGC(dockapp.display, dockapp.root_win, - GCForeground | GCBackground | - GCGraphicsExposures, &gcv); - - /* Convert XPM data to XImage */ - CreateIconFromXpmData(pixmap_data); - - XShapeCombineMask(dockapp.display, dockapp.win, ShapeBounding, 0, - 0, dockapp.xpm_icon.shapemask, ShapeSet); - - XShapeCombineMask(dockapp.display, dockapp.iconwin, ShapeBounding, - 0, 0, dockapp.xpm_icon.shapemask, ShapeSet); - - /* Making the new window visible. */ - (void) XMapWindow(dockapp.display, dockapp.win); } diff --git a/src/dockapp.h b/src/dockapp.h index af0df4c..523b70f 100644 --- a/src/dockapp.h +++ b/src/dockapp.h @@ -21,36 +21,14 @@ #ifndef DOCKAPP_H #define DOCKAPP_H 1 -#include - -struct xpm_icon_t { - XpmAttributes attributes; - Pixmap shapemask; - Pixmap image; -}; +#include struct dockapp_t { - Display *display; - Window root_win; - int screen; - int d_depth; - Pixel back_pix; - Pixel fore_pix; - Window iconwin; - Window win; - GC NormalGC; - struct xpm_icon_t xpm_icon; + GdkPixbuf *background_pixbuf; }; void -InitDockAppWindow(int argc, char *argv[], char *pixmap_data[], - char *display_arg, char *geometry_arg); - -void -RedrawWindow(void); - -void -copyXPMArea(int x, int y, unsigned int sx, unsigned int sy, int dx, int dy); +dockapp_init(int argc, char *argv[], char *display_arg, char *geometry_arg); /* Exported variables */ #undef _SCOPE_ diff --git a/src/hvclock.c b/src/hvclock.c index 23ee5a6..19ae662 100644 --- a/src/hvclock.c +++ b/src/hvclock.c @@ -28,134 +28,18 @@ #include #include #include -#if STDC_HEADERS -# include -#elif HAVE_STRINGS_H -# include -#else -# error "Needs or " -#endif -#include -#include #include -#include -#include -#include #include -#include -#include -#include #include "common.h" #include "dockapp.h" -#include "xevents.h" #include "options.h" -#include "hvclock.xpm" #include "clock.h" -#include "calendar.h" #include "hvclock.h" -/* Constants */ -#define CLOCK_MODE 0 -#define CALENDAR_MODE 1 - -/* Thread ID */ -static pthread_t timer_thread; - -static int mode = CLOCK_MODE; - inline void ErrorLocation(const char *file, int line) { - fprintf(stderr, " Error in file \"%s\" at line #%d\n", file, - line); -} - -void *xmalloc(size_t size, const char *filename, int line_number) -{ - void *value; - - value = malloc(size); - - if (value == NULL) { - perror(PACKAGE); - ErrorLocation(filename, line_number); - exit(EXIT_FAILURE); - } - - return value; -} - -static void CatchTimerSignal(int signal) -{ - if (hvclock_infos.debug) - printf("%s: Catching signal SIGUSR1.\n", PACKAGE); -} - -static void SingleClick(void) -{ - int status; - - if (hvclock_infos.debug) - printf("%s: SingleClick() Entry\n", PACKAGE); - - /* single-click --> changing viewing mode */ - if (mode == CLOCK_MODE) - mode = CALENDAR_MODE; - else - mode = CLOCK_MODE; - - /* Sending a signal to awake the TimerThread() thread. */ - status = pthread_kill(timer_thread, SIGUSR1); - if (status != EXIT_SUCCESS) { - fprintf(stderr, "%s: pthread_kill() error (%d)\n", PACKAGE, - status); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } - - if (hvclock_infos.debug) - printf("%s: SingleClick() Exit\n", PACKAGE); -} - -static void *TimerThread(void *arg) -{ - unsigned int time_remaining; - unsigned int thread_sleep_time; - - thread_sleep_time = 1; /* Updates done at 5 seconds interval. */ - - /* - * For catching the termination signal SIGUSR1. This signal is sent by - * the main program thread when the user is issuing a single-click to - * switch modes. - */ - (void) signal(SIGUSR1, CatchTimerSignal); - - while (TRUE) { - if (mode == CLOCK_MODE) - UpdateClock(); - else - UpdateCalendar(); - - /* - * If sleep() returns because the requested time has elapsed, - * the value returned will be 0. If sleep() returns because of - * premature arousal due to delivery of a signal, the return - * value will be the "unslept" amount (the requested time minus - * the time actually slept) in seconds. - */ - time_remaining = sleep(thread_sleep_time); - if (time_remaining != 0) { - if (hvclock_infos.debug) { - printf("%s: TimerThread() interrupted by " - "signal\n", - PACKAGE); - } - } - } - - /* This code is never reached... */ - pthread_exit(NULL); + fprintf(stderr, " Error in file \"%s\" at line #%d\n", file, line); } /******************************************************************************* @@ -163,30 +47,14 @@ static void *TimerThread(void *arg) ******************************************************************************/ int main(int argc, char *argv[]) { - int status; - /* Initialization */ ParseCommandLineOptions(argc, argv); - /* Initialize callback function pointers. */ - ProcessXlibEventsInit(SingleClick, NULL); - /* Initializing and creating a DockApp window. */ - InitDockAppWindow(argc, argv, hvclock_xpm, - hvclock_infos.display_arg, - hvclock_infos.geometry_arg); - - /* Starting thread for periodically updating the clock. */ - status = pthread_create(&timer_thread, NULL, TimerThread, NULL); - if (status != 0) { - fprintf(stderr, "%s: Thread creation failed (%d)\n", - PACKAGE, status); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } + dockapp_init(argc, argv, hvclock_infos.display_arg, + hvclock_infos.geometry_arg); - /* Main loop, processing X Events */ - ProcessXlibEvents(); + gtk_main(); /* This code is never reached for now. */ fprintf(stderr, "%s: Program exit\n", PACKAGE); diff --git a/src/hvclock.h b/src/hvclock.h index cb70453..22ca15a 100644 --- a/src/hvclock.h +++ b/src/hvclock.h @@ -24,6 +24,7 @@ struct hvclock_t { int debug; int show_seconds; + int dockapp_mode; char *display_arg; char *geometry_arg; }; diff --git a/src/options.c b/src/options.c index 95024be..154a037 100644 --- a/src/options.c +++ b/src/options.c @@ -48,6 +48,7 @@ static void DisplayUsage(void) printf(" -display X display name\n"); printf(" -geometry +XPOS+YPOS initial window position\n"); printf(" -h display this help and exit\n"); + printf(" -n disable dockapp mode\n"); printf(" -s display seconds hand\n"); printf(" -version display version information" " and exit\n"); @@ -83,12 +84,13 @@ void ParseCommandLineOptions(int argc, char *argv[]) { int i; char *token; - int display_on = FALSE; - int geometry_on = FALSE; + int display_on = false; + int geometry_on = false; /* Default values. */ - hvclock_infos.debug = FALSE; - hvclock_infos.show_seconds = FALSE; /* This option is fixed to FALSE */ + hvclock_infos.debug = false; + hvclock_infos.show_seconds = false; + hvclock_infos.dockapp_mode = true; for (i = 1; i < argc; i++) { token = argv[i]; @@ -98,19 +100,22 @@ void ParseCommandLineOptions(int argc, char *argv[]) switch (token[1]) { case 'd': if (STREQ("display", &token[1])) - display_on = TRUE; + display_on = true; else if (strlen(&token[1]) == 1) - hvclock_infos.debug = TRUE; + hvclock_infos.debug = true; break; case 'g': if (STREQ("geometry", &token[1])) - geometry_on = TRUE; + geometry_on = true; break; case 'h': DisplayUsage(); exit(EXIT_SUCCESS); + case 'n': + hvclock_infos.dockapp_mode = false; + break; case 's': - hvclock_infos.show_seconds = TRUE; + hvclock_infos.show_seconds = true; break; case 'v': if (STREQ("version", &token[1])) { @@ -126,11 +131,11 @@ void ParseCommandLineOptions(int argc, char *argv[]) break; default: /* Processing options arguments */ - if (display_on != FALSE) { - display_on = FALSE; + if (display_on != false) { + display_on = false; hvclock_infos.display_arg = token; - } else if (geometry_on != FALSE) { - geometry_on = FALSE; + } else if (geometry_on != false) { + geometry_on = false; hvclock_infos.geometry_arg = token; } else InvalidOption("invalid option", token); @@ -138,9 +143,9 @@ void ParseCommandLineOptions(int argc, char *argv[]) } /* end switch( token[0] ) */ } /* end for */ - if (display_on != FALSE) + if (display_on != false) InvalidOption("missing display parameter", NULL); - else if (geometry_on != FALSE) + else if (geometry_on != false) InvalidOption("missing geometry parameter", NULL); } diff --git a/src/xevents.c b/src/xevents.c deleted file mode 100644 index 6ab38b2..0000000 --- a/src/xevents.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * xevents.c -- handling X events, and detecting single-click and double-click - * mouse events. - * - * Copyright (C) 2005 Hugo Villeneuve - * - * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "common.h" -#include "dockapp.h" -#include "xevents.h" - -/* Maximum time between mouse double-clicks, in milliseconds */ -#define DOUBLE_CLICK_MAX_INTERVAL_MS 250 - -/* Function pointers to handle single and double mouse click events. */ -void (*SingleClickCallback) (void) = NULL; - -void (*DoubleClickCallback) (void) = NULL; - -/* This function must be called at the beginning of your program to initialize - the function pointers to handle single and double click mouse events. */ -void -ProcessXlibEventsInit(void (*single_click_callback) (void), - void (*double_click_callback) (void)) -{ - int status; - - /* This must be called before any other XLib functions. */ - status = XInitThreads(); - if (status == 0) { - fprintf(stderr, - "%s: XInitThreads() initialization failed\n", - PACKAGE); - ErrorLocation(__FILE__, __LINE__); - exit(EXIT_FAILURE); - } - - SingleClickCallback = single_click_callback; - DoubleClickCallback = double_click_callback; -} - -/* Processing of X events */ -void ProcessXlibEvents(void) -{ - int quit = FALSE; - int button1_pressed = FALSE; - int check_for_double_click = FALSE; - XEvent Event; - - while (quit == FALSE) { - if ((check_for_double_click != FALSE) && - (XPending(dockapp.display) == 0)) { - /* - * If no other button 1 events are received after the - * delay, then it is a single-click mouse event. - */ - if (SingleClickCallback != NULL) - (*SingleClickCallback)(); - - check_for_double_click = FALSE; - } - /* - * XNextEvent is a blocking call: it will return only when an - * event is ready to be processed, thus freeing the CPU for - * other tasks when no events are available. - */ - (void) XNextEvent(dockapp.display, &Event); - switch (Event.type) { - case Expose: - /* Window was uncovered... */ - RedrawWindow(); - break; - case DestroyNotify: - /* Window was killed... */ - /* Is this necessary ? */ - (void) XCloseDisplay(dockapp.display); - quit = TRUE; - break; - case ClientMessage: - /* Doesn't seem to work... */ - printf("Client message received...\n"); - break; - case ButtonPress: - if (Event.xbutton.button == Button1) { - /* Mouse LEFT button pressed. */ - button1_pressed = TRUE; - } - break; - case ButtonRelease: - if ((Event.xbutton.button == Button1) && - (button1_pressed != FALSE)) { - /* Mouse LEFT button released. */ - if (check_for_double_click != FALSE) { - /* Double-click */ - if (DoubleClickCallback != NULL) - (*DoubleClickCallback)(); - check_for_double_click = FALSE; - } else { - (void) usleep( - DOUBLE_CLICK_MAX_INTERVAL_MS * - 1000); - check_for_double_click = TRUE; - } - } - break; - } - } /* end while */ -} diff --git a/src/xevents.h b/src/xevents.h deleted file mode 100644 index 953a075..0000000 --- a/src/xevents.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * xevents.h - * - * Copyright (C) 2005 Hugo Villeneuve - * - * 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 St, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef XEVENTS_H -#define XEVENTS_H 1 - -void -ProcessXlibEventsInit(void (*single_click_callback) (void), - void (*double_click_callback) (void)); - -void -ProcessXlibEvents(void); - -#endif /* XEVENTS_H */ -- 2.20.1