Enlightenment CVS committal
Author : devilhorns
Project : e_modules
Module : tclock
Dir : e_modules/tclock
Modified Files:
Makefile.am e_mod_config.c e_mod_main.c e_mod_main.h
tclock.edc
Log Message:
Turn tclock into a gadget for the shelf.
Much more configurable now.
NOTE: You will need to remove your old module.tclock.cfg .
NOTE: Themers and Translators may need to update their work for this.
===================================================================
RCS file: /cvs/e/e_modules/tclock/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- Makefile.am 10 Apr 2006 20:58:55 -0000 1.3
+++ Makefile.am 16 May 2006 16:44:52 -0000 1.4
@@ -6,8 +6,11 @@
EDJE_FLAGS = -id $(srcdir)/images -fd $(srcdir)/fonts
filesdir = $(datadir)
-files_DATA = module_icon.png $(wildcard tclock.ed?) \
- $(wildcard fonts/*.ttf) $(wildcard images/*.png)
+files_DATA = module_icon.png \
+ module.eap \
+ $(wildcard tclock.ed?) \
+ $(wildcard fonts/*.ttf) \
+ $(wildcard images/*.png)
EXTRA_DIST = $(files_DATA) e_modules-tclock.spec
CONFIG_CLEAN_FILES = e_modules-tclock.spec tclock.edj
@@ -22,8 +25,7 @@
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
- e_mod_config.c \
- e_mod_config.h
+ e_mod_config.c
module_la_LIBADD = @e_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h $(top_builddir)/tclock.edj
===================================================================
RCS file: /cvs/e/e_modules/tclock/e_mod_config.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- e_mod_config.c 16 May 2006 05:23:26 -0000 1.16
+++ e_mod_config.c 16 May 2006 16:44:52 -0000 1.17
@@ -1,12 +1,13 @@
#include <e.h>
#include "e_mod_main.h"
-#include "e_mod_config.h"
struct _E_Config_Dialog_Data
{
int resolution;
- char *format;
- int userformat;
+ int show_date;
+ int show_time;
+ char *time_format;
+ char *date_format;
};
/* Protos */
@@ -14,14 +15,16 @@
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
E_Config_Dialog_Data *cfdata);
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data
*cfdata);
-static void onCheckChange(void *data, Evas_Object *obj);
+static void onTimeCheckChange(void *data, Evas_Object *obj);
+static void onDateCheckChange(void *data, Evas_Object *obj);
void
-_config_tclock_module(E_Container *con, TClock_Face *f)
+_config_tclock_module(void)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
-
+ E_Container *con;
+
v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _create_data;
@@ -29,43 +32,51 @@
v->basic.apply_cfdata = _basic_apply_data;
v->basic.create_widgets = _basic_create_widgets;
- cfd = e_config_dialog_new(con, D_("Tclock Configuration"), NULL, 0, v, f);
+ con = e_container_current_get(e_manager_current_get());
+ cfd = e_config_dialog_new(con, D_("Tclock Configuration"), NULL, 0, v,
NULL);
+ tclock_config->config_dialog = cfd;
}
static void
-_fill_data(TClock_Face *f, E_Config_Dialog_Data *cfdata)
+_fill_data(E_Config_Dialog_Data *cfdata)
{
- cfdata->resolution = f->conf->resolution;
- cfdata->format = strdup(f->conf->format);
- cfdata->userformat = f->conf->userformat;
+ if (!tclock_config)
+ return;
+
+ cfdata->resolution = tclock_config->resolution;
+ cfdata->show_time = tclock_config->show_time;
+ cfdata->show_date = tclock_config->show_date;
+ cfdata->time_format = strdup(tclock_config->time_format);
+ cfdata->date_format = strdup(tclock_config->date_format);
}
static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
- TClock_Face *f;
- f = cfd->data;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
-
- _fill_data(f, cfdata);
+ _fill_data(cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
+ if (!tclock_config)
+ return;
+ tclock_config->config_dialog = NULL;
free(cfdata);
}
static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
*cfdata)
{
- Evas_Object *o, *of, *ob, *entry, *checked;
+ Evas_Object *o, *of, *ob, *time_entry, *time_check, *date_entry,
*date_check;
E_Radio_Group *rg;
o = e_widget_list_add(evas, 0, 0);
+
of = e_widget_framelist_add(evas, D_("Resolution"), 0);
rg = e_widget_radio_group_new(&(cfdata->resolution));
ob = e_widget_radio_add(evas, D_("1 Minute"), RESOLUTION_MINUTE, rg);
@@ -74,64 +85,67 @@
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
- of = e_widget_frametable_add(evas, D_("Time Format"), 1);
- checked = e_widget_check_add(evas, D_("User format String"),
&(cfdata->userformat));
- if (cfdata->userformat)
- e_widget_check_checked_set(checked, 1);
- e_widget_frametable_object_append(of, checked, 0, 0, 1, 1, 1, 0, 1, 0);
-
- entry = e_widget_entry_add(evas, &cfdata->format);
- e_widget_disabled_set(entry, !cfdata->userformat);
- //e_widget_min_size_set(entry, 150, 1);
- e_widget_frametable_object_append(of, entry, 0, 1, 1, 1, 1, 0, 1, 0);
-
+ of = e_widget_frametable_add(evas, D_("Date"), 1);
+ date_check = e_widget_check_add(evas, D_("Show Date"),
&(cfdata->show_date));
+ if (cfdata->show_date)
+ e_widget_check_checked_set(date_check, 1);
+ e_widget_frametable_object_append(of, date_check, 0, 0, 1, 1, 1, 0, 1, 0);
+ date_entry = e_widget_entry_add(evas, &cfdata->date_format);
+ e_widget_on_change_hook_set(date_check, onDateCheckChange, date_entry);
+ e_widget_disabled_set(date_entry, !cfdata->show_date);
+ e_widget_min_size_set(date_entry, 150, 1);
+ e_widget_frametable_object_append(of, date_entry, 0, 1, 1, 1, 1, 0, 1, 0);
ob = e_widget_label_add(evas, D_("Consult strftime(3) for format syntax"));
- e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0);
- ob = e_widget_label_add(evas, D_("If you wish to insert %n use <br>
instead"));
- e_widget_frametable_object_append(of, ob, 0, 3, 1, 1, 1, 0, 1, 0);
-
-// ob = e_widget_label_add(evas, "");
-// e_widget_frametable_object_append(of, ob, 0, 1, 1, 1, 1, 0, 1, 0);
+ e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0);
e_widget_list_object_append(o, of, 1, 1, 0.5);
- e_widget_on_change_hook_set(checked, onCheckChange, entry);
-
+
+ of = e_widget_frametable_add(evas, D_("Time"), 1);
+ time_check = e_widget_check_add(evas, D_("Show Time"),
&(cfdata->show_time));
+ if (cfdata->show_time)
+ e_widget_check_checked_set(time_check, 1);
+ e_widget_frametable_object_append(of, time_check, 0, 0, 1, 1, 1, 0, 1, 0);
+ time_entry = e_widget_entry_add(evas, &cfdata->time_format);
+ e_widget_on_change_hook_set(time_check, onTimeCheckChange, time_entry);
+ e_widget_disabled_set(time_entry, !cfdata->show_time);
+ e_widget_min_size_set(time_entry, 150, 1);
+ e_widget_frametable_object_append(of, time_entry, 0, 1, 1, 1, 1, 0, 1, 0);
+ ob = e_widget_label_add(evas, D_("Consult strftime(3) for format syntax"));
+ e_widget_frametable_object_append(of, ob, 0, 2, 1, 1, 1, 0, 1, 0);
+ e_widget_list_object_append(o, of, 1, 1, 0.5);
+
return o;
}
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
- TClock_Face *f;
-
- f = cfd->data;
- if (cfdata->resolution != f->conf->resolution)
- {
- if (cfdata->resolution == RESOLUTION_MINUTE)
- f->tclock->conf->poll_time = 60.0;
- else
- f->tclock->conf->poll_time = 1.0;
- ecore_timer_interval_set(f->tclock->tclock_check_timer,
f->tclock->conf->poll_time);
- }
- f->conf->resolution = cfdata->resolution;
- f->conf->userformat = cfdata->userformat;
-
- /* update the format string with the format string given by the user
- * when the userformat is true and the string(typed by the user) isn't
empty */
- if (f->conf->format)
- evas_stringshare_del(f->conf->format);
+ if (!tclock_config)
+ return;
- if (cfdata->userformat && (strlen(cfdata->format) > 0))
- f->conf->format = (char *)evas_stringshare_add(cfdata->format);
+ tclock_config->resolution = cfdata->resolution;
+ if (cfdata->resolution == RESOLUTION_MINUTE)
+ tclock_config->poll_time = 60.0;
else
- f->conf->format = (char *)evas_stringshare_add("%c");
-
- e_config_save_queue();
-
+ tclock_config->poll_time = 1.0;
+
+ tclock_config->show_date = cfdata->show_date;
+ tclock_config->show_time = cfdata->show_time;
+ tclock_config->time_format = cfdata->time_format;
+ tclock_config->date_format = cfdata->date_format;
+ _tclock_config_updated();
+ e_config_save_queue();
return 1;
}
static void
-onCheckChange(void *data, Evas_Object *obj)
+onTimeCheckChange(void *data, Evas_Object *obj)
+{
+ int checked = e_widget_check_checked_get(obj);
+ e_widget_disabled_set(data, !checked);
+}
+
+static void
+onDateCheckChange(void *data, Evas_Object *obj)
{
int checked = e_widget_check_checked_get(obj);
e_widget_disabled_set(data, !checked);
===================================================================
RCS file: /cvs/e/e_modules/tclock/e_mod_main.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -3 -r1.17 -r1.18
--- e_mod_main.c 16 May 2006 05:23:26 -0000 1.17
+++ e_mod_main.c 16 May 2006 16:44:52 -0000 1.18
@@ -1,437 +1,349 @@
#include <time.h>
#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);
+/* Func Proto Requirements for Gadcon */
+static E_Gadcon_Client *_gc_init (E_Gadcon *gc, char *name, char *id, char
*style);
+static void _gc_shutdown (E_Gadcon_Client *gcc);
+static void _gc_orient (E_Gadcon_Client *gcc);
+static char *_gc_label (void);
+static Evas_Object *_gc_icon (Evas *evas);
+
+/* Module Protos */
+static void _tclock_cb_mouse_down (void *data, Evas *e, Evas_Object *obj, void
*event_info);
+static void _tclock_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi);
+static void _tclock_menu_cb_post(void *data, E_Menu *m);
+static int _tclock_cb_check(void *data);
-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 E_Config_DD *conf_edd = NULL;
+Config *tclock_config = NULL;
-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******************************/
-EAPI E_Module_Api e_modapi = {
- E_MODULE_API_VERSION,
- "TClock"
+/* Define the class and gadcon functions this module provides */
+static const E_Gadcon_Client_Class _gc_class =
+{
+ GADCON_CLIENT_CLASS_VERSION,
+ "tclock",
+ {
+ _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon
+ }
};
-EAPI void *
-e_modapi_init(E_Module *module)
+typedef struct _Instance Instance;
+struct _Instance
{
- TClock *tclock;
-
- /* Set up module's message catalogue */
- bindtextdomain(PACKAGE, LOCALEDIR);
- bind_textdomain_codeset(PACKAGE, "UTF-8");
-
- tclock = _tclock_new();
- module->config_menu = tclock->config_menu;
- return tclock;
-}
+ E_Gadcon_Client *gcc;
+ Evas_Object *tclock;
+};
-EAPI int
-e_modapi_shutdown(E_Module *module)
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
{
- TClock *tclock;
-
- if (module->config_menu)
- module->config_menu = NULL;
+ Evas_Object *o;
+ E_Gadcon_Client *gcc;
+ Instance *inst;
+ char buf[4096];
+
+ inst = E_NEW(Instance, 1);
+
+ o = edje_object_add(gc->evas);
+ snprintf(buf, sizeof(buf), "%s/tclock.edj",
e_module_dir_get(tclock_config->module));
+ if (!e_theme_edje_object_set(o, "base/theme/modules/tclock",
"modules/tclock/main"))
+ edje_object_file_set(o, buf, "modules/tclock/main");
+ evas_object_show(o);
+
+ gcc = e_gadcon_client_new(gc, name, id, style, o);
+ gcc->data = inst;
+ inst->gcc = gcc;
+ inst->tclock = o;
+
+ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
+ _tclock_cb_mouse_down, inst);
+ tclock_config->instances = evas_list_append(tclock_config->instances, inst);
- tclock = module->data;
- if (tclock)
- _tclock_shutdown(tclock);
- return 1;
+ _tclock_cb_check(NULL);
+ return gcc;
}
-EAPI int
-e_modapi_info(E_Module *module)
+static void
+_gc_shutdown(E_Gadcon_Client *gcc)
{
- module->icon_file = strdup(PACKAGE_DATA_DIR "/module_icon.png");
- return 1;
+ Instance *inst;
+
+ inst = gcc->data;
+ tclock_config->instances = evas_list_remove(tclock_config->instances,
inst);
+ evas_object_del(inst->tclock);
+ free(inst);
}
-EAPI int
-e_modapi_save(E_Module *module)
+static void
+_gc_orient(E_Gadcon_Client *gcc)
{
- TClock *tclock;
-
- tclock = module->data;
- e_config_domain_save("module.tclock", conf_edd, tclock->conf);
- return 1;
+ Instance *inst;
+
+ inst = gcc->data;
+ e_gadcon_client_aspect_set(gcc, 30, 16);
+ e_gadcon_client_min_size_set(gcc, 30, 16);
}
-EAPI int
-e_modapi_about(E_Module *module)
+static char *
+_gc_label(void)
{
- e_module_dialog_show(D_("Simple Digital Clock"), D_("Displays a digital
clock on the desktop"));
- return 1;
+ return _("TClock");
}
-EAPI int
-e_modapi_config(E_Module *module)
+static Evas_Object *
+_gc_icon(Evas *evas)
{
- Evas_List *l;
- TClock *t;
-
- t = module->data;
- if (!t)
- return 0;
- if (!t->faces)
- return 0;
- for (l = t->faces; l; l = l->next)
- {
- TClock_Face *tf;
-
- tf = l->data;
- if (!tf)
- return 0;
- if (tf->con == e_container_current_get(e_manager_current_get()))
- {
- /* Configure Clock */
- _config_tclock_module(tf->con, tf);
- break;
- }
- }
- return 1;
+ Evas_Object *o;
+ char buf[4096];
+
+ o = edje_object_add(evas);
+ snprintf(buf, sizeof(buf), "%s/module.eap",
+ e_module_dir_get(tclock_config->module));
+ edje_object_file_set(o, buf, "icon");
+ return o;
}
-/******************************************************************
- * 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, INT);
- E_CONFIG_VAL(D, T, format, STR);
- E_CONFIG_VAL(D, T, userformat, UCHAR);
+static void
+_tclock_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ Instance *inst;
+ Evas_Event_Mouse_Down *ev;
- 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;
- }
-
- E_CONFIG_LIMIT(tclock->conf->poll_time, 1.0, 60.0);
-
- _tclock_config_menu_new(tclock);
-
- managers = e_manager_list();
- cl = tclock->conf->faces;
- for (l = managers; l; l = l->next)
+ inst = data;
+ ev = event_info;
+ if ((ev->button == 3) && (!tclock_config->menu))
{
- 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;
- face->conf->userformat = 0;
- face->conf->format = (char *)evas_stringshare_add("%c");
-
- E_CONFIG_LIMIT(face->conf->resolution, 0, 1);
-
- tclock->conf->faces =
evas_list_append(tclock->conf->faces, face->conf);
- }
- else
- {
- face->conf = cl->data;
- cl = cl->next;
- }
-
- /* to avoid the long display of "Starting the clock..." */
- _tclock_cb_check(tclock);
- tclock->tclock_check_timer =
ecore_timer_add(tclock->conf->poll_time, _tclock_cb_check, tclock);
-
- /* 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;
+ E_Menu *mn;
+ E_Menu_Item *mi;
+ int x, y, w, h;
+
+ mn = e_menu_new();
+ e_menu_post_deactivate_callback_set(mn, _tclock_menu_cb_post, inst);
+ tclock_config->menu = mn;
+
+ mi = e_menu_item_new(mn);
+ e_menu_item_label_set(mi, _("Configuration"));
+ e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
+ e_menu_item_callback_set(mi, _tclock_menu_cb_configure, NULL);
+
+ e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
+ e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
+ &x, &y, &w, &h);
+ e_menu_activate_mouse(mn,
+ e_util_zone_current_get(e_manager_current_get()),
+ x + ev->output.x, y + ev->output.y, 1, 1,
+ E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
+ evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
+ EVAS_BUTTON_NONE, ev->timestamp, NULL);
+ }
}
static void
-_tclock_shutdown(TClock *tclock)
+_tclock_menu_cb_post(void *data, E_Menu *m)
{
- 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);
-
- e_object_del(E_OBJECT(tclock->config_menu));
-
- evas_list_free(tclock->faces);
- evas_list_free(tclock->conf->faces);
- free(tclock->conf);
- free(tclock);
+ if (!tclock_config->menu)
+ return;
+ e_object_del(E_OBJECT(tclock_config->menu));
+ tclock_config->menu = NULL;
}
static void
-_tclock_config_menu_new(TClock *tclock)
+_tclock_menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
{
- tclock->config_menu = e_menu_new();
+ if (!tclock_config)
+ return;
+ if (tclock_config->config_dialog)
+ return;
+ _config_tclock_module();
}
-static TClock_Face *
-_tclock_face_new(E_Container *con)
+void
+_tclock_config_updated(void)
{
- TClock_Face *face;
- Evas_Object *o;
- Evas_Coord x, y, w, h;
- char buff[4096];
-
- 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;
-
- snprintf(buff, sizeof(buff), PACKAGE_DATA_DIR "/tclock.edj");
- if (!e_theme_edje_object_set(o, "base/theme/modules/tclock",
"modules/tclock/main"))
- edje_object_file_set(o, buff, "modules/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_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));
-
- if (face->conf->format)
- evas_stringshare_del(face->conf->format);
+ Evas_List *l;
+
+ if (!tclock_config)
+ return;
- free(face->conf);
- free(face);
- _tclock_count--;
+ for (l = tclock_config->instances; l; l = l->next)
+ {
+ Instance *inst;
+
+ inst = l->data;
+
+ if (!tclock_config->show_time)
+ edje_object_signal_emit(inst->tclock, "time_hidden", "");
+ else
+ edje_object_signal_emit(inst->tclock, "time_visible", "");
+ edje_object_message_signal_process(inst->tclock);
+
+ if (!tclock_config->show_date)
+ {
+ printf("Not Date\n");
+ edje_object_signal_emit(inst->tclock, "date_hidden", "");
+ }
+ else
+ {
+ edje_object_signal_emit(inst->tclock, "date_visible", "");
+ }
+ edje_object_message_signal_process(inst->tclock);
+ }
+
+ if (tclock_config->tclock_check_timer)
+ ecore_timer_del(tclock_config->tclock_check_timer);
+
+ tclock_config->tclock_check_timer =
ecore_timer_add(tclock_config->poll_time,
+ _tclock_cb_check, NULL);
+ _tclock_cb_check(NULL);
}
-static int
-_tclock_cb_check(void *data)
+static int
+_tclock_cb_check(void *data)
{
- TClock *tclock;
+ Instance *inst;
Evas_List *l;
time_t current_time;
struct tm *local_time;
- char buf[TIME_BUF];
+ char buf[1024];
memset(buf, 0, sizeof(buf));
current_time = time(NULL);
local_time = localtime(¤t_time);
- tclock = data;
- for (l = tclock->faces; l; l = l->next)
+ for (l = tclock_config->instances; l; l = l->next)
{
- TClock_Face *face;
-
- face = l->data;
- strftime(buf, TIME_BUF, face->conf->format, local_time);
- edje_object_part_text_set(face->tclock_object, "tclock_text", buf);
+ Instance *inst;
+
+ inst = l->data;
+
+ if (!tclock_config->show_time)
+ edje_object_signal_emit(inst->tclock, "time_hidden", "");
+ else
+ edje_object_signal_emit(inst->tclock, "time_visible", "");
+
+ edje_object_message_signal_process(inst->tclock);
+
+ if (!tclock_config->show_date)
+ edje_object_signal_emit(inst->tclock, "date_hidden", "");
+ else
+ edje_object_signal_emit(inst->tclock, "date_visible", "");
+
+ edje_object_message_signal_process(inst->tclock);
+
+ strftime(buf, 1024, tclock_config->time_format, local_time);
+ edje_object_part_text_set(inst->tclock, "tclock_time", buf);
+ strftime(buf, 1024, tclock_config->date_format, local_time);
+ edje_object_part_text_set(inst->tclock, "tclock_date", buf);
}
return 1;
}
-static void
-_tclock_face_menu_new(TClock_Face *face)
-{
- E_Menu *mn;
- E_Menu_Item *mi;
+EAPI E_Module_Api e_modapi = {
+ E_MODULE_API_VERSION,
+ "TClock"
+};
- mn = e_menu_new();
- face->menu = mn;
+EAPI void *
+e_modapi_init(E_Module *m)
+{
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset(PACKAGE, "UTF-8");
+
+ conf_edd = E_CONFIG_DD_NEW("TClock_Config", Config);
+ #undef T
+ #undef D
+ #define T Config
+ #define D conf_edd
+ E_CONFIG_VAL(D, T, poll_time, DOUBLE);
+ E_CONFIG_VAL(D, T, resolution, INT);
+ E_CONFIG_VAL(D, T, show_date, INT);
+ E_CONFIG_VAL(D, T, show_time, INT);
+ E_CONFIG_VAL(D, T, date_format, STR);
+ E_CONFIG_VAL(D, T, time_format, STR);
+
+ tclock_config = e_config_domain_load("module.tclock", conf_edd);
+ if (!tclock_config)
+ {
+ tclock_config = E_NEW(Config, 1);
+ tclock_config->poll_time = 1.0;
+ tclock_config->resolution = RESOLUTION_SECOND;
+ tclock_config->show_date = 1;
+ tclock_config->show_time = 1;
+ tclock_config->time_format = strdup("%T");
+ tclock_config->date_format = strdup("%d/%m/%y");
+ }
+
+ E_CONFIG_LIMIT(tclock_config->poll_time, 1.0, 60.0);
+ E_CONFIG_LIMIT(tclock_config->resolution, 0, 1);
+ E_CONFIG_LIMIT(tclock_config->show_date, 0, 1);
+ E_CONFIG_LIMIT(tclock_config->show_time, 0, 1);
+
+ tclock_config->tclock_check_timer =
ecore_timer_add(tclock_config->poll_time,
+ _tclock_cb_check, NULL);
+ tclock_config->module = m;
- mi = e_menu_item_new(mn);
- e_menu_item_label_set(mi, _("Configuration"));
- e_util_menu_item_edje_icon_set(mi, "enlightenment/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_util_menu_item_edje_icon_set(mi, "enlightenment/gadgets");
- e_menu_item_callback_set(mi, _tclock_face_cb_menu_edit, face);
+ e_gadcon_provider_register(&_gc_class);
+ return 1;
}
-static void
-_tclock_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change
change)
+EAPI int
+e_modapi_shutdown(E_Module *m)
{
- TClock_Face *face;
- Evas_Coord x, y, w, h;
-
- face = data;
- switch (change)
+ tclock_config->module = NULL;
+ e_gadcon_provider_unregister(&_gc_class);
+
+ if (tclock_config->config_dialog)
+ e_object_del(E_OBJECT(tclock_config->config_dialog));
+
+ if (tclock_config->tclock_check_timer)
+ ecore_timer_del(tclock_config->tclock_check_timer);
+ if (tclock_config->menu)
{
- 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;
+ e_menu_post_deactivate_callback_set(tclock_config->menu, NULL, NULL);
+ e_object_del(E_OBJECT(tclock_config->menu));
+ tclock_config->menu = NULL;
}
+
+ free(tclock_config);
+ tclock_config = NULL;
+ E_CONFIG_DD_FREE(conf_edd);
+ return 1;
}
-static void
-_tclock_face_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void
*event_info)
+EAPI int
+e_modapi_info(E_Module *m)
{
- 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);
- }
+ char buf[4096];
+
+ snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
+ m->icon_file = strdup(buf);
+ return 1;
}
-static void
-_tclock_face_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi)
+EAPI int
+e_modapi_save(E_Module *m)
{
- TClock_Face *face;
-
- face = data;
- e_gadman_mode_set(face->gmc->gadman, E_GADMAN_MODE_EDIT);
+ e_config_domain_save("module.tclock", conf_edd, tclock_config);
+ return 1;
}
-static void
-_tclock_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
+EAPI int
+e_modapi_about(E_Module *m)
{
- TClock_Face *f;
+ e_module_dialog_show(D_("Simple Digital Clock"),
+ D_("Displays a digital clock on the desktop"));
+ return 1;
+}
- f = data;
- if (!f)
- return;
- _config_tclock_module(f->con, f);
+EAPI int
+e_modapi_config(E_Module *m)
+{
+ if (!tclock_config)
+ return 0;
+ if (tclock_config->config_dialog)
+ return 0;
+
+ _config_tclock_module();
+ return 1;
}
===================================================================
RCS file: /cvs/e/e_modules/tclock/e_mod_main.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- e_mod_main.h 16 May 2006 05:23:26 -0000 1.10
+++ e_mod_main.h 16 May 2006 16:44:52 -0000 1.11
@@ -6,53 +6,23 @@
#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;
- char *format;
- unsigned int userformat;
-} Config_Face;
-
-typedef struct _TClock
+typedef struct _Config Config;
+struct _Config
{
- Evas_List *faces;
- E_Menu *config_menu;
- Config *conf;
-
- Ecore_Timer *tclock_check_timer;
-} TClock;
-
-typedef struct _TClock_Face
-{
- E_Container *con;
+ E_Module *module;
+ E_Config_Dialog *config_dialog;
E_Menu *menu;
- E_Menu *resolution_menu;
- Config_Face *conf;
- TClock *tclock;
+ Evas_List *instances;
- struct
- {
- Evas_Coord l, r, t, b;
- } inset;
-
- Evas_Object *tclock_object;
- Evas_Object *event_object;
- E_Gadman_Client *gmc;
-} TClock_Face;
+ Ecore_Timer *tclock_check_timer;
+
+ int resolution;
+ double poll_time;
+ int show_time;
+ int show_date;
+ char *time_format;
+ char *date_format;
+};
EAPI extern E_Module_Api e_modapi;
@@ -63,6 +33,8 @@
EAPI int e_modapi_about(E_Module *m);
EAPI int e_modapi_config(E_Module *m);
-void _tclock_cb_config_updated(void *data);
+void _config_tclock_module(void);
+void _tclock_config_updated(void);
+extern Config *tclock_config;
#endif
===================================================================
RCS file: /cvs/e/e_modules/tclock/tclock.edc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- tclock.edc 16 May 2006 05:21:46 -0000 1.4
+++ tclock.edc 16 May 2006 16:44:52 -0000 1.5
@@ -1,80 +1,154 @@
-// Sample EDC
images
{
image: "background.png" COMP;
}
-styles
-{
- style
- {
- name: "tclock_style";
- base: "font=Edje-Vera font_size=12 text_class=tb_plain align=center
style=soft_shadow color=#fff shadow_color=#00000020 valign=center";
- tag: "br" "\n";
- }
-}
collections
{
group
{
name: "modules/tclock/main";
- min: 32 32;
- max: 1024 768;
-
parts
{
part
{
name: "background";
type: IMAGE;
+ description
+ {
+ state: "default" 0.0;
+ image
+ {
+ normal: "background.png";
+ }
+ }
+ }
+ part
+ {
+ name: "tclock_time";
+ type: TEXT;
+ effect: SOFT_SHADOW;
mouse_events: 0;
description
{
state: "default" 0.0;
+ visible: 0;
rel1
{
relative: 0.0 0.0;
- offset: 0 0;
+ offset: 0 2;
}
rel2
{
- relative: 1.0 1.0;
+ relative: 1.0 0.5;
offset: -1 -1;
}
- image
- {
- normal: "background.png";
- }
+ color: 255 255 255 255;
+ color3: 0 0 0 32;
+ text {
+ text: "";
+ font: "Edje-Vera";
+ size: 12;
+ min: 1 1;
+ align: 0.5 0.5;
+ text_class: "module_large";
+ }
}
+ description
+ {
+ state: "hidden" 0.0;
+ inherit: "default" 0.0;
+ visible: 0;
+ }
+ description
+ {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
}
-
part
{
- name: "tclock_text";
- type: TEXTBLOCK;
+ name: "tclock_date";
+ type: TEXT;
+ effect: SOFT_SHADOW;
mouse_events: 0;
description
{
state: "default" 0.0;
+ visible: 0;
rel1
{
- relative: 0.0 0.0;
- offset: 0 0;
+ relative: 0.0 0.5;
+ offset: 0 2;
}
rel2
{
relative: 1.0 1.0;
offset: -1 -1;
}
- text
- {
- style: "tclock_style";
- min: 1 1;
- }
+ color: 255 255 255 255;
+ color3: 0 0 0 32;
+ text {
+ text: "";
+ font: "Edje-Vera";
+ size: 8;
+ min: 1 1;
+ align: 0.5 0.5;
+ text_class: "module_small";
+ }
}
+ description
+ {
+ state: "hidden" 0.0;
+ inherit: "default" 0.0;
+ visible: 0;
+ }
+ description
+ {
+ state: "visible" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
}
}
/* Close Parts */
+ programs
+ {
+ program
+ {
+ name: "p1";
+ signal: "time_hidden";
+ source: "";
+ action: STATE_SET "hidden" 0.0;
+ target: "tclock_time";
+ }
+ program
+ {
+ name: "p2";
+ signal: "time_visible";
+ source: "";
+ action: STATE_SET "visible" 0.0;
+ target: "tclock_time";
+ }
+ program
+ {
+ name: "p3";
+ signal: "date_hidden";
+ source: "";
+ action: STATE_SET "hidden" 0.0;
+ target: "tclock_date";
+ }
+ program
+ {
+ name: "p4";
+ signal: "date_visible";
+ source: "";
+ action: STATE_SET "visible" 0.0;
+ target: "tclock_date";
+ }
+ }
+ /* Close Programs */
}
/* Close Group */
}
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs