apply FSL(Flora Software License)
[apps/home/gallery.git] / libug / libug-gallery-efl / src / ge-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 "ge-debug.h"
18 #include "ge-ui-util.h"
19 #include "ge-util.h"
20 #include "ge-button.h"
21 #include "ge-strings.h"
22
23 #define GE_BTN_NF_TITLE "naviframe/title/gallery_efl"
24
25 Evas_Object *ge_but_create_title_but(ge_ugdata *ugd, Evas_Object *parent, ge_but_mode mode)
26 {
27         ge_dbg("Button mode: %d", mode);
28         Evas_Object* btn = NULL;
29         GE_CHECK_NULL(ugd);
30         GE_CHECK_NULL(parent);
31
32         btn = elm_button_add(parent);
33         GE_CHECK_NULL(btn);
34         if(ugd->th)
35                 elm_object_theme_set(btn, ugd->th);
36
37         elm_object_style_set(btn, GE_BTN_NF_TITLE);
38         evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
39                                          EVAS_HINT_EXPAND);
40         evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.5);
41
42         switch (mode) {
43         case GE_BUT_DONE:
44                 elm_object_text_set(btn,
45                                     (char*)_GE_GETSYSTEMSTR("IDS_COM_SK_DONE"));
46                 break;
47         case GE_BUT_CANCEL:
48                 elm_object_text_set(btn,
49                                     (char*)_GE_GETSYSTEMSTR("IDS_COM_SK_CANCEL"));
50                 break;
51         default:
52                 break;
53         }
54
55         evas_object_show(btn);
56
57         return btn;
58 }
59
60 Evas_Object *_ge_but_create_but(Evas_Object *parent, ge_but_mode mode, But_Smart_Cb cb_func, const void *data)
61 {
62         ge_dbg("Button mode: %d", mode);
63         Evas_Object *btn = NULL;
64         GE_CHECK_NULL(parent);
65
66         btn = elm_button_add(parent);
67         GE_CHECK_NULL(btn);
68
69         switch (mode) {
70         case GE_BUT_OK:
71                 elm_object_text_set(btn,
72                                     (char*)_GE_GETSYSTEMSTR("IDS_COM_SK_OK"));
73                 break;
74         case GE_BUT_CANCEL:
75                 elm_object_text_set(btn,
76                                     (char*)_GE_GETSYSTEMSTR("IDS_COM_SK_CANCEL"));
77                 break;
78         default:
79                 break;
80         }
81
82         if (cb_func)
83                 evas_object_smart_callback_add(btn, "clicked", cb_func, data);
84
85         return btn;
86 }
87