mirror of
https://github.com/labwc/labwc.git
synced 2026-02-08 10:06:59 -05:00
menu: add menu_finish()
This commit is contained in:
parent
4d1acf645c
commit
d39b158cec
3 changed files with 23 additions and 3 deletions
|
|
@ -22,6 +22,7 @@ struct menu {
|
|||
|
||||
/* menu_create - create menu */
|
||||
void menu_init(struct server *server, struct menu *menu);
|
||||
void menu_finish(struct menu *menu);
|
||||
|
||||
/* menu_move - move to position (x, y) */
|
||||
void menu_move(struct menu *menu, int x, int y);
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ main(int argc, char *argv[])
|
|||
theme_read(rc.theme_name);
|
||||
xbm_load(server.renderer);
|
||||
|
||||
struct menu menu = { 0 };
|
||||
menu_init(&server, &menu);
|
||||
server.rootmenu = &menu;
|
||||
struct menu rootmenu = { 0 };
|
||||
menu_init(&server, &rootmenu);
|
||||
server.rootmenu = &rootmenu;
|
||||
|
||||
session_autostart_init();
|
||||
if (startup_cmd) {
|
||||
|
|
@ -75,6 +75,7 @@ main(int argc, char *argv[])
|
|||
|
||||
server_finish(&server);
|
||||
rcxml_finish();
|
||||
menu_finish(server.rootmenu);
|
||||
pango_cairo_font_map_set_default(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,24 @@ menu_init(struct server *server, struct menu *menu)
|
|||
menu_move(menu, 100, 100);
|
||||
}
|
||||
|
||||
void
|
||||
menu_finish(struct menu *menu)
|
||||
{
|
||||
struct menuitem *menuitem, *next;
|
||||
wl_list_for_each_safe(menuitem, next, &menu->menuitems, link) {
|
||||
if (menuitem->action)
|
||||
free(menuitem->action);
|
||||
if (menuitem->command)
|
||||
free(menuitem->command);
|
||||
if (menuitem->active_texture)
|
||||
free(menuitem->active_texture);
|
||||
if (menuitem->inactive_texture)
|
||||
free(menuitem->inactive_texture);
|
||||
wl_list_remove(&menuitem->link);
|
||||
free(menuitem);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
menu_move(struct menu *menu, int x, int y)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue