GSoC #05 Menu entry class attribute
PATCH 1/1 GSoC #05 Menu entry class attribute
This patch adds support for a 'class' attribute on menu entries. It is somewhat of a kludge, however since currently you just append "|class=this,that" to the menu entry title to specify the classes.
Classes are used to provide a simple and flexible way for the best available icon to be used in a graphical menu, but there are other possible uses for them as well. The idea originates from the CSS (cascading style sheets) and HTML 'class' concept.
Regards,
Colin
2008-08-30 Colin D Bennett <[email protected]>
Support classes for menu entries by adding '|classes=x,y' to the title.
* include/grub/menu.h (grub_menu_entry_class): New struct type. (grub_menu_entry): Added 'classes' field.
* normal/main.c (free_menu_entry_classes): New function. (entry_class_attr_tag): New string constant. (ENTRY_ATTR_SEPARATOR_CHAR): New macro. (get_classes_from_entry_title): New function. (grub_normal_menu_addentry): Parse '|classes=x,y' from entry titles.
=== modified file 'include/grub/menu.h'
grub/menu.h +12 -0
@@ -20,12 +20,24 @@ #ifndef GRUB_MENU_HEADER #define GRUB_MENU_HEADER 1 +struct grub_menu_entry_class +{ + char *name; + struct grub_menu_entry_class *next; +}; + /* The menu entry. */ struct grub_menu_entry { /* The title name. */ const char *title; + /* The classes associated with the menu entry: + used to choose an icon or other style attributes. + This is a dummy head node for the linked list, so for an entry E, + E.classes->next is the first class if it is not NULL. */ + struct grub_menu_entry_class *classes; + /* The commands associated with this menu entry. */ struct grub_script *commands;
=== modified file 'normal/main.c'
main.c +129 -1
161 lines not on this page · raw message
Quoted 8 lines · Colin D Bennett
This patch adds support for a 'class' attribute on menu entries. It is somewhat of a kludge, however since currently you just append "|class=this,that" to the menu entry title to specify the classes.
Classes are used to provide a simple and flexible way for the best available icon to be used in a graphical menu, but there are other possible uses for them as well. The idea originates from the CSS (cascading style sheets) and HTML 'class' concept.
Here is the patch snipped for using menuentry --class foo "title" { }.
Please try it out and see if it fits.
parser.y +1 -1
@@ -204,7 +204,7 @@ ; /* A menu entry. Carefully save the memory that is allocated. */ -menuentry: "menuentry" argument +menuentry: "menuentry" arguments { grub_script_lexer_ref (state->lexerstate); } newlines '{'
main.c +56 -5
79 lines not on this page · raw message
script.c +3 -3
@@ -206,7 +206,7 @@The options for this entry are passed in OPTIONS. */ struct grub_script_cmd *grub_script_create_cmdmenu (struct grub_parser_param *state, -struct grub_script_arg *title, +struct grub_script_arglist *arglist,char *sourcecode,int options) {
@@ -232,9 +232,9 @@ cmd->cmd.next =0 ;/* XXX: Check if this memory is properly freed. */ cmd->sourcecode = sourcecode; - cmd->title = title; + cmd->arglist = arglist; cmd->options = options; - +return (struct grub_script_cmd *) cmd; }
execute.c +33 -12
64 lines not on this page · raw message
grub/script.h +3 -3
@@ -113,8 +113,8 @@ {struct grub_script_cmd cmd; -/* The title of the menu entry. */ -struct grub_script_arg *title; +/* The arguments for this menu entry. */ +struct grub_script_arglist *arglist;/* The sourcecode the entry will be generated from. */ const char *sourcecode;
@@ -204,7 +204,7 @@struct grub_script_cmd *grub_script_create_cmdmenu (struct grub_parser_param *state, -struct grub_script_arg *title, +struct grub_script_arglist *arglist,char *sourcecode,int options);
grub/normal.h +1 -1
@@ -152,7 +152,7 @@char *grub_normal_do_completion (char *buf,int *restore,void (*hook) (const char *item,grub_completion_type_t type,int count));grub_err_t grub_normal_print_device_info (const char *name); -grub_err_t grub_normal_menu_addentry (const char *title, +grub_err_t grub_normal_menu_addentry (int argc,char **args,struct grub_script *script,const char *sourcecode);char *grub_env_write_color_normal (struct grub_env_var *var,const char *val);
Re: [PATCH] GSoC #05 Menu entry class attribute (v2)
Quoted 5 lines · On Sun, 05 Oct 2008 13:07:32 +0300 Vesa Jääskeläinen <[email protected]> wrote:
Quoted 4 lines · Colin D Bennett
This patch adds support for a 'class' attribute on menu entries. It is somewhat of a kludge, however since currently you just append "|class=this,that" to the menu entry title to specify the classes.
Quoted 8 lines
Quoted 4 lines
Classes are used to provide a simple and flexible way for the best available icon to be used in a graphical menu, but there are other possible uses for them as well. The idea originates from the CSS (cascading style sheets) and HTML 'class' concept.
Here is the patch snipped for using menuentry --class foo "title" { }.
Please try it out and see if it fits.
Hi Vesa,
Thanks for the argument parsing improvement. I'm glad to rip out the '|class=' title kludge. Here is the result of merging your patch into the menu entry class code.
Regards,
Colin
2008-10-13 Colin D Bennett <[email protected]>
Support classes for menu entries via the '--class CLASSNAME' argument to the menuentry command. Argument list parsing functionality by Vesa Jääskeläinen <[email protected]>.
* include/grub/menu.h (grub_menu_entry_class): New struct type. (grub_menu_entry): Added 'classes' field.
* include/grub/normal.h (grub_normal_menu_addentry): Changed signature to take a list of arguments instead of just a title.
* include/grub/script.h (grub_script_cmd_menuentry): Replaced title with arglist.
(grub_script_create_cmdmenu): Changed signature to take an arglist instead of just a single arg (title).
* normal/execute.c (grub_script_execute_menuentry): Parse arguments to the 'menuentry' script command.
* normal/main.c (free_menu_entry_classes): New function. (grub_normal_menu_addentry): Take and process a list of arguments; handle '--class CLASSNAME' arguments and store the list of class names in the menu entry.
* normal/parser.y (menuentry): Take a list of arguments.
* normal/script.c (grub_script_create_cmdmenu): Take an argument list, store it in the command.
=== modified file 'include/grub/menu.h'
grub/menu.h +12 -0
@@ -20,12 +20,24 @@ #ifndef GRUB_MENU_HEADER #define GRUB_MENU_HEADER 1 +struct grub_menu_entry_class +{ + char *name; + struct grub_menu_entry_class *next; +}; + /* The menu entry. */ struct grub_menu_entry { /* The title name. */ const char *title; + /* The classes associated with the menu entry: + used to choose an icon or other style attributes. + This is a dummy head node for the linked list, so for an entry E, + E.classes->next is the first class if it is not NULL. */ + struct grub_menu_entry_class *classes; + /* The commands associated with this menu entry. */ struct grub_script *commands;
=== modified file 'include/grub/normal.h'
grub/normal.h +1 -1
@@ -141,7 +141,7 @@char *grub_normal_do_completion (char *buf,int *restore,void (*hook) (const char *item,grub_completion_type_t type,int count));grub_err_t grub_normal_print_device_info (const char *name); -grub_err_t grub_normal_menu_addentry (const char *title, +grub_err_t grub_normal_menu_addentry (int argc,const char **args,struct grub_script *script,const char *sourcecode);char *grub_env_write_color_normal (struct grub_env_var *var,const char *val);
=== modified file 'include/grub/script.h'
grub/script.h +3 -3
@@ -113,8 +113,8 @@ {struct grub_script_cmd cmd; -/* The title of the menu entry. */ -struct grub_script_arg *title; +/* The arguments for this menu entry. */ +struct grub_script_arglist *arglist;/* The sourcecode the entry will be generated from. */ const char *sourcecode;
@@ -204,7 +204,7 @@struct grub_script_cmd *grub_script_create_cmdmenu (struct grub_parser_param *state, -struct grub_script_arg *title, +struct grub_script_arglist *arglist,char *sourcecode,int options);
=== modified file 'normal/execute.c'
execute.c +33 -12
62 lines not on this page · raw message
=== modified file 'normal/main.c'
main.c +105 -5
141 lines not on this page · raw message
=== modified file 'normal/parser.y'
parser.y +1 -1
@@ -204,7 +204,7 @@ ; /* A menu entry. Carefully save the memory that is allocated. */ -menuentry: "menuentry" argument +menuentry: "menuentry" arguments { grub_script_lexer_ref (state->lexerstate); } newlines '{'
=== modified file 'normal/script.c'
script.c +3 -3
@@ -206,7 +206,7 @@The options for this entry are passed in OPTIONS. */ struct grub_script_cmd *grub_script_create_cmdmenu (struct grub_parser_param *state, -struct grub_script_arg *title, +struct grub_script_arglist *arglist,char *sourcecode,int options) {
@@ -232,9 +232,9 @@ cmd->cmd.next =0 ;/* XXX: Check if this memory is properly freed. */ cmd->sourcecode = sourcecode; - cmd->title = title; + cmd->arglist = arglist; cmd->options = options; - +return (struct grub_script_cmd *) cmd; }
Re: [PATCH] GSoC #05 Menu entry class attribute (v2)
Quoted 3 lines · Colin D Bennett
Thanks for the argument parsing improvement. I'm glad to rip out the '|class=' title kludge. Here is the result of merging your patch into the menu entry class code.
Hi Colin,
I combined your menu entry and menu viewer patches and committed them in with slight modifications. See if you are happy with it :)
Oh. And btw. I think I am out of sync what is still missing. So let me know if you think there is something critical that needs to be there in order to integrate your gfxmenu.
As you have now commit access please be free to consult list and commit small changes yourself.
Thanks,
Vesa Jääskeläinen
Re: [PATCH] GSoC #05 Menu entry class attribute (v2)
Quoted 2 lines · On Sat, 31 Jan 2009 11:19:51 +0200 Vesa Jääskeläinen <[email protected]> wrote:
I combined your menu entry and menu viewer patches and committed them in with slight modifications. See if you are happy with it :)
Looks good.
Quoted 3 lines
Oh. And btw. I think I am out of sync what is still missing. So let me know if you think there is something critical that needs to be there in order to integrate your gfxmenu.
There are a few features that are still needed:
- multiple fallback entries
- VBE double buffering
- bitmap scaling
- videotest enhancements (useful for testing, but also provides 'grub_rect_t' type used by gfxmenu)
I just synchronized my patch stack with the latest GRUB (SVN trunk rev 1964). I will post separately with these updated patches for discussion and consideration.
Quoted 2 lines
As you have now commit access please be free to consult list and commit small changes yourself.
OK.
Regards,
Colin