1 #include <Elementary.h>
5 * @defgroup TickerNoti TickerNoti
10 typedef struct _Widget_Data Widget_Data;
14 Evas_Object *win_indi;
15 Evas_Object *win_detail;
16 Evas_Object *edje_indi;
17 Evas_Object *edje_detail;
18 Evas_Object *icon_indi;
19 Evas_Object *icon_detail;
20 Evas_Object *button_detail;
22 const char *label_indi;
23 const char *label_detail;
26 int detail_view_height;
29 Elm_Tickernoti_Mode mode;
32 static const char *widtype = NULL;
33 static void _del_hook(Evas_Object *obj);
34 static void _theme_hook(Evas_Object *obj);
35 static void _sizing_eval(Evas_Object *obj);
40 Evas_Object *obj = data;
45 _del_hook(Evas_Object *obj)
47 Widget_Data *wd = elm_widget_data_get(obj);
50 Evas_Object *p = elm_widget_parent_get(obj);
51 if (p == wd->win_indi) ecore_job_add (_del_job, p);
53 evas_object_del (wd->edje_indi);
55 evas_object_del (wd->edje_detail);
56 wd->edje_detail = NULL;
57 evas_object_del (wd->win_detail);
58 wd->win_detail = NULL;
64 _theme_hook(Evas_Object *obj)
66 Widget_Data *wd = elm_widget_data_get(obj);
67 char *data_win_height = NULL;
71 _elm_theme_object_set (wd->win_indi, wd->edje_indi, "tickernoti", "base", elm_widget_style_get(obj));
72 _elm_theme_object_set (wd->edje_detail, wd->edje_detail, "tickernoti", "2line", elm_widget_style_get(obj));
74 edje_object_scale_set (wd->edje_indi, elm_widget_scale_get(obj) * _elm_config->scale);
75 edje_object_scale_set (wd->edje_detail, elm_widget_scale_get(obj) * _elm_config->scale);
77 /* tickernoti indicator height set */
78 data_win_height = (char *)edje_object_data_get (wd->edje_indi, "height");
79 if (data_win_height != NULL && elm_scale_get() > 0.0)
80 wd->indicator_height = (int)(elm_scale_get() * atoi(data_win_height));
82 /* tickernoti detail height set */
83 data_win_height = (char *)edje_object_data_get (wd->edje_detail, "height");
84 if (data_win_height != NULL && elm_scale_get() > 0.0)
85 wd->detail_view_height = (int)(elm_scale_get() * atoi(data_win_height));
87 #ifdef HAVE_ELEMENTARY_X
90 ecore_x_window_size_get (ecore_x_window_root_first_get(), &w, NULL);
91 evas_object_resize (wd->win_indi, w, wd->indicator_height);
92 evas_object_resize (wd->win_detail, w, wd->detail_view_height);
99 _sizing_eval(Evas_Object *obj)
101 Widget_Data *wd = elm_widget_data_get(obj);
102 // Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
106 edje_object_size_min_calc(wd->win_detail, &minw, &minh);
107 evas_object_size_hint_min_set(obj, minw, minh);
108 evas_object_size_hint_max_set(obj, maxw, maxh);
109 evas_object_size_hint_align_set(obj, maxw, maxh);
112 #ifdef HAVE_ELEMENTARY_X
114 _make_notification_window (Evas_Object *obj)
116 Widget_Data *wd = elm_widget_data_get(obj);
120 Ecore_X_Atom _notification_level_atom;
122 /* elm_win_xwindow_get() must call after elm_win_alpha_set() */
123 xwin = elm_win_xwindow_get (obj);
124 ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
125 ecore_x_icccm_hints_set(xwin, 0, ECORE_X_WINDOW_STATE_HINT_NONE, 0, 0, 0, 0, 0);
127 /* Create atom for notification level */
128 _notification_level_atom = ecore_x_atom_get ("_E_ILLUME_NOTIFICATION_LEVEL");
130 /* HIGH:150, NORMAL:100, LOW:50 */
133 /* Set notification level of the window */
134 ecore_x_window_prop_property_set (xwin, _notification_level_atom, ECORE_X_ATOM_CARDINAL, 32, &level, 1);
138 static void _detail_show_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
140 evas_object_smart_callback_call ((Evas_Object *)data, "detail,show", NULL);
143 static void _detail_hide_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
145 evas_object_smart_callback_call ((Evas_Object *)data, "detail,hide", NULL);
149 *_create_window (Evas_Object *parent, const char *name)
153 win = elm_win_add (parent, name, ELM_WIN_BASIC);
155 elm_win_title_set (win, name);
156 elm_win_borderless_set (win, EINA_TRUE);
157 elm_win_autodel_set (win, EINA_TRUE);
158 elm_win_alpha_set (win, EINA_TRUE);
161 _make_notification_window (win);
167 _create_tickernoti_indi (Evas_Object *obj)
169 Widget_Data *wd = elm_widget_data_get(obj);
173 #ifdef HAVE_ELEMENTARY_X
177 char *data_win_height = NULL;
178 evas_object_move (wd->win_indi, 0, 0);
180 e = evas_object_evas_get (wd->win_indi);
182 wd->edje_indi = edje_object_add (e);
183 _elm_theme_object_set (wd->win_indi, wd->edje_indi, "tickernoti", "base", "default");
184 elm_win_resize_object_add (wd->win_indi, wd->edje_indi);
186 /* tickernoti indicator height set */
187 data_win_height = (char *)edje_object_data_get (wd->edje_indi, "height");
188 if (data_win_height != NULL && elm_scale_get() > 0.0)
189 wd->indicator_height = (int)(elm_scale_get() * atoi(data_win_height));
191 #ifdef HAVE_ELEMENTARY_X
192 ecore_x_window_size_get (ecore_x_window_root_first_get(), &w, NULL);
193 evas_object_resize (wd->win_indi, w, wd->indicator_height);
196 edje_object_signal_callback_add (wd->edje_indi, "request,detail,show", "", _detail_show_cb, obj);
197 evas_object_show (wd->edje_indi);
201 _create_tickernoti_detail (Evas_Object *obj)
203 Widget_Data *wd = elm_widget_data_get(obj);
204 char *data_win_height = NULL;
210 evas_object_move (wd->win_detail, 0, 0);
211 e = evas_object_evas_get (wd->win_detail);
213 wd->edje_detail = edje_object_add (e);
214 _elm_theme_object_set (wd->win_detail, wd->edje_detail, "tickernoti", "2line", "default");
215 elm_win_resize_object_add (wd->win_detail, wd->edje_detail);
217 /* tickernoti detail height set */
218 data_win_height = (char *)edje_object_data_get (wd->edje_detail, "height");
219 if (data_win_height != NULL && elm_scale_get() > 0.0)
220 wd->detail_view_height = (int)(elm_scale_get() * atoi(data_win_height));
222 #ifdef HAVE_ELEMENTARY_X
225 ecore_x_window_size_get (ecore_x_window_root_first_get(), &w, NULL);
226 evas_object_resize (wd->win_detail, w, wd->detail_view_height);
229 edje_object_signal_callback_add(wd->edje_detail, "request,detail,hide", "", _detail_hide_cb, obj);
230 evas_object_show (wd->edje_detail);
234 _show(void *data, Evas *e, Evas_Object *obj, void *event_info)
236 Widget_Data *wd = elm_widget_data_get(obj);
239 if (wd->mode == ELM_TICKERNOTI_DEFAULT)
241 evas_object_hide (wd->win_detail);
242 _make_notification_window (wd->win_indi);
243 evas_object_show (wd->win_indi);
244 edje_object_signal_emit (wd->edje_indi, "effect,show", "bg_1line");
246 else if (wd->mode == ELM_TICKERNOTI_DETAILVIEW)
248 evas_object_hide (wd->win_indi);
249 _make_notification_window (wd->win_detail);
250 evas_object_show (wd->win_detail);
251 edje_object_signal_emit (wd->edje_detail, "effect,show", "bg_2line");
256 _hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
258 Widget_Data *wd = elm_widget_data_get(obj);
261 evas_object_hide (obj);
262 evas_object_hide (wd->win_indi);
263 evas_object_hide (wd->win_detail);
267 * Add a tickernoti object to @p parent
269 * @param parent The parent object
271 * @return The tickernoti object, or NULL upon failure
273 * @ingroup TickerNoti
276 elm_tickernoti_add(Evas_Object *parent)
282 wd = ELM_NEW(Widget_Data);
283 wd->win_indi = _create_window (parent, "indi");
284 wd->win_detail = _create_window (parent, "detail");
286 if (!parent) parent = wd->win_indi;
288 e = evas_object_evas_get(parent);
289 obj = elm_widget_add(e);
290 ELM_SET_WIDTYPE(widtype, "tickernoti");
291 elm_widget_type_set(obj, "tickernoti");
292 elm_widget_sub_object_add(parent, obj);
293 elm_widget_data_set(obj, wd);
294 elm_widget_del_hook_set(obj, _del_hook);
295 elm_widget_theme_hook_set(obj, _theme_hook);
296 elm_widget_can_focus_set(obj, 0);
298 wd->edje_indi = NULL;
299 wd->edje_detail = NULL;
300 wd->icon_indi = NULL;
301 wd->icon_detail = NULL;
302 wd->button_detail = NULL;
304 wd->label_indi = NULL;
305 wd->label_detail = NULL;
307 wd->indicator_height = 0;
310 wd->mode = ELM_TICKERNOTI_DEFAULT;
312 _create_tickernoti_indi (obj);
313 _create_tickernoti_detail (obj);
315 evas_object_event_callback_add (obj, EVAS_CALLBACK_SHOW, _show, NULL);
316 evas_object_event_callback_add (obj, EVAS_CALLBACK_HIDE, _hide, NULL);
323 * Set the icon object used on the tickernoti object
325 * @param obj The tickernotil object
326 * @param icon The icon object will be used on the tickernoti object
327 * @ingroup TickerNoti
330 elm_tickernoti_icon_set (const Evas_Object *obj, Evas_Object *icon)
332 ELM_CHECK_WIDTYPE(obj, widtype);
333 Widget_Data *wd = elm_widget_data_get(obj);
336 edje_object_part_swallow (wd->edje_indi, "icon", icon);
337 wd->icon_indi = icon;
341 * Get the icon object used on the tickernoti object
343 * @param obj The tickernotil object
344 * @return The icon object inside the tickernoti
345 * @ingroup TickerNoti
348 elm_tickernoti_icon_get (const Evas_Object *obj)
350 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
351 Widget_Data *wd = elm_widget_data_get(obj);
352 if (!wd) return NULL;
353 return wd->icon_indi;
357 * Set the label on the tickernoti object
359 * @param obj The tickernoti object
360 * @param label The label will be used on the tickernoti object
362 * @ingroup TickerNoti
365 elm_tickernoti_label_set (Evas_Object *obj, const char *label)
367 ELM_CHECK_WIDTYPE(obj, widtype);
368 Widget_Data *wd = elm_widget_data_get(obj);
370 if (!label) label = "";
371 eina_stringshare_replace(&wd->label_indi, label);
372 edje_object_part_text_set(wd->edje_indi, "text", label);
377 * Get the label used on the tickernoti object
379 * @param obj The tickernotil object
380 * @return The string inside the label
381 * @ingroup TickerNoti
384 elm_tickernoti_label_get (const Evas_Object *obj)
386 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
387 Widget_Data *wd = elm_widget_data_get(obj);
388 if (!wd) return NULL;
389 return wd->label_indi;
393 * Set the detail label on the tickernoti object
395 * @param obj The tickernoti object
396 * @param label The label will be used on the tickernoti object
398 * @ingroup TickerNoti
401 elm_tickernoti_detailview_label_set (Evas_Object *obj, const char *label)
403 ELM_CHECK_WIDTYPE(obj, widtype);
404 Widget_Data *wd = elm_widget_data_get(obj);
406 if (!label) label = "";
407 eina_stringshare_replace(&wd->label_detail, label);
408 edje_object_part_text_set(wd->edje_detail, "text", label);
413 * Get the detail label used on the tickernoti object
415 * @param obj The tickernotil object
416 * @return The string inside the label
417 * @ingroup TickerNoti
420 elm_tickernoti_detailview_label_get (const Evas_Object *obj)
422 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
423 Widget_Data *wd = elm_widget_data_get(obj);
424 if (!wd) return NULL;
425 return wd->label_detail;
429 * Set the button object used on the tickernoti object
431 * @param obj The tickernotil object
432 * @param button The button object will be used on the tickernoti object
433 * @ingroup TickerNoti
436 elm_tickernoti_detailview_button_set (const Evas_Object *obj, Evas_Object *button)
438 ELM_CHECK_WIDTYPE(obj, widtype);
439 Widget_Data *wd = elm_widget_data_get(obj);
442 edje_object_part_swallow (wd->edje_detail, "button", button);
443 wd->button_detail = button;
447 * Get the button object used on the tickernoti object
449 * @param obj The tickernotil object
450 * @return The button object inside the tickernoti
451 * @ingroup TickerNoti
454 elm_tickernoti_detailview_button_get (const Evas_Object *obj)
456 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
457 Widget_Data *wd = elm_widget_data_get(obj);
458 if (!wd) return NULL;
459 return wd->button_detail;
463 * Set the detail icon object used on the tickernoti object
465 * @param obj The tickernotil object
466 * @param icon The icon object will be used on the tickernoti object
467 * @ingroup TickerNoti
470 elm_tickernoti_detailview_icon_set (const Evas_Object *obj, Evas_Object *icon)
472 ELM_CHECK_WIDTYPE(obj, widtype);
473 Widget_Data *wd = elm_widget_data_get(obj);
476 edje_object_part_swallow (wd->edje_detail, "icon", icon);
477 wd->icon_detail = icon;
481 * Get the detail icon object used on the tickernoti object
483 * @param obj The tickernotil object
484 * @return The icon object inside the tickernoti
485 * @ingroup TickerNoti
488 elm_tickernoti_detailview_icon_get (const Evas_Object *obj)
490 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
491 Widget_Data *wd = elm_widget_data_get(obj);
492 if (!wd) return NULL;
493 return wd->icon_detail;
497 * Get the rotation used on the tickernoti object
499 * @param obj The tickernotil object
500 * @return The rotation angle
501 * @ingroup TickerNoti
504 elm_tickernoti_rotation_get (const Evas_Object *obj)
506 ELM_CHECK_WIDTYPE(obj, widtype) -1;
507 Widget_Data *wd = elm_widget_data_get(obj);
513 * Set the rotation used on the tickernoti object
515 * @param obj The tickernotil object
516 * @param angle The rotation angle will be used on the tickernoti object
517 * @ingroup TickerNoti
520 elm_tickernoti_rotation_set (const Evas_Object *obj, int angle)
522 ELM_CHECK_WIDTYPE(obj, widtype);
523 Widget_Data *wd = elm_widget_data_get(obj);
526 Evas_Coord x, y, w, h;
527 #ifdef HAVE_ELEMENTARY_X
528 Evas_Coord root_w, root_h;
530 if (angle%90 != 0) return;
534 * manual calculate win_tickernoti_indi window position & size
535 * - win_indi is not full size window (480 x 27)
537 ecore_x_window_size_get (ecore_x_window_root_first_get(), &root_w, &root_h);
539 evas_object_geometry_get (wd->win_indi, &x, &y, &w, &h);
541 if (evas_object_visible_get (wd->win_detail))
542 evas_object_geometry_get (wd->win_detail, &x, &y, &w, &h);
548 #ifdef HAVE_ELEMENTARY_X
555 #ifdef HAVE_ELEMENTARY_X
558 #ifdef HAVE_ELEMENTARY_X
564 #ifdef HAVE_ELEMENTARY_X
568 #ifdef HAVE_ELEMENTARY_X
574 #ifdef HAVE_ELEMENTARY_X
583 elm_win_rotation_with_resize_set (wd->win_indi, angle);
584 evas_object_move (wd->win_indi, x, y);
585 evas_object_resize (wd->win_indi, w, wd->indicator_height);
586 if (evas_object_visible_get (wd->win_indi))
588 #ifdef HAVE_ELEMENTARY_X
589 _make_notification_window (wd->win_indi);
593 elm_win_rotation_with_resize_set (wd->win_detail, angle);
594 evas_object_move (wd->win_detail, x, y);
595 evas_object_resize (wd->win_detail, w, wd->detail_view_height);
596 if (evas_object_visible_get (wd->win_detail))
598 #ifdef HAVE_ELEMENTARY_X
599 _make_notification_window (wd->win_detail);
605 * Get the view mode on the tickernoti object
607 * @param obj The tickernotil object
608 * @return The view mode
609 * @ingroup TickerNoti
611 EAPI Elm_Tickernoti_Mode
612 elm_tickernoti_mode_get (const Evas_Object *obj)
614 ELM_CHECK_WIDTYPE(obj, widtype) -1;
615 Widget_Data *wd = elm_widget_data_get(obj);
621 * Set the view mode used on the tickernoti object
623 * @param obj The tickernotil object
624 * @param mode The view mode will be used on the tickernoti object
625 * @ingroup TickerNoti
628 elm_tickernoti_mode_set (const Evas_Object *obj, Elm_Tickernoti_Mode mode)
630 ELM_CHECK_WIDTYPE(obj, widtype);
631 Widget_Data *wd = elm_widget_data_get(obj);
635 case ELM_TICKERNOTI_DEFAULT:
636 case ELM_TICKERNOTI_DETAILVIEW:
642 printf("wd->mode : %d\n", wd->mode);
646 * Get the detail view window(elm_win) on the tickernoti object
648 * @param obj The tickernotil object
649 * @return detail view window(elm_win) object
650 * @ingroup TickerNoti
653 elm_tickernoti_detailview_get (const Evas_Object *obj)
655 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
656 Widget_Data *wd = elm_widget_data_get(obj);
657 if (!wd) return NULL;
658 return wd->win_detail;