commit 69e9a61a24dbe224de78868fae35fd5bce206ee3 Author: Christopher Michael Date: Mon Dec 19 22:39:11 2005 +0000 Add tclock module to e_modules SVN revision: 19160 diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..6859961 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,22 @@ +.deps +.libs +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +config.guess +config.h +config.h.in +config.log +config.status +config.sub +configure +depcomp +install-sh +libtool +missing +ltmain.sh +stamp-h1 +*.lo +*.la +*.edj diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..7c4847a --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Originally by Vincent 'caro' Torri, additions by various Enlightenment developers diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..41ab9c2 --- /dev/null +++ b/COPYING @@ -0,0 +1 @@ +Do whatever you want with this code.... it sucks anyway :d diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..ffdfa1b --- /dev/null +++ b/ChangeLog @@ -0,0 +1,2 @@ +09/06/2005 Christopher Michael + * Added Support For Virtual Desktops diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..54caf7c --- /dev/null +++ b/INSTALL @@ -0,0 +1,229 @@ +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Foundation, Inc. + + This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the `--target=TYPE' option to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + + Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +will cause the specified gcc to be used as the C compiler (unless it is +overridden in the site shell script). + +`configure' Invocation +====================== + + `configure' recognizes the following options to control how it +operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..894dea2 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,29 @@ +MAINTAINERCLEANFILES = Makefile.in + +EDJE_CC = @edje_cc@ +EDJE_FLAGS = -id $(srcdir)/images -fd $(srcdir)/fonts + +filesdir = $(datadir) +files_DATA = module_icon.png $(wildcard tclock.ed?) \ + $(wildcard fonts/*.ttf) $(wildcard images/*.png) + +EXTRA_DIST = $(files_DATA) e_modules-tclock.spec + +# the module .so file +INCLUDES = -I. \ + -I$(top_srcdir) \ + -I$(includedir) \ + @e_cflags@ +pkgdir = $(datadir)/$(MODULE_ARCH) + +pkg_LTLIBRARIES = module.la +module_la_SOURCES = e_mod_main.c \ + e_mod_main.h \ + e_mod_config.c \ + e_mod_config.h +module_la_LIBADD = @e_libs@ +module_la_LDFLAGS = -module -avoid-version +module_la_DEPENDENCIES = $(top_builddir)/config.h $(top_builddir)/tclock.edj + +%.edj: %.edc + $(EDJE_CC) $(EDJE_FLAGS) $< $@ diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..f97d44b --- /dev/null +++ b/README @@ -0,0 +1,31 @@ +Simple TEXT Clock module for e17 v0.2 +... it suck less (from you computer resouces) +------------------------------------------------ +made by adi roiban for e17 community + +========================================================= +many thanks to Michael Jennings for making this package +======================================================== + +now let's go +--- +to modify the clock format read the documentation from stftime +and modify the tclock_format part from tclock.edc file then recompile tclock.edc + +so just look for something like /usr/lib/e_modules/tclock +and there you should file an tclock.edc file +hack that file and after that compile it with +edje_cc tclock.edc + +for example you can change the background, just replace the background.png +file and recompile tclock.edc + +restart e17 and you should see the changes + +if you had problems using this module +please write me at adiroiban@gmail.com + +--------------------------------------------------- +now you must restart(reload the module, don't press that button) + when you chose the time resolution.... i do not master e_core_timers + so i can not say it the times work corectly or not. \ No newline at end of file diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..0846992 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +rm -rf autom4te.cache +rm -f aclocal.m4 ltmain.sh + +touch README + +echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1 +echo "Running autoheader..." ; autoheader || exit 1 +echo "Running autoconf..." ; autoconf || exit 1 +echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 +echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 + +if [ -z "$NOCONFIGURE" ]; then + ./configure "$@" +fi diff --git a/configure.in b/configure.in new file mode 100644 index 0000000..466708f --- /dev/null +++ b/configure.in @@ -0,0 +1,193 @@ +dnl Process this file with autoconf to produce a configure script. + +# get rid of that stupid cache mechanism +rm -f config.cache + +AC_INIT(configure.in) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST + +AM_INIT_AUTOMAKE(tclock, 0.0.2) +AM_CONFIG_HEADER(config.h) +AC_ISC_POSIX +AC_PROG_CC +AM_PROG_CC_STDC +AC_HEADER_STDC +AC_C_CONST +AM_ENABLE_SHARED +AM_PROG_LIBTOOL + +MODULE_ARCH="$host_os-$host_cpu" +AC_SUBST(MODULE_ARCH) +AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture") + +if test "x${bindir}" = 'x${exec_prefix}/bin'; then + if test "x${exec_prefix}" = "xNONE"; then + if test "x${prefix}" = "xNONE"; then + bindir="${ac_default_prefix}/bin"; + else + bindir="${prefix}/bin"; + fi + else + if test "x${prefix}" = "xNONE"; then + bindir="${ac_default_prefix}/bin"; + else + bindir="${prefix}/bin"; + fi + fi +fi + +if test "x${libdir}" = 'x${exec_prefix}/lib'; then + if test "x${exec_prefix}" = "xNONE"; then + if test "x${prefix}" = "xNONE"; then + libdir="${ac_default_prefix}/lib"; + else + libdir="${prefix}/lib"; + fi + else + if test "x${prefix}" = "xNONE"; then + libdir="${ac_default_prefix}/lib"; + else + libdir="${prefix}/lib"; + fi + fi +fi + +dnl Set PACKAGE_BIN_DIR in config.h. +if test "x${bindir}" = 'xNONE'; then + if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin", "Package installed binaries destination") + else + AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin", "Package installed binaries destination") + fi +else + AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", "Package installed binaries destination") +fi + +dnl Set PACKAGE_LIB_DIR in config.h. +if test "x${libdir}" = 'xNONE'; then + if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", "Package installed libraries destination") + else + AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", "Package installed libraries destination") + fi +else + AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", "Package installed libraries destination") +fi + +dnl Set PACKAGE_DATA_DIR in config.h. +if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${HOME}/.e/e/modules/${PACKAGE}", "Package installed data destination") + datadir="${HOME}/.e/e/modules/${PACKAGE}" +else + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/lib/enlightenment/modules/${PACKAGE}", "Package installed data destination") + datadir="${prefix}/lib/enlightenment/modules/${PACKAGE}" +fi + +#AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl) +#AC_SUBST(dlopen_libs) + +AC_ARG_WITH(ecore-config, +[ --with-ecore-config=ECORE_CONFIG use ecore-config specified ], +[ + ECORE_CONFIG=$withval; + echo "using "$ECORE_CONFIG" for ecore-config"; +],[ + PROG="ecore-config"; + AC_PATH_PROG(ECORE_CONFIG, $PROG, "", $PATH) +]) +ecore_cflags=`$ECORE_CONFIG --cflags` +ecore_libs=`$ECORE_CONFIG --libs` +AC_SUBST(ecore_cflags) +AC_SUBST(ecore_libs) + +AC_ARG_WITH(evas-config, +[ --with-evas-config=EVAS_CONFIG use evas-config specified ], +[ + EVAS_CONFIG=$withval; + echo "using "$EVAS_CONFIG" for evas-config"; +],[ + PROG="evas-config"; + AC_PATH_PROG(EVAS_CONFIG, $PROG, "", $PATH) +]) +evas_cflags=`$EVAS_CONFIG --cflags` +evas_libs=`$EVAS_CONFIG --libs` +AC_SUBST(evas_cflags) +AC_SUBST(evas_libs) + +AC_ARG_WITH(esmart-config, +[ --with-esmart-config=ESMART_CONFIG use esmart-config specified ], +[ + ESMART_CONFIG=$withval; + echo "using "$ESMART_CONFIG" for esmart-config"; +],[ + PROG="esmart-config"; + AC_PATH_PROG(ESMART_CONFIG, $PROG, "", $PATH) +]) +esmart_cflags=`$ESMART_CONFIG --cflags` +esmart_libs=`$ESMART_CONFIG --libs` +AC_SUBST(esmart_cflags) +AC_SUBST(esmart_libs) + +AC_ARG_WITH(edje-config, +[ --with-edje-config=EDJE_CONFIG use edje-config specified ], +[ + EDJE_CONFIG=$withval; + echo "using "$EDJE_CONFIG" for edje-config"; +/ +],[ + PROG="edje-config"; + AC_PATH_PROG(EDJE_CONFIG, $PROG, "", $PATH) +]) +edje_cflags=`$EDJE_CONFIG --cflags` +edje_libs=`$EDJE_CONFIG --libs` +AC_SUBST(edje_cflags) +AC_SUBST(edje_libs) + +edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc" +AC_ARG_WITH(edje-cc, +[ --with-edje-cc=PATH specify a specific path to edje_cc], +[ + v=$withval; + edje_cc=$v + echo " Enlightenment edje_cc explicitly set to "$edje_cc; +],[ + edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc" +]) +AC_SUBST(edje_cc) + +AC_ARG_WITH(eet-config, +[ --with-eet-config=EET_CONFIG use eet-config specified ], +[ + EET_CONFIG=$withval; + echo "using "$EET_CONFIG" for eet-config"; +],[ + PROG="eet-config"; + AC_PATH_PROG(EET_CONFIG, $PROG, "", $PATH) +]) +eet_cflags=`$EET_CONFIG --cflags` +eet_libs=`$EET_CONFIG --libs` +AC_SUBST(eet_cflags) +AC_SUBST(eet_libs) + +AC_ARG_WITH(enlightenment-config, +[ --with-enlightenment-config=E_CONFIG use enlightenment-config specified ], +[ + E_CONFIG=$withval; + echo "using "$E_CONFIG" for enlightenment-config"; +],[ + PROG="enlightenment-config"; + AC_PATH_PROG(E_CONFIG, $PROG, "", $PATH) +]) +e_cflags=`$E_CONFIG --cflags` +e_libs=`$E_CONFIG --libs` +e_modules=`$E_CONFIG --module-dir` +AC_SUBST(e_cflags) +AC_SUBST(e_libs) +AC_SUBST(e_modules) + +AC_OUTPUT([ +Makefile +],[ +]) + diff --git a/e_mod_config.c b/e_mod_config.c new file mode 100644 index 0000000..6fc871d --- /dev/null +++ b/e_mod_config.c @@ -0,0 +1,92 @@ +#include "e.h" +#include "e_mod_main.h" + +typedef struct _cfdata CFData; +typedef struct _Cfg_File_Data Cfg_File_Data; + +struct _cfdata +{ + int resolution; +}; + +struct _Cfg_File_Data +{ + E_Config_Dialog *cfd; + char *file; +}; + +/* Protos */ +static void *_create_data(E_Config_Dialog *cfd); +static void _free_data(E_Config_Dialog *cfd, CFData *cfdata); +static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata); +static int _basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata); + +void +_config_tclock_module(E_Container *con, TClock_Face *f) +{ + E_Config_Dialog *cfd; + E_Config_Dialog_View v; + + v.create_cfdata = _create_data; + v.free_cfdata = _free_data; + v.basic.apply_cfdata = _basic_apply_data; + v.basic.create_widgets = _basic_create_widgets; + v.advanced.apply_cfdata = NULL; + v.advanced.create_widgets = NULL; + + cfd = e_config_dialog_new(con, _("Tclock Configuration"), NULL, 0, &v, f); +} + +static void +_fill_data(TClock_Face *f, CFData *cfdata) +{ + cfdata->resolution = f->conf->resolution; +} + +static void +*_create_data(E_Config_Dialog *cfd) +{ + CFData *cfdata; + TClock_Face *f; + + f = cfd->data; + cfdata = E_NEW(CFData, 1); + _fill_data(f, cfdata); + return cfdata; +} + +static void +_free_data(E_Config_Dialog *cfd, CFData *cfdata) +{ + free(cfdata); +} + +static Evas_Object +*_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, CFData *cfdata) +{ + Evas_Object *o, *of, *ob; + E_Radio_Group *rg; + + o = e_widget_list_add(evas, 0, 0); + of = e_widget_framelist_add(evas, _("Resolution"), 0); + rg = e_widget_radio_group_new(&(cfdata->resolution)); + ob = e_widget_radio_add(evas, _("1 Minute"), RESOLUTION_MINUTE ,rg); + e_widget_framelist_object_append(of, ob); + ob = e_widget_radio_add(evas, _("1 Second"), RESOLUTION_SECOND ,rg); + e_widget_framelist_object_append(of, ob); + e_widget_list_object_append(o, of, 1, 1, 0.5); + return o; +} + +static int +_basic_apply_data(E_Config_Dialog *cfd, CFData *cfdata) +{ + TClock_Face *f; + + f = cfd->data; + e_border_button_bindings_ungrab_all(); + f->conf->resolution = cfdata->resolution; + e_config_save_queue(); + e_border_button_bindings_grab_all(); + return 1; +} diff --git a/e_mod_config.h b/e_mod_config.h new file mode 100644 index 0000000..eb50386 --- /dev/null +++ b/e_mod_config.h @@ -0,0 +1,8 @@ +#ifdef E_TYPEDEFS +#else +#ifndef E_MOD_CONFIG_H +#define E_MOD_CONFIG_H +#include "e_mod_main.h" +EAPI void _config_tclock_module(E_Container *con, TClock_Face *f); +#endif +#endif diff --git a/e_mod_main.c b/e_mod_main.c new file mode 100644 index 0000000..747fa45 --- /dev/null +++ b/e_mod_main.c @@ -0,0 +1,435 @@ +#include +#include "e.h" +#include "e_mod_main.h" +#include "e_mod_config.h" + +static TClock* _tclock_new(); +static void _tclock_shutdown(TClock *tclock); +static void _tclock_config_menu_new(TClock *tclock); + +static TClock_Face *_tclock_face_new(E_Container *con); +static void _tclock_face_free(TClock_Face *face); +static void _tclock_face_menu_new(TClock_Face *face); + +static void _tclock_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change); + +static void _tclock_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj,void *event_info); +static void _tclock_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi); +static void _tclock_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi); + +static int _tclock_cb_check(void *data); + +static E_Config_DD *conf_edd; +static E_Config_DD *conf_face_edd; + +static int _tclock_count; + +/*public code******************************/ +E_Module_Api e_modapi = +{ + E_MODULE_API_VERSION, + "TClock" +}; + +void +*e_modapi_init(E_Module *module) +{ + TClock *tclock; + tclock = _tclock_new(); + module->config_menu =tclock->config_menu; + return tclock; +} + +int +e_modapi_shutdown(E_Module *module) +{ + TClock *tclock; + + if (module->config_menu) + module->config_menu = NULL; + + tclock = module->data; + if (tclock) + _tclock_shutdown(tclock); + + return 1; +} + +int +e_modapi_info(E_Module *module) +{ + module->icon_file = strdup(PACKAGE_DATA_DIR "/module_icon.png"); + return 1; +} + +int +e_modapi_save(E_Module *module) +{ + TClock *tclock; + + tclock = module->data; + e_config_domain_save("module.tclock", conf_edd, tclock->conf); + return 1; +} + +int +e_modapi_about(E_Module *module) +{ + e_module_dialog_show("Simple Digital Clock", "Displays a digital clock on the desktop"); + return 1; +} + +int +e_modapi_config(E_Module *module) +{ + Evas_List *l; + TClock *t; + TClock_Face *tf; + + t = module->data; + for (l = t->faces; l; l = l->next) + { + tf = l->data; + if (tf->tclock == t) + { + /* Configure Clock */ + _config_tclock_module(tf->con, tf); + break; + } + } + return 1; +} + +/****************************************************************** + * private functions + ****************************************************************/ +static TClock +*_tclock_new() +{ + TClock *tclock; + Evas_List *managers, *l, *l2, *cl; + E_Menu_Item *mi; + + _tclock_count = 0; + + tclock=E_NEW(TClock,1); + if (!tclock) return NULL; + + conf_face_edd = E_CONFIG_DD_NEW("TClock_Config_Face", Config_Face); +#undef T +#undef D +#define T Config_Face +#define D conf_face_edd + E_CONFIG_VAL(D, T, enabled, UCHAR); + E_CONFIG_VAL(D, T, resolution, UINT); + E_CONFIG_VAL(D, T, format, STR); + + conf_edd = E_CONFIG_DD_NEW("TClock_Config", Config); +#undef T +#undef D +#define T Config +#define D conf_edd + E_CONFIG_LIST(D, T, faces, conf_face_edd); + E_CONFIG_VAL(D, T, poll_time, DOUBLE); + + tclock->conf = e_config_domain_load("module.tclock", conf_edd); + + if (!tclock->conf) + { + tclock->conf = E_NEW(Config, 1); + tclock->conf->poll_time = 60.0; + } + + _tclock_config_menu_new(tclock); + + managers = e_manager_list(); + cl = tclock->conf->faces; + for (l = managers; l; l = l->next) + { + E_Manager *man; + + man = l->data; + for (l2 = man->containers; l2; l2 = l2->next) + { + E_Container *con; + TClock_Face *face; + + con = l2->data; + face = _tclock_face_new(con); + if (face) + { + face->tclock = tclock; + tclock->faces = evas_list_append(tclock->faces, face); + + /* Config */ + if (!cl) + { + face->conf = E_NEW(Config_Face, 1); + /* set instance config values*/ + face->conf->enabled = 1; + face->conf->resolution = RESOLUTION_MINUTE; + tclock->conf->faces = evas_list_append(tclock->conf->faces, face->conf); + } + else + { + face->conf = cl->data; + cl = cl->next; + } + + if (face->conf->resolution == RESOLUTION_SECOND) + { + E_CONFIG_LIMIT(tclock->conf->poll_time, 0.1, 1.0); + tclock->tclock_check_timer = ecore_timer_add(tclock->conf->poll_time, _tclock_cb_check, tclock); + TCLOCK_DEBUG("RES_SEC"); + } + else + { + E_CONFIG_LIMIT(tclock->conf->poll_time, 1.0, 60.0); + tclock->tclock_check_timer = ecore_timer_add(tclock->conf->poll_time, _tclock_cb_check, tclock); + TCLOCK_DEBUG("RES_MIN"); + } + + /* Menu */ + /* This menu must be initialized after conf */ + _tclock_face_menu_new(face); + + mi = e_menu_item_new(tclock->config_menu); + e_menu_item_label_set(mi, _("Configuration")); + e_menu_item_callback_set(mi, _tclock_face_cb_menu_configure, face); + + mi = e_menu_item_new(tclock->config_menu); + e_menu_item_label_set(mi, con->name); + e_menu_item_submenu_set(mi, face->menu); + + } + } + } + return tclock; +} + +static void +_tclock_shutdown (TClock *tclock) +{ + Evas_List *list; + + E_CONFIG_DD_FREE(conf_edd); + E_CONFIG_DD_FREE(conf_face_edd); + + ecore_timer_del(tclock->tclock_check_timer); + + for (list = tclock->faces; list; list = list->next) + _tclock_face_free(list->data); + evas_list_free(tclock->faces); + + e_object_del(E_OBJECT(tclock->config_menu)); + + evas_list_free(tclock->conf->faces); + free(tclock->conf); + free(tclock); +} + +static void +_tclock_config_menu_new(TClock *tclock) +{ + tclock->config_menu = e_menu_new(); +} + +static TClock_Face +*_tclock_face_new(E_Container *con) +{ + TClock_Face *face; + Evas_Object *o; + Evas_Coord x, y, w, h; + + face = E_NEW(TClock_Face, 1); + if (!face) return NULL; + + face->con = con; + e_object_ref(E_OBJECT(con)); + + evas_event_freeze(con->bg_evas); + o = edje_object_add(con->bg_evas); + face->tclock_object = o; + + edje_object_file_set(o, PACKAGE_DATA_DIR"/tclock.edj", "tclock/main"); + evas_object_show(o); + + o = evas_object_rectangle_add(con->bg_evas); + face->event_object = o; + evas_object_layer_set(o, 2); + evas_object_repeat_events_set(o, 1); + evas_object_color_set(o, 0, 0, 0, 0); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _tclock_face_cb_mouse_down, face); + evas_object_show(o); + + evas_object_resize(face->tclock_object, 200, 200); + edje_object_calc_force(face->tclock_object); + edje_object_part_geometry_get(face->tclock_object, "main", &x, &y, &w, &h); + face->inset.l = x; + face->inset.r = 200 - (x + w); + face->inset.t = y; + face->inset.b = 200 - (y + h); + + face->gmc = e_gadman_client_new(con->gadman); + e_gadman_client_domain_set(face->gmc, "module.tclock", _tclock_count++); + e_gadman_client_policy_set(face->gmc, + E_GADMAN_POLICY_ANYWHERE | + E_GADMAN_POLICY_HMOVE | + E_GADMAN_POLICY_VMOVE | + E_GADMAN_POLICY_HSIZE | + E_GADMAN_POLICY_VSIZE); + e_gadman_client_min_size_set(face->gmc, 4, 4); + e_gadman_client_max_size_set(face->gmc, 512, 512); + e_gadman_client_auto_size_set(face->gmc, + 40 + (face->inset.l + face->inset.r), + 40 + (face->inset.t + face->inset.b)); + + e_gadman_client_align_set(face->gmc, 1.0, 1.0); + //e_gadman_client_aspect_set(face->gmc, 1.0, 1.0); + e_gadman_client_padding_set(face->gmc, + face->inset.l, face->inset.r, + face->inset.t, face->inset.b); + + e_gadman_client_resize(face->gmc, + 40 + (face->inset.l + face->inset.r), + 40 + (face->inset.t + face->inset.b)); + + e_gadman_client_change_func_set(face->gmc, _tclock_face_cb_gmc_change, face); + e_gadman_client_load(face->gmc); + + evas_event_thaw(con->bg_evas); + + return face; +} + +static void +_tclock_face_free(TClock_Face *face) +{ + e_object_unref(E_OBJECT(face->con)); + e_object_del(E_OBJECT(face->gmc)); + evas_object_del(face->tclock_object); + evas_object_del(face->event_object); + e_object_del(E_OBJECT(face->menu)); + + free(face->conf); + free(face); + _tclock_count--; +} + +static int +_tclock_cb_check(void *data) +{ + TClock *tclock; + Evas_List *l; + time_t current_time; + struct tm *local_time; + char buf[TIME_BUF]; + + memset(buf, 0, sizeof(buf)); + current_time=time(NULL); + local_time = localtime(¤t_time); + + //strftime (buf,TIME_BUF, "%a %d,%b %H:%M", local_time); + + tclock = data; + for (l = tclock->faces; l; l = l->next) + { + TClock_Face *face; + face = l->data; + + const char *format; + format = edje_object_part_state_get(face->tclock_object, "tclock_format",NULL); + face->conf->format = format; + + strftime (buf,TIME_BUF, face->conf->format, local_time); + + TCLOCK_DEBUG(face->conf->format); + edje_object_part_text_set(face->tclock_object, "tclock_text", buf); + e_config_save_queue(); + } +} + +static void +_tclock_face_menu_new(TClock_Face *face) +{ + E_Menu *mn, *smn; + E_Menu_Item *mi; + + mn = e_menu_new(); + face->menu = mn; + + mi = e_menu_item_new(mn); + e_menu_item_label_set(mi, _("Configuration")); + e_menu_item_callback_set(mi, _tclock_face_cb_menu_configure, face); + + /* Edit */ + mi = e_menu_item_new(mn); + e_menu_item_label_set(mi, _("Edit Mode")); + e_menu_item_callback_set(mi, _tclock_face_cb_menu_edit, face); +} + +static void +_tclock_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change) +{ + TClock_Face *face; + Evas_Coord x, y, w, h; + + face = data; + switch (change) + { + case E_GADMAN_CHANGE_MOVE_RESIZE: + e_gadman_client_geometry_get(face->gmc, &x, &y, &w, &h); + evas_object_move(face->tclock_object, x, y); + evas_object_move(face->event_object, x, y); + evas_object_resize(face->tclock_object, w, h); + evas_object_resize(face->event_object, w, h); + break; + case E_GADMAN_CHANGE_RAISE: + evas_object_raise(face->tclock_object); + evas_object_raise(face->event_object); + break; + case E_GADMAN_CHANGE_EDGE: + case E_GADMAN_CHANGE_ZONE: + /* FIXME + * Must we do something here? + */ + break; + } +} + +static void +_tclock_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + TClock_Face *face; + Evas_Event_Mouse_Down *ev; + + face = data; + ev = event_info; + + if (ev->button == 3) + { + e_menu_activate_mouse(face->menu, e_zone_current_get(face->con), + ev->output.x, ev->output.y, 1, 1, + E_MENU_POP_DIRECTION_DOWN, ev->timestamp); + e_util_container_fake_mouse_up_all_later(face->con); + } +} + +static void +_tclock_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi) +{ + TClock_Face *face; + + face = data; + e_gadman_mode_set(face->gmc->gadman, E_GADMAN_MODE_EDIT); +} + +static void +_tclock_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi) +{ + TClock_Face *f; + + f = data; + if (!f) return; + _config_tclock_module(f->con, f); +} diff --git a/e_mod_main.h b/e_mod_main.h new file mode 100644 index 0000000..8c26e45 --- /dev/null +++ b/e_mod_main.h @@ -0,0 +1,65 @@ +#ifndef E_MOD_MAIN_H +#define E_MOD_MAIN_H + +#define RESOLUTION_MINUTE 0 +#define RESOLUTION_SECOND 1 + +#define TIME_BUF 1024 +#define FORMAT_BUF_SIZE 1024 +#define TCLOCK_DEBUG(X) (printf("tclock_debug: %s\n",X)) +#undef TCLOCK_DEBUG +#define TCLOCK_DEBUG(X) +typedef struct _Config +{ + Evas_List *faces; + double poll_time; + +}Config; + +typedef struct _Config_Face +{ + unsigned char enabled; + unsigned int resolution; + const char *format; +}Config_Face; + + +typedef struct _TClock +{ + Evas_List *faces; + E_Menu *config_menu; + Config *conf; + + Ecore_Timer *tclock_check_timer; +}TClock; + +typedef struct _TClock_Face +{ + E_Container *con; + E_Menu *menu; + E_Menu *resolution_menu; + Config_Face *conf; + TClock *tclock; + + struct { + Evas_Coord l, r, t, b; + } inset; + + Evas_Object *tclock_object; + Evas_Object *event_object; + + E_Gadman_Client *gmc; +}TClock_Face; + + +extern E_Module_Api e_modapi; + +EAPI void *e_modapi_init (E_Module *m); +EAPI int e_modapi_shutdown (E_Module *m); +EAPI int e_modapi_save (E_Module *m); +EAPI int e_modapi_info (E_Module *m); +EAPI int e_modapi_about (E_Module *m); + +EAPI void _tclock_cb_config_updated(void *data); + +#endif diff --git a/e_modules-tclock.spec b/e_modules-tclock.spec new file mode 100644 index 0000000..9fb81cf --- /dev/null +++ b/e_modules-tclock.spec @@ -0,0 +1,45 @@ +%define e_module_name tclock + +Summary: Text-based clock module for Enlightenment +Name: e_modules-%{e_module_name} +Version: 0.0.1 +Release: 1.%{?_vendorsuffix:%{_vendorsuffix}}%{!?_vendorsuffix:%{_vendor}} +License: Public Domain +Group: User Interface/X +Source: http://c7obs.net/~adi/projects/e17/%{e_module_name}-%{version}.tar.gz +Packager: %{?_packager:%{_packager}}%{!?_packager:%{_vendor}} +Vendor: %{?_vendorinfo:%{_vendorinfo}}%{!?_vendorinfo:%{_vendor}} +Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} +BuildRequires: enlightenment-devel esmart-devel +Prefix: %{_prefix} +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root + +%description +Text-based clock module for Enlightenment 0.16.999 or greater. + +%prep +%setup -q -n %{e_module_name}-%{version} + +%build +CFLAGS="%{?cflags:%{cflags}}%{!?cflags:$RPM_OPT_FLAGS}" +CXXFLAGS="%{?cxxflags:%{cxxflags}}%{!?cflags:$RPM_OPT_FLAGS}" +export CFLAGS CXXFLAGS + +%configure %{?acflags} +%{__make} %{?mflags} + +%install +%{__make} install DESTDIR=$RPM_BUILD_ROOT %{?mflags_install} + +%clean +test "x$RPM_BUILD_ROOT" != "x/" && rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-, root, root) +%{_libdir}/e_modules/%{e_module_name} +%{_libdir}/enlightenment/modules_extra/%{e_module_name} + +%changelog +* Mon Oct 17 2005 Mezzanine +- Specfile auto-generated by Mezzanine + diff --git a/module_icon.png b/module_icon.png new file mode 100644 index 0000000..888c10b Binary files /dev/null and b/module_icon.png differ diff --git a/tclock.edc b/tclock.edc new file mode 100644 index 0000000..baa233f --- /dev/null +++ b/tclock.edc @@ -0,0 +1,73 @@ +// Sample EDC +images { + image, "background.png" COMP; +} +collections { + group { + name, "tclock/main"; + min, 32 32; + max, 1024 768; + + parts { + part { + name, "background"; + type, IMAGE; + mouse_events, 0; + description { + state, "default" 0.0; + rel1 { + relative, 0.0 0.0; + offset, 0 0; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + } + image { + normal, "background.png"; + } + + } + } + +part { + name: "tclock_format"; + type: TEXT; + mouse_events, 0; + description { + state: " %a %d,%b %H:%M" 0.0; + } +} + +part { + name: "tclock_text"; + type: TEXT; + effect: SOFT_SHADOW; + mouse_events, 0; + + description { + state, "default" 0.0; + rel1 { + relative, 0.0 0.0; + offset, 0 0; + } + + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + } + color: 255 255 255 230; + //color2: 0 0 255 155; + color3: 0 0 0 50; + text { + text, "Starting the clock..."; + font, "vera"; + size, 16; + align, 0.5 0.5; + } +} +} +} /* Close Parts */ + +} /* Close Group */ +} /* Close Coll */