Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1N0STr-0008QO-A9 for mharc-grub-devel@gnu.org; Wed, 21 Oct 2009 00:07:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0STp-0008Pc-N7 for grub-devel@gnu.org; Wed, 21 Oct 2009 00:07:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0STl-0008O4-23 for grub-devel@gnu.org; Wed, 21 Oct 2009 00:07:21 -0400 Received: from [199.232.76.173] (port=50347 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0STk-0008Ny-V0 for grub-devel@gnu.org; Wed, 21 Oct 2009 00:07:16 -0400 Received: from mail-px0-f192.google.com ([209.85.216.192]:38411) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0STk-0004O7-Fn for grub-devel@gnu.org; Wed, 21 Oct 2009 00:07:16 -0400 Received: by pxi30 with SMTP id 30so288171pxi.14 for ; Tue, 20 Oct 2009 21:07:15 -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=w5a0+6yhONGGU/oX++mqc2tB+eNxarCYC9b16NLuEHo=; b=d1LShPZ+uyq65LIXdJJQmRhD+9oSRbZxl/+tb5C5STlqlOLSznYNTCtUP8vjPgOAX/ l72GvMfLcjzDrQdW/GARjRScBbQ3bvXMytLOL+a7SQnKzZPAk8duFZoHQ+m9fIJ6uQ0u tX9sE7e+f9RHW3owQvbmLVUq8HYKfp9A6Hds4= 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=tumEmO1NpKaebmcWFyuZEw5jj00QJpUBpptRTbRqRfbtA2m4YY+8VqQkBNXAlS7KSX LYY0vdX0/u+apAyMl1XP5og15A1mCoTHyYlxAglwAEu86vsfQWg6dZswzd8trpu96RXd pTsXuGdXn6xsDVx+n2rsCn0pRMtJdKAilvIoQ= MIME-Version: 1.0 Received: by 10.141.40.7 with SMTP id s7mr1682615rvj.25.1256098035384; Tue, 20 Oct 2009 21:07:15 -0700 (PDT) In-Reply-To: References: Date: Wed, 21 Oct 2009 12:07:15 +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 04:07:22 -0000 On Wed, Oct 21, 2009 at 3:31 AM, Michal Suchanek wrot= e: > 2009/10/20 Bean : >> Hi, >> >> Update: >> >> Add dialog support, it allows you to write a template and call it with >> different parameters, for example: >> >> dialog_edit { >> =A0panel { >> =A0 =A0parameters =3D "text=3Dedit.text" >> =A0 =A0class =3D frame >> =A0 =A0width =3D 80% >> =A0 =A0attach_hcenter =3D 0 >> =A0 =A0attach_vcenter =3D 0 >> >> =A0 =A0edit { >> =A0 =A0 =A0lines =3D 10 >> =A0 =A0} >> =A0} >> } > > I can see this used for the edit boxen and text mesasge dialogs which > would be quite similar. > > Also the templating seems quite flexible and versatile. > > However, can't this be done with a shell function? > > Both the grub.d scripts and grub.cfg can define a function with a few > parameters to achieve pretty much the same results. > > IIRC one of the sample menu.cfg files defined functions as part of > grub configuration so we do not need another facility for this. > Hi, IMO it's more easy to write widget this way, you can still pack it in shell script as menu_popup support string argument: menu_popup -s "panel { width=3D100% height=3D100% }" This is fine for short code, but as the widget become more complex, it's quite difficult to use this notion, especially when you add command property which requires quotes. There seems to be some issue with embedded quote handling. >> >> The parameters property control the mapping between parameter and >> internal property name. To use it to edit current command: >> >> menu_edit dialog_edit text=3Dcommand >> >> It also allows you to edit other properties, for example, the demo add >> a hotkey t to edit the title: >> >> t =3D "menu_edit dialog_edit text=3Dtitle\nmenu_refresh" >> >> The generated menu also uses templates, one for submenu, and one for men= uitem: >> >> menu_template { >> =A0panel { >> =A0 =A0class =3D frame >> =A0} >> } >> >> item_template { >> =A0panel { >> =A0 =A0parameters =3D "class=3Dimage.class:title=3Dtext.text" >> =A0 =A0class =3D select >> =A0 =A0image {} >> =A0 =A0text {} >> =A0} >> } >> >> The names of the template is passed to menu_create command: >> >> menu_create menu_template item_template. >> >> Smart popup window. The sub menu would pop to the direction with the >> most space, which would make sure it won't be truncated by the border. > > It won't. You cannot know how much space the "most space" is. First I calculate the central point of current node, if it's in the top-left quadrant, I pop up sub menu at its bottom-right corner, etc. The handling is quite simple and it should avoid popping up sub menu off screen. --=20 Bean gitgrub home: http://github.com/grub/grub/ my fork page: http://github.com/bean123/grub/