1 #include <Elementary.h>
5 * @defgroup TickerNoti TickerNoti
10 typedef struct _Widget_Data Widget_Data;
14 Evas_Object *win_indi,
22 const char *label_indi,
28 Elm_Tickernoti_Mode mode;
31 static const char *widtype = NULL;
32 static void _del_hook(Evas_Object *obj);
33 static void _theme_hook(Evas_Object *obj);
34 static void _sizing_eval(Evas_Object *obj);
39 Evas_Object *obj = data;
44 _del_hook(Evas_Object *obj)
46 Widget_Data *wd = elm_widget_data_get(obj);
49 Evas_Object *p = elm_widget_parent_get(obj);
50 if (p == wd->win_indi) {
51 ecore_job_add (_del_job, p);
54 evas_object_del (wd->edje_indi);
56 evas_object_del (wd->edje_detail);
57 wd->edje_detail = NULL;
58 evas_object_del (wd->win_detail);
59 wd->win_detail = NULL;
65 _theme_hook(Evas_Object *obj)
67 Widget_Data *wd = elm_widget_data_get(obj);
70 _elm_theme_object_set (wd->win_indi, wd->edje_indi, "tickernoti", "base", elm_widget_style_get(obj));
71 _elm_theme_object_set (wd->edje_detail, wd->edje_detail, "tickernoti", "2line", elm_widget_style_get(obj));
73 edje_object_scale_set (wd->edje_indi, elm_widget_scale_get(obj) * _elm_config->scale);
74 edje_object_scale_set (wd->edje_detail, elm_widget_scale_get(obj) * _elm_config->scale);
80 _sizing_eval(Evas_Object *obj)
82 Widget_Data *wd = elm_widget_data_get(obj);
83 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
87 edje_object_size_min_calc(wd->win_detail, &minw, &minh);
88 evas_object_size_hint_min_set(obj, minw, minh);
89 evas_object_size_hint_max_set(obj, maxw, maxh);
90 evas_object_size_hint_align_set(obj, maxw, maxh);
95 _make_notification_window (Evas_Object *obj)
99 /* elm_win_xwindow_get() must call after elm_win_alpha_set() */
100 xwin = elm_win_xwindow_get (obj);
101 ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
104 static void _detail_show_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
106 evas_object_smart_callback_call ((Evas_Object *)data, "detail,show", NULL);
109 static void _detail_hide_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
111 evas_object_smart_callback_call ((Evas_Object *)data, "detail,hide", NULL);
115 *_create_window (Evas_Object *parent, const char *name)
119 win = elm_win_add (parent, name, ELM_WIN_BASIC);
122 elm_win_title_set (win, name);
123 elm_win_borderless_set (win, EINA_TRUE);
124 elm_win_autodel_set (win, EINA_TRUE);
125 elm_win_alpha_set (win, EINA_TRUE);
128 _make_notification_window (win);
134 _create_tickernoti_indi (Evas_Object *obj)
136 Widget_Data *wd = elm_widget_data_get(obj);
142 char *data_win_height = NULL;
144 ecore_x_window_size_get (ecore_x_window_root_first_get(), &w, &h);
146 evas_object_move (wd->win_indi, 0, 0);
148 e = evas_object_evas_get (wd->win_indi);
150 wd->edje_indi = edje_object_add (e);
151 _elm_theme_object_set (wd->win_indi, wd->edje_indi, "tickernoti", "base", "default");
152 elm_win_resize_object_add (wd->win_indi, wd->edje_indi);
154 /* tickernoti indicator height set */
155 data_win_height = (char *)edje_object_data_get (wd->edje_indi, "height");
156 if (data_win_height != NULL && elm_scale_get() > 0.0)
157 wd->indicator_height = (int)(elm_scale_get() * atoi(data_win_height));
159 evas_object_resize (wd->win_indi, w, wd->indicator_height);
161 edje_object_signal_callback_add (wd->edje_indi, "request,detail,show", "", _detail_show_cb, obj);
162 evas_object_show (wd->edje_indi);
166 _create_tickernoti_detail (Evas_Object *obj)
168 Widget_Data *wd = elm_widget_data_get(obj);
174 ecore_x_window_size_get (ecore_x_window_root_first_get(), &w, &h);
176 evas_object_resize (wd->win_detail, w, h);
177 evas_object_move (wd->win_detail, 0, 0);
179 e = evas_object_evas_get (wd->win_detail);
181 wd->edje_detail = edje_object_add (e);
182 _elm_theme_object_set (wd->win_detail, wd->edje_detail, "tickernoti", "2line", "default");
183 elm_win_resize_object_add (wd->win_detail, wd->edje_detail);
185 edje_object_signal_callback_add(wd->edje_detail, "request,detail,hide", "", _detail_hide_cb, obj);
186 evas_object_show (wd->edje_detail);
190 _show(void *data, Evas *e, Evas_Object *obj, void *event_info)
192 Widget_Data *wd = elm_widget_data_get(obj);
195 if (wd->mode == ELM_TICKERNOTI_DEFAULT) {
196 evas_object_hide (wd->win_detail);
197 _make_notification_window (wd->win_indi);
198 evas_object_show (wd->win_indi);
199 edje_object_signal_emit (wd->edje_indi, "effect,show", "bg_1line");
201 else if (wd->mode == ELM_TICKERNOTI_DETAILVIEW) {
202 evas_object_hide (wd->win_indi);
203 _make_notification_window (wd->win_detail);
204 evas_object_show (wd->win_detail);
205 edje_object_signal_emit (wd->edje_detail, "effect,show", "bg_2line");
210 _hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
212 Widget_Data *wd = elm_widget_data_get(obj);
215 evas_object_hide (obj);
216 evas_object_hide (wd->win_indi);
217 evas_object_hide (wd->win_detail);
221 * Add a tickernoti object to @p parent
223 * @param parent The parent object
225 * @return The tickernoti object, or NULL upon failure
227 * @ingroup TickerNoti
230 elm_tickernoti_add(Evas_Object *parent)
236 wd = ELM_NEW(Widget_Data);
237 wd->win_indi = _create_window (parent, "indi");
238 wd->win_detail = _create_window (parent, "detail");
241 parent = wd->win_indi;
243 e = evas_object_evas_get(parent);
244 obj = elm_widget_add(e);
245 ELM_SET_WIDTYPE(widtype, "tickernoti");
246 elm_widget_type_set(obj, "tickernoti");
247 elm_widget_sub_object_add(parent, obj);
248 elm_widget_data_set(obj, wd);
249 elm_widget_del_hook_set(obj, _del_hook);
250 elm_widget_theme_hook_set(obj, _theme_hook);
251 elm_widget_can_focus_set(obj, 0);
253 wd->edje_indi = NULL;
254 wd->edje_detail = NULL;
255 wd->icon_indi = NULL;
256 wd->icon_detail = NULL;
257 wd->button_detail = NULL;
259 wd->label_indi = NULL;
260 wd->label_detail = NULL;
262 wd->indicator_height = 0;
265 wd->mode = ELM_TICKERNOTI_DEFAULT;
267 _create_tickernoti_indi (obj);
268 _create_tickernoti_detail (obj);
270 evas_object_event_callback_add (obj, EVAS_CALLBACK_SHOW, _show, NULL);
271 evas_object_event_callback_add (obj, EVAS_CALLBACK_HIDE, _hide, NULL);
278 * Set the icon object used on the tickernoti object
280 * @param obj The tickernotil object
281 * @param icon The icon object will be used on the tickernoti object
282 * @ingroup TickerNoti
285 elm_tickernoti_icon_set (const Evas_Object *obj, Evas_Object *icon)
287 ELM_CHECK_WIDTYPE(obj, widtype);
288 Widget_Data *wd = elm_widget_data_get(obj);
291 edje_object_part_swallow (wd->edje_indi, "icon", icon);
292 wd->icon_indi = icon;
296 * Get the icon object used on the tickernoti object
298 * @param obj The tickernotil object
299 * @return The icon object inside the tickernoti
300 * @ingroup TickerNoti
303 elm_tickernoti_icon_get (const Evas_Object *obj)
305 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
306 Widget_Data *wd = elm_widget_data_get(obj);
307 if (!wd) return NULL;
308 return wd->icon_indi;
312 * Set the label on the tickernoti object
314 * @param obj The tickernoti object
315 * @param label The label will be used on the tickernoti object
317 * @ingroup TickerNoti
320 elm_tickernoti_label_set (Evas_Object *obj, const char *label)
322 ELM_CHECK_WIDTYPE(obj, widtype);
323 Widget_Data *wd = elm_widget_data_get(obj);
325 if (!label) label = "";
326 eina_stringshare_replace(&wd->label_indi, label);
327 edje_object_part_text_set(wd->edje_indi, "text", label);
332 * Get the label used on the tickernoti object
334 * @param obj The tickernotil object
335 * @return The string inside the label
336 * @ingroup TickerNoti
339 elm_tickernoti_label_get (const Evas_Object *obj)
341 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
342 Widget_Data *wd = elm_widget_data_get(obj);
343 if (!wd) return NULL;
344 return wd->label_indi;
348 * Set the label on the tickernoti object
350 * @param obj The tickernoti object
351 * @param label The label will be used on the tickernoti object
353 * @ingroup TickerNoti
356 elm_tickernoti_detailview_label_set (Evas_Object *obj, const char *label)
358 ELM_CHECK_WIDTYPE(obj, widtype);
359 Widget_Data *wd = elm_widget_data_get(obj);
361 if (!label) label = "";
362 eina_stringshare_replace(&wd->label_detail, label);
363 edje_object_part_text_set(wd->edje_detail, "text", label);
368 * Get the label used on the tickernoti object
370 * @param obj The tickernotil object
371 * @return The string inside the label
372 * @ingroup TickerNoti
375 elm_tickernoti_detailview_label_get (const Evas_Object *obj)
377 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
378 Widget_Data *wd = elm_widget_data_get(obj);
379 if (!wd) return NULL;
380 return wd->label_detail;
384 * Set the button object used on the tickernoti object
386 * @param obj The tickernotil object
387 * @param button The button object will be used on the tickernoti object
388 * @ingroup TickerNoti
391 elm_tickernoti_detailview_button_set (const Evas_Object *obj, Evas_Object *button)
393 ELM_CHECK_WIDTYPE(obj, widtype);
394 Widget_Data *wd = elm_widget_data_get(obj);
397 edje_object_part_swallow (wd->edje_detail, "button", button);
398 wd->button_detail = button;
402 * Get the button object used on the tickernoti object
404 * @param obj The tickernotil object
405 * @return The button object inside the tickernoti
406 * @ingroup TickerNoti
409 elm_tickernoti_detailview_button_get (const Evas_Object *obj)
411 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
412 Widget_Data *wd = elm_widget_data_get(obj);
413 if (!wd) return NULL;
414 return wd->button_detail;
418 * Set the icon object used on the tickernoti object
420 * @param obj The tickernotil object
421 * @param icon The icon object will be used on the tickernoti object
422 * @ingroup TickerNoti
425 elm_tickernoti_detailview_icon_set (const Evas_Object *obj, Evas_Object *icon)
427 ELM_CHECK_WIDTYPE(obj, widtype);
428 Widget_Data *wd = elm_widget_data_get(obj);
431 edje_object_part_swallow (wd->edje_detail, "icon", icon);
432 wd->icon_detail = icon;
436 * Get the icon object used on the tickernoti object
438 * @param obj The tickernotil object
439 * @return The icon object inside the tickernoti
440 * @ingroup TickerNoti
443 elm_tickernoti_detailview_icon_get (const Evas_Object *obj)
445 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
446 Widget_Data *wd = elm_widget_data_get(obj);
447 if (!wd) return NULL;
448 return wd->icon_detail;
452 * Get the rotation used on the tickernoti object
454 * @param obj The tickernotil object
455 * @return The rotation angle
456 * @ingroup TickerNoti
459 elm_tickernoti_rotation_get (const Evas_Object *obj)
461 ELM_CHECK_WIDTYPE(obj, widtype) -1;
462 Widget_Data *wd = elm_widget_data_get(obj);
468 * Set the rotation used on the tickernoti object
470 * @param obj The tickernotil object
471 * @param angle The rotation angle will be used on the tickernoti object
472 * @ingroup TickerNoti
475 elm_tickernoti_rotation_set (const Evas_Object *obj, int angle)
477 ELM_CHECK_WIDTYPE(obj, widtype);
478 Widget_Data *wd = elm_widget_data_get(obj);
481 Evas_Coord x, y, w, h;
482 Evas_Coord root_w, root_h;
485 * manual calculate win_tickernoti_indi window position & size
486 * - win_indi is not full size window (480 x 27)
488 ecore_x_window_size_get (ecore_x_window_root_first_get(), &root_w, &root_h);
489 evas_object_geometry_get (wd->win_indi, &x, &y, &w, &h);
495 h = wd->indicator_height;
502 h = wd->indicator_height;
509 h = wd->indicator_height;
517 h = wd->indicator_height;
524 elm_win_rotation_with_resize_set (wd->win_indi, angle);
525 evas_object_move (wd->win_indi, x, y);
526 evas_object_resize (wd->win_indi, w, h);
527 if (evas_object_visible_get (wd->win_indi)) {
528 _make_notification_window (wd->win_indi);
532 elm_win_rotation_with_resize_set (wd->win_detail, angle);
533 if (evas_object_visible_get (wd->win_detail)) {
534 _make_notification_window (wd->win_detail);
539 * Get the view mode on the tickernoti object
541 * @param obj The tickernotil object
542 * @return The view mode
543 * @ingroup TickerNoti
545 EAPI Elm_Tickernoti_Mode
546 elm_tickernoti_mode_get (const Evas_Object *obj)
548 ELM_CHECK_WIDTYPE(obj, widtype) -1;
549 Widget_Data *wd = elm_widget_data_get(obj);
555 * Set the view mode used on the tickernoti object
557 * @param obj The tickernotil object
558 * @param mode The view mode will be used on the tickernoti object
559 * @ingroup TickerNoti
562 elm_tickernoti_mode_set (const Evas_Object *obj, Elm_Tickernoti_Mode mode)
564 ELM_CHECK_WIDTYPE(obj, widtype);
565 Widget_Data *wd = elm_widget_data_get(obj);
572 * Get the detail view window(elm_win) on the tickernoti object
574 * @param obj The tickernotil object
575 * @return detail view window(elm_win) object
576 * @ingroup TickerNoti
579 elm_tickernoti_detailview_get (const Evas_Object *obj)
581 ELM_CHECK_WIDTYPE(obj, widtype) -1;
582 Widget_Data *wd = elm_widget_data_get(obj);
584 return wd->win_detail;