grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GITGRUB] New menu interface (implementation)


From: Bean
Subject: Re: [GITGRUB] New menu interface (implementation)
Date: Wed, 21 Oct 2009 11:21:42 +0800

On Wed, Oct 21, 2009 at 3:06 AM, Michal Suchanek <address@hidden> wrote:
> Hello
>
> 2009/10/17 Bean <address@hidden>:
>> 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" {
>>  set root=(hd0,1)
>>  chainloader +1
>> }
>>
>> menuentry "BBB" --class ubuntu {
>>  true
>> }
>>
>> . /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 {
>>  Tools {
>>    "Toggle Mode" {
>>      command = menu_toggle_mode
>>    }
>>
>>    "Terminal" {
>>      command = "menu_popup term_window"
>>    }
>>
>>    "Change Theme" {
>>      Default {
>>        command="load_config /menu/blue.txt\nmenu_refresh"
>>      }
>>
>>      Green {
>>        command="load_config /menu/green.txt\nmenu_refresh"
>>      }
>>
>>      White {
>>        command="load_config /menu/white.txt\nmenu_refresh"
>>      }
>>    }
>>
>>    "Layout Demo" {
>>      command = "menu_popup layout_test"
>>    }
>>
>>    Halt {
>>      command = "halt"
>>    }
>>
>>    Reboot {
>>      command = "reboot"
>>    }
>>  }
>> }
>>
>> merge_config command would append this with user defined menu items.
>>
>> The screen section is very simple now:
>>
>> screen {
>>  panel {
>>    extend = 1
>>    valign = center
>>    halign = center
>>
>>    panel {
>>      class = frame
>>      id = __menu__
>>    }
>>  }
>> }
>
> 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 = __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
>> {
>>  class = select
>>  command = COMMAND
>>  image { class =  CLASS }
>>  text { text = 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 = "class=image.class:title=text.text"
    class = select
    direction = left_to_right
    image {}
    text { valign = 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
>> {
>>  class = frame
>>  command = "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.

-- 
Bean

gitgrub home: http://github.com/grub/grub/
my fork page: http://github.com/bean123/grub/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]