fix icon in notification module to scale right.

SVN revision: 64550
This commit is contained in:
Carsten Haitzler 2011-10-31 09:41:27 +00:00
parent 2ebfbe9b9f
commit 218fb2917a
1 changed files with 45 additions and 71 deletions

View File

@ -40,20 +40,14 @@ notification_popup_notify(E_Notification *n,
switch (urgency) switch (urgency)
{ {
case E_NOTIFICATION_URGENCY_LOW: case E_NOTIFICATION_URGENCY_LOW:
if (!notification_cfg->show_low) if (!notification_cfg->show_low) return 0;
return 0;
break; break;
case E_NOTIFICATION_URGENCY_NORMAL: case E_NOTIFICATION_URGENCY_NORMAL:
if (!notification_cfg->show_normal) if (!notification_cfg->show_normal) return 0;
return 0;
break; break;
case E_NOTIFICATION_URGENCY_CRITICAL: case E_NOTIFICATION_URGENCY_CRITICAL:
if (!notification_cfg->show_critical) if (!notification_cfg->show_critical) return 0;
return 0;
break; break;
default: default:
break; break;
} }
@ -92,8 +86,7 @@ notification_popup_notify(E_Notification *n,
if (timeout < 0 || notification_cfg->force_timeout) if (timeout < 0 || notification_cfg->force_timeout)
timeout = notification_cfg->timeout; timeout = notification_cfg->timeout;
else else timeout = (double)timeout / 1000.0;
timeout = (double)timeout / 1000.0;
if (timeout > 0) if (timeout > 0)
popup->timer = ecore_timer_add(timeout, (Ecore_Task_Cb)_notification_timer_cb, popup); popup->timer = ecore_timer_add(timeout, (Ecore_Task_Cb)_notification_timer_cb, popup);
@ -130,19 +123,13 @@ _notification_popup_merge(E_Notification *n)
size_t len; size_t len;
str1 = e_notification_app_name_get(n); str1 = e_notification_app_name_get(n);
/* printf("merge %s\n", str1); */ if (!str1) return NULL;
if (!str1)
return NULL;
EINA_LIST_FOREACH(notification_cfg->popups, l, popup) EINA_LIST_FOREACH(notification_cfg->popups, l, popup)
{ {
if (!popup->notif) if (!popup->notif) continue;
continue;
if (!(str2 = e_notification_app_name_get(popup->notif))) if (!(str2 = e_notification_app_name_get(popup->notif)))
continue; continue;
if (str1 == str2) break; if (str1 == str2) break;
} }
@ -173,10 +160,10 @@ _notification_popup_merge(E_Notification *n)
if ((!!i) + (!!i2) == 1) return NULL; if ((!!i) + (!!i2) == 1) return NULL;
a = i->data, a2 = i2->data; a = i->data, a2 = i2->data;
if ((!!a) + (!!a2) == 1) return NULL; if ((!!a) + (!!a2) == 1) return NULL;
if (e_notification_action_id_get(a) != e_notification_action_id_get(a2)) if (e_notification_action_id_get(a) !=
return NULL; e_notification_action_id_get(a2)) return NULL;
if (e_notification_action_name_get(a) != e_notification_action_name_get(a2)) if (e_notification_action_name_get(a) !=
return NULL; e_notification_action_name_get(a2)) return NULL;
} }
/* TODO p->n is not fallback alert..*/ /* TODO p->n is not fallback alert..*/
@ -187,10 +174,8 @@ _notification_popup_merge(E_Notification *n)
len = strlen(body_old); len = strlen(body_old);
len += strlen(body_new); len += strlen(body_new);
if (len < 65536) if (len < 65536) body_final = alloca(len + 5);
body_final = alloca(len + 5); else body_final = malloc(len + 5);
else
body_final = malloc(len + 5);
snprintf(body_final, len, "%s<ps>%s", body_old, body_new); snprintf(body_final, len, "%s<ps>%s", body_old, body_new);
/* printf("set body %s\n", body_final); */ /* printf("set body %s\n", body_final); */
@ -278,7 +263,8 @@ _notification_popup_new(E_Notification *n)
popup->e = popup->win->evas; popup->e = popup->win->evas;
/* Setup the theme */ /* Setup the theme */
snprintf(buf, sizeof(buf), "%s/e-module-notification.edj", notification_mod->dir); snprintf(buf, sizeof(buf), "%s/e-module-notification.edj",
notification_mod->dir);
popup->theme = edje_object_add(popup->e); popup->theme = edje_object_add(popup->e);
if (!e_theme_edje_object_set(popup->theme, if (!e_theme_edje_object_set(popup->theme,
@ -327,26 +313,24 @@ _notification_popup_place(Popup_Data *popup,
e_popup_move(popup->win, e_popup_move(popup->win,
to_edge, to_edge + pos); to_edge, to_edge + pos);
break; break;
case CORNER_TR: case CORNER_TR:
e_popup_move(popup->win, e_popup_move(popup->win,
con->w - (w + to_edge), con->w - (w + to_edge),
to_edge + pos); to_edge + pos);
break; break;
case CORNER_BL: case CORNER_BL:
e_popup_move(popup->win, e_popup_move(popup->win,
to_edge, to_edge,
(con->h - h) - (to_edge + pos)); (con->h - h) - (to_edge + pos));
break; break;
case CORNER_BR: case CORNER_BR:
e_popup_move(popup->win, e_popup_move(popup->win,
con->w - (w + to_edge), con->w - (w + to_edge),
(con->h - h) - (to_edge + pos)); (con->h - h) - (to_edge + pos));
break; break;
default:
break;
} }
return pos + h + gap; return pos + h + gap;
} }
@ -379,7 +363,6 @@ _notification_popup_refresh(Popup_Data *popup)
if (popup->app_icon) if (popup->app_icon)
{ {
edje_object_part_unswallow(popup->theme, popup->app_icon);
evas_object_del(popup->app_icon); evas_object_del(popup->app_icon);
popup->app_icon = NULL; popup->app_icon = NULL;
} }
@ -402,8 +385,7 @@ _notification_popup_refresh(Popup_Data *popup)
if (endptr) if (endptr)
{ {
height = strtol(endptr, NULL, 10); height = strtol(endptr, NULL, 10);
if (errno || (height < 1)) if (errno || (height < 1)) height = 80;
height = 80;
} }
else height = 80; else height = 80;
} }
@ -419,14 +401,14 @@ _notification_popup_refresh(Popup_Data *popup)
unsigned int size; unsigned int size;
size = e_util_icon_size_normalize(width * e_scale); size = e_util_icon_size_normalize(width * e_scale);
new_path = efreet_icon_path_find(e_config->icon_theme, icon_path, size); new_path = efreet_icon_path_find(e_config->icon_theme,
icon_path, size);
if (new_path) if (new_path)
icon_path = new_path; icon_path = new_path;
else else
{ {
Evas_Object *o = e_icon_add(popup->e); Evas_Object *o = e_icon_add(popup->e);
if (!e_util_icon_theme_set(o, icon_path)) if (!e_util_icon_theme_set(o, icon_path)) evas_object_del(o);
evas_object_del(o);
else else
{ {
popup->app_icon = o; popup->app_icon = o;
@ -438,20 +420,13 @@ _notification_popup_refresh(Popup_Data *popup)
if (!popup->app_icon) if (!popup->app_icon)
{ {
popup->app_icon = evas_object_image_add(popup->e); popup->app_icon = e_icon_add(popup->e);
evas_object_image_alpha_set(popup->app_icon, 1); if (!e_icon_file_set(popup->app_icon, icon_path))
evas_object_image_file_set(popup->app_icon, icon_path, NULL);
if (evas_object_image_load_error_get(popup->app_icon))
{ {
evas_object_del(popup->app_icon); evas_object_del(popup->app_icon);
popup->app_icon = NULL; popup->app_icon = NULL;
} }
else else e_icon_size_get(popup->app_icon, &w, &h);
{
evas_object_image_size_get(popup->app_icon, &w, &h);
evas_object_image_fill_set(popup->app_icon, 0, 0, w, h);
}
} }
} }
else else
@ -460,8 +435,10 @@ _notification_popup_refresh(Popup_Data *popup)
if (!img) img = e_notification_hint_image_data_get(popup->notif); if (!img) img = e_notification_hint_image_data_get(popup->notif);
if (img) if (img)
{ {
popup->app_icon = e_notification_image_evas_object_add(popup->e, img); popup->app_icon = e_notification_image_evas_object_add(popup->e,
evas_object_image_alpha_set(popup->app_icon, 1); img);
evas_object_image_filled_set(popup->app_icon, EINA_TRUE);
evas_object_image_alpha_set(popup->app_icon, EINA_TRUE);
evas_object_image_size_get(popup->app_icon, &w, &h); evas_object_image_size_get(popup->app_icon, &w, &h);
} }
} }
@ -470,28 +447,31 @@ _notification_popup_refresh(Popup_Data *popup)
{ {
char buf[PATH_MAX]; char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/e-module-notification.edj", notification_mod->dir); snprintf(buf, sizeof(buf), "%s/e-module-notification.edj",
notification_mod->dir);
popup->app_icon = edje_object_add(popup->e); popup->app_icon = edje_object_add(popup->e);
if (!e_theme_edje_object_set(popup->app_icon, "base/theme/modules/notification", if (!e_theme_edje_object_set(popup->app_icon,
"base/theme/modules/notification",
"modules/notification/logo")) "modules/notification/logo"))
edje_object_file_set(popup->app_icon, buf, "modules/notification/logo"); edje_object_file_set(popup->app_icon, buf,
w = width; h = height; "modules/notification/logo");
w = width;
h = height;
} }
if (w > width || h > height) if ((w > width) || (h > height))
{ {
int v; int v;
v = w > h ? w : h; v = w > h ? w : h;
h = h * height / v; h = h * height / v;
w = w * width / v; w = w * width / v;
evas_object_image_fill_set(popup->app_icon, 0, 0, w, h);
} }
evas_object_resize(popup->app_icon, w, h);
edje_extern_object_min_size_set(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_extern_object_max_size_set(popup->app_icon, w, h);
edje_object_calc_force(popup->theme); edje_object_calc_force(popup->theme);
edje_object_part_swallow(popup->theme, "notification.swallow.app_icon", popup->app_icon); edje_object_part_swallow(popup->theme, "notification.swallow.app_icon",
popup->app_icon);
edje_object_signal_emit(popup->theme, "notification,icon", "notification"); edje_object_signal_emit(popup->theme, "notification,icon", "notification");
/* Fill up the event message */ /* Fill up the event message */
@ -513,13 +493,10 @@ _notification_popup_find(unsigned int id)
Popup_Data *popup; Popup_Data *popup;
if (!id) return NULL; if (!id) return NULL;
EINA_LIST_FOREACH(notification_cfg->popups, l, popup) EINA_LIST_FOREACH(notification_cfg->popups, l, popup)
{ {
if (e_notification_id_get(popup->notif) == id) if (e_notification_id_get(popup->notif) == id) return popup;
return popup;
} }
return NULL; return NULL;
} }
@ -539,10 +516,8 @@ _notification_popup_del(unsigned int id,
notification_cfg->popups = eina_list_remove_list(notification_cfg->popups, l); notification_cfg->popups = eina_list_remove_list(notification_cfg->popups, l);
} }
else else
{
pos = _notification_popup_place(popup, pos); pos = _notification_popup_place(popup, pos);
} }
}
next_pos = pos; next_pos = pos;
} }
@ -557,9 +532,8 @@ _notification_popdown(Popup_Data *popup,
evas_object_del(popup->theme); evas_object_del(popup->theme);
e_object_del(E_OBJECT(popup->win)); e_object_del(E_OBJECT(popup->win));
e_notification_closed_set(popup->notif, 1); e_notification_closed_set(popup->notif, 1);
e_notification_daemon_signal_notification_closed(notification_cfg->daemon, e_notification_daemon_signal_notification_closed
e_notification_id_get(popup->notif), (notification_cfg->daemon, e_notification_id_get(popup->notif), reason);
reason);
e_notification_unref(popup->notif); e_notification_unref(popup->notif);
free(popup); free(popup);
} }