summaryrefslogtreecommitdiff
path: root/src/examples/popup_example_02.c
diff options
context:
space:
mode:
authorRajeev Ranjan <rajeev.r@samsung.com>2012-03-05 23:51:56 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-03-05 23:51:56 +0000
commit9485962f9e4ee00b5bdae89a5e62729b8f0eab4c (patch)
tree44e5bf02eb6b6ddbd8d0492e0938a2807304a6c9 /src/examples/popup_example_02.c
parentc836b1a007130b66ce3333771a4f8786b6343e0e (diff)
From: Rajeev Ranjan <rajeev.r@samsung.com>
Subject: [E-devel] [Patch] Elementary: New custom widget Popup Hi All, Attached to the mail is the patch for a new custom elementary widget elm_popup for your review. Change description: New custom widget Popup added. elm_popup is an enhancement over elm_notify widget with widely used parts such as Title, Content and Action Buttons. Items are supported as well and they are put inside the content area which can have either an Evas Object/Set of items/Description text. SVN revision: 68747
Diffstat (limited to 'src/examples/popup_example_02.c')
-rw-r--r--src/examples/popup_example_02.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/examples/popup_example_02.c b/src/examples/popup_example_02.c
new file mode 100644
index 000000000..9ecd03aa4
--- /dev/null
+++ b/src/examples/popup_example_02.c
@@ -0,0 +1,85 @@
1//Compile with:
2//gcc -g `pkg-config --cflags --libs elementary` popup_example_02.c -o popup_example_02
3
4#include <Elementary.h>
5#ifdef HAVE_CONFIG_H
6# include "elementary_config.h"
7#else
8# define __UNUSED__ __attribute__((unused))
9# define PACKAGE_DATA_DIR "../../data"
10#endif
11
12static void _response_cb(void *data, Evas_Object *obj, void *event_info);
13
14EAPI_MAIN int
15elm_main(int argc __UNUSED__, char **argv __UNUSED__)
16{
17 Evas_Object *win, *bg, *popup, *btn1, *btn2, *btn3, *icon1;
18 char buf[256];
19
20 win = elm_win_add(NULL, "popup", ELM_WIN_BASIC);
21 elm_win_title_set(win, "Popup");
22 elm_win_autodel_set(win, EINA_TRUE);
23 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
24
25 bg = elm_bg_add(win);
26 elm_win_resize_object_add(win, bg);
27 evas_object_show(bg);
28
29 popup = elm_popup_add(win);
30
31 // Setting popup content-text
32 elm_object_text_set(popup, "This is the Content-Text for popup. The wrap"
33 "for the content-text is character wrapping");
34 // Setting the wrapping type to character wrapping
35 elm_popup_content_text_wrap_type_set(popup, ELM_WRAP_CHAR);
36
37 // Seting popup title-text
38 elm_object_part_text_set(popup, "title,text", "Title");
39
40 icon1 = elm_icon_add(popup);
41 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
42 elm_icon_file_set(icon1, buf, NULL);
43 //Setting popup title-icon
44 elm_object_part_content_set(popup, "title,icon", icon1);
45
46 // Creating the first action button
47 btn1 = elm_button_add(popup);
48 elm_object_text_set(btn1, "OK");
49
50 // Setting the fist action button
51 elm_object_part_content_set(popup, "button1", btn1);
52 evas_object_smart_callback_add(btn1, "clicked", _response_cb, popup);
53
54 // Creating the second action button
55 btn2 = elm_button_add(popup);
56 elm_object_text_set(btn2, "Cancel");
57
58 // Setting the second action button
59 elm_object_part_content_set(popup, "button2", btn2);
60 evas_object_smart_callback_add(btn2, "clicked", _response_cb, popup);
61
62 btn3 = elm_button_add(popup);
63 elm_object_text_set(btn3, "Close");
64 // Setting this action button
65 elm_object_part_content_set(popup, "button3", btn3);
66 // Setting the orientation of popup to Top
67 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
68 // Display the popup object
69 evas_object_show(popup);
70
71 evas_object_resize(win, 480, 800);
72 evas_object_show(win);
73
74 elm_run();
75
76 return 0;
77}
78ELM_MAIN()
79static void
80_response_cb(void *data, Evas_Object *obj __UNUSED__,
81 void *event_info __UNUSED__)
82{
83 evas_object_del(data);
84}
85