apply FSL(Flora Software License)
[apps/home/gallery.git] / src / features / gl-button.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *     http://www.tizenopensource.org/license
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 #include "gl-debug.h"
18 #include "gl-ui-util.h"
19 #include "gl-button.h"
20 #include "gl-strings.h"
21
22 #define GL_BUT_NAME_DELETE GL_STR_DELETE
23 #define GL_BUT_NAME_CANCEL GL_STR_CANCEL
24 #define GL_BUT_NAME_DONE GL_STR_DONE
25
26 /*******************************************************
27 ** Prototype            : _gl_but_create_but
28 ** Description          : Create button
29 ** Input                : Evas_Object *parent
30 ** Input                : gl_but_mode mode
31 ** Input                : const char *style
32 ** Output               : None
33 ** Return Value         :
34 ** Calls                :
35 ** Called By            :
36 **
37 **  History             :
38 **  1.Date              : 2011/06/10
39 **    Author            : Samsung
40 **    Modification : Created function
41 **
42 *********************************************************/
43 Evas_Object *_gl_but_create_but(Evas_Object *parent, gl_but_mode mode, const char *style)
44 {
45         gl_dbg("button mode: %d", mode);
46         Evas_Object *btn = NULL;
47
48         btn = elm_button_add(parent);
49         GL_CHECK_NULL(btn);
50         elm_object_focus_allow_set(btn, EINA_FALSE);
51         elm_object_style_set(btn, style);
52         evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
53                                          EVAS_HINT_EXPAND);
54         evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.5);
55
56         if (mode == GL_BUT_DEL)
57                 elm_object_text_set(btn, GL_BUT_NAME_DELETE);
58         else if (mode == GL_BUT_CANCEL)
59                 elm_object_text_set(btn, GL_BUT_NAME_CANCEL);
60         else if (mode == GL_BUT_DONE)
61                 elm_object_text_set(btn, GL_BUT_NAME_DONE);
62         else if (mode == GL_BUT_RENAME)
63                 elm_object_text_set(btn, GL_BUT_NAME_RENAME);
64
65         evas_object_show(btn);
66         return btn;
67 }
68
69 Evas_Object *_gl_but_create_but_popup(Evas_Object *parent, const char *text, But_Smart_Cb cb_func, const void *data)
70 {
71         Evas_Object *btn = NULL;
72         GL_CHECK_NULL(parent);
73         GL_CHECK_NULL(text);
74         gl_dbg("Button text: %s", text);
75
76         btn = elm_button_add(parent);
77         GL_CHECK_NULL(btn);
78         elm_object_text_set(btn, text);
79
80         if (cb_func)
81                 evas_object_smart_callback_add(btn, "clicked", cb_func, data);
82
83         return btn;
84 }