From: Bluezery <ohpowel@gmail.com>
[framework/uifw/elementary.git] / src / examples / notify_example_01.c
1 //Compile with:
2 //gcc -o notify_example_01 notify_example_01.c -g `pkg-config --cflags --libs elementary`
3
4 #include <Elementary.h>
5 #ifdef HAVE_CONFIG_H
6 # include "elementary_config.h"
7 #endif
8
9 static void _hide(void *data, Evas_Object *obj, void *event_info);
10
11 EAPI_MAIN int
12 elm_main(int argc, char **argv)
13 {
14    Evas_Object *win, *bg, *bx, *notify, *content;
15
16    win = elm_win_add(NULL, "notify", ELM_WIN_BASIC);
17    elm_win_title_set(win, "Notify");
18    elm_win_autodel_set(win, EINA_TRUE);
19    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
20
21    bg = elm_bg_add(win);
22    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
23    elm_win_resize_object_add(win, bg);
24    evas_object_show(bg);
25
26    bx = elm_box_add(win);
27    elm_box_horizontal_set(bx, EINA_FALSE);
28    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
29    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
30    elm_win_resize_object_add(win, bx);
31    evas_object_show(bx);
32
33    content = elm_label_add(win);
34    elm_object_text_set(content, "default");
35    evas_object_show(content);
36
37    notify = elm_notify_add(win);
38    elm_notify_allow_events_set(notify, EINA_FALSE);
39    elm_notify_timeout_set(notify, 5);
40    elm_object_content_set(notify, content);
41    evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
42    evas_object_show(notify);
43    elm_box_pack_end(bx, notify);
44    evas_object_smart_callback_add(notify, "block,clicked", _hide, NULL);
45
46    content = elm_label_add(win);
47    elm_object_text_set(content, "bottom");
48    evas_object_show(content);
49
50    notify = elm_notify_add(win);
51    elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);
52    elm_object_content_set(notify, content);
53    evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
54    evas_object_show(notify);
55    elm_box_pack_end(bx, notify);
56
57    content = elm_label_add(win);
58    elm_object_text_set(content, "center");
59    evas_object_show(content);
60
61    notify = elm_notify_add(win);
62    elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_CENTER);
63    elm_object_content_set(notify, content);
64    evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
65    evas_object_show(notify);
66    elm_box_pack_end(bx, notify);
67
68    evas_object_resize(win, 100, 200);
69    evas_object_show(win);
70
71    elm_run();
72
73    return 0;
74 }
75 ELM_MAIN()
76
77 static void
78 _hide(void *data, Evas_Object *obj, void *event_info)
79 {
80    evas_object_hide(obj);
81 }