mirror of
https://github.com/ventoy/Ventoy.git
synced 2025-02-04 18:36:04 -05:00
Support specify menu_tip position and color per theme.
This commit is contained in:
parent
791da48673
commit
f2bb3667c4
@ -163,6 +163,12 @@ theme_set_string (grub_gfxmenu_view_t view,
|
|||||||
grub_video_parse_color (value, &view->message_color);
|
grub_video_parse_color (value, &view->message_color);
|
||||||
else if (! grub_strcmp ("message-bg-color", name))
|
else if (! grub_strcmp ("message-bg-color", name))
|
||||||
grub_video_parse_color (value, &view->message_bg_color);
|
grub_video_parse_color (value, &view->message_bg_color);
|
||||||
|
else if (! grub_strcmp("menu-tip-left", name))
|
||||||
|
grub_env_set("VTOY_TIP_LEFT", value);
|
||||||
|
else if (! grub_strcmp("menu-tip-top", name))
|
||||||
|
grub_env_set("VTOY_TIP_TOP", value);
|
||||||
|
else if (! grub_strcmp("menu-tip-color", name))
|
||||||
|
grub_env_set("VTOY_TIP_COLOR", value);
|
||||||
else if (! grub_strcmp ("desktop-image", name))
|
else if (! grub_strcmp ("desktop-image", name))
|
||||||
{
|
{
|
||||||
struct grub_video_bitmap *raw_bitmap;
|
struct grub_video_bitmap *raw_bitmap;
|
||||||
@ -740,6 +746,7 @@ extern int g_menu_update_mode;
|
|||||||
grub_err_t
|
grub_err_t
|
||||||
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
||||||
{
|
{
|
||||||
|
int flag = 0;
|
||||||
grub_file_t file;
|
grub_file_t file;
|
||||||
struct parsebuf p;
|
struct parsebuf p;
|
||||||
|
|
||||||
@ -783,32 +790,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
|
|
||||||
if (tip && tip[0] == '1')
|
|
||||||
{
|
|
||||||
char tmpmsg[512];
|
|
||||||
|
|
||||||
grub_memset(tmpmsg, 'w', 500);
|
|
||||||
tmpmsg[500] = 0;
|
|
||||||
|
|
||||||
g_menu_update_mode = 1;
|
|
||||||
p.len += grub_snprintf(p.buf + p.len, 4096,
|
|
||||||
"\n+ vbox{\n left = %s\n top = %s\n"
|
|
||||||
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
|
||||||
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
|
||||||
"}\n",
|
|
||||||
grub_env_get("VTOY_TIP_LEFT"),
|
|
||||||
grub_env_get("VTOY_TIP_TOP"),
|
|
||||||
tmpmsg,
|
|
||||||
grub_env_get("VTOY_TIP_COLOR"),
|
|
||||||
grub_env_get("VTOY_TIP_ALIGN"),
|
|
||||||
tmpmsg,
|
|
||||||
grub_env_get("VTOY_TIP_COLOR"),
|
|
||||||
grub_env_get("VTOY_TIP_ALIGN")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view->canvas)
|
if (view->canvas)
|
||||||
view->canvas->component.ops->destroy (view->canvas);
|
view->canvas->component.ops->destroy (view->canvas);
|
||||||
@ -820,6 +802,7 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
|||||||
->ops->set_bounds ((grub_gui_component_t) view->canvas,
|
->ops->set_bounds ((grub_gui_component_t) view->canvas,
|
||||||
&view->screen);
|
&view->screen);
|
||||||
|
|
||||||
|
parse:
|
||||||
while (has_more (&p))
|
while (has_more (&p))
|
||||||
{
|
{
|
||||||
/* Skip comments (lines beginning with #). */
|
/* Skip comments (lines beginning with #). */
|
||||||
@ -848,6 +831,40 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (flag == 0)
|
||||||
|
{
|
||||||
|
const char *tip = grub_env_get("VTOY_MENU_TIP_ENABLE");
|
||||||
|
if (tip && tip[0] == '1')
|
||||||
|
{
|
||||||
|
char tmpmsg[512];
|
||||||
|
|
||||||
|
grub_memset(tmpmsg, 'w', 500);
|
||||||
|
tmpmsg[500] = 0;
|
||||||
|
|
||||||
|
g_menu_update_mode = 1;
|
||||||
|
p.len += grub_snprintf(p.buf + p.len, 4096,
|
||||||
|
"\n+ vbox{\n left = %s\n top = %s\n"
|
||||||
|
"+ label { id=\"VTOY_MENU_TIP_1\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
||||||
|
"+ label { id=\"VTOY_MENU_TIP_2\" text = \"%s\" color = \"%s\" align = \"%s\"}\n"
|
||||||
|
"}\n",
|
||||||
|
grub_env_get("VTOY_TIP_LEFT"),
|
||||||
|
grub_env_get("VTOY_TIP_TOP"),
|
||||||
|
tmpmsg,
|
||||||
|
grub_env_get("VTOY_TIP_COLOR"),
|
||||||
|
grub_env_get("VTOY_TIP_ALIGN"),
|
||||||
|
tmpmsg,
|
||||||
|
grub_env_get("VTOY_TIP_COLOR"),
|
||||||
|
grub_env_get("VTOY_TIP_ALIGN")
|
||||||
|
);
|
||||||
|
|
||||||
|
flag = 1;
|
||||||
|
goto parse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Set the new theme path. */
|
/* Set the new theme path. */
|
||||||
grub_free (view->theme_path);
|
grub_free (view->theme_path);
|
||||||
view->theme_path = grub_strdup (theme_path);
|
view->theme_path = grub_strdup (theme_path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user