This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efm2.
View the commit online.
commit ae3e970e884377a19002918c1ee6d7f6489ef80f
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Tue Jul 23 19:02:13 2024 +0100
more polishing on efm menus.... now rthe elm ones begin to be nice
elm menus still cant do titles... :(
---
src/efm/efm.c | 166 ++++++++++++++++++++++++++++++++++++++++-------------
src/efm/efm_util.c | 41 ++++++-------
2 files changed, 148 insertions(+), 59 deletions(-)
diff --git a/src/efm/efm.c b/src/efm/efm.c
index 8ae520f..0635232 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -16,6 +16,7 @@
#include "efm_custom.h"
#include "efm_private.h"
#include "eina_types.h"
+#include "elm_table_eo.legacy.h"
int _log_dom = -1;
@@ -1986,20 +1987,21 @@ _cb_menu_item(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
efm_menu_provider_select(efm, mi->index);
}
-static void _menu_create_walk(void *data, Evas_Object *obj, const Efm_Menu *m,
- Evas_Object *o_menu, Elm_Object_Item *it_parent)
+static Evas_Object *
+_menu_icon_radcheck_add(Evas_Object *o_base, int icon_col, const char *icon, int icon_num)
{
- int i;
- Elm_Object_Item *it;
- Evas_Object *o, *o_radio = NULL;
- int radioval = 0;
+ Evas_Object *o_table, *o;
- for (i = 0; i < m->item_num; i++)
- {
- const Efm_Menu_Item *mi = &(m->item[i]);
- // XXX: figure out an icon name from mi->icon properly
- // use elm_object_item_content_set() if needed
- // e.g.
+ o_table = o = elm_table_add(o_base);
+ elm_table_homogeneous_set(o, EINA_TRUE);
+ // add a "dummy" never shown check+radio in first cell for sizing.
+ // homogenous cells mean 2nd cell will be same size too if there
+ elm_table_pack(o, elm_check_add(o_base), 0, 0, 1, 1);
+ elm_table_pack(o, elm_radio_add(o_base), 0, 0, 1, 1);
+ if (icon)
+ { // we have an icon to add to the icon column
+ // icon can be,,,,
+ //
// "std:menu-eject" - native to elm menus (strip std:)
// "std:menu/folder" - native to elm menus (strip std:)
// "file:/path/to/file.png" - use efm_icon
@@ -2008,24 +2010,100 @@ static void _menu_create_walk(void *data, Evas_Object *obj, const Efm_Menu *m,
// "thumb:/path/to/file" - use efm_icon
// "video:/path/to/file.mp4" - use efm_icon
// "fdo:icon-name" - use efreet to look up icon then use that
- //
- // XXX: we have a core problem with elm menus. radio, check OR icon. not
- // both - maybe use an box or table for menu content and do our own
- // menu icons ? then we can have a radio/check and icon... to do this
- // we need to pre-scan all items to see if any have icons at all, and
- // if any are check or radio - then 0 column, 1 or 2 column for the
- // box or table and add some padding i guess...
+ if (!strncmp(icon, "std:", 4))
+ {
+ o = elm_icon_add(o_base);
+ elm_icon_standard_set(o, icon + 4);
+ }
+ else if (!strncmp(icon, "file:", 5))
+ {
+ o = efm_icon_add(o_base);
+ efm_icon_keep_aspect_set(o, EINA_TRUE);
+ efm_icon_file_set(o, icon + 5);
+ }
+ else if (!strncmp(icon, "/", 1))
+ {
+ o = efm_icon_add(o_base);
+ efm_icon_keep_aspect_set(o, EINA_TRUE);
+ efm_icon_file_set(o, icon);
+ }
+ else if (!strncmp(icon, "thumb:", 6))
+ {
+ o = efm_icon_add(o_base);
+ efm_icon_keep_aspect_set(o, EINA_TRUE);
+ efm_icon_thumb_set(o, icon + 6);
+ }
+ else if (!strncmp(icon, "video:", 6))
+ {
+ o = efm_icon_add(o_base);
+ efm_icon_keep_aspect_set(o, EINA_TRUE);
+ efm_icon_video_set(o, icon + 6);
+ }
+ else if (!strncmp(icon, "fdo:", 4))
+ {
+ o = elm_icon_add(o_base);
+ elm_icon_standard_set(o, icon + 4);
+ }
+ evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_table_pack(o_table, o, icon_col, 0, 1, 1);
+ evas_object_show(o);
+ }
+ else if (icon_num)
+ { // other icons in the list, but not this one - so dummy rect
+ o = evas_object_rectangle_add(evas_object_evas_get(o_base));
+ elm_table_pack(o_table, o, icon_col, 0, 1, 1);
+ }
+ return o_table;
+}
+static void _menu_create_walk(void *data, Evas_Object *obj, const Efm_Menu *m,
+ Evas_Object *o_menu, Elm_Object_Item *it_parent)
+{
+ Elm_Object_Item *it;
+ Evas_Object *o, *o_radio = NULL, *o_table;
+ int i, radioval = 0;
+ int icon_num = 0, checkradio_num = 0, do_table, icon_col, radcheck_col;
+
+ // count columns for icon and radio
+ for (i = 0; i < m->item_num; i++)
+ {
+ const Efm_Menu_Item *mi = &(m->item[i]);
+
+ if (mi->type == EFM_MENU_ITEM_CHECK) checkradio_num++;
+ else if (mi->type == EFM_MENU_ITEM_RADIO) checkradio_num++;
+ if (mi->icon) icon_num++;
+ }
+ do_table = checkradio_num + icon_num;
+ for (i = 0; i < m->item_num; i++)
+ {
+ const Efm_Menu_Item *mi = &(m->item[i]);
+
+ icon_col = 0;
+ radcheck_col = 0;
+ if (checkradio_num > 0) icon_col = 1;
switch (mi->type)
{
case EFM_MENU_ITEM_NORMAL:
- it = elm_menu_item_add(o_menu, it_parent, mi->icon, mi->label,
+ it = elm_menu_item_add(o_menu, it_parent, NULL, mi->label,
_cb_menu_item, mi);
+ if (do_table)
+ {
+ o_table
+ = _menu_icon_radcheck_add(o_menu, icon_col, mi->icon, icon_num);
+ elm_object_item_content_set(it, o_table);
+ }
o_radio = NULL;
break;
case EFM_MENU_ITEM_SUBMENU:
- it = elm_menu_item_add(o_menu, it_parent, mi->icon, mi->label, NULL,
- NULL);
+ it = elm_menu_item_add(o_menu, it_parent, NULL, mi->label,
+ NULL, NULL);
+ if (do_table)
+ {
+ o_table
+ = _menu_icon_radcheck_add(o_menu, icon_col, mi->icon, icon_num);
+ elm_object_item_content_set(it, o_table);
+ }
_menu_create_walk(data, obj, mi->sub, o_menu, it);
o_radio = NULL;
break;
@@ -2034,36 +2112,46 @@ static void _menu_create_walk(void *data, Evas_Object *obj, const Efm_Menu *m,
o_radio = NULL;
break;
case EFM_MENU_ITEM_CHECK:
- o = elm_check_add(o_menu);
- // state change will be handled in cb for original data then rebuild
- // of menu will reflect that next time it's popped up.
it = elm_menu_item_add(o_menu, it_parent, NULL, mi->label,
_cb_menu_item, mi);
- elm_check_selected_set(o, mi->selected);
- elm_object_item_content_set(it, o);
+ if (do_table)
+ {
+ o_table
+ = _menu_icon_radcheck_add(o_menu, icon_col, mi->icon, icon_num);
+ o = elm_check_add(o_menu);
+ elm_check_selected_set(o, mi->selected);
+ elm_table_pack(o_table, o, radcheck_col, 0, 1, 1);
+ evas_object_show(o);
+ elm_object_item_content_set(it, o_table);
+ }
o_radio = NULL;
break;
case EFM_MENU_ITEM_RADIO:
- o = elm_radio_add(o_menu);
- // state change will be handled in cb for original data then rebuild
- // of menu will reflect that next time it's popped up.
it = elm_menu_item_add(o_menu, it_parent, NULL, mi->label,
_cb_menu_item, mi);
- if (!o_radio)
+ if (do_table)
{
- o_radio = o;
- radioval = 0;
+ o_table
+ = _menu_icon_radcheck_add(o_menu, icon_col, mi->icon, icon_num);
+ o = elm_radio_add(o_menu);
+ if (!o_radio)
+ {
+ o_radio = o;
+ radioval = 0;
+ }
+ else elm_radio_group_add(o, o_radio);
+ elm_radio_state_value_set(o, radioval);
+ if (mi->selected) elm_radio_value_set(o_radio, radioval);
+ elm_table_pack(o_table, o, radcheck_col, 0, 1, 1);
+ evas_object_show(o);
+ elm_object_item_content_set(it, o_table);
+ radioval++;
}
- else elm_radio_group_add(o, o_radio);
- elm_radio_state_value_set(o, radioval);
- if (mi->selected) elm_radio_value_set(o_radio, radioval);
- elm_object_item_content_set(it, o);
- radioval++;
break;
default:
break;
}
- }
+ }
}
void *
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 5c55f85..1103c26 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -6,7 +6,6 @@
#include "efm_dnd.h"
#include "efm_back_end.h"
#include "efm_private.h"
-#include "eina_binbuf.h"
// util funcs for the efm view
static inline int
@@ -1103,39 +1102,41 @@ _cb_icon_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
Efm_Menu *m1, *m2;
printf("XXX: right mouse\n");
- m1 = _efm_menu_add("Submenu", "mail-reply-all");
- _efm_menu_it_normal(m1, "Item 1", "menu/folder", _cb_ic_item1,
+ m1 = _efm_menu_add("Submenu", "std:mail-reply-all");
+ _efm_menu_it_normal(m1, "Item 1", "std:menu/folder", _cb_ic_item1,
icon, NULL);
- _efm_menu_it_normal(m1, "Item 2", "system-lock-screen",
+ _efm_menu_it_normal(m1, "Item 2", "std:system-lock-screen",
_cb_ic_item2, icon, NULL);
_efm_menu_it_separator(m1);
- _efm_menu_it_normal(m1, "Item 3 - much longer label", "media-eject",
+ _efm_menu_it_normal(m1, "Item 3 - much longer label", "std:media-eject",
_cb_ic_item3, icon, NULL);
- _efm_menu_it_normal(m1, "Item 4", "media-eject", _cb_ic_item4,
- icon, NULL);
- m2 = _efm_menu_add("Main Menu", "mail-reply-all");
- _efm_menu_it_normal(m2, "Item 5", "system-run", _cb_ic_item5, icon,
+ _efm_menu_it_normal(m1, "Item 4", "std:battery", _cb_ic_item4, icon,
NULL);
- _efm_menu_it_separator(m1);
- _efm_menu_it_check(m2, "Check 1", "system-run", EINA_FALSE,
+
+ m2 = _efm_menu_add("Main Menu", "std:security-high");
+ _efm_menu_it_normal(m2, "Item 5", "std:system-run", _cb_ic_item5, icon,
+ NULL);
+ _efm_menu_it_separator(m2);
+ _efm_menu_it_check(m2, "Check 1", "std:folder", EINA_FALSE,
_cb_ic_item6, icon, NULL);
- _efm_menu_it_check(m2, "Check 2", "system-run", EINA_TRUE,
+ _efm_menu_it_check(m2, "Check 2", "std:user-home", EINA_TRUE,
_cb_ic_item7, icon, NULL);
- _efm_menu_it_separator(m1);
- _efm_menu_it_radio(m2, "Radio 1", "system-run", EINA_FALSE,
+ _efm_menu_it_separator(m2);
+ _efm_menu_it_radio(m2, "Radio 1", "std:user-desktop", EINA_FALSE,
_cb_ic_item6, icon, NULL);
- _efm_menu_it_radio(m2, "Radio 2", "system-run", EINA_TRUE,
+ _efm_menu_it_radio(m2, "Radio 2", NULL, EINA_TRUE,
_cb_ic_item6, icon, NULL);
- _efm_menu_it_radio(m2, "Radio 3", "system-run", EINA_FALSE,
+ _efm_menu_it_radio(m2, "Radio 3", "std:computer", EINA_FALSE,
_cb_ic_item6, icon, NULL);
_efm_menu_it_separator(m2);
- _efm_menu_it_radio(m2, "Radio 1", "system-run", EINA_FALSE,
+ _efm_menu_it_radio(m2, "Radio 1", "std:drive-optical", EINA_FALSE,
_cb_ic_item6, icon, NULL);
- _efm_menu_it_radio(m2, "Radio 2", "system-run", EINA_FALSE,
+ _efm_menu_it_radio(m2, "Radio 2", "std:drive-harddisk", EINA_FALSE,
_cb_ic_item6, icon, NULL);
- _efm_menu_it_radio(m2, "Radio 3", "system-run", EINA_TRUE,
+ _efm_menu_it_radio(m2, "Radio 3", NULL, EINA_TRUE,
_cb_ic_item6, icon, NULL);
- _efm_menu_it_sub(m2, "Submenu here", "system-lock-screen", m1);
+ _efm_menu_it_sub(m2, "Submenu here", "fdo:terminology", m1);
+
_efm_menu_show(icon->sd->o_smart, m2, icon->down_x, icon->down_y);
}
icon->sd->last_focused = icon;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.