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;
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) ecore_job_add (_del_job, p);
52 evas_object_del (wd->edje_indi);
54 evas_object_del (wd->edje_detail);
55 wd->edje_detail = NULL;
56 evas_object_del (wd->win_detail);
57 wd->win_detail = NULL;
63 _theme_hook(Evas_Object *obj)
65 Widget_Data *wd = elm_widget_data_get(obj);
68 _elm_theme_object_set (wd->win_indi, wd->edje_indi, "tickernoti", "base", elm_widget_style_get(obj));
69 _elm_theme_object_set (wd->edje_detail, wd->edje_detail, "tickernoti", "2line", elm_widget_style_get(obj));
71 edje_object_scale_set (wd->edje_indi, elm_widget_scale_get(obj) * _elm_config->scale);
72 edje_object_scale_set (wd->edje_detail, elm_widget_scale_get(obj) * _elm_config->scale);
78 _sizing_eval(Evas_Object *obj)
80 Widget_Data *wd = elm_widget_data_get(obj);
81 // Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
85 edje_object_size_min_calc(wd->win_detail, &minw, &minh);
86 evas_object_size_hint_min_set(obj, minw, minh);
87 evas_object_size_hint_max_set(obj, maxw, maxh);
88 evas_object_size_hint_align_set(obj, maxw, maxh);
93 _make_notification_window (Evas_Object *obj)
96 /* elm_win_xwindow_get() must call after elm_win_alpha_set() */
97 xwin = elm_win_xwindow_get (obj);
98 ecore_x_netwm_window_type_set (xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
101 static void _detail_show_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
103 evas_object_smart_callback_call ((Evas_Object *)data, "detail,show", NULL);
106 static void _detail_hide_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
108 evas_object_smart_callback_call ((Evas_Object *)data, "detail,hide", NULL);
112 *_create_window (Evas_Object *parent, const char *name)
116 win = elm_win_add (parent, name, ELM_WIN_BASIC);
118 elm_win_title_set (win, name);
119 elm_win_borderless_set (win, EINA_TRUE);
120 elm_win_autodel_set (win, EINA_TRUE);
121 elm_win_alpha_set (win, EINA_TRUE);
124 _make_notification_window (win);
130 _create_tickernoti_indi (Evas_Object *obj)
132 Widget_Data *wd = elm_widget_data_get(obj);
138 char *data_win_height = NULL;
140 ecore_x_window_size_get (ecore_x_window_root_first_get(), &w, &h);
142 evas_object_move (wd->win_indi, 0, 0);
144 e = evas_object_evas_get (wd->win_indi);
146 wd->edje_indi = edje_object_add (e);
147 _elm_theme_object_set (wd->win_indi, wd->edje_indi, "tickernoti", "base", "default");
148 elm_win_resize_object_add (wd->win_indi, wd->edje_indi);
150 /* tickernoti indicator height set */
151 data_win_height = (char *)edje_object_data_get (wd->edje_indi, "height");
152 if (data_win_height != NULL && elm_scale_get() > 0.0)
153 wd->indicator_height = (int)(elm_scale_get() * atoi(data_win_height));
155 evas_object_resize (wd->win_indi, w, wd->indicator_height);
157 edje_object_signal_callback_add (wd->edje_indi, "request,detail,show", "", _detail_show_cb, obj);
158 evas_object_show (wd->edje_indi);
162 _create_tickernoti_detail (Evas_Object *obj)
164 Widget_Data *wd = elm_widget_data_get(obj);
170 ecore_x_window_size_get (ecore_x_window_root_first_get(), &w, &h);
172 evas_object_resize (wd->win_detail, w, h);
173 evas_object_move (wd->win_detail, 0, 0);
175 e = evas_object_evas_get (wd->win_detail);
177 wd->edje_detail = edje_object_add (e);
178 _elm_theme_object_set (wd->win_detail, wd->edje_detail, "tickernoti", "2line", "default");
179 elm_win_resize_object_add (wd->win_detail, wd->edje_detail);
181 edje_object_signal_callback_add(wd->edje_detail, "request,detail,hide", "", _detail_hide_cb, obj);
182 evas_object_show (wd->edje_detail);
186 _show(void *data, Evas *e, Evas_Object *obj, void *event_info)
188 Widget_Data *wd = elm_widget_data_get(obj);
191 if (wd->mode == ELM_TICKERNOTI_DEFAULT)
193 evas_object_hide (wd->win_detail);
194 _make_notification_window (wd->win_indi);
195 evas_object_show (wd->win_indi);
196 edje_object_signal_emit (wd->edje_indi, "effect,show", "bg_1line");
198 else if (wd->mode == ELM_TICKERNOTI_DETAILVIEW)
200 evas_object_hide (wd->win_indi);
201 _make_notification_window (wd->win_detail);
202 evas_object_show (wd->win_detail);
203 edje_object_signal_emit (wd->edje_detail, "effect,show", "bg_2line");
208 _hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
210 Widget_Data *wd = elm_widget_data_get(obj);
213 evas_object_hide (obj);
214 evas_object_hide (wd->win_indi);
215 evas_object_hide (wd->win_detail);
219 * Add a tickernoti object to @p parent
221 * @param parent The parent object
223 * @return The tickernoti object, or NULL upon failure
225 * @ingroup TickerNoti
228 elm_tickernoti_add(Evas_Object *parent)
234 wd = ELM_NEW(Widget_Data);
235 wd->win_indi = _create_window (parent, "indi");
236 wd->win_detail = _create_window (parent, "detail");
238 if (!parent) parent = wd->win_indi;
240 e = evas_object_evas_get(parent);
241 obj = elm_widget_add(e);
242 ELM_SET_WIDTYPE(widtype, "tickernoti");
243 elm_widget_type_set(obj, "tickernoti");
244 elm_widget_sub_object_add(parent, obj);
245 elm_widget_data_set(obj, wd);
246 elm_widget_del_hook_set(obj, _del_hook);
247 elm_widget_theme_hook_set(obj, _theme_hook);
248 elm_widget_can_focus_set(obj, 0);
250 wd->edje_indi = NULL;
251 wd->edje_detail = NULL;
252 wd->icon_indi = NULL;
253 wd->icon_detail = NULL;
254 wd->button_detail = NULL;
256 wd->label_indi = NULL;
257 wd->label_detail = NULL;
259 wd->indicator_height = 0;
262 wd->mode = ELM_TICKERNOTI_DEFAULT;
264 _create_tickernoti_indi (obj);
265 _create_tickernoti_detail (obj);
267 evas_object_event_callback_add (obj, EVAS_CALLBACK_SHOW, _show, NULL);
268 evas_object_event_callback_add (obj, EVAS_CALLBACK_HIDE, _hide, NULL);
275 * Set the icon object used on the tickernoti object
277 * @param obj The tickernotil object
278 * @param icon The icon object will be used on the tickernoti object
279 * @ingroup TickerNoti
282 elm_tickernoti_icon_set (const Evas_Object *obj, Evas_Object *icon)
284 ELM_CHECK_WIDTYPE(obj, widtype);
285 Widget_Data *wd = elm_widget_data_get(obj);
288 edje_object_part_swallow (wd->edje_indi, "icon", icon);
289 wd->icon_indi = icon;
293 * Get the icon object used on the tickernoti object
295 * @param obj The tickernotil object
296 * @return The icon object inside the tickernoti
297 * @ingroup TickerNoti
300 elm_tickernoti_icon_get (const Evas_Object *obj)
302 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
303 Widget_Data *wd = elm_widget_data_get(obj);
304 if (!wd) return NULL;
305 return wd->icon_indi;
309 * Set the label on the tickernoti object
311 * @param obj The tickernoti object
312 * @param label The label will be used on the tickernoti object
314 * @ingroup TickerNoti
317 elm_tickernoti_label_set (Evas_Object *obj, const char *label)
319 ELM_CHECK_WIDTYPE(obj, widtype);
320 Widget_Data *wd = elm_widget_data_get(obj);
322 if (!label) label = "";
323 eina_stringshare_replace(&wd->label_indi, label);
324 edje_object_part_text_set(wd->edje_indi, "text", label);
329 * Get the label used on the tickernoti object
331 * @param obj The tickernotil object
332 * @return The string inside the label
333 * @ingroup TickerNoti
336 elm_tickernoti_label_get (const Evas_Object *obj)
338 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
339 Widget_Data *wd = elm_widget_data_get(obj);
340 if (!wd) return NULL;
341 return wd->label_indi;
345 * Set the detail label on the tickernoti object
347 * @param obj The tickernoti object
348 * @param label The label will be used on the tickernoti object
350 * @ingroup TickerNoti
353 elm_tickernoti_detailview_label_set (Evas_Object *obj, const char *label)
355 ELM_CHECK_WIDTYPE(obj, widtype);
356 Widget_Data *wd = elm_widget_data_get(obj);
358 if (!label) label = "";
359 eina_stringshare_replace(&wd->label_detail, label);
360 edje_object_part_text_set(wd->edje_detail, "text", label);
365 * Get the detail label used on the tickernoti object
367 * @param obj The tickernotil object
368 * @return The string inside the label
369 * @ingroup TickerNoti
372 elm_tickernoti_detailview_label_get (const Evas_Object *obj)
374 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
375 Widget_Data *wd = elm_widget_data_get(obj);
376 if (!wd) return NULL;
377 return wd->label_detail;
381 * Set the button object used on the tickernoti object
383 * @param obj The tickernotil object
384 * @param button The button object will be used on the tickernoti object
385 * @ingroup TickerNoti
388 elm_tickernoti_detailview_button_set (const Evas_Object *obj, Evas_Object *button)
390 ELM_CHECK_WIDTYPE(obj, widtype);
391 Widget_Data *wd = elm_widget_data_get(obj);
394 edje_object_part_swallow (wd->edje_detail, "button", button);
395 wd->button_detail = button;
399 * Get the button object used on the tickernoti object
401 * @param obj The tickernotil object
402 * @return The button object inside the tickernoti
403 * @ingroup TickerNoti
406 elm_tickernoti_detailview_button_get (const Evas_Object *obj)
408 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
409 Widget_Data *wd = elm_widget_data_get(obj);
410 if (!wd) return NULL;
411 return wd->button_detail;
415 * Set the detail icon object used on the tickernoti object
417 * @param obj The tickernotil object
418 * @param icon The icon object will be used on the tickernoti object
419 * @ingroup TickerNoti
422 elm_tickernoti_detailview_icon_set (const Evas_Object *obj, Evas_Object *icon)
424 ELM_CHECK_WIDTYPE(obj, widtype);
425 Widget_Data *wd = elm_widget_data_get(obj);
428 edje_object_part_swallow (wd->edje_detail, "icon", icon);
429 wd->icon_detail = icon;
433 * Get the detail icon object used on the tickernoti object
435 * @param obj The tickernotil object
436 * @return The icon object inside the tickernoti
437 * @ingroup TickerNoti
440 elm_tickernoti_detailview_icon_get (const Evas_Object *obj)
442 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
443 Widget_Data *wd = elm_widget_data_get(obj);
444 if (!wd) return NULL;
445 return wd->icon_detail;
449 * Get the rotation used on the tickernoti object
451 * @param obj The tickernotil object
452 * @return The rotation angle
453 * @ingroup TickerNoti
456 elm_tickernoti_rotation_get (const Evas_Object *obj)
458 ELM_CHECK_WIDTYPE(obj, widtype) -1;
459 Widget_Data *wd = elm_widget_data_get(obj);
465 * Set the rotation used on the tickernoti object
467 * @param obj The tickernotil object
468 * @param angle The rotation angle will be used on the tickernoti object
469 * @ingroup TickerNoti
472 elm_tickernoti_rotation_set (const Evas_Object *obj, int angle)
474 ELM_CHECK_WIDTYPE(obj, widtype);
475 Widget_Data *wd = elm_widget_data_get(obj);
478 Evas_Coord x, y, w, h;
479 Evas_Coord root_w, root_h;
482 * manual calculate win_tickernoti_indi window position & size
483 * - win_indi is not full size window (480 x 27)
485 ecore_x_window_size_get (ecore_x_window_root_first_get(), &root_w, &root_h);
486 evas_object_geometry_get (wd->win_indi, &x, &y, &w, &h);
493 h = wd->indicator_height;
499 h = wd->indicator_height;
505 h = wd->indicator_height;
512 h = wd->indicator_height;
519 elm_win_rotation_with_resize_set (wd->win_indi, angle);
520 evas_object_move (wd->win_indi, x, y);
521 evas_object_resize (wd->win_indi, w, h);
522 if (evas_object_visible_get (wd->win_indi))
524 _make_notification_window (wd->win_indi);
527 elm_win_rotation_with_resize_set (wd->win_detail, angle);
528 if (evas_object_visible_get (wd->win_detail))
530 _make_notification_window (wd->win_detail);
535 * Get the view mode on the tickernoti object
537 * @param obj The tickernotil object
538 * @return The view mode
539 * @ingroup TickerNoti
541 EAPI Elm_Tickernoti_Mode
542 elm_tickernoti_mode_get (const Evas_Object *obj)
544 ELM_CHECK_WIDTYPE(obj, widtype) -1;
545 Widget_Data *wd = elm_widget_data_get(obj);
551 * Set the view mode used on the tickernoti object
553 * @param obj The tickernotil object
554 * @param mode The view mode will be used on the tickernoti object
555 * @ingroup TickerNoti
558 elm_tickernoti_mode_set (const Evas_Object *obj, Elm_Tickernoti_Mode mode)
560 ELM_CHECK_WIDTYPE(obj, widtype);
561 Widget_Data *wd = elm_widget_data_get(obj);
568 * Get the detail view window(elm_win) on the tickernoti object
570 * @param obj The tickernotil object
571 * @return detail view window(elm_win) object
572 * @ingroup TickerNoti
575 elm_tickernoti_detailview_get (const Evas_Object *obj)
577 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
578 Widget_Data *wd = elm_widget_data_get(obj);
579 if (!wd) return NULL;
580 return wd->win_detail;