2010-10-19 11:25:22 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2012-03-29 12:27:13 -07:00
|
|
|
#include <Elementary.h>
|
2009-10-15 13:34:42 -07:00
|
|
|
#ifndef ELM_LIB_QUICKLAUNCH
|
|
|
|
|
2012-02-12 14:35:56 -08:00
|
|
|
#define LIST_ITEM_MAX 20
|
|
|
|
|
2009-12-13 15:25:31 -08:00
|
|
|
static Elm_Genlist_Item_Class itc;
|
2009-11-15 08:14:51 -08:00
|
|
|
|
2010-05-27 02:03:22 -07:00
|
|
|
static void _bstatus(void *data, Evas_Object *obj, void *event_info);
|
|
|
|
static void _tstatus(void *data, Evas_Object *obj, void *event_info);
|
2011-11-30 22:15:08 -08:00
|
|
|
static char *_text_get(void *data, Evas_Object *obj, const char *source);
|
2011-10-23 19:10:35 -07:00
|
|
|
static Evas_Object *_content_get(void *data, Evas_Object *obj, const char *source);
|
2010-09-17 09:34:59 -07:00
|
|
|
static Eina_Bool _state_get(void *data, Evas_Object *obj, const char *source);
|
|
|
|
static void _item_del(void *data, Evas_Object *obj);
|
2009-11-15 08:14:51 -08:00
|
|
|
static void _fill_list(Evas_Object *obj);
|
|
|
|
static Eina_Bool _dir_has_subs(const char *path);
|
|
|
|
|
2012-02-12 14:35:56 -08:00
|
|
|
static Eina_List *dirs = NULL;
|
|
|
|
|
2010-05-27 02:03:22 -07:00
|
|
|
static void
|
2010-10-19 11:25:22 -07:00
|
|
|
_tstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-10-15 13:34:42 -07:00
|
|
|
{
|
2011-11-29 21:10:23 -08:00
|
|
|
Elm_Object_Item *tb_it;
|
2010-10-20 10:15:14 -07:00
|
|
|
const char *status;
|
2009-11-15 08:14:51 -08:00
|
|
|
|
2010-05-27 02:03:22 -07:00
|
|
|
if (elm_panel_hidden_get((Evas_Object*)data))
|
|
|
|
status = "hidden";
|
2010-10-20 10:15:14 -07:00
|
|
|
else
|
|
|
|
status = "shown";
|
2010-05-27 02:03:22 -07:00
|
|
|
printf("The top panel is currently %s\n", status);
|
2011-11-29 21:10:23 -08:00
|
|
|
tb_it = elm_toolbar_selected_item_get(obj);
|
|
|
|
elm_toolbar_item_selected_set(tb_it, EINA_FALSE);
|
2010-05-27 02:03:22 -07:00
|
|
|
}
|
2009-11-15 08:14:51 -08:00
|
|
|
|
2010-05-27 02:03:22 -07:00
|
|
|
static void
|
2010-10-19 11:25:22 -07:00
|
|
|
_bstatus(void *data, Evas_Object *obj, void *event_info __UNUSED__)
|
2010-05-27 02:03:22 -07:00
|
|
|
{
|
2011-11-29 21:10:23 -08:00
|
|
|
Elm_Object_Item *tb_it;
|
2010-10-20 10:15:14 -07:00
|
|
|
const char *status;
|
2009-11-15 08:14:51 -08:00
|
|
|
|
2010-05-27 02:03:22 -07:00
|
|
|
if (elm_panel_hidden_get((Evas_Object*)data))
|
|
|
|
status = "hidden";
|
2010-10-20 10:15:14 -07:00
|
|
|
else
|
|
|
|
status = "shown";
|
2010-05-27 02:03:22 -07:00
|
|
|
printf("The bottom panel is currently %s\n", status);
|
2011-11-29 21:10:23 -08:00
|
|
|
tb_it = elm_toolbar_selected_item_get(obj);
|
|
|
|
elm_toolbar_item_selected_set(tb_it, EINA_FALSE);
|
2009-10-15 13:34:42 -07:00
|
|
|
}
|
|
|
|
|
2009-11-15 08:14:51 -08:00
|
|
|
static char *
|
2011-11-30 22:15:08 -08:00
|
|
|
_text_get(void *data, Evas_Object *obj __UNUSED__, const char *source __UNUSED__)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
return strdup(ecore_file_file_get(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
2011-10-23 19:10:35 -07:00
|
|
|
_content_get(void *data, Evas_Object *obj, const char *source)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
2011-04-08 07:30:48 -07:00
|
|
|
if (!strcmp(source, "elm.swallow.icon"))
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
Evas_Object *ic;
|
|
|
|
|
|
|
|
ic = elm_icon_add(obj);
|
|
|
|
if (ecore_file_is_dir((char *)data))
|
|
|
|
elm_icon_standard_set(ic, "folder");
|
|
|
|
else
|
|
|
|
elm_icon_standard_set(ic, "file");
|
|
|
|
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
|
|
|
|
evas_object_show(ic);
|
|
|
|
return ic;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-04-08 07:30:48 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_state_get(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const char *source __UNUSED__)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2011-04-08 07:30:48 -07:00
|
|
|
static void
|
|
|
|
_item_del(void *data, Evas_Object *obj __UNUSED__)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
eina_stringshare_del(data);
|
|
|
|
}
|
|
|
|
|
2011-04-08 07:30:48 -07:00
|
|
|
static void
|
|
|
|
_fill_list(Evas_Object *obj)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
DIR *d;
|
|
|
|
struct dirent *de;
|
2012-02-12 14:35:56 -08:00
|
|
|
Eina_List *l;
|
2009-11-15 08:14:51 -08:00
|
|
|
char *real;
|
2012-02-12 14:35:56 -08:00
|
|
|
unsigned int x = 0;
|
2009-11-15 08:14:51 -08:00
|
|
|
|
2012-02-12 14:35:56 -08:00
|
|
|
if (!dirs)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
2012-02-12 14:35:56 -08:00
|
|
|
if (!(d = opendir(getenv("HOME")))) return;
|
|
|
|
while ((de = readdir(d)) && (x < LIST_ITEM_MAX))
|
|
|
|
{
|
|
|
|
char buff[PATH_MAX];
|
|
|
|
|
|
|
|
if (de->d_name[0] == '.') continue;
|
|
|
|
snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), de->d_name);
|
|
|
|
if (!ecore_file_is_dir(buff)) continue;
|
|
|
|
x++;
|
|
|
|
real = ecore_file_realpath(buff);
|
|
|
|
dirs = eina_list_sorted_insert(dirs, EINA_COMPARE_CB(strcoll), real);
|
|
|
|
}
|
|
|
|
closedir(d);
|
2009-11-15 08:14:51 -08:00
|
|
|
}
|
2011-04-08 07:30:48 -07:00
|
|
|
EINA_LIST_FOREACH(dirs, l, real)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
Eina_Bool result = EINA_FALSE;
|
|
|
|
|
|
|
|
result = _dir_has_subs(real);
|
2011-04-08 07:30:48 -07:00
|
|
|
if (!result)
|
|
|
|
elm_genlist_item_append(obj, &itc, eina_stringshare_add(real),
|
2009-11-15 08:14:51 -08:00
|
|
|
NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
|
2011-04-08 07:30:48 -07:00
|
|
|
else
|
|
|
|
elm_genlist_item_append(obj, &itc, eina_stringshare_add(real),
|
2012-03-07 04:57:13 -08:00
|
|
|
NULL, ELM_GENLIST_ITEM_TREE,
|
2009-11-15 08:14:51 -08:00
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-08 07:30:48 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_dir_has_subs(const char *path)
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
DIR *d;
|
|
|
|
struct dirent *de;
|
|
|
|
Eina_Bool result = EINA_FALSE;
|
|
|
|
|
|
|
|
if (!path) return result;
|
|
|
|
if (!(d = opendir(path))) return result;
|
2011-04-08 07:30:48 -07:00
|
|
|
while ((de = readdir(d)))
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
char buff[PATH_MAX];
|
|
|
|
|
|
|
|
if (de->d_name[0] == '.') continue;
|
|
|
|
snprintf(buff, sizeof(buff), "%s/%s", path, de->d_name);
|
2011-04-08 07:30:48 -07:00
|
|
|
if (ecore_file_is_dir(buff))
|
2009-11-15 08:14:51 -08:00
|
|
|
{
|
|
|
|
result = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(d);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-05-25 20:08:10 -07:00
|
|
|
void
|
2010-10-19 11:25:22 -07:00
|
|
|
test_panel(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2010-05-25 20:08:10 -07:00
|
|
|
{
|
2012-04-01 23:20:28 -07:00
|
|
|
Evas_Object *win, *panel, *bx, *vbx, *toolbar;
|
2010-05-25 20:08:10 -07:00
|
|
|
Evas_Object *list;
|
|
|
|
|
2012-04-01 23:20:28 -07:00
|
|
|
win = elm_win_util_standard_add("panel", "Panel");
|
2011-07-25 07:22:19 -07:00
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
2010-05-25 20:08:10 -07:00
|
|
|
|
|
|
|
vbx = elm_box_add(win);
|
|
|
|
evas_object_size_hint_weight_set(vbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-11-14 02:49:45 -08:00
|
|
|
elm_win_resize_object_add(win, vbx);
|
2010-05-25 20:08:10 -07:00
|
|
|
evas_object_show(vbx);
|
|
|
|
|
|
|
|
bx = elm_box_add(win);
|
|
|
|
elm_box_horizontal_set(bx, EINA_TRUE);
|
|
|
|
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(bx);
|
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
panel = elm_panel_add(vbx);
|
2010-05-27 02:03:22 -07:00
|
|
|
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_TOP);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
toolbar = elm_toolbar_add(panel);
|
2011-05-03 21:53:39 -07:00
|
|
|
elm_toolbar_homogeneous_set(toolbar, 0);
|
2012-01-05 22:42:10 -08:00
|
|
|
elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_NONE);
|
2010-05-27 02:03:22 -07:00
|
|
|
evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(toolbar);
|
|
|
|
|
Change toolbar API for consistency with other widgets
BIG FAT WARNING: lots of changes on toolbar API
Trying to get a lib with easy to use API, I'm changing toolbar API
to be consistent with genlist / gengrid widgets and to be more concise.
Functions select_next, select_first, select_last, unselect, unselect_all
get all are gone.
You can do this calling a combination of the others functions.
This commit changes toolbar to use inlist, and previous items can be
get.
So now we have:
Elm_Toolbar_Item *elm_toolbar_first_item_get(const Evas_Object *obj)
Elm_Toolbar_Item *elm_toolbar_last_item_get(const Evas_Object *obj)
Elm_Toolbar_Item *elm_toolbar_item_next_get(const Elm_Toolbar_Item *it)
Elm_Toolbar_Item *elm_toolbar_item_prev_get(const Elm_Toolbar_Item *it)
Eina_Bool elm_toolbar_item_selected_get(const Elm_Toolbar_Item)
void elm_toolbar_item_selected_set(Elm_Toolbar_Item *item, Eina_Bool selected)
Elm_Toolbar_Item *elm_toolbar_selected_item_get(const Evas_Object *obj)
With these functions you can iterate over the items list getting /
selecting the item you need.
Another big change is that elm_toolbar_item_add is gone. Now you can
insert items in the position you want, with the functions append,
prepend, insert after, insert before (a relative item).
If you don't like any changes or have a case of use for something
that should be different, please ping me.
At last, includes ELM_TOOLBAR_ITEM_CHECK_OR_RETURN on EAPI that
receives items.
SVN revision: 53894
2010-10-26 03:29:24 -07:00
|
|
|
elm_toolbar_item_append(toolbar, "home", "Hello", _tstatus, panel);
|
2010-05-27 02:03:22 -07:00
|
|
|
|
2011-10-28 21:32:24 -07:00
|
|
|
elm_object_content_set(panel, toolbar);
|
2010-05-27 02:03:22 -07:00
|
|
|
elm_box_pack_end(vbx, panel);
|
|
|
|
evas_object_show(panel);
|
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
panel = elm_panel_add(bx);
|
2010-05-25 20:08:10 -07:00
|
|
|
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_LEFT);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-06-29 23:42:18 -07:00
|
|
|
// evas_object_size_hint_align_set(panel, 0, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2010-05-25 20:08:10 -07:00
|
|
|
|
|
|
|
itc.item_style = "default";
|
2011-11-30 22:15:08 -08:00
|
|
|
itc.func.text_get = _text_get;
|
2011-10-23 19:10:35 -07:00
|
|
|
itc.func.content_get = _content_get;
|
2010-05-25 20:08:10 -07:00
|
|
|
itc.func.state_get = _state_get;
|
|
|
|
itc.func.del = _item_del;
|
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
list = elm_genlist_add(panel);
|
2010-05-25 20:08:10 -07:00
|
|
|
evas_object_size_hint_min_set(list, 100, -1);
|
|
|
|
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(list);
|
|
|
|
|
2011-10-28 21:32:24 -07:00
|
|
|
elm_object_content_set(panel, list);
|
2010-05-25 20:08:10 -07:00
|
|
|
|
|
|
|
elm_box_pack_end(bx, panel);
|
|
|
|
evas_object_show(panel);
|
|
|
|
|
|
|
|
_fill_list(list);
|
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
panel = elm_panel_add(bx);
|
2010-05-25 20:08:10 -07:00
|
|
|
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_RIGHT);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
2012-06-29 23:42:18 -07:00
|
|
|
// evas_object_size_hint_align_set(panel, 1, EVAS_HINT_FILL);
|
|
|
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2010-09-27 14:13:32 -07:00
|
|
|
elm_panel_hidden_set(panel, EINA_TRUE);
|
2010-05-25 20:08:10 -07:00
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
list = elm_genlist_add(panel);
|
2010-05-25 20:08:10 -07:00
|
|
|
evas_object_size_hint_min_set(list, 100, -1);
|
|
|
|
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(list);
|
|
|
|
|
2011-10-28 21:32:24 -07:00
|
|
|
elm_object_content_set(panel, list);
|
2010-05-25 20:08:10 -07:00
|
|
|
|
|
|
|
elm_box_pack_end(bx, panel);
|
|
|
|
evas_object_show(panel);
|
|
|
|
|
|
|
|
_fill_list(list);
|
2012-02-12 14:35:56 -08:00
|
|
|
{
|
|
|
|
char *dir;
|
|
|
|
EINA_LIST_FREE(dirs, dir)
|
|
|
|
free(dir);
|
|
|
|
}
|
2010-05-25 20:08:10 -07:00
|
|
|
|
|
|
|
elm_box_pack_end(vbx, bx);
|
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
panel = elm_panel_add(vbx);
|
2010-05-27 02:03:22 -07:00
|
|
|
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(panel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2010-09-27 14:13:32 -07:00
|
|
|
elm_panel_hidden_set(panel, EINA_TRUE);
|
2010-05-27 02:03:22 -07:00
|
|
|
|
2012-03-26 23:47:07 -07:00
|
|
|
toolbar = elm_toolbar_add(panel);
|
2011-05-03 21:53:39 -07:00
|
|
|
elm_toolbar_homogeneous_set(toolbar, 0);
|
2012-01-05 22:42:10 -08:00
|
|
|
elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_NONE);
|
2010-05-25 20:08:10 -07:00
|
|
|
evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0);
|
|
|
|
evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_show(toolbar);
|
|
|
|
|
Change toolbar API for consistency with other widgets
BIG FAT WARNING: lots of changes on toolbar API
Trying to get a lib with easy to use API, I'm changing toolbar API
to be consistent with genlist / gengrid widgets and to be more concise.
Functions select_next, select_first, select_last, unselect, unselect_all
get all are gone.
You can do this calling a combination of the others functions.
This commit changes toolbar to use inlist, and previous items can be
get.
So now we have:
Elm_Toolbar_Item *elm_toolbar_first_item_get(const Evas_Object *obj)
Elm_Toolbar_Item *elm_toolbar_last_item_get(const Evas_Object *obj)
Elm_Toolbar_Item *elm_toolbar_item_next_get(const Elm_Toolbar_Item *it)
Elm_Toolbar_Item *elm_toolbar_item_prev_get(const Elm_Toolbar_Item *it)
Eina_Bool elm_toolbar_item_selected_get(const Elm_Toolbar_Item)
void elm_toolbar_item_selected_set(Elm_Toolbar_Item *item, Eina_Bool selected)
Elm_Toolbar_Item *elm_toolbar_selected_item_get(const Evas_Object *obj)
With these functions you can iterate over the items list getting /
selecting the item you need.
Another big change is that elm_toolbar_item_add is gone. Now you can
insert items in the position you want, with the functions append,
prepend, insert after, insert before (a relative item).
If you don't like any changes or have a case of use for something
that should be different, please ping me.
At last, includes ELM_TOOLBAR_ITEM_CHECK_OR_RETURN on EAPI that
receives items.
SVN revision: 53894
2010-10-26 03:29:24 -07:00
|
|
|
elm_toolbar_item_append(toolbar, "home", "Hello", _bstatus, panel);
|
2010-05-25 20:08:10 -07:00
|
|
|
|
2011-10-28 21:32:24 -07:00
|
|
|
elm_object_content_set(panel, toolbar);
|
2010-05-25 20:08:10 -07:00
|
|
|
elm_box_pack_end(vbx, panel);
|
|
|
|
evas_object_show(panel);
|
|
|
|
|
|
|
|
evas_object_resize(win, 320, 400);
|
|
|
|
evas_object_show(win);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-15 13:34:42 -07:00
|
|
|
#endif
|