#define STYLE_MENU_BTN "style.menu.button"
#define STYLE_SORT_BTN "style.sort.button"
#define STYLE_OPTION_BTN "style.option.button"
-#define STYLE_SORT_CTXPOPUP "style.sort.ctxpopup"
+#define STYLE_CTXPOPUP "style.ctxpopup"
#define STYLE_MYAPP "style.myapp"
#define STYLE_FAVORITE "style.favorite"
#define STYLE_LIVETV_BTN "style.livetv.button"
#define SIZE_STR 1024
#define SIZE_MENU_BOX_PAD_H (40 + 40)
#define SIZE_MENU_BOX_PAD_V 0
-#define SIZE_SORT_BOX_PAD_H 0
-#define SIZE_SORT_BOX_PAD_V 0
#define SIZE_ICON_MAX 100
#define SIZE_ACTION_TABLE_BORDER 0
#define SIZE_COL_MAX 4
#ifndef __AIR_APPS_UTILS_H__
#define __AIR_APPS_UTILS_H__
+#include <inputmgr.h>
+
Evas_Object *utils_add_window(const char *name);
Evas_Object *utils_add_layout(Evas_Object *parent, const char *group);
Evas_Object *utils_add_box(Evas_Object *parent, const char *part,
int timeout);
Evas_Object *utils_add_popup(Evas_Object *parent, const char *style,
const char *popup_title, const char *popup_text);
+Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size,
+ const char **opt_text, input_handler *opt_handler, void *data);
bool utils_launch_app(const char *appid);
bool utils_uninstall_app(const char *pkgid, const char *pkgtype);
group {
- name, "elm/ctxpopup/base/style.sort.ctxpopup";
+ name, "elm/ctxpopup/base/style.ctxpopup";
data.item, "focus_hightlight" "on";
parts {
part {
return popup;
}
+Evas_Object *utils_add_ctxpopup(Evas_Object *parent, int opt_size,
+ const char **opt_text, input_handler *opt_handler, void *data)
+{
+ Evas_Object *ctxpopup, *box, *btn = NULL, *firstbtn = NULL;
+ int i;
+
+ if (!parent || opt_size <= 0 || !opt_text) {
+ _ERR("Invalid argument.");
+ return NULL;
+ }
+
+ ctxpopup = elm_ctxpopup_add(parent);
+ if (!ctxpopup) {
+ _ERR("elm_ctxpopup_add failed.");
+ return NULL;
+ }
+
+ box = utils_add_box(ctxpopup, NULL, EINA_FALSE, 0, 0);
+ if (!box) {
+ _ERR("Add box failed.");
+ evas_object_del(ctxpopup);
+ return NULL;
+ }
+
+ elm_object_style_set(ctxpopup, STYLE_CTXPOPUP);
+ elm_object_content_set(ctxpopup, box);
+ elm_ctxpopup_direction_priority_set(ctxpopup, 0, 0, 0, 0);
+ evas_object_show(ctxpopup);
+
+ for (i = 0; i < opt_size; i++) {
+ btn = utils_add_button(box, NULL, opt_text[i],
+ STYLE_OPTION_BTN);
+ if (!btn) {
+ _ERR("Add button failed.");
+ evas_object_del(ctxpopup);
+ return NULL;
+ }
+
+ elm_box_pack_end(box, btn);
+
+ if (opt_handler)
+ inputmgr_add_callback(btn, i, opt_handler, data);
+
+ if (i == 0)
+ firstbtn = btn;
+ }
+
+ elm_object_focus_next_object_set(firstbtn, btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(btn, firstbtn, ELM_FOCUS_DOWN);
+
+ return ctxpopup;
+}
+
bool utils_launch_app(const char *appid)
{
app_control_h app_ctrl;
return true;
}
-void _set_action_state(int idx, Evas_Object *btn, struct _priv *priv)
+static void _set_action_state(int idx, Evas_Object *btn, struct _priv *priv)
{
char *pkgtype;
bool isfavorite;
static bool _draw_sort_option(struct _priv *priv)
{
- Evas_Object *ctxpopup, *box, *btn, *firstbtn;
+ Evas_Object *ctxpopup;
Evas_Coord x, y, w, h;
- int i;
elm_object_signal_emit(priv->sort_btn, SIG_SELECTED, SRC_SORT_BTN);
- ctxpopup = elm_ctxpopup_add(priv->base);
+ ctxpopup = utils_add_ctxpopup(priv->base, SORT_COUNT, str_sort,
+ &_option_input_handler, priv);
if (!ctxpopup) {
- _ERR("elm_ctxpopup_add failed.");
- return false;
- }
-
- box = utils_add_box(ctxpopup, NULL, EINA_FALSE,
- SIZE_SORT_BOX_PAD_H, SIZE_SORT_BOX_PAD_V);
- if (!box) {
- _ERR("elm_box_add failed.");
- evas_object_del(ctxpopup);
+ _ERR("Add ctxpopup failed.");
return false;
}
- elm_object_style_set(ctxpopup, STYLE_SORT_CTXPOPUP);
- elm_object_content_set(ctxpopup, box);
-
- elm_ctxpopup_direction_priority_set(ctxpopup, 0, 0, 0, 0);
evas_object_geometry_get(priv->sort_btn, &x, &y, &w, &h);
evas_object_move(ctxpopup, (x + w / 2) * elm_config_scale_get(),
y * elm_config_scale_get());
- evas_object_show(ctxpopup);
priv->sort_popup = ctxpopup;
- for (i = 0; i < SORT_COUNT; i++) {
- btn = utils_add_button(box, NULL, str_sort[i],
- STYLE_OPTION_BTN);
- if (!btn) {
- _ERR("Add button failed.");
- evas_object_del(ctxpopup);
- return false;
- }
-
- elm_box_pack_end(box, btn);
-
- inputmgr_add_callback(btn, i, &_option_input_handler, priv);
-
- if (i == 0)
- firstbtn = btn;
- }
-
- if (firstbtn && btn) {
- elm_object_focus_next_object_set(firstbtn, btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn, firstbtn, ELM_FOCUS_DOWN);
- }
-
return true;
}