2009-10-15 13:34:42 -07:00
|
|
|
#include <Elementary.h>
|
2010-10-19 11:25:22 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
2009-10-15 13:34:42 -07:00
|
|
|
#ifndef ELM_LIB_QUICKLAUNCH
|
|
|
|
|
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);
|
|
|
|
|
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;
|
|
|
|
Eina_List *dirs = NULL, *l;
|
|
|
|
char *real;
|
|
|
|
|
|
|
|
if (!(d = opendir(getenv("HOME")))) return;
|
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", getenv("HOME"), de->d_name);
|
|
|
|
if (!ecore_file_is_dir(buff)) continue;
|
|
|
|
real = ecore_file_realpath(buff);
|
|
|
|
dirs = eina_list_append(dirs, real);
|
|
|
|
}
|
|
|
|
closedir(d);
|
|
|
|
|
2010-01-16 05:54:55 -08:00
|
|
|
dirs = eina_list_sort(dirs, eina_list_count(dirs), EINA_COMPARE_CB(strcoll));
|
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),
|
|
|
|
NULL, ELM_GENLIST_ITEM_SUBITEMS,
|
2009-11-15 08:14:51 -08:00
|
|
|
NULL, NULL);
|
|
|
|
free(real);
|
|
|
|
}
|
|
|
|
eina_list_free(dirs);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2010-10-14 10:58:01 -07:00
|
|
|
Evas_Object *win, *bg, *panel, *bx, *vbx, *toolbar;
|
2010-05-25 20:08:10 -07:00
|
|
|
Evas_Object *list;
|
|
|
|
|
|
|
|
win = elm_win_add(NULL, "panel", ELM_WIN_BASIC);
|
|
|
|
elm_win_title_set(win, "Panel");
|
2011-07-25 07:22:19 -07:00
|
|
|
elm_win_autodel_set(win, EINA_TRUE);
|
2010-05-25 20:08:10 -07:00
|
|
|
|
|
|
|
bg = elm_bg_add(win);
|
|
|
|
elm_win_resize_object_add(win, bg);
|
|
|
|
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_show(bg);
|
|
|
|
|
|
|
|
vbx = elm_box_add(win);
|
|
|
|
elm_win_resize_object_add(win, vbx);
|
|
|
|
evas_object_size_hint_weight_set(vbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(vbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
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);
|
|
|
|
|
2010-05-27 02:03:22 -07:00
|
|
|
panel = elm_panel_add(win);
|
|
|
|
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);
|
|
|
|
|
|
|
|
toolbar = elm_toolbar_add(win);
|
2011-05-03 21:53:39 -07:00
|
|
|
elm_toolbar_homogeneous_set(toolbar, 0);
|
[Elementary] Implement priority in Elm_Toolbar.
Toolbars can now be scrollable, non-scrollable, or hide icons selectively
according to a priority. This changed the API slightly, thus
elm_toolbar_scrollable_set(obj, 1)
Should be
elm_toolbar_mode_expand_set(obj, ELM_TOOLBAR_EXPAND_SCROLL)
Values for non-scrollable and scrollable remain the same, so if constants
aren't being used, just the function name should be changed.
The new mode, ELM_TOOLBAR_EXPAND_MENU, will create a menu of items when the
space isn't large enough to hold all the items. Which items will be kept on
the toolbar or which items will be added to the menu is controlled by the
priority of each item: higher ones will be kept if possible, lower ones will
be tratored on the first opportunity.
SVN revision: 53406
2010-10-14 08:27:25 -07:00
|
|
|
elm_toolbar_mode_shrink_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);
|
|
|
|
|
2010-05-25 20:08:10 -07:00
|
|
|
panel = elm_panel_add(win);
|
|
|
|
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_LEFT);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(panel, 0, EVAS_HINT_FILL);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
list = elm_genlist_add(win);
|
|
|
|
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);
|
|
|
|
|
|
|
|
panel = elm_panel_add(win);
|
|
|
|
elm_panel_orient_set(panel, ELM_PANEL_ORIENT_RIGHT);
|
|
|
|
evas_object_size_hint_weight_set(panel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_align_set(panel, 1, 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
|
|
|
|
|
|
|
list = elm_genlist_add(win);
|
|
|
|
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);
|
|
|
|
|
|
|
|
elm_box_pack_end(vbx, bx);
|
|
|
|
|
2010-05-27 02:03:22 -07:00
|
|
|
panel = elm_panel_add(win);
|
|
|
|
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
|
|
|
|
2010-05-25 20:08:10 -07:00
|
|
|
toolbar = elm_toolbar_add(win);
|
2011-05-03 21:53:39 -07:00
|
|
|
elm_toolbar_homogeneous_set(toolbar, 0);
|
[Elementary] Implement priority in Elm_Toolbar.
Toolbars can now be scrollable, non-scrollable, or hide icons selectively
according to a priority. This changed the API slightly, thus
elm_toolbar_scrollable_set(obj, 1)
Should be
elm_toolbar_mode_expand_set(obj, ELM_TOOLBAR_EXPAND_SCROLL)
Values for non-scrollable and scrollable remain the same, so if constants
aren't being used, just the function name should be changed.
The new mode, ELM_TOOLBAR_EXPAND_MENU, will create a menu of items when the
space isn't large enough to hold all the items. Which items will be kept on
the toolbar or which items will be added to the menu is controlled by the
priority of each item: higher ones will be kept if possible, lower ones will
be tratored on the first opportunity.
SVN revision: 53406
2010-10-14 08:27:25 -07:00
|
|
|
elm_toolbar_mode_shrink_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
|