forked from enlightenment/enlightenment
Add traps in toolbar widget to make sure obj & wd are valid.
Add traps in e_fwin to make sure we have a toolbar before trying to operate on it. SVN revision: 55792
This commit is contained in:
parent
71d8f97aff
commit
645ad54f55
|
@ -103,7 +103,8 @@ e_widget_toolbar_item_append(Evas_Object *obj, Evas_Object *icon, const char *la
|
|||
Item *it;
|
||||
Evas_Coord mw = 0, mh = 0, vw = 0, vh = 0;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
o = edje_object_add(evas_object_evas_get(obj));
|
||||
e_theme_edje_object_set(o, "base/theme/widgets",
|
||||
"e/widgets/toolbar/item");
|
||||
|
@ -150,7 +151,8 @@ e_widget_toolbar_item_remove(Evas_Object *obj, int num)
|
|||
E_Widget_Data *wd;
|
||||
Item *it;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
it = eina_list_nth(wd->items, num);
|
||||
if (it)
|
||||
{
|
||||
|
@ -169,7 +171,8 @@ e_widget_toolbar_item_select(Evas_Object *obj, int num)
|
|||
Item *it = NULL;
|
||||
int i = 0;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
if (i == num)
|
||||
|
@ -190,7 +193,8 @@ e_widget_toolbar_item_label_set(Evas_Object *obj, int num, const char *label)
|
|||
E_Widget_Data *wd = NULL;
|
||||
Item *it = NULL;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
it = eina_list_nth(wd->items, num);
|
||||
if (it)
|
||||
{
|
||||
|
@ -214,7 +218,8 @@ e_widget_toolbar_scrollable_set(Evas_Object *obj, Eina_Bool scrollable)
|
|||
E_Widget_Data *wd;
|
||||
Evas_Coord mw = 0, mh = 0, vw = 0, vh = 0;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
wd->scrollable = scrollable;
|
||||
e_box_size_min_get(wd->o_box, &mw, &mh);
|
||||
evas_object_resize(wd->o_box, mw, mh);
|
||||
|
@ -232,7 +237,8 @@ e_widget_toolbar_focus_steal_set(Evas_Object *obj, Eina_Bool steal)
|
|||
{
|
||||
E_Widget_Data *wd;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
if (wd->focus_steal == steal) return;
|
||||
if (steal)
|
||||
{
|
||||
|
@ -256,7 +262,8 @@ e_widget_toolbar_clear(Evas_Object *obj)
|
|||
E_Widget_Data *wd = NULL;
|
||||
Item *it = NULL;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
EINA_LIST_FREE(wd->items, it)
|
||||
{
|
||||
evas_object_del(it->o_base);
|
||||
|
@ -273,7 +280,8 @@ e_widget_toolbar_item_selected_get(Evas_Object *obj)
|
|||
Item *it = NULL;
|
||||
int i = 0;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return 0;
|
||||
if (!(wd = e_widget_data_get(obj))) return 0;
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
if (it->selected) return i;
|
||||
|
@ -289,7 +297,8 @@ _e_wid_del_hook(Evas_Object *obj)
|
|||
E_Widget_Data *wd;
|
||||
Item *it;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
EINA_LIST_FREE(wd->items, it)
|
||||
{
|
||||
evas_object_del(it->o_base);
|
||||
|
@ -304,7 +313,8 @@ _e_wid_disable_hook(Evas_Object *obj)
|
|||
{
|
||||
E_Widget_Data *wd;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
if (e_widget_disabled_get(obj))
|
||||
edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_base),
|
||||
"e,state,disabled", "e");
|
||||
|
@ -341,7 +351,7 @@ _e_wid_signal_prev(void *data, Evas_Object *obj __UNUSED__, const char *emission
|
|||
Eina_List *l, *l2;
|
||||
Item *it = NULL, *it2 = NULL;
|
||||
|
||||
wd = e_widget_data_get(data);
|
||||
if (!(wd = e_widget_data_get(data))) return;
|
||||
if ((!wd->o_base) || (!wd->o_box)) return;
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
|
@ -366,7 +376,7 @@ _e_wid_signal_next(void *data, Evas_Object *obj __UNUSED__, const char *emission
|
|||
Eina_List *l, *l2;
|
||||
Item *it = NULL, *it2 = NULL;
|
||||
|
||||
wd = e_widget_data_get(data);
|
||||
if (!(wd = e_widget_data_get(data))) return;
|
||||
if ((!wd->o_base) || (!wd->o_box)) return;
|
||||
EINA_LIST_FOREACH(wd->items, l, it)
|
||||
{
|
||||
|
@ -392,7 +402,7 @@ _e_wid_cb_scrollframe_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __
|
|||
Eina_List *l;
|
||||
Item *it;
|
||||
|
||||
wd = e_widget_data_get(data);
|
||||
if (!(wd = e_widget_data_get(data))) return;
|
||||
if ((!wd->o_base) || (!wd->o_box)) return;
|
||||
|
||||
e_scrollframe_child_viewport_size_get(wd->o_base, &vw, &vh);
|
||||
|
@ -486,7 +496,8 @@ _e_wid_focus_hook(Evas_Object *obj)
|
|||
{
|
||||
E_Widget_Data *wd;
|
||||
|
||||
wd = e_widget_data_get(obj);
|
||||
if (!obj) return;
|
||||
if (!(wd = e_widget_data_get(obj))) return;
|
||||
if (e_widget_focus_get(obj))
|
||||
{
|
||||
edje_object_signal_emit(wd->o_base, "e,state,focused", "e");
|
||||
|
|
|
@ -52,9 +52,10 @@ struct _E_Fwin_Page
|
|||
Evas_Object *fm_obj;
|
||||
E_Toolbar *tbar;
|
||||
|
||||
struct {
|
||||
Evas_Coord x, y, max_x, max_y, w, h;
|
||||
} fm_pan, fm_pan_last;
|
||||
struct
|
||||
{
|
||||
Evas_Coord x, y, max_x, max_y, w, h;
|
||||
} fm_pan, fm_pan_last;
|
||||
|
||||
int index;
|
||||
};
|
||||
|
@ -558,12 +559,12 @@ _e_fwin_page_new(E_Fwin *fwin)
|
|||
|
||||
/* There is no toolbar yet */
|
||||
fwin->tb_obj = e_widget_toolbar_add(evas_object_evas_get(page->fm_obj),
|
||||
48 * e_scale, 48 * e_scale);
|
||||
48 * e_scale, 48 * e_scale);
|
||||
|
||||
e_widget_toolbar_focus_steal_set(fwin->tb_obj, 0);
|
||||
real = ecore_file_file_get(e_fm2_real_path_get(page->fm_obj));
|
||||
e_widget_toolbar_item_append(fwin->tb_obj, NULL, real,
|
||||
_e_fwin_cb_page_change, fwin, page);
|
||||
_e_fwin_cb_page_change, fwin, page);
|
||||
|
||||
evas_object_move(fwin->tb_obj, 0, 0);
|
||||
evas_object_show(fwin->tb_obj);
|
||||
|
@ -573,7 +574,7 @@ _e_fwin_page_new(E_Fwin *fwin)
|
|||
fwin->pages = eina_list_append(fwin->pages, page);
|
||||
real = ecore_file_file_get(e_fm2_real_path_get(fwin->cur_page->fm_obj));
|
||||
e_widget_toolbar_item_append(fwin->tb_obj, NULL, real,
|
||||
_e_fwin_cb_page_change, fwin, page);
|
||||
_e_fwin_cb_page_change, fwin, page);
|
||||
e_fm2_path_get(fwin->cur_page->fm_obj, &dev, &path);
|
||||
e_fm2_path_set(page->fm_obj, dev, path);
|
||||
|
||||
|
@ -625,7 +626,8 @@ _e_fwin_custom_file_path_eval(E_Fwin *fwin, Efreet_Desktop *ef, const char *prev
|
|||
/* relative path to the dir */
|
||||
else
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "%s/%s", e_fm2_real_path_get(fwin->cur_page->fm_obj), res);
|
||||
snprintf(buf, sizeof(buf), "%s/%s",
|
||||
e_fm2_real_path_get(fwin->cur_page->fm_obj), res);
|
||||
ret = eina_stringshare_add(buf);
|
||||
}
|
||||
return ret;
|
||||
|
@ -717,14 +719,14 @@ _e_fwin_desktop_run(Efreet_Desktop *desktop, E_Fwin_Page *page, Eina_Bool skip_h
|
|||
_e_fwin_file_exec(page, ici, ext);
|
||||
if (buf[0] != 0)
|
||||
{
|
||||
if (ici->mime && desktop && !skip_history)
|
||||
if ((ici->mime) && (desktop) && !(skip_history))
|
||||
e_exehist_mime_desktop_add(ici->mime, desktop);
|
||||
files = eina_list_append(files, strdup(ici->file));
|
||||
}
|
||||
}
|
||||
eina_list_free(selected);
|
||||
|
||||
if (fwin->win && desktop)
|
||||
if ((fwin->win) && (desktop))
|
||||
e_exec(fwin->win->border->zone, desktop, NULL, files, "fwin");
|
||||
else if (fwin->zone && desktop)
|
||||
e_exec(fwin->zone, desktop, NULL, files, "fwin");
|
||||
|
@ -1285,11 +1287,19 @@ _e_fwin_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
|
|||
int i = 0;
|
||||
|
||||
page = fwin->cur_page;
|
||||
if (fwin->page_index > 0)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, fwin->page_index - 1);
|
||||
else
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, 1);
|
||||
e_widget_toolbar_item_remove(fwin->tb_obj, page->index);
|
||||
if (fwin->page_index > 0)
|
||||
{
|
||||
if (fwin->tb_obj)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj,
|
||||
fwin->page_index - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwin->tb_obj)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, 1);
|
||||
}
|
||||
if (fwin->tb_obj)
|
||||
e_widget_toolbar_item_remove(fwin->tb_obj, page->index);
|
||||
fwin->pages = eina_list_remove(fwin->pages, page);
|
||||
_e_fwin_page_free(page);
|
||||
EINA_LIST_FOREACH(fwin->pages, l, page)
|
||||
|
@ -1297,7 +1307,8 @@ _e_fwin_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
|
|||
}
|
||||
else if (count > 1)
|
||||
{
|
||||
evas_object_del(fwin->tb_obj);
|
||||
if (fwin->tb_obj)
|
||||
evas_object_del(fwin->tb_obj);
|
||||
fwin->tb_obj = NULL;
|
||||
fwin->page_index = 0;
|
||||
fwin->pages = eina_list_remove(fwin->pages, fwin->cur_page);
|
||||
|
@ -1324,21 +1335,37 @@ _e_fwin_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
|
|||
if (!strcmp(ev->key, "Tab"))
|
||||
{
|
||||
Eina_List *l;
|
||||
|
||||
if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
|
||||
{
|
||||
l = eina_list_nth_list(fwin->pages, fwin->page_index);
|
||||
if (l->prev)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, fwin->page_index - 1);
|
||||
else
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, eina_list_count(fwin->pages) - 1);
|
||||
if (l->prev)
|
||||
{
|
||||
if (fwin->tb_obj)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj,
|
||||
fwin->page_index - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwin->tb_obj)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj,
|
||||
eina_list_count(fwin->pages) - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
l = eina_list_nth_list(fwin->pages, fwin->page_index);
|
||||
if (l->next)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, fwin->page_index + 1);
|
||||
else
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, 0);
|
||||
if (l->next)
|
||||
{
|
||||
if (fwin->tb_obj)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj,
|
||||
fwin->page_index + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fwin->tb_obj)
|
||||
e_widget_toolbar_item_select(fwin->tb_obj, 0);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue