From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N0Rlm-0002w9-Hy for mharc-grub-devel@gnu.org; Tue, 20 Oct 2009 23:21:50 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0Rll-0002w4-66 for grub-devel@gnu.org; Tue, 20 Oct 2009 23:21:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0Rlg-0002vR-Iy for grub-devel@gnu.org; Tue, 20 Oct 2009 23:21:48 -0400 Received: from [199.232.76.173] (port=41770 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0Rlg-0002vO-Dm for grub-devel@gnu.org; Tue, 20 Oct 2009 23:21:44 -0400 Received: from mail-px0-f192.google.com ([209.85.216.192]:44030) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0Rlf-0006z6-Jz for grub-devel@gnu.org; Tue, 20 Oct 2009 23:21:44 -0400 Received: by pxi30 with SMTP id 30so264910pxi.14 for ; Tue, 20 Oct 2009 20:21:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=Sp6Rj25QGkG4JU6djf58XfAd3hE5jYS6E8yx3sexkhE=; b=nEzeSJWnK/Vq90YF5s3ZlIxNbFkjBWwalmcD77y4LqSbVenTaP6cmQVEg/LbdQOqhQ 15EajF274/1CzeE2Epu8WknkqAdO5cGrFpkOXS8g5dw/0cGhbYbIfZz3VV7JETV6UTkD uusngkpy+azqToYbn9hWE2xMy3TOcRwQYVGYU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=AQ7guRULnLeRIw8lrSof187oeUCM2zklmv3SbFsD+p6O7XAmlRj3B8Or7asckSMVD7 geREuJTbmtjEJ4JpQGD80YIw5PT8RCS+pZBdu4BsaZ/c1c1E3YBw5/C6ZhxdTYMM6Rko QUmcj7iFZ3oYdNYhYuooTZzGxlIZ7RaNEy//w= MIME-Version: 1.0 Received: by 10.140.147.21 with SMTP id u21mr1669235rvd.250.1256095302333; Tue, 20 Oct 2009 20:21:42 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Oct 2009 11:21:42 +0800 Message-ID: From: Bean To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [GITGRUB] New menu interface (implementation) X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2009 03:21:49 -0000 On Wed, Oct 21, 2009 at 3:06 AM, Michal Suchanek wrot= e: > Hello > > 2009/10/17 Bean : >> Hi, >> >> Update: >> >> Add sub menu support, generate widgets dynamically using menu entries. > > The example is very complex and I don't quite understand what is the > advantage of this baroque scheme over generating the menus in grub.d > in files like 00_header or 10_linux. > > For example, each menuentry for loading a linux kernel is generated by > a function in 10_linux which in turn calls functions from > grub-mkconfig_lib. Thus it is possible to create arbitrarily complex > menu entries without additional C code in grub or user-edited > configuration. I don't see why these shell scripts cannot include all > the panels and stuff needed for the new menu and have to be generated > by C code in grub. > Hi, Don't forget that menu items can be generated at runtime. For example, with my osdetect,lua script, it's possible to scan the disk for existing OS and add them to the menu automatically, so a generic config file can be used. This is quite useful in removable boot media like usb and cdrom, as you can't predict in advanced what OS would be present when the media boots. In this case, the menu have to be generated dynamically as well. >> >> Now grub.cfg should look like this: >> >> menuentry "AAA" { >> =A0set root=3D(hd0,1) >> =A0chainloader +1 >> } >> >> menuentry "BBB" --class ubuntu { >> =A0true >> } >> >> . /menu/menu.cfg >> >> The menu have three items, AAA, BBB and Tools, which is a menu >> appended in menu.cfg. >> >> Tools are a submenu, its content is defined using menu section: >> >> menu { >> =A0Tools { >> =A0 =A0"Toggle Mode" { >> =A0 =A0 =A0command =3D menu_toggle_mode >> =A0 =A0} >> >> =A0 =A0"Terminal" { >> =A0 =A0 =A0command =3D "menu_popup term_window" >> =A0 =A0} >> >> =A0 =A0"Change Theme" { >> =A0 =A0 =A0Default { >> =A0 =A0 =A0 =A0command=3D"load_config /menu/blue.txt\nmenu_refresh" >> =A0 =A0 =A0} >> >> =A0 =A0 =A0Green { >> =A0 =A0 =A0 =A0command=3D"load_config /menu/green.txt\nmenu_refresh" >> =A0 =A0 =A0} >> >> =A0 =A0 =A0White { >> =A0 =A0 =A0 =A0command=3D"load_config /menu/white.txt\nmenu_refresh" >> =A0 =A0 =A0} >> =A0 =A0} >> >> =A0 =A0"Layout Demo" { >> =A0 =A0 =A0command =3D "menu_popup layout_test" >> =A0 =A0} >> >> =A0 =A0Halt { >> =A0 =A0 =A0command =3D "halt" >> =A0 =A0} >> >> =A0 =A0Reboot { >> =A0 =A0 =A0command =3D "reboot" >> =A0 =A0} >> =A0} >> } >> >> merge_config command would append this with user defined menu items. >> >> The screen section is very simple now: >> >> screen { >> =A0panel { >> =A0 =A0extend =3D 1 >> =A0 =A0valign =3D center >> =A0 =A0halign =3D center >> >> =A0 =A0panel { >> =A0 =A0 =A0class =3D frame >> =A0 =A0 =A0id =3D __menu__ >> =A0 =A0} >> =A0} >> } > > So you invent a new property here just to bind the menu to a panel. If > you insist then screen should be a panel { id =3D __screen__ }. > id can be useful in templates to name children widgets having the same name= . >> >> command menu_create would scan screen for id __menu__, and add widgets >> according to the menu content. The generated widget entry looks like >> this: >> >> panel >> { >> =A0class =3D select >> =A0command =3D COMMAND >> =A0image { class =3D =A0CLASS } >> =A0text { text =3D TITLE } >> } > > And if I want a slightly different structure I have to patch and > recompile grub. I also wonder how do you specify the image bitmap here > because it's the sole content of the image so it should not be > specified by style. > See my latest patch, this have already been replaced by templates. You specify the template names in menu_create command: menu_create menu_template item_template item_template { panel { parameters =3D "class=3Dimage.class:title=3Dtext.text" class =3D select direction =3D left_to_right image {} text { valign =3D center } } } In the template, parameters property sets the mapping between external parameter name and internal properties. for example, this example shows class is mapped to class property of image widget, and title is mapped to text property of text widget. >> >> The submenu is this: >> >> panel >> { >> =A0class =3D frame >> =A0command =3D "menu_popup -r menu_tree N" >> } >> > > I have no idea what the above is supposed to mean. Care to explain? menu_popup create a popup window using template, menu_tree is an section auto generated by menu_create, N is the index of children widget. BTW, the syntax has changed in the latest patch to: menu_popup -ri N menu_tree The index is moved as option, as we can append assignment after the name. --=20 Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/