Add in some safety checks.

This commit is contained in:
Jaime Thomas 2009-01-09 01:25:52 +00:00
parent 797a8a8498
commit ef625941f9

View File

@ -57,6 +57,12 @@ ecdb_widget_add(Evas_Object *parent, const char *name)
int x, y, w, h; int x, y, w, h;
o = edje_object_add(evas_object_evas_get(parent)); o = edje_object_add(evas_object_evas_get(parent));
if (!o)
{
printf("ecdb_widget_add: NULL return!\n");
return NULL;
}
edje_object_signal_callback_add(o, "mouse,down,*", "*", edje_object_signal_callback_add(o, "mouse,down,*", "*",
_mouse_down_edje, _mouse_down_edje,
(void *)name); (void *)name);
@ -88,9 +94,15 @@ ecdb_button_add(Evas_Object *parent, const char *name)
Evas_Object *b; Evas_Object *b;
b = ecdb_widget_add(parent, name); b = ecdb_widget_add(parent, name);
if (!b)
{
printf("ecdb_button_add: NULL return!\n");
return NULL;
}
edje_object_file_set(b, em->theme_path, "ecdb/button"); edje_object_file_set(b, em->theme_path, "ecdb/button");
edje_object_signal_callback_add(b, "clicked", "ecdb", edje_object_signal_callback_add(b, "clicked", "ecdb", _button_click_cb_call,
_button_click_cb_call, b); b);
return b; return b;
} }
@ -98,6 +110,11 @@ ecdb_button_add(Evas_Object *parent, const char *name)
void void
ecdb_button_label_set(Evas_Object *b, const char *label) ecdb_button_label_set(Evas_Object *b, const char *label)
{ {
if (!b)
{
printf("ecdb_button_label_set: NULL object!\n");
return;
}
edje_object_part_text_set(b, "ecdb.label", label); edje_object_part_text_set(b, "ecdb.label", label);
} }
@ -106,7 +123,18 @@ ecdb_button_icon_set(Evas_Object *b, const char *group)
{ {
Evas_Object *icon; Evas_Object *icon;
if (!b)
{
printf("ecdb_button_icon_set: NULL object!\n");
return;
}
icon = ecdb_widget_add(b, "ecdb.swallow.icon"); icon = ecdb_widget_add(b, "ecdb.swallow.icon");
if (!icon)
{
printf("ecdb_button_icon_set: NULL icon!\n");
return;
}
edje_object_file_set(icon, em->theme_path, group); edje_object_file_set(icon, em->theme_path, group);
evas_object_show(icon); evas_object_show(icon);
} }
@ -114,6 +142,11 @@ ecdb_button_icon_set(Evas_Object *b, const char *group)
const char * const char *
ecdb_button_label_get(Evas_Object *b) ecdb_button_label_get(Evas_Object *b)
{ {
if (!b)
{
printf("ecdb_button_label_get: NULL object!\n");
return NULL;
}
return edje_object_part_text_get(b, "ecdb.label"); return edje_object_part_text_get(b, "ecdb.label");
} }
@ -131,6 +164,11 @@ ecdb_combo_item_add(Evas_Object *parent, const char *name)
Evas_Object *ci; Evas_Object *ci;
ci = ecdb_widget_add(parent, name); ci = ecdb_widget_add(parent, name);
if (!ci)
{
printf("ecdb_combo_item_add: NULL return!\n");
return NULL;
}
edje_object_file_set(ci, em->theme_path, "ecdb/combo_item"); edje_object_file_set(ci, em->theme_path, "ecdb/combo_item");
edje_object_signal_callback_add(ci, "clicked", "ecdb", edje_object_signal_callback_add(ci, "clicked", "ecdb",
_combo_item_click_cb_call, ci); _combo_item_click_cb_call, ci);
@ -141,6 +179,11 @@ ecdb_combo_item_add(Evas_Object *parent, const char *name)
void void
ecdb_combo_item_label_set(Evas_Object *ci, const char *label) ecdb_combo_item_label_set(Evas_Object *ci, const char *label)
{ {
if (!ci)
{
printf("ecdb_combo_label_set: NULL ci!\n");
return;
}
edje_object_part_text_set(ci, "ecdb.label", label); edje_object_part_text_set(ci, "ecdb.label", label);
} }
@ -149,7 +192,18 @@ ecdb_combo_item_icon_set(Evas_Object *ci, const char *group)
{ {
Evas_Object *icon; Evas_Object *icon;
if (!ci)
{
printf("ecdb_combo_item_icon_set: NULL object!\n");
return;
}
icon = ecdb_widget_add(ci, "ecdb.swallow.icon"); icon = ecdb_widget_add(ci, "ecdb.swallow.icon");
if (!icon)
{
printf("ecdb_combo_item_icon_set: NULL icon!\n");
return;
}
edje_object_file_set(icon, em->theme_path, group); edje_object_file_set(icon, em->theme_path, group);
evas_object_show(icon); evas_object_show(icon);
} }
@ -167,6 +221,7 @@ struct _Check_Data
{ {
unsigned int checked; unsigned int checked;
}; };
static void static void
_check_del(void *data, Evas *e, Evas_Object *obj, void *event_info) _check_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
{ {
@ -201,12 +256,23 @@ ecdb_check_add(Evas_Object *parent, const char *name)
Check_Data *cd; Check_Data *cd;
c = ecdb_widget_add(parent, name); c = ecdb_widget_add(parent, name);
if (!c)
{
printf("ecdb_check_add: NULL return!\n");
return NULL;
}
edje_object_file_set(c, em->theme_path, "ecdb/check"); edje_object_file_set(c, em->theme_path, "ecdb/check");
edje_object_signal_callback_add(c, "ecdb,check,*", "ecdb", edje_object_signal_callback_add(c, "ecdb,check,*", "ecdb",
_check_toggle_cb_call, c); _check_toggle_cb_call, c);
evas_object_event_callback_add(c, EVAS_CALLBACK_DEL, _check_del, c); evas_object_event_callback_add(c, EVAS_CALLBACK_DEL, _check_del, c);
cd = calloc(1, sizeof(Check_Data)); cd = calloc(1, sizeof(Check_Data));
if (!cd)
{
printf("ecdb_check_add: NULL data!\n");
return NULL;
}
evas_object_data_set(c, "cd", cd); evas_object_data_set(c, "cd", cd);
return c; return c;
@ -215,12 +281,24 @@ ecdb_check_add(Evas_Object *parent, const char *name)
void void
ecdb_check_label_set(Evas_Object *c, const char *label) ecdb_check_label_set(Evas_Object *c, const char *label)
{ {
if (!c)
{
printf("ecdb_check_label_set: NULL object!\n");
return;
}
edje_object_part_text_set(c, "ecdb.label", label); edje_object_part_text_set(c, "ecdb.label", label);
} }
void void
ecdb_check_states_set(Evas_Object *c, const char *ystate, const char *nstate) ecdb_check_states_set(Evas_Object *c, const char *ystate, const char *nstate)
{ {
if (!c)
{
printf("ecdb_check_states_set: NULL object!\n");
return;
}
edje_object_part_text_set(c, "ecdb.ystate", ystate); edje_object_part_text_set(c, "ecdb.ystate", ystate);
edje_object_part_text_set(c, "ecdb.nstate", nstate); edje_object_part_text_set(c, "ecdb.nstate", nstate);
} }
@ -230,7 +308,19 @@ ecdb_check_checked_set(Evas_Object *c, int state)
{ {
Check_Data *cd; Check_Data *cd;
if (!c)
{
printf("ecdb_check_checked_set: NULL object!\n");
return;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_check_checked_set: NULL data!\n");
return;
}
if (state) if (state)
{ {
cd->checked = 1; cd->checked = 1;
@ -248,7 +338,18 @@ ecdb_check_checked_get(Evas_Object *c)
{ {
Check_Data *cd; Check_Data *cd;
if (!c)
{
printf("ecdb_check_checked_get: NULL object!\n");
return 0;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_check_checked_get: NULL data!\n");
return 0;
}
return cd->checked; return cd->checked;
} }
@ -427,6 +528,11 @@ ecdb_entry_add(Evas_Object *parent, const char *name)
Evas_Object *e; Evas_Object *e;
e = ecdb_widget_add(parent, name); e = ecdb_widget_add(parent, name);
if (!e)
{
printf("ecdb_entry_add: NULL return!\n");
return NULL;
}
edje_object_file_set(e, em->theme_path, "ecdb/entry"); edje_object_file_set(e, em->theme_path, "ecdb/entry");
em->evas_dnd_candidates = eina_list_append(em->evas_dnd_candidates, e); em->evas_dnd_candidates = eina_list_append(em->evas_dnd_candidates, e);
evas_object_data_set(e, "dnd_call_func", ecdb_dnd_entry_dnd_set); evas_object_data_set(e, "dnd_call_func", ecdb_dnd_entry_dnd_set);
@ -559,6 +665,12 @@ _combo_clicked(void *data, Evas_Object *obj, void *event_info)
it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup, it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup,
"ecdb.box")); "ecdb.box"));
if (!it)
{
printf("_combo_clicked: NULL iterator!\n");
return;
}
while (eina_iterator_next(it, (void **)&swallow)) while (eina_iterator_next(it, (void **)&swallow))
{ {
if (swallow == obj) if (swallow == obj)
@ -623,6 +735,12 @@ ecdb_combo_add(Evas_Object *parent, const char *name)
Combo_Data *cd; Combo_Data *cd;
c = ecdb_widget_add(parent, name); c = ecdb_widget_add(parent, name);
if (!c)
{
printf("ecdb_combo_add: NULL return!\n");
return NULL;
}
edje_object_file_set(c, em->theme_path, "ecdb/combo"); edje_object_file_set(c, em->theme_path, "ecdb/combo");
evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _combo_resize, evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _combo_resize,
c); c);
@ -632,6 +750,11 @@ ecdb_combo_add(Evas_Object *parent, const char *name)
_combo_click_cb, c); _combo_click_cb, c);
cd = calloc(1, sizeof(Combo_Data)); cd = calloc(1, sizeof(Combo_Data));
if (!cd)
{
printf("ecdb_combo_add: NULL data!\n");
return NULL;
}
cd->back = edje_object_add(evas_object_evas_get(parent)); cd->back = edje_object_add(evas_object_evas_get(parent));
edje_object_file_set(cd->back, em->theme_path, "ecdb/combo/background"); edje_object_file_set(cd->back, em->theme_path, "ecdb/combo/background");
@ -662,7 +785,19 @@ ecdb_combo_header_set(Evas_Object *c, const char *text)
{ {
Combo_Data *cd; Combo_Data *cd;
if (!c)
{
printf("ecdb_combo_header_set: NULL object!\n");
return;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_header_set: NULL data!\n");
return;
}
edje_object_part_text_set(c, "ecdb.header", text); edje_object_part_text_set(c, "ecdb.header", text);
eina_stringshare_del(cd->header); eina_stringshare_del(cd->header);
cd->header = eina_stringshare_add(text); cd->header = eina_stringshare_add(text);
@ -673,7 +808,18 @@ ecdb_combo_append(Evas_Object *c, Evas_Object *o)
{ {
Combo_Data *cd; Combo_Data *cd;
if (!c)
{
printf("ecdb_combo_append: NULL object!\n");
return;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_append: NULL data!\n");
return;
}
cd->count++; cd->count++;
edje_object_part_box_append(cd->popup, "ecdb.box", o); edje_object_part_box_append(cd->popup, "ecdb.box", o);
evas_object_smart_callback_add(o, "clicked", _combo_clicked, c); evas_object_smart_callback_add(o, "clicked", _combo_clicked, c);
@ -691,9 +837,20 @@ ecdb_combo_expand(Evas_Object *c)
char buf[1024]; char buf[1024];
int x, y, w, h, h2, padding; int x, y, w, h, h2, padding;
cd = evas_object_data_get(c, "cd"); if (!c)
{
printf("ecdb_combo_expand: NULL object!\n");
return;
}
if (cd->count == 0) cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_expand: NULL data!\n");
return;
}
if ((cd->count == 0) || (cd->expanded))
return; return;
edje_object_signal_emit(c, "ecdb,combo,active", "ecdb"); edje_object_signal_emit(c, "ecdb,combo,active", "ecdb");
@ -715,6 +872,12 @@ ecdb_combo_expand(Evas_Object *c)
it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup, it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup,
"ecdb.box")); "ecdb.box"));
if (!it)
{
printf("ecdb_combo_expand: NULL iterator!\n");
return;
}
while (eina_iterator_next(it, (void **)&o)) while (eina_iterator_next(it, (void **)&o))
{ {
min_size = edje_object_data_get(o, "ecdb/combo_item/minh"); min_size = edje_object_data_get(o, "ecdb/combo_item/minh");
@ -756,7 +919,18 @@ ecdb_combo_collapse(Evas_Object *c)
if ((!em) || (!em->main_win_ee)) if ((!em) || (!em->main_win_ee))
return; return;
if (!c)
{
printf("ecdb_combo_collapse: NULL object!\n");
return;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_collapse: NULL data!\n");
return;
}
edje_object_signal_emit(cd->back, "ecdb,combo,back,hide", "ecdb"); edje_object_signal_emit(cd->back, "ecdb,combo,back,hide", "ecdb");
evas_object_pass_events_set(cd->back, 1); evas_object_pass_events_set(cd->back, 1);
@ -769,6 +943,12 @@ ecdb_combo_collapse(Evas_Object *c)
it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup, it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup,
"ecdb.box")); "ecdb.box"));
if (!it)
{
printf("ecdb_combo_collapse: NULL iterator!\n");
return;
}
while ((eina_iterator_next(it, (void **)&o))) while ((eina_iterator_next(it, (void **)&o)))
evas_object_smart_callback_call(o, "hidden", c); evas_object_smart_callback_call(o, "hidden", c);
eina_iterator_free(it); eina_iterator_free(it);
@ -783,7 +963,19 @@ ecdb_combo_header_create_set(Evas_Object *c, void (*func)
{ {
Combo_Data *cd; Combo_Data *cd;
if (!c)
{
printf("ecdb_combo_header_create_set: NULL object!\n");
return;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_header_create_set: NULL data!\n");
return;
}
cd->create_header = func; cd->create_header = func;
} }
@ -792,7 +984,18 @@ ecdb_combo_selected_get(Evas_Object *c)
{ {
Combo_Data *cd; Combo_Data *cd;
if (!c)
{
printf("ecdb_combo_selected_get: NULL object!\n");
return -1;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_selected_get: NULL data!\n");
return -1;
}
return cd->selected; return cd->selected;
} }
@ -802,7 +1005,18 @@ ecdb_combo_data_set(Evas_Object *c, void *data)
{ {
Combo_Data *cd; Combo_Data *cd;
if (!c)
{
printf("ecdb_combo_data_set: NULL object!\n");
return;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
if (!cd)
{
printf("ecdb_combo_data_set: NULL data!\n");
return;
}
cd->data = data; cd->data = data;
} }
@ -811,6 +1025,12 @@ ecdb_combo_clear(Evas_Object *c)
{ {
Combo_Data *cd; Combo_Data *cd;
if (!c)
{
printf("ecdb_combo_clear: NULL object!");
return;
}
cd = evas_object_data_get(c, "cd"); cd = evas_object_data_get(c, "cd");
edje_object_part_box_remove_all(cd->popup, "ecdb.box", 1); edje_object_part_box_remove_all(cd->popup, "ecdb.box", 1);
cd->selected = 1; cd->selected = 1;
@ -825,6 +1045,11 @@ ecdb_label_add(Evas_Object *parent, const char *name)
Evas_Object *l; Evas_Object *l;
l = ecdb_widget_add(parent, name); l = ecdb_widget_add(parent, name);
if (!l)
{
printf("ecdb_label_add: NULL return!\n");
return NULL;
}
edje_object_file_set(l, em->theme_path, "ecdb/label"); edje_object_file_set(l, em->theme_path, "ecdb/label");
return l; return l;
@ -833,6 +1058,11 @@ ecdb_label_add(Evas_Object *parent, const char *name)
void void
ecdb_label_text_set(Evas_Object *l, const char *text) ecdb_label_text_set(Evas_Object *l, const char *text)
{ {
if (!l)
{
printf("ecdb_label_text_set: NULL object!\n");
return;
}
edje_object_part_text_set(l, "ecdb.label", text); edje_object_part_text_set(l, "ecdb.label", text);
} }
@ -843,6 +1073,11 @@ ecdb_config_inwin_add(Evas_Object *parent, const char *name)
Evas_Object *iw; Evas_Object *iw;
iw = ecdb_widget_add(parent, name); iw = ecdb_widget_add(parent, name);
if (!iw)
{
printf("ecdb_config_inwin_add: NULL return!\n");
return NULL;
}
edje_object_file_set(iw, em->theme_path, "ecdb/config_inwin"); edje_object_file_set(iw, em->theme_path, "ecdb/config_inwin");
/* /*