gfxmenu import
This commit is contained in:
parent
bd86691a07
commit
d920a32ab6
25 changed files with 5977 additions and 1 deletions
59
include/grub/gfxmenu_model.h
Normal file
59
include/grub/gfxmenu_model.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* gfxmenu_model.h - gfxmenu model interface. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GFXMENU_MODEL_HEADER
|
||||
#define GRUB_GFXMENU_MODEL_HEADER 1
|
||||
|
||||
#include <grub/menu.h>
|
||||
|
||||
struct grub_gfxmenu_model; /* Forward declaration of opaque type. */
|
||||
typedef struct grub_gfxmenu_model *grub_gfxmenu_model_t;
|
||||
|
||||
|
||||
grub_gfxmenu_model_t grub_gfxmenu_model_new (grub_menu_t menu);
|
||||
|
||||
void grub_gfxmenu_model_destroy (grub_gfxmenu_model_t model);
|
||||
|
||||
grub_menu_t grub_gfxmenu_model_get_menu (grub_gfxmenu_model_t model);
|
||||
|
||||
void grub_gfxmenu_model_set_timeout (grub_gfxmenu_model_t model);
|
||||
|
||||
void grub_gfxmenu_model_clear_timeout (grub_gfxmenu_model_t model);
|
||||
|
||||
int grub_gfxmenu_model_get_timeout_ms (grub_gfxmenu_model_t model);
|
||||
|
||||
int grub_gfxmenu_model_get_timeout_remaining_ms (grub_gfxmenu_model_t model);
|
||||
|
||||
int grub_gfxmenu_model_timeout_expired (grub_gfxmenu_model_t model);
|
||||
|
||||
int grub_gfxmenu_model_get_num_entries (grub_gfxmenu_model_t model);
|
||||
|
||||
int grub_gfxmenu_model_get_selected_index (grub_gfxmenu_model_t model);
|
||||
|
||||
void grub_gfxmenu_model_set_selected_index (grub_gfxmenu_model_t model,
|
||||
int index);
|
||||
|
||||
const char *grub_gfxmenu_model_get_entry_title (grub_gfxmenu_model_t model,
|
||||
int index);
|
||||
|
||||
grub_menu_entry_t grub_gfxmenu_model_get_entry (grub_gfxmenu_model_t model,
|
||||
int index);
|
||||
|
||||
#endif /* GRUB_GFXMENU_MODEL_HEADER */
|
||||
|
91
include/grub/gfxmenu_view.h
Normal file
91
include/grub/gfxmenu_view.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
/* gfxmenu_view.h - gfxmenu view interface. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GFXMENU_VIEW_HEADER
|
||||
#define GRUB_GFXMENU_VIEW_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/menu.h>
|
||||
#include <grub/font.h>
|
||||
#include <grub/gfxmenu_model.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
|
||||
struct grub_gfxmenu_view; /* Forward declaration of opaque type. */
|
||||
typedef struct grub_gfxmenu_view *grub_gfxmenu_view_t;
|
||||
|
||||
|
||||
grub_gfxmenu_view_t grub_gfxmenu_view_new (const char *theme_path,
|
||||
grub_gfxmenu_model_t model);
|
||||
|
||||
void grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view);
|
||||
|
||||
/* Set properties on the view based on settings from the specified
|
||||
theme file. */
|
||||
grub_err_t grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view,
|
||||
const char *theme_path);
|
||||
|
||||
grub_err_t grub_gui_recreate_box (grub_gfxmenu_box_t *boxptr,
|
||||
const char *pattern, const char *theme_dir);
|
||||
|
||||
void grub_gfxmenu_view_draw (grub_gfxmenu_view_t view);
|
||||
|
||||
int grub_gfxmenu_view_execute_with_fallback (grub_gfxmenu_view_t view,
|
||||
grub_menu_entry_t entry);
|
||||
|
||||
int grub_gfxmenu_view_execute_entry (grub_gfxmenu_view_t view,
|
||||
grub_menu_entry_t entry);
|
||||
|
||||
void grub_gfxmenu_view_run_terminal (grub_gfxmenu_view_t view);
|
||||
|
||||
|
||||
|
||||
/* Implementation details -- this should not be used outside of the
|
||||
view itself. */
|
||||
|
||||
#include <grub/video.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/gui.h>
|
||||
#include <grub/gfxwidgets.h>
|
||||
#include <grub/icon_manager.h>
|
||||
|
||||
/* Definition of the private representation of the view. */
|
||||
struct grub_gfxmenu_view
|
||||
{
|
||||
grub_video_rect_t screen;
|
||||
|
||||
grub_font_t title_font;
|
||||
grub_font_t message_font;
|
||||
char *terminal_font_name;
|
||||
grub_gui_color_t title_color;
|
||||
grub_gui_color_t message_color;
|
||||
grub_gui_color_t message_bg_color;
|
||||
struct grub_video_bitmap *desktop_image;
|
||||
grub_gui_color_t desktop_color;
|
||||
grub_gfxmenu_box_t terminal_box;
|
||||
char *title_text;
|
||||
char *progress_message_text;
|
||||
char *theme_path;
|
||||
|
||||
grub_gui_container_t canvas;
|
||||
|
||||
grub_gfxmenu_model_t model;
|
||||
};
|
||||
|
||||
#endif /* ! GRUB_GFXMENU_VIEW_HEADER */
|
49
include/grub/gfxwidgets.h
Normal file
49
include/grub/gfxwidgets.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* gfxwidgets.h - Widgets for the graphical menu (gfxmenu). */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GFXWIDGETS_HEADER
|
||||
#define GRUB_GFXWIDGETS_HEADER 1
|
||||
|
||||
#include <grub/video.h>
|
||||
|
||||
typedef struct grub_gfxmenu_box *grub_gfxmenu_box_t;
|
||||
|
||||
struct grub_gfxmenu_box
|
||||
{
|
||||
/* The size of the content. */
|
||||
int content_width;
|
||||
int content_height;
|
||||
|
||||
struct grub_video_bitmap **raw_pixmaps;
|
||||
struct grub_video_bitmap **scaled_pixmaps;
|
||||
|
||||
void (*draw) (grub_gfxmenu_box_t self, int x, int y);
|
||||
void (*set_content_size) (grub_gfxmenu_box_t self,
|
||||
int width, int height);
|
||||
int (*get_left_pad) (grub_gfxmenu_box_t self);
|
||||
int (*get_top_pad) (grub_gfxmenu_box_t self);
|
||||
int (*get_right_pad) (grub_gfxmenu_box_t self);
|
||||
int (*get_bottom_pad) (grub_gfxmenu_box_t self);
|
||||
void (*destroy) (grub_gfxmenu_box_t self);
|
||||
};
|
||||
|
||||
grub_gfxmenu_box_t grub_gfxmenu_create_box (const char *pixmaps_prefix,
|
||||
const char *pixmaps_suffix);
|
||||
|
||||
#endif /* ! GRUB_GFXWIDGETS_HEADER */
|
165
include/grub/gui.h
Normal file
165
include/grub/gui.h
Normal file
|
@ -0,0 +1,165 @@
|
|||
/* gui.h - GUI components header file. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/bitmap.h>
|
||||
#include <grub/gfxmenu_model.h>
|
||||
|
||||
#ifndef GRUB_GUI_H
|
||||
#define GRUB_GUI_H 1
|
||||
|
||||
/* A representation of a color. Unlike grub_video_color_t, this
|
||||
representation is independent of any video mode specifics. */
|
||||
typedef struct grub_gui_color
|
||||
{
|
||||
grub_uint8_t red;
|
||||
grub_uint8_t green;
|
||||
grub_uint8_t blue;
|
||||
grub_uint8_t alpha;
|
||||
} grub_gui_color_t;
|
||||
|
||||
typedef struct grub_gui_component *grub_gui_component_t;
|
||||
typedef struct grub_gui_container *grub_gui_container_t;
|
||||
typedef struct grub_gui_list *grub_gui_list_t;
|
||||
|
||||
typedef void (*grub_gui_component_callback) (grub_gui_component_t component,
|
||||
void *userdata);
|
||||
|
||||
/* Component interface. */
|
||||
|
||||
struct grub_gui_component_ops
|
||||
{
|
||||
void (*destroy) (void *self);
|
||||
const char * (*get_id) (void *self);
|
||||
int (*is_instance) (void *self, const char *type);
|
||||
void (*paint) (void *self);
|
||||
void (*set_parent) (void *self, grub_gui_container_t parent);
|
||||
grub_gui_container_t (*get_parent) (void *self);
|
||||
void (*set_bounds) (void *self, const grub_video_rect_t *bounds);
|
||||
void (*get_bounds) (void *self, grub_video_rect_t *bounds);
|
||||
void (*get_preferred_size) (void *self, int *width, int *height);
|
||||
grub_err_t (*set_property) (void *self, const char *name, const char *value);
|
||||
};
|
||||
|
||||
struct grub_gui_container_ops
|
||||
{
|
||||
struct grub_gui_component_ops component;
|
||||
void (*add) (void *self, grub_gui_component_t comp);
|
||||
void (*remove) (void *self, grub_gui_component_t comp);
|
||||
void (*iterate_children) (void *self,
|
||||
grub_gui_component_callback cb, void *userdata);
|
||||
};
|
||||
|
||||
struct grub_gui_list_ops
|
||||
{
|
||||
struct grub_gui_component_ops component_ops;
|
||||
void (*set_view_info) (void *self,
|
||||
const char *theme_path,
|
||||
grub_gfxmenu_model_t menu);
|
||||
};
|
||||
|
||||
struct grub_gui_component
|
||||
{
|
||||
struct grub_gui_component_ops *ops;
|
||||
};
|
||||
|
||||
struct grub_gui_container
|
||||
{
|
||||
struct grub_gui_container_ops *ops;
|
||||
};
|
||||
|
||||
struct grub_gui_list
|
||||
{
|
||||
struct grub_gui_list_ops *ops;
|
||||
};
|
||||
|
||||
|
||||
/* Interfaces to concrete component classes. */
|
||||
|
||||
grub_gui_container_t grub_gui_canvas_new (void);
|
||||
grub_gui_container_t grub_gui_vbox_new (void);
|
||||
grub_gui_container_t grub_gui_hbox_new (void);
|
||||
grub_gui_component_t grub_gui_label_new (void);
|
||||
grub_gui_component_t grub_gui_image_new (void);
|
||||
grub_gui_component_t grub_gui_progress_bar_new (void);
|
||||
grub_gui_component_t grub_gui_list_new (void);
|
||||
grub_gui_component_t grub_gui_circular_progress_new (void);
|
||||
|
||||
/* Manipulation functions. */
|
||||
|
||||
/* Visit all components with the specified ID. */
|
||||
void grub_gui_find_by_id (grub_gui_component_t root,
|
||||
const char *id,
|
||||
grub_gui_component_callback cb,
|
||||
void *userdata);
|
||||
|
||||
/* Visit all components. */
|
||||
void grub_gui_iterate_recursively (grub_gui_component_t root,
|
||||
grub_gui_component_callback cb,
|
||||
void *userdata);
|
||||
|
||||
/* Helper functions. */
|
||||
|
||||
static __inline void
|
||||
grub_gui_save_viewport (grub_video_rect_t *r)
|
||||
{
|
||||
grub_video_get_viewport ((unsigned *) &r->x,
|
||||
(unsigned *) &r->y,
|
||||
(unsigned *) &r->width,
|
||||
(unsigned *) &r->height);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
grub_gui_restore_viewport (const grub_video_rect_t *r)
|
||||
{
|
||||
grub_video_set_viewport (r->x, r->y, r->width, r->height);
|
||||
}
|
||||
|
||||
/* Set a new viewport relative the the current one, saving the current
|
||||
viewport in OLD so it can be later restored. */
|
||||
static __inline void
|
||||
grub_gui_set_viewport (const grub_video_rect_t *r, grub_video_rect_t *old)
|
||||
{
|
||||
grub_gui_save_viewport (old);
|
||||
grub_video_set_viewport (old->x + r->x,
|
||||
old->y + r->y,
|
||||
r->width,
|
||||
r->height);
|
||||
}
|
||||
|
||||
static __inline grub_gui_color_t
|
||||
grub_gui_color_rgb (int r, int g, int b)
|
||||
{
|
||||
grub_gui_color_t c;
|
||||
c.red = r;
|
||||
c.green = g;
|
||||
c.blue = b;
|
||||
c.alpha = 255;
|
||||
return c;
|
||||
}
|
||||
|
||||
static __inline grub_video_color_t
|
||||
grub_gui_map_color (grub_gui_color_t c)
|
||||
{
|
||||
return grub_video_map_rgba (c.red, c.green, c.blue, c.alpha);
|
||||
}
|
||||
|
||||
#endif /* ! GRUB_GUI_H */
|
39
include/grub/gui_string_util.h
Normal file
39
include/grub/gui_string_util.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* gui_string_util.h - String utilities for the graphical menu interface. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_GUI_STRING_UTIL_HEADER
|
||||
#define GRUB_GUI_STRING_UTIL_HEADER 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/gui.h>
|
||||
|
||||
char *grub_new_substring (const char *buf,
|
||||
grub_size_t start, grub_size_t end);
|
||||
|
||||
char *grub_resolve_relative_path (const char *base, const char *path);
|
||||
|
||||
char *grub_get_dirname (const char *file_path);
|
||||
|
||||
int grub_gui_get_named_color (const char *name, grub_gui_color_t *color);
|
||||
|
||||
grub_err_t grub_gui_parse_color (const char *s, grub_gui_color_t *color);
|
||||
|
||||
grub_err_t grub_gui_parse_2_tuple (const char *s, int *px, int *py);
|
||||
|
||||
#endif /* GRUB_GUI_STRING_UTIL_HEADER */
|
41
include/grub/icon_manager.h
Normal file
41
include/grub/icon_manager.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* icon_manager.h - gfxmenu icon manager. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2008 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GRUB_ICON_MANAGER_HEADER
|
||||
#define GRUB_ICON_MANAGER_HEADER 1
|
||||
|
||||
#include <grub/menu.h>
|
||||
#include <grub/bitmap.h>
|
||||
|
||||
/* Forward declaration of opaque structure handle type. */
|
||||
typedef struct grub_gfxmenu_icon_manager *grub_gfxmenu_icon_manager_t;
|
||||
|
||||
grub_gfxmenu_icon_manager_t grub_gfxmenu_icon_manager_new (void);
|
||||
void grub_gfxmenu_icon_manager_destroy (grub_gfxmenu_icon_manager_t mgr);
|
||||
void grub_gfxmenu_icon_manager_clear_cache (grub_gfxmenu_icon_manager_t mgr);
|
||||
void grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr,
|
||||
const char *path);
|
||||
void grub_gfxmenu_icon_manager_set_icon_size (grub_gfxmenu_icon_manager_t mgr,
|
||||
int width, int height);
|
||||
struct grub_video_bitmap *
|
||||
grub_gfxmenu_icon_manager_get_icon (grub_gfxmenu_icon_manager_t mgr,
|
||||
grub_menu_entry_t entry);
|
||||
|
||||
#endif /* GRUB_ICON_MANAGER_HEADER */
|
||||
|
|
@ -261,7 +261,7 @@ grub_term_set_current_input (grub_term_input_t term)
|
|||
}
|
||||
|
||||
static inline grub_err_t
|
||||
grub_term_set_current_output (grub_term_output_t term)
|
||||
grub_term_set_current_output (const struct grub_term_output *term)
|
||||
{
|
||||
return grub_handler_set_current (&grub_term_output_class,
|
||||
GRUB_AS_HANDLER (term));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue