forked from enlightenment/enlightenment
notification module no longer has a broken and buggy gadget. bug hunters everywhere rejoice in the streets
SVN revision: 79773
This commit is contained in:
parent
da0c0f3eb7
commit
0ccafb765f
|
@ -9,9 +9,7 @@ notificationpkg_LTLIBRARIES = notification/module.la
|
||||||
|
|
||||||
notification_module_la_SOURCES = notification/e_mod_main.h \
|
notification_module_la_SOURCES = notification/e_mod_main.h \
|
||||||
notification/e_mod_main.c \
|
notification/e_mod_main.c \
|
||||||
notification/e_mod_box.c \
|
|
||||||
notification/e_mod_config.c \
|
notification/e_mod_config.c \
|
||||||
notification/e_mod_config_item.c \
|
|
||||||
notification/e_mod_popup.c
|
notification/e_mod_popup.c
|
||||||
|
|
||||||
notification_module_la_LIBADD = @ENOTIFY_LIBS@
|
notification_module_la_LIBADD = @ENOTIFY_LIBS@
|
||||||
|
|
|
@ -1,708 +0,0 @@
|
||||||
#include "e_mod_main.h"
|
|
||||||
|
|
||||||
/* Notification box protos */
|
|
||||||
static Notification_Box *_notification_box_new(const char *id,
|
|
||||||
Evas *evas);
|
|
||||||
static void _notification_box_free(Notification_Box *b);
|
|
||||||
static void _notification_box_evas_set(Notification_Box *b,
|
|
||||||
Evas *evas);
|
|
||||||
static void _notification_box_empty(Notification_Box *b);
|
|
||||||
static void _notification_box_resize_handle(Notification_Box *b);
|
|
||||||
static void _notification_box_empty_handle(Notification_Box *b);
|
|
||||||
static Eina_List *_notification_box_find(E_Notification_Urgency urgency);
|
|
||||||
|
|
||||||
/* Notification box icons protos */
|
|
||||||
static Notification_Box_Icon *_notification_box_icon_new(Notification_Box *b,
|
|
||||||
E_Notification *n,
|
|
||||||
E_Border *bd,
|
|
||||||
unsigned int id);
|
|
||||||
static void _notification_box_icon_free(Notification_Box_Icon *ic);
|
|
||||||
static void _notification_box_icon_fill(Notification_Box_Icon *ic,
|
|
||||||
E_Notification *n);
|
|
||||||
static void _notification_box_icon_fill_label(Notification_Box_Icon *ic);
|
|
||||||
static void _notification_box_icon_empty(Notification_Box_Icon *ic);
|
|
||||||
static Notification_Box_Icon *_notification_box_icon_find(Notification_Box *b,
|
|
||||||
E_Border *bd,
|
|
||||||
unsigned int n_id);
|
|
||||||
static void _notification_box_icon_signal_emit(Notification_Box_Icon *ic,
|
|
||||||
char *sig,
|
|
||||||
char *src);
|
|
||||||
|
|
||||||
/* Utils */
|
|
||||||
static E_Border *_notification_find_source_border(E_Notification *n);
|
|
||||||
|
|
||||||
/* Notification box callbacks */
|
|
||||||
void
|
|
||||||
notification_box_notify(E_Notification *n,
|
|
||||||
unsigned int replaces_id,
|
|
||||||
unsigned int id)
|
|
||||||
{
|
|
||||||
Eina_List *n_box;
|
|
||||||
E_Border *bd;
|
|
||||||
Notification_Box *b;
|
|
||||||
Notification_Box_Icon *ic = NULL;
|
|
||||||
|
|
||||||
bd = _notification_find_source_border(n);
|
|
||||||
|
|
||||||
n_box = _notification_box_find(e_notification_hint_urgency_get(n));
|
|
||||||
EINA_LIST_FREE(n_box, b)
|
|
||||||
{
|
|
||||||
if (bd || replaces_id)
|
|
||||||
ic = _notification_box_icon_find(b, bd, replaces_id);
|
|
||||||
if (ic)
|
|
||||||
{
|
|
||||||
e_notification_unref(ic->notif);
|
|
||||||
e_notification_ref(n);
|
|
||||||
ic->notif = n;
|
|
||||||
ic->n_id = id;
|
|
||||||
_notification_box_icon_empty(ic);
|
|
||||||
_notification_box_icon_fill(ic, n);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ic = _notification_box_icon_new(b, n, bd, id);
|
|
||||||
if (!ic) continue;
|
|
||||||
b->icons = eina_list_append(b->icons, ic);
|
|
||||||
e_box_pack_end(b->o_box, ic->o_holder);
|
|
||||||
}
|
|
||||||
_notification_box_empty_handle(b);
|
|
||||||
_notification_box_resize_handle(b);
|
|
||||||
_gc_orient(b->inst->gcc, b->inst->gcc->gadcon->orient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
notification_box_shutdown(void)
|
|
||||||
{
|
|
||||||
Notification_Box *b;
|
|
||||||
|
|
||||||
EINA_LIST_FREE(notification_cfg->n_box, b)
|
|
||||||
{
|
|
||||||
if (b) _notification_box_free(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
notification_box_visible_set(Notification_Box *b, Eina_Bool visible)
|
|
||||||
{
|
|
||||||
Eina_List *l;
|
|
||||||
Notification_Box_Icon *ic;
|
|
||||||
Ecore_Cb cb = (Ecore_Cb)(visible ? evas_object_show : evas_object_hide);
|
|
||||||
|
|
||||||
if (b->o_box) cb(b->o_box);
|
|
||||||
if (b->o_empty) cb(b->o_empty);
|
|
||||||
EINA_LIST_FOREACH(b->icons, l, ic)
|
|
||||||
{
|
|
||||||
if (!ic) continue;
|
|
||||||
cb(ic->o_holder);
|
|
||||||
cb(ic->o_holder2);
|
|
||||||
cb(ic->o_icon);
|
|
||||||
cb(ic->o_icon2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Notification_Box *
|
|
||||||
notification_box_get(const char *id,
|
|
||||||
Evas *evas)
|
|
||||||
{
|
|
||||||
Eina_List *l;
|
|
||||||
Notification_Box *b;
|
|
||||||
|
|
||||||
/* Find old config */
|
|
||||||
EINA_LIST_FOREACH(notification_cfg->n_box, l, b)
|
|
||||||
{
|
|
||||||
if (b->id == id)
|
|
||||||
{
|
|
||||||
_notification_box_evas_set(b, evas);
|
|
||||||
notification_box_visible_set(b, EINA_TRUE);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
b = _notification_box_new(id, evas);
|
|
||||||
notification_cfg->n_box = eina_list_append(notification_cfg->n_box, b);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
Config_Item *
|
|
||||||
notification_box_config_item_get(const char *id)
|
|
||||||
{
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
GADCON_CLIENT_CONFIG_GET(Config_Item, notification_cfg->items, _gc_class, id);
|
|
||||||
|
|
||||||
ci = E_NEW(Config_Item, 1);
|
|
||||||
ci->id = eina_stringshare_add(id);
|
|
||||||
ci->show_label = 1;
|
|
||||||
ci->show_popup = 1;
|
|
||||||
ci->focus_window = 1;
|
|
||||||
ci->store_low = 1;
|
|
||||||
ci->store_normal = 1;
|
|
||||||
ci->store_critical = 0;
|
|
||||||
notification_cfg->items = eina_list_append(notification_cfg->items, ci);
|
|
||||||
|
|
||||||
return ci;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
notification_box_orient_set(Notification_Box *b,
|
|
||||||
int horizontal)
|
|
||||||
{
|
|
||||||
e_box_orientation_set(b->o_box, horizontal);
|
|
||||||
e_box_align_set(b->o_box, 0.5, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
notification_box_cb_obj_moveresize(void *data,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
void *event_info __UNUSED__)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
inst = data;
|
|
||||||
_notification_box_resize_handle(inst->n_box);
|
|
||||||
}
|
|
||||||
|
|
||||||
Eina_Bool
|
|
||||||
notification_box_cb_border_remove(void *data __UNUSED__,
|
|
||||||
int type __UNUSED__,
|
|
||||||
E_Event_Border_Remove *ev)
|
|
||||||
{
|
|
||||||
Notification_Box_Icon *ic;
|
|
||||||
Eina_List *l;
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(notification_cfg->instances, l, inst)
|
|
||||||
{
|
|
||||||
Notification_Box *b;
|
|
||||||
|
|
||||||
if (!inst) continue;
|
|
||||||
b = inst->n_box;
|
|
||||||
|
|
||||||
ic = _notification_box_icon_find(b, ev->border, 0);
|
|
||||||
if (!ic) continue;
|
|
||||||
b->icons = eina_list_remove(b->icons, ic);
|
|
||||||
_notification_box_icon_free(ic);
|
|
||||||
_notification_box_empty_handle(b);
|
|
||||||
_notification_box_resize_handle(b);
|
|
||||||
_gc_orient(inst->gcc, inst->gcc->gadcon->orient);
|
|
||||||
}
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Notification_Box *
|
|
||||||
_notification_box_new(const char *id,
|
|
||||||
Evas *evas)
|
|
||||||
{
|
|
||||||
Notification_Box *b;
|
|
||||||
|
|
||||||
b = E_NEW(Notification_Box, 1);
|
|
||||||
b->id = eina_stringshare_ref(id);
|
|
||||||
b->o_box = e_box_add(evas);
|
|
||||||
e_box_homogenous_set(b->o_box, 1);
|
|
||||||
e_box_orientation_set(b->o_box, 1);
|
|
||||||
e_box_align_set(b->o_box, 0.5, 0.5);
|
|
||||||
_notification_box_empty(b);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_free(Notification_Box *b)
|
|
||||||
{
|
|
||||||
_notification_box_empty(b);
|
|
||||||
eina_stringshare_del(b->id);
|
|
||||||
free(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_evas_set(Notification_Box *b,
|
|
||||||
Evas *evas)
|
|
||||||
{
|
|
||||||
Eina_List *new_icons = NULL;
|
|
||||||
Notification_Box_Icon *ic, *new_ic;
|
|
||||||
|
|
||||||
if (b->o_box) evas_object_del(b->o_box);
|
|
||||||
if (b->o_empty) evas_object_del(b->o_empty);
|
|
||||||
b->o_empty = NULL;
|
|
||||||
b->o_box = e_box_add(evas);
|
|
||||||
|
|
||||||
e_box_homogenous_set(b->o_box, 1);
|
|
||||||
e_box_orientation_set(b->o_box, 1);
|
|
||||||
e_box_align_set(b->o_box, 0.5, 0.5);
|
|
||||||
|
|
||||||
EINA_LIST_FREE(b->icons, ic)
|
|
||||||
{
|
|
||||||
if (!ic) continue;
|
|
||||||
|
|
||||||
new_ic = _notification_box_icon_new(b, ic->notif, ic->border, ic->n_id);
|
|
||||||
_notification_box_icon_free(ic);
|
|
||||||
new_icons = eina_list_append(new_icons, new_ic);
|
|
||||||
|
|
||||||
e_box_pack_end(b->o_box, new_ic->o_holder);
|
|
||||||
}
|
|
||||||
b->icons = new_icons;
|
|
||||||
_notification_box_empty_handle(b);
|
|
||||||
_notification_box_resize_handle(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_empty(Notification_Box *b)
|
|
||||||
{
|
|
||||||
Notification_Box_Icon *ic;
|
|
||||||
EINA_LIST_FREE(b->icons, ic)
|
|
||||||
_notification_box_icon_free(ic);
|
|
||||||
_notification_box_empty_handle(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_resize_handle(Notification_Box *b)
|
|
||||||
{
|
|
||||||
Notification_Box_Icon *ic;
|
|
||||||
Evas_Coord w, h;
|
|
||||||
|
|
||||||
evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
|
|
||||||
if (e_box_orientation_get(b->o_box))
|
|
||||||
w = h;
|
|
||||||
else
|
|
||||||
h = w;
|
|
||||||
e_box_freeze(b->o_box);
|
|
||||||
EINA_LIST_FREE(b->icons, ic)
|
|
||||||
e_box_pack_options_set(ic->o_holder, 1, 1, 0, 0, 0.5, 0.5, w, h, w, h);
|
|
||||||
e_box_thaw(b->o_box);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_List *
|
|
||||||
_notification_box_find(E_Notification_Urgency urgency)
|
|
||||||
{
|
|
||||||
Eina_List *l, *n_box = NULL;
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(notification_cfg->instances, l, inst)
|
|
||||||
{
|
|
||||||
if ((urgency == E_NOTIFICATION_URGENCY_LOW) && (!inst->ci->store_low))
|
|
||||||
continue;
|
|
||||||
if ((urgency == E_NOTIFICATION_URGENCY_NORMAL) && (!inst->ci->store_normal))
|
|
||||||
continue;
|
|
||||||
if ((urgency == E_NOTIFICATION_URGENCY_CRITICAL) && (!inst->ci->store_critical))
|
|
||||||
continue;
|
|
||||||
n_box = eina_list_append(n_box, inst->n_box);
|
|
||||||
}
|
|
||||||
return n_box;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_icon_free(Notification_Box_Icon *ic)
|
|
||||||
{
|
|
||||||
_notification_box_icon_empty(ic);
|
|
||||||
evas_object_del(ic->o_holder);
|
|
||||||
evas_object_del(ic->o_holder2);
|
|
||||||
if (ic->border) e_object_unref(E_OBJECT(ic->border));
|
|
||||||
if (ic->notif) e_notification_unref(ic->notif);
|
|
||||||
free(ic);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_icon_fill(Notification_Box_Icon *ic,
|
|
||||||
E_Notification *n)
|
|
||||||
{
|
|
||||||
void *img;
|
|
||||||
const char *icon_path;
|
|
||||||
Evas_Object *app_icon;
|
|
||||||
Evas_Object *dummy = NULL;
|
|
||||||
int w, h = 0;
|
|
||||||
|
|
||||||
// XXX: this is horrible.
|
|
||||||
if ((icon_path = e_notification_app_icon_get(n)) && *icon_path)
|
|
||||||
{
|
|
||||||
if (!memcmp(icon_path, "file://", 7)) icon_path += 7;
|
|
||||||
app_icon = evas_object_image_add(evas_object_evas_get(ic->n_box->o_box));
|
|
||||||
evas_object_image_load_scale_down_set(app_icon, 1);
|
|
||||||
evas_object_image_load_size_set(app_icon, 80, 80);
|
|
||||||
evas_object_image_file_set(app_icon, icon_path, NULL);
|
|
||||||
evas_object_image_fill_set(app_icon, 0, 0, 80, 80);
|
|
||||||
}
|
|
||||||
else if ((img = e_notification_hint_icon_data_get(n)))
|
|
||||||
{
|
|
||||||
app_icon = e_notification_image_evas_object_add(evas_object_evas_get(ic->n_box->o_box), img);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char buf[PATH_MAX];
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/e-module-notification.edj", notification_mod->dir);
|
|
||||||
dummy = edje_object_add(evas_object_evas_get(ic->n_box->o_box));
|
|
||||||
if (!e_theme_edje_object_set(dummy, "base/theme/modules/notification",
|
|
||||||
"e/modules/notification/logo"))
|
|
||||||
if (!e_theme_edje_object_set(dummy, "base/theme/modules/notification",
|
|
||||||
"modules/notification/logo"))
|
|
||||||
edje_object_file_set(dummy, buf, "modules/notification/logo");
|
|
||||||
evas_object_resize(dummy, 80, 80);
|
|
||||||
app_icon = (Evas_Object*)edje_object_part_object_get(dummy, "image");
|
|
||||||
}
|
|
||||||
evas_object_image_size_get(app_icon, &w, &h);
|
|
||||||
|
|
||||||
ic->o_icon = e_icon_add(evas_object_evas_get(ic->n_box->o_box));
|
|
||||||
e_icon_alpha_set(ic->o_icon, 1);
|
|
||||||
e_icon_data_set(ic->o_icon, evas_object_image_data_get(app_icon, 0), w, h);
|
|
||||||
edje_object_part_swallow(ic->o_holder, "e.swallow.content", ic->o_icon);
|
|
||||||
evas_object_pass_events_set(ic->o_icon, 1);
|
|
||||||
evas_object_show(ic->o_icon);
|
|
||||||
|
|
||||||
ic->o_icon2 = e_icon_add(evas_object_evas_get(ic->n_box->o_box));
|
|
||||||
e_icon_alpha_set(ic->o_icon2, 1);
|
|
||||||
e_icon_data_set(ic->o_icon2, evas_object_image_data_get(app_icon, 0), w, h);
|
|
||||||
edje_object_part_swallow(ic->o_holder2, "e.swallow.content", ic->o_icon2);
|
|
||||||
evas_object_pass_events_set(ic->o_icon2, 1);
|
|
||||||
evas_object_show(ic->o_icon2);
|
|
||||||
|
|
||||||
if (dummy) evas_object_del(dummy);
|
|
||||||
else evas_object_del(app_icon);
|
|
||||||
_notification_box_icon_fill_label(ic);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_icon_fill_label(Notification_Box_Icon *ic)
|
|
||||||
{
|
|
||||||
const char *label = NULL;
|
|
||||||
|
|
||||||
if (ic->border)
|
|
||||||
label = ic->border->client.netwm.name;
|
|
||||||
|
|
||||||
if (!label) label = e_notification_app_name_get(ic->notif);
|
|
||||||
edje_object_part_text_set(ic->o_holder, "e.text.label", label);
|
|
||||||
edje_object_part_text_set(ic->o_holder2, "e.text.label", label);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_icon_empty(Notification_Box_Icon *ic)
|
|
||||||
{
|
|
||||||
if (ic->o_icon) evas_object_del(ic->o_icon);
|
|
||||||
if (ic->o_icon2) evas_object_del(ic->o_icon2);
|
|
||||||
ic->o_icon2 = ic->o_icon = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Notification_Box_Icon *
|
|
||||||
_notification_box_icon_find(Notification_Box *b,
|
|
||||||
E_Border *bd,
|
|
||||||
unsigned int n_id)
|
|
||||||
{
|
|
||||||
Eina_List *l;
|
|
||||||
Notification_Box_Icon *ic;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(b->icons, l, ic)
|
|
||||||
{
|
|
||||||
if (!ic) continue;
|
|
||||||
if ((ic->border == bd) || (ic->n_id == n_id))
|
|
||||||
return ic;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_icon_signal_emit(Notification_Box_Icon *ic,
|
|
||||||
char *sig,
|
|
||||||
char *src)
|
|
||||||
{
|
|
||||||
if (ic->o_holder)
|
|
||||||
edje_object_signal_emit(ic->o_holder, sig, src);
|
|
||||||
if (ic->o_icon)
|
|
||||||
edje_object_signal_emit(ic->o_icon, sig, src);
|
|
||||||
if (ic->o_holder2)
|
|
||||||
edje_object_signal_emit(ic->o_holder2, sig, src);
|
|
||||||
if (ic->o_icon2)
|
|
||||||
edje_object_signal_emit(ic->o_icon2, sig, src);
|
|
||||||
}
|
|
||||||
|
|
||||||
static E_Border *
|
|
||||||
_notification_find_source_border(E_Notification *n)
|
|
||||||
{
|
|
||||||
const char *app_name;
|
|
||||||
Eina_List *l;
|
|
||||||
E_Border *bd;
|
|
||||||
|
|
||||||
if (!(app_name = e_notification_app_name_get(n))) return NULL;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(e_border_client_list(), l, bd)
|
|
||||||
{
|
|
||||||
size_t app, test;
|
|
||||||
|
|
||||||
if ((!bd) || ((!bd->client.icccm.name) && (!bd->client.icccm.class))) continue;
|
|
||||||
/* 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.
|
|
||||||
*/
|
|
||||||
app = strlen(app_name);
|
|
||||||
if (bd->client.icccm.name)
|
|
||||||
{
|
|
||||||
test = eina_strlen_bounded(bd->client.icccm.name, app + 1);
|
|
||||||
if (!strncasecmp(bd->client.icccm.name, app_name, (app < test) ? app : test))
|
|
||||||
return bd;
|
|
||||||
}
|
|
||||||
if (bd->client.icccm.class)
|
|
||||||
{
|
|
||||||
test = eina_strlen_bounded(bd->client.icccm.class, app + 1);
|
|
||||||
if (!strncasecmp(bd->client.icccm.class, app_name, (app < test) ? app : test))
|
|
||||||
return bd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_menu_configuration(Notification_Box *b,
|
|
||||||
E_Menu *m __UNUSED__,
|
|
||||||
E_Menu_Item *mi __UNUSED__)
|
|
||||||
{
|
|
||||||
Eina_List *l;
|
|
||||||
E_Config_Dialog *cfd;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(notification_cfg->config_dialog, l, cfd)
|
|
||||||
{
|
|
||||||
if (cfd->data == b->inst->ci) return;
|
|
||||||
}
|
|
||||||
config_notification_box_module(b->inst->ci);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_empty_mouse_down(Notification_Box *b,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
Evas_Event_Mouse_Down *ev)
|
|
||||||
{
|
|
||||||
E_Menu *m;
|
|
||||||
E_Menu_Item *mi;
|
|
||||||
int cx, cy, cw, ch;
|
|
||||||
|
|
||||||
m = e_menu_new();
|
|
||||||
mi = e_menu_item_new(m);
|
|
||||||
e_menu_item_label_set(mi, _("Settings"));
|
|
||||||
e_util_menu_item_theme_icon_set(mi, "preferences-system");
|
|
||||||
e_menu_item_callback_set(mi, (E_Menu_Cb)_notification_box_cb_menu_configuration, b);
|
|
||||||
|
|
||||||
m = e_gadcon_client_util_menu_items_append(b->inst->gcc, m, 0);
|
|
||||||
e_gadcon_canvas_zone_geometry_get(b->inst->gcc->gadcon,
|
|
||||||
&cx, &cy, &cw, &ch);
|
|
||||||
e_menu_activate_mouse(m,
|
|
||||||
e_util_zone_current_get(e_manager_current_get()),
|
|
||||||
cx + ev->output.x, cy + ev->output.y, 1, 1,
|
|
||||||
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
|
||||||
evas_event_feed_mouse_up(b->inst->gcc->gadcon->evas, ev->button,
|
|
||||||
EVAS_BUTTON_NONE, ev->timestamp, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_icon_move(Notification_Box_Icon *ic,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
void *event_info __UNUSED__)
|
|
||||||
{
|
|
||||||
Evas_Coord x, y;
|
|
||||||
|
|
||||||
evas_object_geometry_get(ic->o_holder, &x, &y, NULL, NULL);
|
|
||||||
evas_object_move(ic->o_holder2, x, y);
|
|
||||||
evas_object_raise(ic->o_holder2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_icon_resize(Notification_Box_Icon *ic,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
void *event_info __UNUSED__)
|
|
||||||
{
|
|
||||||
Evas_Coord w, h;
|
|
||||||
|
|
||||||
evas_object_geometry_get(ic->o_holder, NULL, NULL, &w, &h);
|
|
||||||
evas_object_resize(ic->o_holder2, w, h);
|
|
||||||
evas_object_raise(ic->o_holder2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static Eina_Bool
|
|
||||||
_notification_box_cb_icon_mouse_still_in(Notification_Box_Icon *ic)
|
|
||||||
{
|
|
||||||
e_notification_timeout_set(ic->notif, 0);
|
|
||||||
e_notification_hint_urgency_set(ic->notif, 4);
|
|
||||||
ic->popup = notification_popup_notify(ic->notif,
|
|
||||||
e_notification_id_get(ic->notif),
|
|
||||||
e_notification_app_name_get(ic->notif));
|
|
||||||
ecore_timer_del(ic->mouse_in_timer);
|
|
||||||
ic->mouse_in_timer = NULL;
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_icon_mouse_in(Notification_Box_Icon *ic,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
void *event_info __UNUSED__)
|
|
||||||
{
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
if ((!ic) || !ic->n_box || !ic->n_box->inst) return;
|
|
||||||
if (!(ci = ic->n_box->inst->ci)) return;
|
|
||||||
|
|
||||||
_notification_box_icon_signal_emit(ic, "e,state,focused", "e");
|
|
||||||
if (ci->show_label)
|
|
||||||
{
|
|
||||||
_notification_box_icon_fill_label(ic);
|
|
||||||
_notification_box_icon_signal_emit(ic, "e,action,show,label", "e");
|
|
||||||
}
|
|
||||||
if (ci->show_popup && !ic->popup && !ic->mouse_in_timer)
|
|
||||||
ic->mouse_in_timer = ecore_timer_add(0.5, (Ecore_Task_Cb)_notification_box_cb_icon_mouse_still_in, ic);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_icon_mouse_out(Notification_Box_Icon *ic,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
void *event_info __UNUSED__)
|
|
||||||
{
|
|
||||||
_notification_box_icon_signal_emit(ic, "e,state,unfocused", "e");
|
|
||||||
if (ic->n_box->inst->ci->show_label)
|
|
||||||
_notification_box_icon_signal_emit(ic, "e,action,hide,label", "e");
|
|
||||||
|
|
||||||
if (ic->mouse_in_timer)
|
|
||||||
{
|
|
||||||
ecore_timer_del(ic->mouse_in_timer);
|
|
||||||
ic->mouse_in_timer = NULL;
|
|
||||||
}
|
|
||||||
if (ic->popup)
|
|
||||||
{
|
|
||||||
notification_popup_close(e_notification_id_get(ic->notif));
|
|
||||||
ic->popup = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_icon_mouse_up(Notification_Box_Icon *ic,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
Evas_Event_Mouse_Up *ev)
|
|
||||||
{
|
|
||||||
Notification_Box *b;
|
|
||||||
|
|
||||||
b = ic->n_box;
|
|
||||||
if (ev->button != 1) return;
|
|
||||||
|
|
||||||
if (b->inst->ci->focus_window && ic->border)
|
|
||||||
{
|
|
||||||
e_border_uniconify(ic->border);
|
|
||||||
e_desk_show(ic->border->desk);
|
|
||||||
e_border_show(ic->border);
|
|
||||||
e_border_raise(ic->border);
|
|
||||||
e_border_focus_set(ic->border, 1, 1);
|
|
||||||
}
|
|
||||||
b->icons = eina_list_remove(b->icons, ic);
|
|
||||||
_notification_box_icon_free(ic);
|
|
||||||
_notification_box_empty_handle(b);
|
|
||||||
_notification_box_resize_handle(b);
|
|
||||||
_gc_orient(b->inst->gcc, b->inst->gcc->gadcon->orient);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_cb_icon_mouse_down(Notification_Box_Icon *ic,
|
|
||||||
Evas *e __UNUSED__,
|
|
||||||
Evas_Object *obj __UNUSED__,
|
|
||||||
Evas_Event_Mouse_Down *ev)
|
|
||||||
{
|
|
||||||
E_Menu *m;
|
|
||||||
E_Menu_Item *mi;
|
|
||||||
int cx, cy, cw, ch;
|
|
||||||
|
|
||||||
if (ev->button != 3) return;
|
|
||||||
|
|
||||||
m = e_menu_new();
|
|
||||||
mi = e_menu_item_new(m);
|
|
||||||
e_menu_item_label_set(mi, _("Settings"));
|
|
||||||
e_util_menu_item_theme_icon_set(mi, "preferences-system");
|
|
||||||
e_menu_item_callback_set(mi, (E_Menu_Cb)_notification_box_cb_menu_configuration, ic->n_box);
|
|
||||||
|
|
||||||
m = e_gadcon_client_util_menu_items_append(ic->n_box->inst->gcc, m, 0);
|
|
||||||
e_gadcon_canvas_zone_geometry_get(ic->n_box->inst->gcc->gadcon,
|
|
||||||
&cx, &cy, &cw, &ch);
|
|
||||||
e_menu_activate_mouse(m,
|
|
||||||
e_util_zone_current_get(e_manager_current_get()),
|
|
||||||
cx + ev->output.x, cy + ev->output.y, 1, 1,
|
|
||||||
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_notification_box_empty_handle(Notification_Box *b)
|
|
||||||
{
|
|
||||||
if (!b->icons)
|
|
||||||
{
|
|
||||||
Evas_Coord w, h;
|
|
||||||
if (b->o_empty) return;
|
|
||||||
|
|
||||||
b->o_empty = evas_object_rectangle_add(evas_object_evas_get(b->o_box));
|
|
||||||
evas_object_event_callback_add(b->o_empty, EVAS_CALLBACK_MOUSE_DOWN,
|
|
||||||
(Evas_Object_Event_Cb)_notification_box_cb_empty_mouse_down, b);
|
|
||||||
evas_object_color_set(b->o_empty, 0, 0, 0, 0);
|
|
||||||
evas_object_show(b->o_empty);
|
|
||||||
e_box_pack_end(b->o_box, b->o_empty);
|
|
||||||
evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
|
|
||||||
if (e_box_orientation_get(b->o_box))
|
|
||||||
w = h;
|
|
||||||
else
|
|
||||||
h = w;
|
|
||||||
e_box_pack_options_set(b->o_empty,
|
|
||||||
1, 1, /* fill */
|
|
||||||
1, 1, /* expand */
|
|
||||||
0.5, 0.5, /* align */
|
|
||||||
w, h, /* min */
|
|
||||||
9999, 9999 /* max */
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (b->o_empty)
|
|
||||||
{
|
|
||||||
evas_object_del(b->o_empty);
|
|
||||||
b->o_empty = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Notification_Box_Icon *
|
|
||||||
_notification_box_icon_new(Notification_Box *b,
|
|
||||||
E_Notification *n,
|
|
||||||
E_Border *bd,
|
|
||||||
unsigned int id)
|
|
||||||
{
|
|
||||||
Notification_Box_Icon *ic;
|
|
||||||
|
|
||||||
ic = E_NEW(Notification_Box_Icon, 1);
|
|
||||||
if (bd) e_object_ref(E_OBJECT(bd));
|
|
||||||
e_notification_ref(n);
|
|
||||||
ic->label = e_notification_app_name_get(n);
|
|
||||||
ic->n_box = b;
|
|
||||||
ic->n_id = id;
|
|
||||||
ic->border = bd;
|
|
||||||
ic->notif = n;
|
|
||||||
ic->o_holder = edje_object_add(evas_object_evas_get(b->o_box));
|
|
||||||
e_theme_edje_object_set(ic->o_holder, "base/theme/modules/ibox",
|
|
||||||
"e/modules/ibox/icon");
|
|
||||||
evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_IN,
|
|
||||||
(Evas_Object_Event_Cb)_notification_box_cb_icon_mouse_in, ic);
|
|
||||||
evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_OUT,
|
|
||||||
(Evas_Object_Event_Cb)_notification_box_cb_icon_mouse_out, ic);
|
|
||||||
evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_DOWN,
|
|
||||||
(Evas_Object_Event_Cb)_notification_box_cb_icon_mouse_down, ic);
|
|
||||||
evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_UP,
|
|
||||||
(Evas_Object_Event_Cb)_notification_box_cb_icon_mouse_up, ic);
|
|
||||||
evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOVE,
|
|
||||||
(Evas_Object_Event_Cb)_notification_box_cb_icon_move, ic);
|
|
||||||
evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_RESIZE,
|
|
||||||
(Evas_Object_Event_Cb)_notification_box_cb_icon_resize, ic);
|
|
||||||
evas_object_show(ic->o_holder);
|
|
||||||
|
|
||||||
ic->o_holder2 = edje_object_add(evas_object_evas_get(b->o_box));
|
|
||||||
e_theme_edje_object_set(ic->o_holder2, "base/theme/modules/ibox",
|
|
||||||
"e/modules/ibox/icon_overlay");
|
|
||||||
evas_object_layer_set(ic->o_holder2, 9999);
|
|
||||||
evas_object_pass_events_set(ic->o_holder2, 1);
|
|
||||||
evas_object_show(ic->o_holder2);
|
|
||||||
|
|
||||||
_notification_box_icon_fill(ic, n);
|
|
||||||
return ic;
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
#include "e_mod_main.h"
|
|
||||||
|
|
||||||
struct _E_Config_Dialog_Data
|
|
||||||
{
|
|
||||||
int show_label;
|
|
||||||
int show_popup;
|
|
||||||
int focus_window;
|
|
||||||
int store_low;
|
|
||||||
int store_normal;
|
|
||||||
int store_critical;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void _ci_fill_data(Config_Item *ci,
|
|
||||||
E_Config_Dialog_Data *cfdata);
|
|
||||||
static void *_ci_create_data(E_Config_Dialog *cfd);
|
|
||||||
static void _ci_free_data(E_Config_Dialog *cfd,
|
|
||||||
E_Config_Dialog_Data *cfdata);
|
|
||||||
static Evas_Object *_ci_basic_create_widgets(E_Config_Dialog *cfd,
|
|
||||||
Evas *evas,
|
|
||||||
E_Config_Dialog_Data *cfdata);
|
|
||||||
static int _ci_basic_apply_data(E_Config_Dialog *cfd,
|
|
||||||
E_Config_Dialog_Data *cfdata);
|
|
||||||
|
|
||||||
void
|
|
||||||
config_notification_box_module(Config_Item *ci)
|
|
||||||
{
|
|
||||||
E_Config_Dialog *cfd;
|
|
||||||
E_Config_Dialog_View *v;
|
|
||||||
char buf[4096];
|
|
||||||
|
|
||||||
v = E_NEW(E_Config_Dialog_View, 1);
|
|
||||||
|
|
||||||
/* Dialog Methods */
|
|
||||||
v->create_cfdata = _ci_create_data;
|
|
||||||
v->free_cfdata = _ci_free_data;
|
|
||||||
v->basic.apply_cfdata = _ci_basic_apply_data;
|
|
||||||
v->basic.create_widgets = _ci_basic_create_widgets;
|
|
||||||
|
|
||||||
/* Create The Dialog */
|
|
||||||
snprintf(buf, sizeof(buf), "%s/e-module-notification.edj", e_module_dir_get(notification_mod));
|
|
||||||
cfd = e_config_dialog_new(e_container_current_get(e_manager_current_get()),
|
|
||||||
_("Notification Box Configuration"),
|
|
||||||
"E", "_e_mod_notification_box_config_dialog",
|
|
||||||
buf, 0, v, ci);
|
|
||||||
notification_cfg->config_dialog = eina_list_append(notification_cfg->config_dialog, cfd);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_ci_fill_data(Config_Item *ci,
|
|
||||||
E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
cfdata->show_label = ci->show_label;
|
|
||||||
cfdata->show_popup = ci->show_popup;
|
|
||||||
cfdata->focus_window = ci->focus_window;
|
|
||||||
cfdata->store_low = ci->store_low;
|
|
||||||
cfdata->store_normal = ci->store_normal;
|
|
||||||
cfdata->store_critical = ci->store_critical;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *
|
|
||||||
_ci_create_data(E_Config_Dialog *cfd)
|
|
||||||
{
|
|
||||||
E_Config_Dialog_Data *cfdata;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
ci = cfd->data;
|
|
||||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
|
||||||
_ci_fill_data(ci, cfdata);
|
|
||||||
return cfdata;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_ci_free_data(E_Config_Dialog *cfd,
|
|
||||||
E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
notification_cfg->config_dialog = eina_list_remove(notification_cfg->config_dialog, cfd);
|
|
||||||
free(cfdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_ci_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__,
|
|
||||||
Evas *evas,
|
|
||||||
E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
Evas_Object *o, *of, *ob;
|
|
||||||
|
|
||||||
o = e_widget_list_add(evas, 0, 0);
|
|
||||||
|
|
||||||
of = e_widget_framelist_add(evas, _("General Settings"), 0);
|
|
||||||
ob = e_widget_check_add(evas, _("Show Icon Label"), &(cfdata->show_label));
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_check_add(evas, _("Show the popup on mouse over"), &(cfdata->show_popup));
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_check_add(evas, _("Focus the source window when clicking"), &(cfdata->focus_window));
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
|
||||||
|
|
||||||
of = e_widget_framelist_add(evas, _("Urgency"), 0);
|
|
||||||
ob = e_widget_label_add(evas, _("Levels of urgency to store:"));
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_check_add(evas, _("Low"), &(cfdata->store_low));
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_check_add(evas, _("Normal"), &(cfdata->store_normal));
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
ob = e_widget_check_add(evas, _("Critical"), &(cfdata->store_critical));
|
|
||||||
e_widget_framelist_object_append(of, ob);
|
|
||||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_ci_basic_apply_data(E_Config_Dialog *cfd,
|
|
||||||
E_Config_Dialog_Data *cfdata)
|
|
||||||
{
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
ci = cfd->data;
|
|
||||||
ci->show_label = cfdata->show_label;
|
|
||||||
ci->show_popup = cfdata->show_popup;
|
|
||||||
ci->focus_window = cfdata->focus_window;
|
|
||||||
ci->store_low = cfdata->store_low;
|
|
||||||
ci->store_normal = cfdata->store_normal;
|
|
||||||
ci->store_critical = cfdata->store_critical;
|
|
||||||
|
|
||||||
e_config_save_queue();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
#include "e_mod_main.h"
|
#include "e_mod_main.h"
|
||||||
|
|
||||||
/* 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 const char *_gc_label(const E_Gadcon_Client_Class *client_class);
|
|
||||||
static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class,
|
|
||||||
Evas *evas);
|
|
||||||
static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class);
|
|
||||||
|
|
||||||
/* Callback function protos */
|
/* Callback function protos */
|
||||||
static int _notification_cb_notify(E_Notification_Daemon *daemon,
|
static int _notification_cb_notify(E_Notification_Daemon *daemon,
|
||||||
E_Notification *n);
|
E_Notification *n);
|
||||||
|
@ -26,141 +15,6 @@ E_Module *notification_mod = NULL;
|
||||||
Config *notification_cfg = NULL;
|
Config *notification_cfg = NULL;
|
||||||
|
|
||||||
static E_Config_DD *conf_edd = NULL;
|
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 =
|
|
||||||
{
|
|
||||||
GADCON_CLIENT_CLASS_VERSION, "notification",
|
|
||||||
{
|
|
||||||
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, NULL,
|
|
||||||
e_gadcon_site_is_not_toolbar
|
|
||||||
},
|
|
||||||
E_GADCON_CLIENT_STYLE_PLAIN
|
|
||||||
};
|
|
||||||
|
|
||||||
static E_Gadcon_Client *
|
|
||||||
_gc_init(E_Gadcon *gc,
|
|
||||||
const char *name,
|
|
||||||
const char *id,
|
|
||||||
const char *style)
|
|
||||||
{
|
|
||||||
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 = eina_list_append(notification_cfg->instances, inst);
|
|
||||||
_gc_orient(gcc, gc->orient);
|
|
||||||
return gcc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_gc_shutdown(E_Gadcon_Client *gcc)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
Notification_Box_Icon *ic;
|
|
||||||
|
|
||||||
inst = gcc->data;
|
|
||||||
EINA_LIST_FREE(inst->n_box->icons, ic)
|
|
||||||
{
|
|
||||||
evas_object_del(ic->o_holder);
|
|
||||||
evas_object_del(ic->o_holder2);
|
|
||||||
if (ic->border) e_object_unref(E_OBJECT(ic->border));
|
|
||||||
if (ic->notif) e_notification_unref(ic->notif);
|
|
||||||
free(ic);
|
|
||||||
}
|
|
||||||
if (inst->n_box->o_empty) evas_object_del(inst->n_box->o_empty);
|
|
||||||
if (inst->n_box->o_box) evas_object_del(inst->n_box->o_box);
|
|
||||||
inst->n_box->o_box = inst->n_box->o_empty = NULL;
|
|
||||||
notification_cfg->instances = eina_list_remove(notification_cfg->instances, inst);
|
|
||||||
free(inst);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_gc_orient(E_Gadcon_Client *gcc,
|
|
||||||
E_Gadcon_Orient orient)
|
|
||||||
{
|
|
||||||
Instance *inst;
|
|
||||||
|
|
||||||
inst = gcc->data;
|
|
||||||
switch (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, MAX(eina_list_count(inst->n_box->icons), 1) * 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, MAX(eina_list_count(inst->n_box->icons), 1) * 16);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
e_gadcon_client_min_size_set(gcc, 16, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
_gc_label(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
|
||||||
{
|
|
||||||
return _("Notification Box");
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_gc_icon(const E_Gadcon_Client_Class *client_class __UNUSED__,
|
|
||||||
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));
|
|
||||||
if (!e_theme_edje_object_set(o, "base/theme/modules/notification",
|
|
||||||
"icon"))
|
|
||||||
edje_object_file_set(o, buf, "icon");
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
_gc_id_new(const E_Gadcon_Client_Class *client_class __UNUSED__)
|
|
||||||
{
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
ci = notification_box_config_item_get(NULL);
|
|
||||||
return ci->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int
|
static unsigned int
|
||||||
_notification_notify(E_Notification *n)
|
_notification_notify(E_Notification *n)
|
||||||
|
@ -176,8 +30,6 @@ _notification_notify(E_Notification *n)
|
||||||
e_notification_id_set(n, new_id);
|
e_notification_id_set(n, new_id);
|
||||||
|
|
||||||
popuped = notification_popup_notify(n, replaces_id, appname);
|
popuped = notification_popup_notify(n, replaces_id, appname);
|
||||||
notification_box_notify(n, replaces_id, new_id);
|
|
||||||
|
|
||||||
if (!popuped)
|
if (!popuped)
|
||||||
{
|
{
|
||||||
e_notification_hint_urgency_set(n, 4);
|
e_notification_hint_urgency_set(n, 4);
|
||||||
|
@ -297,18 +149,6 @@ e_modapi_init(E_Module *m)
|
||||||
_("Notification"), NULL,
|
_("Notification"), NULL,
|
||||||
buf, e_int_config_notification_module);
|
buf, e_int_config_notification_module);
|
||||||
|
|
||||||
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, show_popup, INT);
|
|
||||||
E_CONFIG_VAL(D, T, focus_window, 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);
|
conf_edd = E_CONFIG_DD_NEW("Notification_Config", Config);
|
||||||
#undef T
|
#undef T
|
||||||
|
@ -324,7 +164,6 @@ e_modapi_init(E_Module *m)
|
||||||
E_CONFIG_VAL(D, T, force_timeout, INT);
|
E_CONFIG_VAL(D, T, force_timeout, INT);
|
||||||
E_CONFIG_VAL(D, T, ignore_replacement, INT);
|
E_CONFIG_VAL(D, T, ignore_replacement, INT);
|
||||||
E_CONFIG_VAL(D, T, dual_screen, INT);
|
E_CONFIG_VAL(D, T, dual_screen, INT);
|
||||||
E_CONFIG_LIST(D, T, items, conf_item_edd);
|
|
||||||
|
|
||||||
notification_cfg = e_config_domain_load("module.notification", conf_edd);
|
notification_cfg = e_config_domain_load("module.notification", conf_edd);
|
||||||
if (notification_cfg &&
|
if (notification_cfg &&
|
||||||
|
@ -359,54 +198,34 @@ e_modapi_init(E_Module *m)
|
||||||
|
|
||||||
notification_cfg->last_config_mode.presentation = e_config->mode.presentation;
|
notification_cfg->last_config_mode.presentation = e_config->mode.presentation;
|
||||||
notification_cfg->last_config_mode.offline = e_config->mode.offline;
|
notification_cfg->last_config_mode.offline = e_config->mode.offline;
|
||||||
notification_cfg->handlers = eina_list_append
|
notification_cfg->handler = ecore_event_handler_add
|
||||||
(notification_cfg->handlers, ecore_event_handler_add
|
|
||||||
(E_EVENT_CONFIG_MODE_CHANGED, (Ecore_Event_Handler_Cb)_notification_cb_config_mode_changed,
|
(E_EVENT_CONFIG_MODE_CHANGED, (Ecore_Event_Handler_Cb)_notification_cb_config_mode_changed,
|
||||||
notification_cfg));
|
notification_cfg);
|
||||||
notification_cfg->initial_mode_timer = ecore_timer_add
|
notification_cfg->initial_mode_timer = ecore_timer_add
|
||||||
(0.1, (Ecore_Task_Cb)_notification_cb_initial_mode_timer, notification_cfg);
|
(0.1, (Ecore_Task_Cb)_notification_cb_initial_mode_timer, notification_cfg);
|
||||||
|
|
||||||
/* set up the borders events callbacks */
|
|
||||||
notification_cfg->handlers = eina_list_append
|
|
||||||
(notification_cfg->handlers, ecore_event_handler_add
|
|
||||||
(E_EVENT_BORDER_REMOVE, (Ecore_Event_Handler_Cb)notification_box_cb_border_remove, NULL));
|
|
||||||
|
|
||||||
notification_mod = m;
|
notification_mod = m;
|
||||||
e_gadcon_provider_register(&_gc_class);
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_modapi_shutdown(E_Module *m __UNUSED__)
|
e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||||
{
|
{
|
||||||
Ecore_Event_Handler *h;
|
|
||||||
Config_Item *ci;
|
|
||||||
|
|
||||||
e_gadcon_provider_unregister(&_gc_class);
|
|
||||||
|
|
||||||
if (notification_cfg->initial_mode_timer)
|
if (notification_cfg->initial_mode_timer)
|
||||||
ecore_timer_del(notification_cfg->initial_mode_timer);
|
ecore_timer_del(notification_cfg->initial_mode_timer);
|
||||||
|
|
||||||
EINA_LIST_FREE(notification_cfg->handlers, h)
|
if (notification_cfg->handler)
|
||||||
ecore_event_handler_del(h);
|
ecore_event_handler_del(notification_cfg->handler);
|
||||||
|
|
||||||
if (notification_cfg->cfd) e_object_del(E_OBJECT(notification_cfg->cfd));
|
if (notification_cfg->cfd) e_object_del(E_OBJECT(notification_cfg->cfd));
|
||||||
e_configure_registry_item_del("extensions/notification");
|
e_configure_registry_item_del("extensions/notification");
|
||||||
e_configure_registry_category_del("extensions");
|
e_configure_registry_category_del("extensions");
|
||||||
|
|
||||||
EINA_LIST_FREE(notification_cfg->items, ci)
|
|
||||||
{
|
|
||||||
eina_stringshare_del(ci->id);
|
|
||||||
free(ci);
|
|
||||||
}
|
|
||||||
|
|
||||||
notification_box_shutdown();
|
|
||||||
notification_popup_shutdown();
|
notification_popup_shutdown();
|
||||||
|
|
||||||
e_notification_daemon_free(notification_cfg->daemon);
|
e_notification_daemon_free(notification_cfg->daemon);
|
||||||
e_notification_daemon_shutdown();
|
e_notification_daemon_shutdown();
|
||||||
_notification_cfg_free(notification_cfg);
|
_notification_cfg_free(notification_cfg);
|
||||||
E_CONFIG_DD_FREE(conf_item_edd);
|
|
||||||
E_CONFIG_DD_FREE(conf_edd);
|
E_CONFIG_DD_FREE(conf_edd);
|
||||||
notification_mod = NULL;
|
notification_mod = NULL;
|
||||||
|
|
||||||
|
@ -416,9 +235,7 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||||
EAPI int
|
EAPI int
|
||||||
e_modapi_save(E_Module *m __UNUSED__)
|
e_modapi_save(E_Module *m __UNUSED__)
|
||||||
{
|
{
|
||||||
int ret;
|
return e_config_domain_save("module.notification", conf_edd, notification_cfg);
|
||||||
ret = e_config_domain_save("module.notification", conf_edd, notification_cfg);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callbacks */
|
/* Callbacks */
|
||||||
|
@ -459,6 +276,6 @@ _notification_cfg_new(void)
|
||||||
static void
|
static void
|
||||||
_notification_cfg_free(Config *cfg)
|
_notification_cfg_free(Config *cfg)
|
||||||
{
|
{
|
||||||
E_FREE(cfg);
|
free(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
#ifndef E_MOD_MAIN_H
|
#ifndef E_MOD_MAIN_H
|
||||||
#define E_MOD_MAIN_H
|
#define E_MOD_MAIN_H
|
||||||
|
|
||||||
#define HAVE_EDBUS 1
|
#include "e.h"
|
||||||
#include <e.h>
|
|
||||||
#include <E_Notification_Daemon.h>
|
#include <E_Notification_Daemon.h>
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#define MOD_CFG_FILE_EPOCH 0x0002
|
#define MOD_CFG_FILE_EPOCH 0x0002
|
||||||
#define MOD_CFG_FILE_GENERATION 0x0006
|
#define MOD_CFG_FILE_GENERATION 0x0007
|
||||||
#define MOD_CFG_FILE_VERSION \
|
#define MOD_CFG_FILE_VERSION \
|
||||||
((MOD_CFG_FILE_EPOCH << 16) | MOD_CFG_FILE_GENERATION)
|
((MOD_CFG_FILE_EPOCH << 16) | MOD_CFG_FILE_GENERATION)
|
||||||
|
|
||||||
typedef enum _Popup_Corner Popup_Corner;
|
typedef enum _Popup_Corner Popup_Corner;
|
||||||
typedef struct _Config Config;
|
typedef struct _Config Config;
|
||||||
typedef struct _Config_Item Config_Item;
|
|
||||||
typedef struct _Instance Instance;
|
|
||||||
typedef struct _Popup_Data Popup_Data;
|
typedef struct _Popup_Data Popup_Data;
|
||||||
typedef struct _Notification_Box Notification_Box;
|
|
||||||
typedef struct _Notification_Box_Icon Notification_Box_Icon;
|
|
||||||
|
|
||||||
enum _Popup_Corner
|
enum _Popup_Corner
|
||||||
{
|
{
|
||||||
|
@ -47,11 +41,7 @@ struct _Config
|
||||||
Eina_Bool offline;
|
Eina_Bool offline;
|
||||||
} last_config_mode;
|
} last_config_mode;
|
||||||
|
|
||||||
Eina_List *instances;
|
Ecore_Event_Handler *handler;
|
||||||
Eina_List *n_box;
|
|
||||||
Eina_List *config_dialog;
|
|
||||||
Eina_List *handlers;
|
|
||||||
Eina_List *items;
|
|
||||||
Eina_List *popups;
|
Eina_List *popups;
|
||||||
int next_id;
|
int next_id;
|
||||||
|
|
||||||
|
@ -59,50 +49,6 @@ struct _Config
|
||||||
E_Notification_Daemon *daemon;
|
E_Notification_Daemon *daemon;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Config_Item
|
|
||||||
{
|
|
||||||
const char *id;
|
|
||||||
int show_label;
|
|
||||||
int show_popup;
|
|
||||||
int focus_window;
|
|
||||||
int store_low;
|
|
||||||
int store_normal;
|
|
||||||
int store_critical;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Instance
|
|
||||||
{
|
|
||||||
E_Gadcon_Client *gcc;
|
|
||||||
Notification_Box *n_box;
|
|
||||||
Config_Item *ci;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct _Notification_Box
|
|
||||||
{
|
|
||||||
const char *id;
|
|
||||||
Instance *inst;
|
|
||||||
Evas_Object *o_box;
|
|
||||||
Evas_Object *o_empty;
|
|
||||||
Eina_List *icons;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Notification_Box_Icon
|
|
||||||
{
|
|
||||||
Notification_Box *n_box;
|
|
||||||
unsigned int n_id;
|
|
||||||
const char *label;
|
|
||||||
Evas_Object *o_holder;
|
|
||||||
Evas_Object *o_icon;
|
|
||||||
Evas_Object *o_holder2;
|
|
||||||
Evas_Object *o_icon2;
|
|
||||||
E_Border *border;
|
|
||||||
E_Notification *notif;
|
|
||||||
|
|
||||||
int popup;
|
|
||||||
Ecore_Timer *mouse_in_timer;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _Popup_Data
|
struct _Popup_Data
|
||||||
{
|
{
|
||||||
E_Notification *notif;
|
E_Notification *notif;
|
||||||
|
@ -120,15 +66,6 @@ int notification_popup_notify(E_Notification *n, unsigned int replaces_id, cons
|
||||||
void notification_popup_shutdown(void);
|
void notification_popup_shutdown(void);
|
||||||
void notification_popup_close(unsigned int id);
|
void notification_popup_close(unsigned int id);
|
||||||
|
|
||||||
void notification_box_notify(E_Notification *n, unsigned int replaces_id, unsigned int id);
|
|
||||||
void notification_box_shutdown(void);
|
|
||||||
void notification_box_visible_set(Notification_Box *b, Eina_Bool visible);
|
|
||||||
Notification_Box *notification_box_get(const char *id, Evas *evas);
|
|
||||||
Config_Item *notification_box_config_item_get(const char *id);
|
|
||||||
void notification_box_orient_set(Notification_Box *b, int horizontal);
|
|
||||||
void notification_box_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
|
||||||
Eina_Bool notification_box_cb_border_remove(void *data, int type, E_Event_Border_Remove *ev);
|
|
||||||
|
|
||||||
EAPI extern E_Module_Api e_modapi;
|
EAPI extern E_Module_Api e_modapi;
|
||||||
EAPI void *e_modapi_init(E_Module *m);
|
EAPI void *e_modapi_init(E_Module *m);
|
||||||
EAPI int e_modapi_shutdown(E_Module *m);
|
EAPI int e_modapi_shutdown(E_Module *m);
|
||||||
|
@ -136,14 +73,10 @@ EAPI int e_modapi_save(E_Module *m);
|
||||||
|
|
||||||
void _gc_orient (E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
void _gc_orient (E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
|
||||||
|
|
||||||
void config_notification_box_module(Config_Item *ci);
|
E_Config_Dialog *e_int_config_notification_module(E_Container *con, const char *params);
|
||||||
|
|
||||||
E_Config_Dialog *e_int_config_notification_module(E_Container *con,
|
|
||||||
const char *params __UNUSED__);
|
|
||||||
|
|
||||||
extern E_Module *notification_mod;
|
extern E_Module *notification_mod;
|
||||||
extern Config *notification_cfg;
|
extern Config *notification_cfg;
|
||||||
extern const E_Gadcon_Client_Class _gc_class;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup Optional_Monitors
|
* @addtogroup Optional_Monitors
|
||||||
|
|
Loading…
Reference in New Issue