Enlightenment CVS committal
Author : lok
Project : e_modules
Module : notification
Dir : e_modules/notification/src
Modified Files:
Makefile.am e_mod_config.c e_mod_main.c e_mod_main.h
Added Files:
e_mod_box.c e_mod_box.h e_mod_config_item.c
e_mod_config_item.h e_mod_macro.h e_mod_popup.c e_mod_popup.h
e_mod_types.h
Log Message:
Notification Module 0.2
Now also works with box for less intrusive notification.
A left click on the icon will focus the application source of the event.
A mouse_in during 0.5s will (re-)show depending of the config the popup.
There is two different config dialogs, one by box, and one for the popups.
===================================================================
RCS file: /cvs/e/e_modules/notification/src/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- Makefile.am 17 Jan 2008 22:01:58 -0000 1.2
+++ Makefile.am 2 Mar 2008 01:33:28 -0000 1.3
@@ -9,7 +9,15 @@
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.h \
e_mod_main.c \
- e_mod_config.c
+ e_mod_macro.h \
+ e_mod_types.h \
+ e_mod_box.h \
+ e_mod_box.c \
+ e_mod_popup.h \
+ e_mod_popup.c \
+ e_mod_config.c \
+ e_mod_config_item.h \
+ e_mod_config_item.c
module_la_LIBADD = @e_libs@ @ENOTIFY_LIBS@
module_la_LDFLAGS = -module -avoid-version
===================================================================
RCS file: /cvs/e/e_modules/notification/src/e_mod_config.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_mod_config.c 17 Jan 2008 22:01:58 -0000 1.1
+++ e_mod_config.c 2 Mar 2008 01:33:28 -0000 1.2
@@ -1,9 +1,11 @@
-#include <e.h>
#include "e_mod_main.h"
struct _E_Config_Dialog_Data
{
int direction;
+ int show_low;
+ int show_normal;
+ int show_critical;
int gap;
struct
{
@@ -64,22 +66,35 @@
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
- cfdata->direction = notification_cfg->direction;
- cfdata->gap = notification_cfg->gap;
- cfdata->placement.x = notification_cfg->placement.x;
- cfdata->placement.y = notification_cfg->placement.y;
+ cfdata->show_low = notification_cfg->show_low;
+ cfdata->show_normal = notification_cfg->show_normal;
+ cfdata->show_critical = notification_cfg->show_critical;
+ cfdata->direction = notification_cfg->direction;
+ cfdata->gap = notification_cfg->gap;
+ cfdata->placement.x = notification_cfg->placement.x;
+ cfdata->placement.y = notification_cfg->placement.y;
}
static Evas_Object *
_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas,
E_Config_Dialog_Data *cfdata)
{
- Evas_Object *o = NULL, *of = NULL;
- Evas_Object *ow = NULL;
+ Evas_Object *o = NULL, *of = NULL, *ow = NULL;
E_Radio_Group *rg;
E_Manager *man;
- man = e_manager_current_get();
o = e_widget_list_add(evas, 0, 0);
+ of = e_widget_framelist_add(evas, D_("Urgency"), 0);
+ ow = e_widget_label_add(evas, D_("Levels of urgency to popup : "));
+ e_widget_framelist_object_append(of, ow);
+ ow = e_widget_check_add(evas, D_("low"), &(cfdata->show_low));
+ e_widget_framelist_object_append(of, ow);
+ ow = e_widget_check_add(evas, D_("normal"), &(cfdata->show_normal));
+ e_widget_framelist_object_append(of, ow);
+ ow = e_widget_check_add(evas, D_("critical"), &(cfdata->show_critical));
+ e_widget_framelist_object_append(of, ow);
+ e_widget_list_object_append(o, of, 1, 1, 0.5);
+
+ man = e_manager_current_get();
of = e_widget_framelist_add(evas, D_("Placement"), 0);
ow = e_widget_slider_add(evas, 1, 0, D_("%2.0f x"), 0.0, man->w, 1.0, 0,
NULL, &(cfdata->placement.x), 200);
@@ -113,10 +128,13 @@
static int
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
- notification_cfg->direction = cfdata->direction;
- notification_cfg->gap = cfdata->gap;
- notification_cfg->placement.x = cfdata->placement.x;
- notification_cfg->placement.y = cfdata->placement.y;
+ notification_cfg->show_low = cfdata->show_low;
+ notification_cfg->show_normal = cfdata->show_normal;
+ notification_cfg->show_critical = cfdata->show_critical;
+ notification_cfg->direction = cfdata->direction;
+ notification_cfg->gap = cfdata->gap;
+ notification_cfg->placement.x = cfdata->placement.x;
+ notification_cfg->placement.y = cfdata->placement.y;
e_modapi_save(notification_mod);
return 1;
===================================================================
RCS file: /cvs/e/e_modules/notification/src/e_mod_main.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- e_mod_main.c 25 Feb 2008 07:23:57 -0000 1.6
+++ e_mod_main.c 2 Mar 2008 01:33:28 -0000 1.7
@@ -1,59 +1,158 @@
-#include <E_Notification_Daemon.h>
-#include <e.h>
#include "e_mod_main.h"
-typedef struct _Popup_Data Popup_Data;
-struct _Popup_Data
+/* Gadcon function protos */
+static E_Gadcon_Client *_gc_init (E_Gadcon *gc,
+ const char *name,
+ const char *id,
+ const char *style);
+static void _gc_shutdown (E_Gadcon_Client *gcc);
+static char *_gc_label (void);
+static Evas_Object *_gc_icon (Evas *evas);
+static const char *_gc_id_new (void);
+static void _gc_id_del (const char *id);
+
+/* Callback function protos */
+static int _notification_cb_notify (E_Notification_Daemon
*daemon,
+ E_Notification *n);
+static void _notification_cb_close_notification (E_Notification_Daemon
*daemon,
+ unsigned int id);
+
+/* Config function protos */
+static Config *_notification_cfg_new (void);
+static void _notification_cfg_free (Config *cfg);
+
+/* Global variables */
+E_Module *notification_mod = NULL;
+Config *notification_cfg = NULL;
+int uuid = 0;
+
+static E_Config_DD *conf_edd = NULL;
+static E_Config_DD *conf_item_edd = NULL;
+
+/* Gadcon Api Functions */
+const E_Gadcon_Client_Class _gc_class =
{
- E_Notification *notif;
- E_Win *win;
- Evas *e;
- Evas_Object *theme;
- const char *app_name;
- Evas_Object *app_icon;
- Ecore_Timer *timer;
+ GADCON_CLIENT_CLASS_VERSION, "notification",
+ {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new,
_gc_id_del},
+ E_GADCON_CLIENT_STYLE_PLAIN
};
-typedef struct _Daemon_Data Daemon_Data;
-struct _Daemon_Data
+static E_Gadcon_Client *
+_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
{
- E_Notification_Daemon *daemon;
- Evas_List *popups;
-
- float default_timeout;
- int next_id;
-};
+ Notification_Box *b;
+ E_Gadcon_Client *gcc;
+ Config_Item *ci;
+ Instance *inst;
+
+ inst = E_NEW(Instance, 1);
+ ci = notification_box_config_item_get(id);
+ b = notification_box_get(ci->id, gc->evas);
+
+ inst->ci = ci;
+ b->inst = inst;
+ inst->n_box = b;
+
+ gcc = e_gadcon_client_new(gc, name, id, style, b->o_box);
+ gcc->data = inst;
+ inst->gcc = gcc;
+
+ evas_object_event_callback_add(b->o_box, EVAS_CALLBACK_MOVE,
+ notification_box_cb_obj_moveresize, inst);
+ evas_object_event_callback_add(b->o_box, EVAS_CALLBACK_RESIZE,
+ notification_box_cb_obj_moveresize, inst);
+ notification_cfg->instances = evas_list_append(notification_cfg->instances,
inst);
+ return gcc;
+}
-/* local function protos */
-static int _notification_cb_notify(E_Notification_Daemon *daemon,
E_Notification *n);
-static void _notification_cb_close_notification(E_Notification_Daemon *daemon,
- unsigned int id);
-static int _notification_timer_cb(void *data);
-static void _notification_theme_cb_deleted(void *data, Evas_Object *obj,
- const char *emission, const char
*source);
-static void _notification_theme_cb_close(void *data, Evas_Object *obj,
- const char *emission, const char
*source);
-static void _notification_theme_cb_find(void *data, Evas_Object *obj,
- const char *emission, const char
*source);
-
-static Popup_Data *_notification_popup_new(E_Notification *n);
-static void _notification_popup_place(Popup_Data *popup, int num);
-static void _notification_popup_refresh(Popup_Data *popup);
-static Popup_Data *_notification_popup_find(unsigned int id);
-static void _notification_popup_del(unsigned int id,
- E_Notification_Closed_Reason
reason);
-static void _notification_popdown(Popup_Data *popup,
- E_Notification_Closed_Reason reason);
+static void
+_gc_shutdown(E_Gadcon_Client *gcc)
+{
+ Instance *inst;
-static char *_notification_format_message(E_Notification *n);
+ inst = gcc->data;
+ notification_box_hide(inst->n_box);
+ notification_cfg->instances = evas_list_remove(notification_cfg->instances,
inst);
+ free(inst);
+}
+
+void
+_gc_orient(E_Gadcon_Client *gcc)
+{
+ Instance *inst;
+
+ inst = gcc->data;
+ switch (gcc->gadcon->orient)
+ {
+ case E_GADCON_ORIENT_FLOAT:
+ case E_GADCON_ORIENT_HORIZ:
+ case E_GADCON_ORIENT_TOP:
+ case E_GADCON_ORIENT_BOTTOM:
+ case E_GADCON_ORIENT_CORNER_TL:
+ case E_GADCON_ORIENT_CORNER_TR:
+ case E_GADCON_ORIENT_CORNER_BL:
+ case E_GADCON_ORIENT_CORNER_BR:
+ notification_box_orient_set(inst->n_box, 1);
+ e_gadcon_client_aspect_set(gcc, evas_list_count(inst->n_box->icons) *
16, 16);
+ break;
+ case E_GADCON_ORIENT_VERT:
+ case E_GADCON_ORIENT_LEFT:
+ case E_GADCON_ORIENT_RIGHT:
+ case E_GADCON_ORIENT_CORNER_LT:
+ case E_GADCON_ORIENT_CORNER_RT:
+ case E_GADCON_ORIENT_CORNER_LB:
+ case E_GADCON_ORIENT_CORNER_RB:
+ notification_box_orient_set(inst->n_box, 0);
+ e_gadcon_client_aspect_set(gcc, 16, evas_list_count(inst->n_box->icons)
* 16);
+ break;
+ default:
+ break;
+ }
+ e_gadcon_client_min_size_set(gcc, 16, 16);
+}
-static Config *_notification_cfg_new(void);
-static void _notification_cfg_free(Config *cfg);
-/* Global variables */
-static Daemon_Data *dd;
-static E_Config_DD *conf_edd = NULL;
-E_Module *notification_mod = NULL;
-Config *notification_cfg = NULL;
+static char *
+_gc_label(void)
+{
+ return D_("Notification Box");
+}
+
+static Evas_Object *
+_gc_icon(Evas *evas)
+{
+ Evas_Object *o;
+ char buf[4096];
+
+ o = edje_object_add(evas);
+ snprintf(buf, sizeof(buf), "%s/e-module-notification.edj",
+ e_module_dir_get(notification_mod));
+ edje_object_file_set(o, buf, "icon");
+ return o;
+}
+
+static const char *
+_gc_id_new(void)
+{
+ Config_Item *ci;
+
+ ci = notification_box_config_item_get(NULL);
+ return ci->id;
+}
+
+static void
+_gc_id_del(const char *id)
+{
+ Config_Item *ci;
+
+ notification_box_del(id);
+ ci = notification_box_config_item_get(id);
+ if (ci)
+ {
+ if (ci->id) evas_stringshare_del(ci->id);
+ notification_cfg->items = evas_list_remove(notification_cfg->items, ci);
+ free(ci);
+ }
+}
/* Module Api Functions */
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Notification"};
@@ -62,25 +161,40 @@
e_modapi_init(E_Module *m)
{
E_Notification_Daemon *d;
+ char buf[PATH_MAX];
- dd = calloc(1, sizeof(Daemon_Data));
-
+ snprintf(buf, sizeof(buf), "%s/e-module-notification.edj", m->dir);
/* register config panel entry */
e_configure_registry_category_add("extensions", 90, D_("Extensions"), NULL,
"enlightenment/extensions");
e_configure_registry_item_add("extensions/notification", 30,
D_("Notification"), NULL,
- "enlightenment/e",
e_int_config_notification_module);
+ buf, e_int_config_notification_module);
- conf_edd = E_CONFIG_DD_NEW("Config", Config);
+ conf_item_edd = E_CONFIG_DD_NEW("Notification_Config_Item", Config_Item);
+ #undef T
+ #undef D
+ #define T Config_Item
+ #define D conf_item_edd
+ E_CONFIG_VAL(D, T, id, STR);
+ E_CONFIG_VAL(D, T, show_label, INT);
+ E_CONFIG_VAL(D, T, store_low, INT);
+ E_CONFIG_VAL(D, T, store_normal, INT);
+ E_CONFIG_VAL(D, T, store_critical, INT);
+
+ conf_edd = E_CONFIG_DD_NEW("Notification_Config", Config);
#undef T
#undef D
#define T Config
#define D conf_edd
E_CONFIG_VAL(D, T, version, INT);
+ E_CONFIG_VAL(D, T, show_low, INT);
+ E_CONFIG_VAL(D, T, show_normal, INT);
+ E_CONFIG_VAL(D, T, show_critical, INT);
E_CONFIG_VAL(D, T, direction, INT);
E_CONFIG_VAL(D, T, gap, INT);
E_CONFIG_VAL(D, T, placement.x, INT);
E_CONFIG_VAL(D, T, placement.y, INT);
+ E_CONFIG_LIST(D, T, items, conf_item_edd);
notification_cfg = e_config_domain_load("module.notification", conf_edd);
if (notification_cfg)
@@ -126,48 +240,91 @@
}
}
- if (!notification_cfg) notification_cfg = _notification_cfg_new();
+ if (!notification_cfg)
+ {
+ notification_cfg = _notification_cfg_new();
+ }
+ else
+ {
+ Config_Item *ci;
+ const char *p;
- /* set up the daemon */
+ /* Init uuid */
+ ci = evas_list_last(notification_cfg->items)->data;
+ p = strrchr(ci->id, '.');
+ if (p) uuid = atoi(p + 1);
+ }
+
+ /* set up the notification daemon */
d = e_notification_daemon_add("e_notification_module", "Enlightenment");
- e_notification_daemon_data_set(d, dd);
- dd->daemon = d;
- dd->default_timeout = 5.0;
+ notification_cfg->daemon = d;
+ notification_cfg->default_timeout = 5.0;
+ e_notification_daemon_data_set(d, notification_cfg);
e_notification_daemon_callback_notify_set(d, _notification_cb_notify);
e_notification_daemon_callback_close_notification_set(d,
_notification_cb_close_notification);
+ /* set up the borders events callbacks */
+ notification_cfg->handlers = evas_list_append
+ (notification_cfg->handlers, ecore_event_handler_add
+ (E_EVENT_BORDER_REMOVE, notification_box_cb_border_remove, NULL));
+
notification_mod = m;
+ e_gadcon_provider_register(&_gc_class);
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m __UNUSED__)
{
- Popup_Data *popup;
- Evas_List *l, *next;
+ e_gadcon_provider_unregister(&_gc_class);
+
+ while (notification_cfg->handlers)
+ {
+ ecore_event_handler_del(notification_cfg->handlers->data);
+ notification_cfg->handlers =
evas_list_remove_list(notification_cfg->handlers,
+
notification_cfg->handlers);
+ }
if (notification_cfg->cfd) e_object_del(E_OBJECT(notification_cfg->cfd));
e_configure_registry_item_del("extensions/notification");
e_configure_registry_category_del("extensions");
- for (l = dd->popups; l && (popup = l->data); l = next)
+ if (notification_cfg->menu)
{
- next = l->next;
- _notification_popdown(popup, E_NOTIFICATION_CLOSED_REQUESTED);
- dd->popups = evas_list_remove_list(dd->popups, l);
+ e_menu_post_deactivate_callback_set(notification_cfg->menu, NULL, NULL);
+ e_object_del(E_OBJECT(notification_cfg->menu));
+ notification_cfg->menu = NULL;
}
- e_notification_daemon_free(dd->daemon);
- free(dd);
- notification_mod = NULL;
+
+ while (notification_cfg->items)
+ {
+ Config_Item *ci;
+
+ ci = notification_cfg->items->data;
+ notification_cfg->items = evas_list_remove_list(notification_cfg->items,
+
notification_cfg->items);
+ if (ci->id) evas_stringshare_del(ci->id);
+ free(ci);
+ }
+
+ notification_box_shutdown();
+ notification_popup_shutdown();
+
+ e_notification_daemon_free(notification_cfg->daemon);
_notification_cfg_free(notification_cfg);
+ E_CONFIG_DD_FREE(conf_item_edd);
E_CONFIG_DD_FREE(conf_edd);
+ notification_mod = NULL;
+
return 1;
}
EAPI int
e_modapi_save(E_Module *m __UNUSED__)
{
- return e_config_domain_save("module.notification", conf_edd,
notification_cfg);
+ int ret;
+ ret = e_config_domain_save("module.notification", conf_edd,
notification_cfg);
+ return ret;
}
/* Callbacks */
@@ -176,37 +333,21 @@
{
unsigned int replaces_id;
unsigned int new_id;
- int timeout;
- Popup_Data *popup = NULL;
-
+ int stacked, popuped;
+
replaces_id = e_notification_replaces_id_get(n);
- if (replaces_id && (popup = _notification_popup_find(replaces_id)))
- {
- if (popup->notif) e_notification_unref(popup->notif);
- e_notification_ref(n);
- popup->notif = n;
- edje_object_signal_emit(popup->theme, "notification,del",
"notification");
- }
+ new_id = notification_cfg->next_id++;
+ e_notification_id_set(n, new_id);
- if (!popup)
+ popuped = notification_popup_notify(n, replaces_id, new_id);
+ stacked = notification_box_notify(n, replaces_id, new_id);
+
+ if (!popuped && !stacked)
{
- popup = _notification_popup_new(n);
- dd->popups = evas_list_append(dd->popups, popup);
- edje_object_signal_emit(popup->theme, "notification,new",
"notification");
+ e_notification_hint_urgency_set(n, 4);
+ notification_popup_notify(n, replaces_id, new_id);
}
- new_id = dd->next_id++;
- e_notification_id_set(n, new_id);
-
- if (popup->timer) ecore_timer_del(popup->timer);
- timeout = e_notification_timeout_get(popup->notif);
- if (timeout == 0)
- popup->timer = NULL;
- else
- popup->timer = ecore_timer_add(timeout == -1 ? dd->default_timeout :
(float)timeout / 1000,
- _notification_timer_cb,
- popup);
-
return new_id;
}
@@ -214,344 +355,7 @@
_notification_cb_close_notification(E_Notification_Daemon *daemon __UNUSED__,
unsigned int id)
{
- _notification_popup_del(id,
- E_NOTIFICATION_CLOSED_REQUESTED);
-}
-
-static int
-_notification_timer_cb(void *data)
-{
- Popup_Data *popup = data;
- _notification_popup_del(e_notification_id_get(popup->notif),
- E_NOTIFICATION_CLOSED_EXPIRED);
- return 0;
-}
-
-static void
-_notification_theme_cb_deleted(void *data,
- Evas_Object *obj __UNUSED__,
- const char *emission __UNUSED__,
- const char *source __UNUSED__)
-{
- Popup_Data *popup = data;
- _notification_popup_refresh(popup);
- edje_object_signal_emit(popup->theme, "notification,new", "notification");
-}
-
-static void
-_notification_theme_cb_close(void *data,
- Evas_Object *obj __UNUSED__,
- const char *emission __UNUSED__,
- const char *source __UNUSED__)
-{
- Popup_Data *popup = data;
- _notification_popup_del(e_notification_id_get(popup->notif),
- E_NOTIFICATION_CLOSED_DISMISSED);
-}
-
-static void
-_notification_theme_cb_find(void *data,
- Evas_Object *obj __UNUSED__,
- const char *emission __UNUSED__,
- const char *source __UNUSED__)
-{
- Popup_Data *popup = data;
- Evas_List *l;
-
- if (!popup->app_name) return;
-
- for (l = e_border_client_list(); l; l = l->next)
- {
- int compare_len;
- E_Border *bd = l->data;
-
- compare_len = strlen(popup->app_name);
- if (strlen(bd->client.icccm.name) < compare_len)
- compare_len = strlen(bd->client.icccm.name);
-
- /* We can't be sure that the app_name really match the application name.
- * Some plugin put their name instead. But this search gives some good
- * results.
- */
- if (!strncasecmp(bd->client.icccm.name, popup->app_name, compare_len))
- {
- e_desk_show(bd->desk);
- e_border_show(bd);
- e_border_raise(bd);
- e_border_focus_set_with_pointer(bd);
- break;
- }
- }
-}
-
-/* Local functions */
-static Popup_Data *
-_notification_popup_new(E_Notification *n)
-{
- E_Container *con;
- Popup_Data *popup;
- char buf[PATH_MAX];
- const char *shape_option;
- int shaped;
- Ecore_X_Window_State state[5] = {
- ECORE_X_WINDOW_STATE_STICKY,
- ECORE_X_WINDOW_STATE_SKIP_TASKBAR,
- ECORE_X_WINDOW_STATE_SKIP_PAGER,
- ECORE_X_WINDOW_STATE_HIDDEN,
- ECORE_X_WINDOW_STATE_ABOVE
- };
-
- popup = calloc(1, sizeof(Popup_Data));
- if (!popup) return NULL;
- e_notification_ref(n);
- popup->notif = n;
-
- con = e_container_current_get(e_manager_current_get());
-
- /* Create the popup window */
- popup->win = e_win_new(con);
- e_win_name_class_set(popup->win, "E", "_notification_dialog");
- e_win_title_set(popup->win, "Event Notification");
- e_win_borderless_set(popup->win, 1);
- e_win_placed_set(popup->win, 1);
- e_win_sticky_set(popup->win, 1);
- ecore_x_icccm_transient_for_set(popup->win->evas_win, con->win);
- ecore_x_icccm_protocol_set(popup->win->evas_win,
ECORE_X_WM_PROTOCOL_TAKE_FOCUS, 0);
-
- ecore_x_netwm_window_type_set(popup->win->evas_win,
ECORE_X_WINDOW_TYPE_DOCK);
- ecore_x_netwm_window_state_set(popup->win->evas_win, state, 6);
-
- popup->e = e_win_evas_get(popup->win);
-
- /* Setup the theme */
- snprintf(buf, sizeof(buf), "%s/e-module-notification.edj",
notification_mod->dir);
- popup->theme = edje_object_add(popup->e);
- if (!e_theme_edje_object_set(popup->theme,
"base/theme/modules/notification",
- "modules/notification/main"))
- edje_object_file_set(popup->theme, buf, "modules/notification/main");
- evas_object_show(popup->theme);
- edje_object_signal_callback_add(popup->theme, "notification,deleted",
"theme",
- _notification_theme_cb_deleted, popup);
- edje_object_signal_callback_add(popup->theme, "notification,close",
"theme",
- _notification_theme_cb_close, popup);
- edje_object_signal_callback_add(popup->theme, "notification,find", "theme",
- _notification_theme_cb_find, popup);
-
- shape_option = edje_object_data_get(popup->theme, "shaped");
- if (shape_option)
- {
- if (!strcmp(shape_option, "1"))
- shaped = 1;
- else
- shaped = 0;
- if (e_config->use_composite)
- {
- ecore_evas_alpha_set(popup->win->ecore_evas, shaped);
- e_container_window_raise(popup->win->container,
-
ecore_evas_software_x11_window_get(popup->win->ecore_evas),
- ecore_evas_layer_get(popup->win->ecore_evas));
- }
- else
- {
- e_win_shaped_set(popup->win, shaped);
- e_win_avoid_damage_set(popup->win, shaped);
- }
- }
-
- _notification_popup_refresh(popup);
- _notification_popup_place(popup, evas_list_count(dd->popups));
- e_win_show(popup->win);
-
- return popup;
-}
-
-static void
-_notification_popup_place(Popup_Data *popup, int num)
-{
- int x, y, w, h, dir = 0;
-
- evas_object_geometry_get(popup->theme, NULL, NULL, &w, &h);
- if (e_notification_hint_xy_get(popup->notif, &x, &y))
- {
- if (!popup->win->container) return;
-
- if (x + w > popup->win->container->w)
- x -= w;
- if (y + h > popup->win->container->h)
- y -= h;
- e_win_move(popup->win, x, y);
- }
- else
- {
- switch (notification_cfg->direction)
- {
- case DIRECTION_DOWN:
- case DIRECTION_RIGHT:
- dir = 1;
- break;
- case DIRECTION_UP:
- case DIRECTION_LEFT:
- dir = -1;
- break;
- }
-
- if (notification_cfg->direction == DIRECTION_DOWN ||
- notification_cfg->direction == DIRECTION_UP)
- e_win_move(popup->win,
- notification_cfg->placement.x,
- notification_cfg->placement.y
- + dir * num * (h + notification_cfg->gap));
- else
- e_win_move(popup->win,
- notification_cfg->placement.x
- + dir * num * (w + notification_cfg->gap),
- notification_cfg->placement.y);
- }
-}
-
-static void
-_notification_popup_refresh(Popup_Data *popup)
-{
- const char *icon_path;
- char *msg;
- void *img;
- int w, h;
-
- if (!popup) return;
-
- popup->app_name = e_notification_app_name_get(popup->notif);
-
- if (popup->app_icon)
- {
- edje_object_part_unswallow(popup->theme, popup->app_icon);
- evas_object_del(popup->app_icon);
- }
-
- /* Check if the app specify an icon either by a path or by a hint */
- if ((icon_path = e_notification_app_icon_get(popup->notif)) && *icon_path)
- {
- popup->app_icon = evas_object_image_add(popup->e);
- evas_object_image_load_scale_down_set(popup->app_icon, 1);
- evas_object_image_load_size_set(popup->app_icon, 80, 80);
- evas_object_image_file_set(popup->app_icon, icon_path, NULL);
- evas_object_image_fill_set(popup->app_icon, 0, 0, 80, 80);
- }
- else if ((img = e_notification_hint_icon_data_get(popup->notif)))
- {
- popup->app_icon = e_notification_image_evas_object_add(popup->e, img);
- }
- evas_object_image_size_get(popup->app_icon, &w, &h);
- edje_extern_object_min_size_set(popup->app_icon, w, h);
- edje_extern_object_max_size_set(popup->app_icon, w, h);
- edje_object_part_swallow(popup->theme, "notification.swallow.app_icon",
popup->app_icon);
-
- /* Fill up the event message */
- msg = _notification_format_message(popup->notif);
- edje_object_part_text_set(popup->theme, "notification.textblock.message",
msg);
- free(msg);
-
- /* Compute the new size of the popup */
- edje_object_size_min_calc(popup->theme, &w, &h);
- e_win_size_min_set(popup->win, w, h);
- e_win_size_max_set(popup->win, w, h);
- e_win_resize(popup->win, w, h);
- evas_object_resize(popup->theme, w, h);
- edje_object_calc_force(popup->theme);
-}
-
-static Popup_Data *
-_notification_popup_find(unsigned int id)
-{
- Evas_List *l;
- Popup_Data *popup;
-
- for (l = dd->popups; l && (popup = l->data); l = l->next)
- if (e_notification_id_get(popup->notif) == id) return popup;
-
- return NULL;
-}
-
-static void
-_notification_popup_del(unsigned int id, E_Notification_Closed_Reason reason)
-{
- Popup_Data *popup;
- Evas_List *l, *next;
- int i;
-
- for (l = dd->popups, i = 0; l && (popup = l->data); l = next)
- {
- next = l->next;
- if (e_notification_id_get(popup->notif) == id)
- {
- _notification_popdown(popup, reason);
- dd->popups = evas_list_remove_list(dd->popups, l);
- }
- else
- {
- _notification_popup_place(popup, i);
- i++;
- }
- }
-}
-
-static void
-_notification_popdown(Popup_Data *popup, E_Notification_Closed_Reason reason)
-{
- ecore_timer_del(popup->timer);
- e_win_hide(popup->win);
- evas_object_del(popup->app_icon);
- evas_object_del(popup->theme);
- e_object_del(E_OBJECT(popup->win));
- e_notification_closed_set(popup->notif, 1);
- e_notification_daemon_signal_notification_closed(dd->daemon,
-
e_notification_id_get(popup->notif),
- reason);
- e_notification_unref(popup->notif);
- free(popup);
-}
-
-static char *
-_notification_format_message(E_Notification *n)
-{
- char *msg;
- const char *orig;
- char *dest;
- int len;
- int size = 512;
-
- msg = calloc(1, 512);
- snprintf(msg, 511, "<subject>%s</subject><br><body>",
- e_notification_summary_get(n));
- len = strlen(msg);
-
- for (orig = e_notification_body_get(n), dest = msg + strlen(msg); orig &&
*orig; orig++)
- {
- if (len >= size - 4)
- {
- size = len + 512;
- msg = realloc(msg, size);
- msg = memset(msg + len, 0, size - len);
- dest = msg + len;
- }
-
- if (*orig == '\n')
- {
- dest[0] = '<';
- dest[1] = 'b';
- dest[2] = 'r';
- dest[3] = '>';
- len += 4;
- dest += 4;
- }
- else
- {
- *dest = *orig;
- len++;
- dest++;
- }
- }
-
- return msg;
+ notification_popup_close(id);
}
static Config *
@@ -560,12 +364,15 @@
Config *cfg;
cfg = E_NEW(Config, 1);
- cfg->cfd = NULL;
- cfg->version = MOD_CFG_FILE_VERSION;
- cfg->direction = DIRECTION_DOWN;
- cfg->gap = 10;
- cfg->placement.x = 10;
- cfg->placement.y = 10;
+ cfg->cfd = NULL;
+ cfg->version = MOD_CFG_FILE_VERSION;
+ cfg->show_low = 0;
+ cfg->show_normal = 1;
+ cfg->show_critical = 1;
+ cfg->direction = DIRECTION_DOWN;
+ cfg->gap = 10;
+ cfg->placement.x = 10;
+ cfg->placement.y = 10;
e_modapi_save(notification_mod);
return cfg;
===================================================================
RCS file: /cvs/e/e_modules/notification/src/e_mod_main.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- e_mod_main.h 17 Jan 2008 22:01:58 -0000 1.2
+++ e_mod_main.h 2 Mar 2008 01:33:28 -0000 1.3
@@ -1,19 +1,18 @@
-#define D_(str) dgettext(PACKAGE, str)
-
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
+#define HAVE_EDBUS 1
+#include <E_Notification_Daemon.h>
+#include <e.h>
+#include <Evas.h>
+
+#include "e_mod_macro.h"
+#include "e_mod_types.h"
+#include "e_mod_config_item.h"
+#include "e_mod_box.h"
+#include "e_mod_popup.h"
#include "config.h"
-#define MOD_CFG_FILE_EPOCH 0x0001
-#define MOD_CFG_FILE_GENERATION 0x0001
-#define MOD_CFG_FILE_VERSION \
- ((MOD_CFG_FILE_EPOCH << 16) | MOD_CFG_FILE_GENERATION)
-
-#undef __UNUSED__
-#define __UNUSED__ __attribute__((unused))
-
-typedef enum _Popup_Direction Popup_Direction;
enum _Popup_Direction
{
DIRECTION_UP,
@@ -22,12 +21,14 @@
DIRECTION_RIGHT
};
-typedef struct _Config Config;
struct _Config
{
E_Config_Dialog *cfd;
int version;
+ int show_low;
+ int show_normal;
+ int show_critical;
Popup_Direction direction;
int gap;
struct
@@ -35,6 +36,34 @@
int x;
int y;
} placement;
+
+ E_Notification_Daemon *daemon;
+
+ Evas_List *instances;
+ Evas_List *n_box;
+ Evas_List *config_dialog;
+ E_Menu *menu;
+ Evas_List *handlers;
+ Evas_List *items;
+ Evas_List *popups;
+ float default_timeout;
+ int next_id;
+};
+
+struct _Config_Item
+{
+ const char *id;
+ int show_label;
+ int store_low;
+ int store_normal;
+ int store_critical;
+};
+
+struct _Instance
+{
+ E_Gadcon_Client *gcc;
+ Notification_Box *n_box;
+ Config_Item *ci;
};
EAPI extern E_Module_Api e_modapi;
@@ -43,10 +72,14 @@
EAPI int e_modapi_shutdown(E_Module *m);
EAPI int e_modapi_save(E_Module *m);
+void _gc_orient (E_Gadcon_Client *gcc);
+
EAPI E_Config_Dialog *e_int_config_notification_module(E_Container *con,
const char *params
__UNUSED__);
extern E_Module *notification_mod;
extern Config *notification_cfg;
+extern const E_Gadcon_Client_Class _gc_class;
+extern int uuid;
#endif
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs