dont play with menu struct innards! use api calls :)


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
Carsten Haitzler 22 years ago
parent 064f03cce5
commit 72043d3682
  1. 10
      src/e.h
  2. 111
      src/menu.c
  3. 15
      src/menudb.c

@ -752,6 +752,16 @@ void e_menu_update_finish(E_Menu *m);
void e_menu_update_shows(E_Menu *m);
void e_menu_update_hides(E_Menu *m);
void e_menu_update(E_Menu *m);
void e_menu_item_set_icon(E_Menu_Item *mi, char *icon);
void e_menu_item_set_text(E_Menu_Item *mi, char *text);
void e_menu_item_set_separator(E_Menu_Item *mi, int sep);
void e_menu_item_set_radio(E_Menu_Item *mi, int radio);
void e_menu_item_set_check(E_Menu_Item *mi, int check);
void e_menu_item_set_state(E_Menu_Item *mi, int state);
void e_menu_item_set_submenu(E_Menu_Item *mi, E_Menu *submenu);
void e_menu_item_set_scale_icon(E_Menu_Item *mi, int scale);
void e_menu_set_padding_icon(E_Menu *m, int pad);
void e_menu_set_padding_state(E_Menu *m, int pad);
void e_build_menu_unbuild(E_Build_Menu *bm);
E_Menu *e_build_menu_build_number(E_Build_Menu *bm, E_DB_File *db, int num);

@ -1452,3 +1452,114 @@ e_menu_update(E_Menu *m)
e_menu_update_hides(m);
e_menu_update_finish(m);
}
void
e_menu_item_set_icon(E_Menu_Item *mi, char *icon)
{
IF_FREE(mi->icon);
mi->icon = NULL;
if (icon) mi->icon = strdup(icon);
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->changed = 1;
}
}
void
e_menu_item_set_text(E_Menu_Item *mi, char *text)
{
IF_FREE(mi->str);
mi->str = NULL;
if (text) mi->str = strdup(text);
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->changed = 1;
}
}
void
e_menu_item_set_separator(E_Menu_Item *mi, int sep)
{
mi->separator = sep;
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->changed = 1;
}
}
void
e_menu_item_set_radio(E_Menu_Item *mi, int radio)
{
mi->radio = radio;
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->changed = 1;
}
}
void
e_menu_item_set_check(E_Menu_Item *mi, int check)
{
mi->check = check;
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->changed = 1;
}
}
void
e_menu_item_set_state(E_Menu_Item *mi, int state)
{
mi->on = state;
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->redo_sel = 1;
mi->menu->changed = 1;
}
}
void
e_menu_item_set_submenu(E_Menu_Item *mi, E_Menu *submenu)
{
if (mi->submenu) e_menu_hide(mi->submenu);
mi->submenu = submenu;
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->redo_sel = 1;
mi->menu->changed = 1;
}
}
void
e_menu_item_set_scale_icon(E_Menu_Item *mi, int scale)
{
mi->scale_icon = scale;
if (mi->menu)
{
mi->menu->recalc_entries = 1;
mi->menu->changed = 1;
}
}
void
e_menu_set_padding_icon(E_Menu *m, int pad)
{
m->pad.icon = pad;
m->recalc_entries = 1;
m->changed = 1;
}
void
e_menu_set_padding_state(E_Menu *m, int pad)
{
m->pad.state = pad;
m->recalc_entries = 1;
m->changed = 1;
}

@ -81,8 +81,8 @@ e_build_menu_build_number(E_Build_Menu *bm, E_DB_File *db, int num)
sprintf(buf, "/menu/%i/count", num);
if (!e_db_int_get(db, buf, &num2)) return NULL;
menu = e_menu_new();
menu->pad.icon = 2;
menu->pad.state = 2;
e_menu_set_padding_icon(menu, 2);
e_menu_set_padding_state(menu, 2);
for (i2 = 0; i2 < num2; i2++)
{
E_Menu_Item *menuitem;
@ -101,10 +101,11 @@ e_build_menu_build_number(E_Build_Menu *bm, E_DB_File *db, int num)
sprintf(buf, "/menu/%i/%i/separator", num, i2);
e_db_int_get(db, buf, &sep);
menuitem = e_menu_item_new(text);
menuitem->icon = icon;
if ((icon) && (text)) menuitem->scale_icon = 1;
if (sep)
menuitem->separator = 1;
IF_FREE(text);
e_menu_item_set_icon(menuitem, icon);
IF_FREE(icon);
if ((icon) && (text)) e_menu_item_set_scale_icon(menuitem, 1);
if (sep) e_menu_item_set_separator(menuitem, 1);
else
{
if (ok)
@ -112,7 +113,7 @@ e_build_menu_build_number(E_Build_Menu *bm, E_DB_File *db, int num)
E_Menu *menu2;
menu2 = e_build_menu_build_number(bm, db, sub);
menuitem->submenu = menu2;
e_menu_item_set_submenu(menuitem, menu2);
}
}
if (exe)

Loading…
Cancel
Save