[Release] livebox.web-provider-1.9
[platform/framework/web/web-provider.git] / src / Core / Service / PeriodChanger.cpp
old mode 100644 (file)
new mode 100755 (executable)
index e73ad5b..453160b
@@ -5,7 +5,7 @@
  *    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
+ *        http://floralicense.org/license/
  *
  *    Unless required by applicable law or agreed to in writing, software
  *    distributed under the License is distributed on an "AS IS" BASIS,
@@ -39,11 +39,7 @@ PeriodChanger::PeriodChanger(
     , m_instanceId(instanceId)
     , m_currentPeriod(currentPeriod)
     , m_requestedPeriod(requestedPeriod)
-    , m_1hour()
-    , m_3hour()
-    , m_6hour()
-    , m_12hour()
-    , m_noUpdate()
+    , m_hour()
 {
     LogD("enter");
 }
@@ -86,6 +82,8 @@ void PeriodChanger::showPeriodPopup()
 
     Evas_Object* window = createWindow();
     Evas_Object* periodList = elm_list_add(window);
+    Evas_Object* radio;
+
     if (!periodList) {
         LogD("failed to add elm_list_add");
     }
@@ -93,11 +91,16 @@ void PeriodChanger::showPeriodPopup()
 
     setPopupListData();
     // TODO Language ID should be used, not static string
-    elm_list_item_append(periodList, "1 hour", NULL, NULL, selectPeriodCallback, &m_1hour);
-    elm_list_item_append(periodList, "3 hour", NULL, NULL, selectPeriodCallback, &m_3hour);
-    elm_list_item_append(periodList, "6 hour", NULL, NULL, selectPeriodCallback, &m_6hour);
-    elm_list_item_append(periodList, "12 hour", NULL, NULL, selectPeriodCallback, &m_12hour);
-    elm_list_item_append(periodList, "Never", NULL, NULL, selectPeriodCallback, &m_noUpdate);
+    for(int i = 0 ; i < sizeof(m_hour) / sizeof(PopupListData); i++) {
+        radio = elm_radio_add(periodList);
+        elm_radio_state_value_set(radio,
+            m_currentPeriod == m_hour[i].newPeriod ? EINA_FALSE : EINA_TRUE);
+        elm_list_item_append(periodList,
+            m_hour[i].period,
+            radio,
+            NULL,
+            selectPeriodCallback, &m_hour[i]);
+    }
 
     // create popup
     Evas_Object *popup = elm_popup_add(window);
@@ -105,7 +108,7 @@ void PeriodChanger::showPeriodPopup()
         LogD("failed to add elm_popup_add");
         return;
     }
-    elm_object_style_set(popup, "min_menustyle");
+    elm_object_style_set(popup, "popup-item list");
     evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
     elm_object_part_text_set(popup, "title,text", "Update Period");
     elm_object_content_set(popup, periodList);
@@ -144,20 +147,26 @@ void PeriodChanger::setPopupListData()
 {
     LogD("enter");
 
-    m_1hour.periodChanger = this;
-    m_1hour.newPeriod = 1.0 * 60.0 * 60.0;
+    m_hour[0].periodChanger = this;
+    m_hour[0].newPeriod = 1.0 * 60.0 * 60.0;
+    m_hour[0].period = "1 hour";
+
+    m_hour[1].periodChanger = this;
+    m_hour[1].newPeriod = 3.0 * 60.0 * 60.0;
+    m_hour[1].period = "3 hour";
 
-    m_3hour.periodChanger = this;
-    m_3hour.newPeriod = 3.0 * 60.0 * 60.0;
+    m_hour[2].periodChanger = this;
+    m_hour[2].newPeriod = 6.0 * 60.0 * 60.0;
+    m_hour[2].period = "6 hour";
 
-    m_6hour.periodChanger = this;
-    m_6hour.newPeriod = 6.0 * 60.0 * 60.0;
+    m_hour[3].periodChanger = this;
+    m_hour[3].newPeriod = 12.0 * 60.0 * 60.0;
+    m_hour[3].period = "12 hour";
 
-    m_12hour.periodChanger = this;
-    m_12hour.newPeriod = 12.0 * 60.0 * 60.0;
+    m_hour[4].periodChanger = this;
+    m_hour[4].newPeriod = 0.0;
+    m_hour[4].period = "Never";
 
-    m_noUpdate.periodChanger = this;
-    m_noUpdate.newPeriod = 0.0;
 }
 
 bool PeriodChanger::requestToPlatform(float newPeriod)