summaryrefslogtreecommitdiff
path: root/src/widget/mf-ug-popup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget/mf-ug-popup.c')
-rw-r--r--[-rwxr-xr-x]src/widget/mf-ug-popup.c226
1 files changed, 216 insertions, 10 deletions
diff --git a/src/widget/mf-ug-popup.c b/src/widget/mf-ug-popup.c
index cceeb69..f47d857 100755..100644
--- a/src/widget/mf-ug-popup.c
+++ b/src/widget/mf-ug-popup.c
@@ -1,26 +1,140 @@
/*
+ * myfile
+ *
* Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.0 (the "License");
- *
- * You may not use this file except in compliance with the License.
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
+ *
* http://www.tizenopensource.org/license
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an "AS IS" BASIS,
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * See the License for the specific language governing permissions and limitations under the License.
*/
-
#include "mf-ug-util.h"
#include "mf-ug-winset.h"
+#include "mf-ug-fs-util.h"
#include "mf-ug-resource.h"
+#define MF_UG_POPUP_STYLE_MIN_MENUSTYLE "min_menustyle"
+#define MF_UG_POPUP_MENUSTYLE_WIDTH (614*elm_config_scale_get())
+#define MF_UG_POPUP_MENUSTYLE_HEIGHT(x) ((113*x-1)*elm_config_scale_get())
+#define MF_UG_POPUP_MENUSTYLE_HEIGHT_MAX (408*elm_config_scale_get())
+Elm_Genlist_Item_Class ug_listby_itc;
+#define MF_UG_ITEM_COUNT 4
+
+typedef struct {
+ int index;
+ ugData* ugd;
+} ugListByData_s;
+
+static int __mf_ug_popup_get_list_by_selected_item(void *data)
+{
+ ug_mf_retvm_if(data == NULL, 0, "data is NULL");
+ ugData *ugd = (ugData *)data;
+
+ int iSortTypeValue = ugd->ug_Status.ug_iSortType;
+
+ int ret = -1;
+ switch (iSortTypeValue) {
+ case MF_UG_SORT_BY_DATE_O2R:
+ case MF_UG_SORT_BY_DATE_R2O:
+ ret = 1;
+ break;
+ case MF_UG_SORT_BY_TYPE_A2Z:
+ case MF_UG_SORT_BY_TYPE_Z2A:
+ ret = 3;
+ break;
+ case MF_UG_SORT_BY_NAME_A2Z:
+ case MF_UG_SORT_BY_NAME_Z2A:
+ ret = 0;
+ break;
+ case MF_UG_SORT_BY_SIZE_S2L:
+ case MF_UG_SORT_BY_SIZE_L2S:
+ ret = 2;
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+ return ret;
+}
+
+
+static char *__mf_ug_popup_get_genlist_label(void *data, Evas_Object * obj, const char *part)
+{
+ ugListByData_s *params = (ugListByData_s *) data;
+ assert(params);
+ ugData *ugd = params->ugd;
+ assert(ugd);
+ assert(part);
+
+ char *ret = NULL;
+ if (!strcmp(part, "elm.text")) {
+ switch (params->index) {
+ case 0: /**< Sort by file name ascending */
+ ret = g_strdup(MF_UG_LABEL_NAME);
+ break;
+ case 1: /**< Sort by file size ascending */
+ ret = g_strdup(MF_UG_LABEL_DATE);
+ break;
+ case 2: /**< Sort by file date ascending */
+ ret = g_strdup(MF_UG_LABEL_SIZE);
+ break;
+ case 3: /**< Sort by file type ascending */
+ ret = g_strdup(MF_UG_LABEL_TYPE);
+ break;
+ default:
+ break;
+ }
+ return ret;
+ }
+ return NULL;
+}
+
+static Evas_Object* __mf_ug_popup_get_genlist_icon(void *data, Evas_Object * obj, const char *part)
+{
+ ugListByData_s *params = (ugListByData_s *) data;
+ assert(params);
+ ugData *ugd = params->ugd;
+ assert(ugd);
+ assert(part);
+
+ if (!strcmp(part, "elm.icon")) {
+ Evas_Object *radio = NULL;
+ radio = elm_radio_add(obj);
+ elm_object_focus_set(radio, EINA_FALSE);
+ elm_radio_state_value_set(radio, params->index);
+ elm_radio_group_add(radio, ugd->ug_Status.ug_pRadioGroup);
+ elm_radio_value_set(radio, ugd->ug_Status.ug_iRadioValue);
+ evas_object_show(radio);
+ return radio;
+ }
+ return NULL;
+}
+
+static void __mf_ug_popup_genlist_select(void *data, Evas_Object * obj, void *event_info)
+{
+ assert(data);
+ assert(event_info);
+ ugListByData_s *params = NULL;
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+ if (item != NULL) {
+ params = (ugListByData_s *) elm_object_item_data_get(item);
+ if (params != NULL && params->ugd != NULL) {
+ params->ugd->ug_Status.ug_iSelectedSortType = params->index;
+ elm_radio_value_set(params->ugd->ug_Status.ug_pRadioGroup, params->index);
+ }
+ }
+}
/******************************
** Prototype : mfPopupCreate
@@ -45,20 +159,57 @@
** Modification : Created function
**
******************************/
-void mf_ug_popup_create(void *data, mf_ug_popup_mode popupMode, char *title, char *context, char *first_btn_text, char *second_btn_text,
- char *third_btn_text, Evas_Smart_Cb func, void *param)
+static Evas_Object *__ug_mf_popup_button_create(Evas_Object *parent, const char *label)
+{
+ Evas_Object *btn = NULL;
+ btn = elm_button_add(parent);
+ if (label) {
+ elm_object_text_set(btn, label);
+ }
+ return btn;
+
+}
+
+static Evas_Object *__mf_ug_popup_box_set(Evas_Object *parent, Evas_Object *content, int item_cnt)
+{
+ ug_mf_retvm_if(parent == NULL, NULL, "parent is NULL");
+ ug_mf_retvm_if(content == NULL, NULL, "content is NULL");
+ ug_mf_retvm_if(item_cnt < 0, NULL, "content is NULL");
+
+ Evas_Object *box = elm_box_add(parent);
+ if (item_cnt > MF_UG_ITEM_COUNT) {
+ evas_object_size_hint_min_set(box, MF_UG_POPUP_MENUSTYLE_WIDTH,
+ MF_UG_POPUP_MENUSTYLE_HEIGHT(item_cnt));
+ } else {
+ evas_object_size_hint_min_set(box, MF_UG_POPUP_MENUSTYLE_WIDTH,
+ MF_UG_POPUP_MENUSTYLE_HEIGHT(item_cnt));
+ }
+
+ evas_object_show(content);
+ elm_box_pack_end(box, content);
+ return box;
+}
+
+void mf_ug_popup_create(void *data, mf_ug_popup_mode popupMode, char *title, const char *context, const char *first_btn_text, const char *second_btn_text,
+ const char *third_btn_text, Evas_Smart_Cb func, void *param)
{
Evas_Object *popup;
ugData *ugd = (ugData *)data;
ug_mf_retm_if(ugd == NULL, "ugd is NULL");
+
+ Evas_Object *genlist;
+ Evas_Object *radio_group = NULL;
+ Evas_Object *box = NULL;
Evas_Object *btn1 = NULL;
Evas_Object *btn2 = NULL;
+ int index = 0;
+ int listby_selected= 0;
popup = elm_popup_add(ugd->ug_MainWindow.ug_pMainLayout);
ugd->ug_MainWindow.ug_pNormalPopup = popup;
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
if (title) {
- elm_object_part_text_set(popup, "elm.title", title);
+ elm_object_part_text_set(popup, "title,text", title);
}
if (context && popupMode != UG_POPMODE_PROGRESSBAR) {
elm_object_text_set(popup, context);
@@ -87,9 +238,64 @@ void mf_ug_popup_create(void *data, mf_ug_popup_mode popupMode, char *title, cha
evas_object_smart_callback_add(btn1, "clicked", func, param);
elm_object_part_content_set(popup, "button1", btn1);
break;
+ case UG_POPMODE_SEARCH:
+ btn1 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_CANCEL);
+ evas_object_smart_callback_add(btn1, "clicked", func, param);
+ elm_object_part_content_set(popup, "button1", btn1);
+ break;
+ case UG_POPMODE_LIST_BY:
+ elm_object_style_set(popup, MF_UG_POPUP_STYLE_MIN_MENUSTYLE);
+
+ btn1 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_ASCENDING);
+ evas_object_smart_callback_add(btn1, "clicked", func, param);
+ elm_object_part_content_set(popup, "button1", btn1);
+
+ btn2 = __ug_mf_popup_button_create(popup, MF_UG_LABEL_DESCENDING);
+ evas_object_smart_callback_add(btn2, "clicked", func, param);
+ elm_object_part_content_set(popup, "button2", btn2);
+
+ if (ugd->ug_Status.ug_pRadioGroup) {
+ evas_object_del(ugd->ug_Status.ug_pRadioGroup);
+ ugd->ug_Status.ug_pRadioGroup = NULL;
+ }
+
+ radio_group = elm_radio_add(ugd->ug_MainWindow.ug_pWindow);
+ elm_object_focus_set(radio_group, EINA_FALSE);
+ elm_radio_value_set(radio_group, 0);
+ evas_object_hide(radio_group);
+ ugd->ug_Status.ug_pRadioGroup = radio_group;
+
+ listby_selected = __mf_ug_popup_get_list_by_selected_item(ugd);
+ ugd->ug_Status.ug_iRadioValue = listby_selected;
+
+ ug_listby_itc.item_style = "1text.1icon.2";
+ ug_listby_itc.func.text_get = __mf_ug_popup_get_genlist_label;
+ ug_listby_itc.func.content_get = __mf_ug_popup_get_genlist_icon;
+ ug_listby_itc.func.state_get = NULL;
+ ug_listby_itc.func.del = NULL;
+ genlist = elm_genlist_add(popup);
+ elm_object_focus_set(genlist, EINA_FALSE);
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ for (index = 0; index < MF_UG_ITEM_COUNT; index++) {
+ Elm_Object_Item *it = NULL;
+ ugListByData_s *item_data = malloc(sizeof(ugListByData_s));
+ if (item_data == NULL)
+ continue;
+
+ item_data->index = index;
+ item_data->ugd = ugd;
+ it = elm_genlist_item_append(genlist, &ug_listby_itc, (void *)item_data, NULL,
+ ELM_GENLIST_ITEM_NONE, __mf_ug_popup_genlist_select, popup);
+ }
+
+ box = __mf_ug_popup_box_set(popup, genlist, MF_UG_ITEM_COUNT);
+ elm_object_content_set(popup, box);
+ evas_object_smart_callback_add(popup, "response", func, param);
+
+ break;
default:
return;
}
evas_object_show(popup);
}
-