summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@samsung.com>2014-09-23 15:19:24 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-10-02 15:07:28 +0300
commit5a57f4cb3557b14ca3f192104ca4b45d4265bfcb (patch)
tree65a2fe3639cebd985a2d61ae5b5e4f7da9dfa3d3
parent85be9c25ee8e179b3f62db755b5a8920d354225c (diff)
Main Widgets: refactor parent_set
-rw-r--r--src/lib/gui_widget.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/lib/gui_widget.c b/src/lib/gui_widget.c
index cddd11a..dca6c05 100644
--- a/src/lib/gui_widget.c
+++ b/src/lib/gui_widget.c
@@ -1355,34 +1355,37 @@ wdg_public_get(const Gui_Widget *wdg)
1355 return wdg->public; 1355 return wdg->public;
1356} 1356}
1357 1357
1358static Eina_Bool 1358/* Wrapper to avoid case, when widget is not created yet. */
1359_wdg_parent_set_int(Gui_Widget *wdg, Dep_Id *new_parent_id) 1359Eina_Bool
1360wdg_parent_set(Gui_Widget *wdg, const char *parent_name)
1360{ 1361{
1361 EINA_SAFETY_ON_NULL_RETURN_VAL(wdg, EINA_FALSE); 1362 EINA_SAFETY_ON_NULL_RETURN_VAL(wdg, EINA_FALSE);
1363 Gui_Context *ctx = (Gui_Context *)wdg_context_get(wdg);
1362 Dep_Id *old_parent_id = wdg->parent_id; 1364 Dep_Id *old_parent_id = wdg->parent_id;
1363 /* Check is parent is not widget itself*/ 1365 Dep_Id *new_parent_id = parent_name?gui_context_dep_id_by_name_get(wdg_context_get(wdg), parent_name):NULL;
1364 if (new_parent_id && wdg->name_id == new_parent_id) 1366
1367 if (parent_name && !new_parent_id)
1365 { 1368 {
1366 ERR("wdg == new_parent");
1367 return EINA_FALSE; 1369 return EINA_FALSE;
1368 } 1370 }
1369 1371
1370 /* Check that we are not trying to set NULL parent to widget which is not win*/ 1372 /* Check is parent is not widget itself*/
1371 if ((!IS_WIN(wdg)) && (!new_parent_id)) 1373 if (new_parent_id && wdg->name_id == new_parent_id)
1372 { 1374 {
1373 ERR("cannot set NULL parent to non win widget"); 1375 ERR("wdg == new_parent");
1374 return EINA_FALSE; 1376 return EINA_FALSE;
1375 } 1377 }
1376 1378
1377 /* Check that the parent has really to be updated */ 1379 /* Check that the parent has really to be updated. If the parents are NULL, we update anyway. */
1378 if (old_parent_id == new_parent_id) return EINA_TRUE; 1380 if (old_parent_id && old_parent_id == new_parent_id) return EINA_TRUE;
1379 1381
1380 /* Case when parent of win is NULL*/
1381 if (old_parent_id) 1382 if (old_parent_id)
1382 { 1383 {
1383 Gui_Widget *old_parent = wdg_get(old_parent_id); 1384 Gui_Widget *old_parent = wdg_get(old_parent_id);
1384 old_parent->children = eina_list_remove(old_parent->children, wdg->name_id); 1385 old_parent->children = eina_list_remove(old_parent->children, wdg->name_id);
1385 } 1386 }
1387 else
1388 ctx->win_list = eina_list_remove(ctx->win_list, wdg->name_id); /* Remove the object from the main objects */
1386 1389
1387 wdg->parent_id = new_parent_id; 1390 wdg->parent_id = new_parent_id;
1388 if (new_parent_id) 1391 if (new_parent_id)
@@ -1390,26 +1393,12 @@ _wdg_parent_set_int(Gui_Widget *wdg, Dep_Id *new_parent_id)
1390 Gui_Widget *new_parent = wdg_get(new_parent_id); 1393 Gui_Widget *new_parent = wdg_get(new_parent_id);
1391 new_parent->children = eina_list_append(new_parent->children, wdg->name_id); 1394 new_parent->children = eina_list_append(new_parent->children, wdg->name_id);
1392 } 1395 }
1396 else
1397 ctx->win_list = eina_list_append(ctx->win_list, wdg->name_id); /* Set the object as a main object */
1393 1398
1394 return EINA_TRUE; 1399 return EINA_TRUE;
1395} 1400}
1396 1401
1397/* Wrapper to avoid case, when widget is not created yet. */
1398Eina_Bool
1399wdg_parent_set(Gui_Widget *wdg, const char *parent_name)
1400{
1401 EINA_SAFETY_ON_NULL_RETURN_VAL(wdg, EINA_FALSE);
1402 Dep_Id *parent_id = 0;
1403
1404 if (parent_name)
1405 parent_id = gui_context_dep_id_by_name_get(wdg_context_get(wdg), parent_name);
1406 if (parent_name && !parent_id)
1407 {
1408 return EINA_FALSE;
1409 }
1410 return _wdg_parent_set_int(wdg, parent_id);
1411}
1412
1413const Gui_Widget* 1402const Gui_Widget*
1414wdg_parent_win_wdg_get(const Gui_Widget *wdg) 1403wdg_parent_win_wdg_get(const Gui_Widget *wdg)
1415{ 1404{