]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Merge mainline into gfxmenu
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 3 Feb 2010 00:24:07 +0000 (01:24 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 3 Feb 2010 00:24:07 +0000 (01:24 +0100)
19 files changed:
1  2 
Makefile.in
conf/any-emu.rmk
conf/common.rmk
configure.ac
gfxmenu/gui_progress_bar.c
include/grub/misc.h
include/grub/video.h
kern/misc.c
loader/i386/pc/xnu.c
loader/xnu.c
normal/cmdline.c
normal/menu.c
term/gfxterm.c
util/grub.d/00_header.in
util/grub.d/10_hurd.in
util/grub.d/10_kfreebsd.in
util/grub.d/10_linux.in
video/fb/video_fb.c
video/i386/pc/vbe.c

diff --cc Makefile.in
Simple merge
Simple merge
diff --cc conf/common.rmk
Simple merge
diff --cc configure.ac
Simple merge
index 550b5d43c0d1bdbfb4738d92d24ba83beffa3a58,0000000000000000000000000000000000000000..4fda61d49f057a3146355545833f6feb5fe32b10
mode 100644,000000..100644
--- /dev/null
@@@ -1,384 -1,0 +1,384 @@@
-       char *text = grub_malloc (grub_strlen (self->template) + 10);
 +/* gui_progress_bar.c - GUI progress bar component.  */
 +/*
 + *  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/mm.h>
 +#include <grub/misc.h>
 +#include <grub/gui.h>
 +#include <grub/font.h>
 +#include <grub/gui_string_util.h>
 +#include <grub/gfxmenu_view.h>
 +#include <grub/gfxwidgets.h>
 +#include <grub/i18n.h>
 +
 +struct grub_gui_progress_bar
 +{
 +  struct grub_gui_progress progress;
 +
 +  grub_gui_container_t parent;
 +  grub_video_rect_t bounds;
 +  char *id;
 +  int visible;
 +  int start;
 +  int end;
 +  int value;
 +  int show_text;
 +  char *template;
 +  grub_font_t font;
 +  grub_gui_color_t text_color;
 +  grub_gui_color_t border_color;
 +  grub_gui_color_t bg_color;
 +  grub_gui_color_t fg_color;
 +
 +  char *theme_dir;
 +  int need_to_recreate_pixmaps;
 +  int pixmapbar_available;
 +  char *bar_pattern;
 +  char *highlight_pattern;
 +  grub_gfxmenu_box_t bar_box;
 +  grub_gfxmenu_box_t highlight_box;
 +};
 +
 +typedef struct grub_gui_progress_bar *grub_gui_progress_bar_t;
 +
 +static void
 +progress_bar_destroy (void *vself)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  grub_free (self);
 +}
 +
 +static const char *
 +progress_bar_get_id (void *vself)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  return self->id;
 +}
 +
 +static int
 +progress_bar_is_instance (void *vself __attribute__((unused)), const char *type)
 +{
 +  return grub_strcmp (type, "component") == 0;
 +}
 +
 +static int
 +check_pixmaps (grub_gui_progress_bar_t self)
 +{
 +  if (!self->pixmapbar_available)
 +    return 0;
 +  if (self->need_to_recreate_pixmaps)
 +    {
 +      grub_gui_recreate_box (&self->bar_box,
 +                             self->bar_pattern,
 +                             self->theme_dir);
 +
 +      grub_gui_recreate_box (&self->highlight_box,
 +                             self->highlight_pattern,
 +                             self->theme_dir);
 +
 +      self->need_to_recreate_pixmaps = 0;
 +    }
 +
 +  return (self->bar_box != 0 && self->highlight_box != 0);
 +}
 +
 +static void
 +draw_filled_rect_bar (grub_gui_progress_bar_t self)
 +{
 +  /* Set the progress bar's frame.  */
 +  grub_video_rect_t f;
 +  f.x = 1;
 +  f.y = 1;
 +  f.width = self->bounds.width - 2;
 +  f.height = self->bounds.height - 2;
 +
 +  /* Border.  */
 +  grub_video_fill_rect (grub_gui_map_color (self->border_color),
 +                        f.x - 1, f.y - 1,
 +                        f.width + 2, f.height + 2);
 +
 +  /* Bar background.  */
 +  int barwidth = (f.width
 +                  * (self->value - self->start)
 +                  / (self->end - self->start));
 +  grub_video_fill_rect (grub_gui_map_color (self->bg_color),
 +                        f.x + barwidth, f.y,
 +                        f.width - barwidth, f.height);
 +
 +  /* Bar foreground.  */
 +  grub_video_fill_rect (grub_gui_map_color (self->fg_color),
 +                        f.x, f.y,
 +                        barwidth, f.height);
 +}
 +
 +static void
 +draw_pixmap_bar (grub_gui_progress_bar_t self)
 +{
 +  grub_gfxmenu_box_t bar = self->bar_box;
 +  grub_gfxmenu_box_t hl = self->highlight_box;
 +  int w = self->bounds.width;
 +  int h = self->bounds.height;
 +  int bar_l_pad = bar->get_left_pad (bar);
 +  int bar_r_pad = bar->get_right_pad (bar);
 +  int bar_t_pad = bar->get_top_pad (bar);
 +  int bar_b_pad = bar->get_bottom_pad (bar);
 +  int bar_h_pad = bar_l_pad + bar_r_pad;
 +  int bar_v_pad = bar_t_pad + bar_b_pad;
 +  int tracklen = w - bar_h_pad;
 +  int trackheight = h - bar_v_pad;
 +  int barwidth;
 +
 +  bar->set_content_size (bar, tracklen, trackheight);
 +
 +  barwidth = (tracklen * (self->value - self->start) 
 +            / (self->end - self->start));
 +
 +  hl->set_content_size (hl, barwidth, h - bar_v_pad);
 +
 +  bar->draw (bar, 0, 0);
 +  hl->draw (hl, bar_l_pad, bar_t_pad);
 +}
 +
 +static void
 +draw_text (grub_gui_progress_bar_t self)
 +{
 +  if (self->template)
 +    {
 +      grub_font_t font = self->font;
 +      grub_video_color_t text_color = grub_gui_map_color (self->text_color);
 +      int width = self->bounds.width;
 +      int height = self->bounds.height;
-       grub_sprintf (text, self->template,
-                   self->value > 0 ? self->value : -self->value);
++      char *text;
++      text = grub_xasprintf (self->template,
++                           self->value > 0 ? self->value : -self->value);
 +      if (!text)
 +      {
 +        grub_print_error ();
 +        grub_errno = GRUB_ERR_NONE;
 +        return;
 +      }
 +      /* Center the text. */
 +      int text_width = grub_font_get_string_width (font, text);
 +      int x = (width - text_width) / 2;
 +      int y = ((height - grub_font_get_descent (font)) / 2
 +               + grub_font_get_ascent (font) / 2);
 +      grub_font_draw_string (text, font, text_color, x, y);
 +    }
 +}
 +
 +static void
 +progress_bar_paint (void *vself, const grub_video_rect_t *region)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  grub_video_rect_t vpsave;
 +
 +  if (! self->visible)
 +    return;
 +  if (!grub_video_have_common_points (region, &self->bounds))
 +    return;
 +
 +  if (self->end == self->start)
 +    return;
 +
 +  grub_gui_set_viewport (&self->bounds, &vpsave);
 +
 +  if (check_pixmaps (self))
 +    draw_pixmap_bar (self);
 +  else
 +    draw_filled_rect_bar (self);
 +
 +  draw_text (self);
 +
 +  grub_gui_restore_viewport (&vpsave);
 +}
 +
 +static void
 +progress_bar_set_parent (void *vself, grub_gui_container_t parent)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  self->parent = parent;
 +}
 +
 +static grub_gui_container_t
 +progress_bar_get_parent (void *vself)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  return self->parent;
 +}
 +
 +static void
 +progress_bar_set_bounds (void *vself, const grub_video_rect_t *bounds)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  self->bounds = *bounds;
 +}
 +
 +static void
 +progress_bar_get_bounds (void *vself, grub_video_rect_t *bounds)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  *bounds = self->bounds;
 +}
 +
 +static void
 +progress_bar_get_minimal_size (void *vself,
 +                             unsigned *width, unsigned *height)
 +{
 +  unsigned text_width = 0, text_height = 0;
 +  grub_gui_progress_bar_t self = vself;
 +
 +  if (self->template)
 +    {
 +      text_width = grub_font_get_string_width (self->font, self->template);
 +      text_width += grub_font_get_string_width (self->font, "XXXXXXXXXX");
 +      text_height = grub_font_get_descent (self->font)
 +      + grub_font_get_ascent (self->font);
 +    }
 +  *width = 200;
 +  if (*width < text_width)
 +    *width = text_width;
 +  *height = 28;
 +  if (*height < text_height)
 +    *height = text_height;
 +}
 +
 +static void
 +progress_bar_set_state (void *vself, int visible, int start,
 +                      int current, int end)
 +{
 +  grub_gui_progress_bar_t self = vself;  
 +  self->visible = visible;
 +  self->start = start;
 +  self->value = current;
 +  self->end = end;
 +}
 +
 +static grub_err_t
 +progress_bar_set_property (void *vself, const char *name, const char *value)
 +{
 +  grub_gui_progress_bar_t self = vself;
 +  if (grub_strcmp (name, "text") == 0)
 +    {
 +      grub_free (self->template);
 +      if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_LONG@") == 0)
 +      value 
 +        = _("The highlighted entry will be executed automatically in %ds.");
 +      else if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_MIDDLE@") == 0)
 +      /* TRANSLATORS:  's' stands for seconds.
 +         It's a standalone timeout notification.
 +         Please use the short form in your language.  */
 +      value = _("%ds remaining.");
 +      else if (grub_strcmp (value, "@TIMEOUT_NOTIFICATION_SHORT@") == 0)
 +      /* TRANSLATORS:  's' stands for seconds.
 +         It's a standalone timeout notification.
 +         Please use the shortest form available in you language.  */
 +      value = _("%ds");
 +
 +      self->template = grub_strdup (value);
 +    }
 +  else if (grub_strcmp (name, "font") == 0)
 +    {
 +      self->font = grub_font_get (value);
 +    }
 +  else if (grub_strcmp (name, "text_color") == 0)
 +    {
 +      grub_gui_parse_color (value, &self->text_color);
 +    }
 +  else if (grub_strcmp (name, "border_color") == 0)
 +    {
 +       grub_gui_parse_color (value, &self->border_color);
 +    }
 +  else if (grub_strcmp (name, "bg_color") == 0)
 +    {
 +       grub_gui_parse_color (value, &self->bg_color);
 +    }
 +  else if (grub_strcmp (name, "fg_color") == 0)
 +    {
 +      grub_gui_parse_color (value, &self->fg_color);
 +    }
 +  else if (grub_strcmp (name, "bar_style") == 0)
 +    {
 +      self->need_to_recreate_pixmaps = 1;
 +      self->pixmapbar_available = 1;
 +      grub_free (self->bar_pattern);
 +      self->bar_pattern = value ? grub_strdup (value) : 0;
 +    }
 +  else if (grub_strcmp (name, "highlight_style") == 0)
 +    {
 +      self->need_to_recreate_pixmaps = 1;
 +      self->pixmapbar_available = 1;
 +      grub_free (self->highlight_pattern);
 +      self->highlight_pattern = value ? grub_strdup (value) : 0;
 +    }
 +  else if (grub_strcmp (name, "theme_dir") == 0)
 +    {
 +      self->need_to_recreate_pixmaps = 1;
 +      grub_free (self->theme_dir);
 +      self->theme_dir = value ? grub_strdup (value) : 0;
 +    }
 +  else if (grub_strcmp (name, "id") == 0)
 +    {
 +      grub_free (self->id);
 +      if (value)
 +        self->id = grub_strdup (value);
 +      else
 +        self->id = 0;
 +    }
 +  return grub_errno;
 +}
 +
 +static struct grub_gui_component_ops progress_bar_ops =
 +{
 +  .destroy = progress_bar_destroy,
 +  .get_id = progress_bar_get_id,
 +  .is_instance = progress_bar_is_instance,
 +  .paint = progress_bar_paint,
 +  .set_parent = progress_bar_set_parent,
 +  .get_parent = progress_bar_get_parent,
 +  .set_bounds = progress_bar_set_bounds,
 +  .get_bounds = progress_bar_get_bounds,
 +  .get_minimal_size = progress_bar_get_minimal_size,
 +  .set_property = progress_bar_set_property
 +};
 +
 +static struct grub_gui_progress_ops progress_bar_pb_ops =
 +  {
 +    .set_state = progress_bar_set_state
 +  };
 +
 +grub_gui_component_t
 +grub_gui_progress_bar_new (void)
 +{
 +  grub_gui_progress_bar_t self;
 +  self = grub_zalloc (sizeof (*self));
 +  if (! self)
 +    return 0;
 +  self->progress.ops = &progress_bar_pb_ops;
 +  self->progress.component.ops = &progress_bar_ops;
 +  self->visible = 1;
 +  self->font = grub_font_get ("Helvetica 10");
 +  grub_gui_color_t black = { .red = 0, .green = 0, .blue = 0, .alpha = 255 };
 +  grub_gui_color_t gray = { .red = 128, .green = 128, .blue = 128, .alpha = 255 };
 +  grub_gui_color_t lightgray = { .red = 200, .green = 200, .blue = 200, .alpha = 255 };
 +  self->text_color = black;
 +  self->border_color = black;
 +  self->bg_color = gray;
 +  self->fg_color = lightgray;
 +
 +  return (grub_gui_component_t) self;
 +}
Simple merge
Simple merge
diff --cc kern/misc.c
index 6b481dc7a132d6be29ea7a80e24634666b5608e9,ba31d24bb7aecf034934995c204ca601e19276a9..309267786d4bd18c43dc10715691e0550bbf65b9
@@@ -202,7 -205,8 +205,7 @@@ grub_vprintf (const char *fmt, va_list 
  {
    int ret;
  
-   ret = grub_vsprintf (0, fmt, args);
+   ret = grub_vsnprintf_real (0, 0, fmt, args);
 -  grub_refresh ();
    return ret;
  }
  
Simple merge
diff --cc loader/xnu.c
index 7f6c697cfed5d5c9d75fb5c525a5fb27112471bc,e0a2dfe8b6806cfdb4f4fc32dfdff2806bd0100c..cf9fa740b986ada73bb508c3fac7fdb1de63c5dd
@@@ -31,8 -31,8 +31,9 @@@
  #include <grub/gzio.h>
  #include <grub/command.h>
  #include <grub/misc.h>
 +#include <grub/extcmd.h>
  #include <grub/env.h>
+ #include <grub/i18n.h>
  
  struct grub_xnu_devtree_key *grub_xnu_devtree_root = 0;
  static int driverspackagenum = 0;
@@@ -1425,24 -1404,21 +1425,24 @@@ static grub_extcmd_t cmd_splash
  GRUB_MOD_INIT(xnu)
  {
    cmd_kernel = grub_register_command ("xnu_kernel", grub_cmd_xnu_kernel, 0,
-                                     "Load XNU image.");
+                                     N_("Load XNU image."));
    cmd_kernel64 = grub_register_command ("xnu_kernel64", grub_cmd_xnu_kernel64,
-                                       0, "Load 64-bit XNU image.");
+                                       0, N_("Load 64-bit XNU image."));
    cmd_mkext = grub_register_command ("xnu_mkext", grub_cmd_xnu_mkext, 0,
-                                    "Load XNU extension package.");
+                                    N_("Load XNU extension package."));
    cmd_kext = grub_register_command ("xnu_kext", grub_cmd_xnu_kext, 0,
-                                   "Load XNU extension.");
+                                   N_("Load XNU extension."));
    cmd_kextdir = grub_register_command ("xnu_kextdir", grub_cmd_xnu_kextdir,
-                                      "DIRECTORY [OSBundleRequired]",
-                                      "Load XNU extension directory.");
+                                      N_("DIRECTORY [OSBundleRequired]"),
+                                      N_("Load XNU extension directory."));
    cmd_ramdisk = grub_register_command ("xnu_ramdisk", grub_cmd_xnu_ramdisk, 0,
 -                                     N_("Load XNU ramdisk. "
 -                                     "It will be seen as md0."));
 -  cmd_splash = grub_register_command ("xnu_splash", grub_cmd_xnu_splash, 0,
 -                                    N_("Load a splash image for XNU."));
 +                                     "Load XNU ramdisk. "
 +                                     "It will be seen as md0.");
 +  cmd_splash = grub_register_extcmd ("xnu_splash",
 +                                   grub_cmd_xnu_splash,
 +                                   GRUB_COMMAND_FLAG_BOTH, 0,
-                                    "Load a splash image for XNU.",
++                                   N_("Load a splash image for XNU."),
 +                                   xnu_splash_cmd_options);
  
  #ifndef GRUB_UTIL
    cmd_resume = grub_register_command ("xnu_resume", grub_cmd_xnu_resume,
Simple merge
diff --cc normal/menu.c
Simple merge
diff --cc term/gfxterm.c
index 26e94e474cdf0232df76ae3916c5762d4cbdb2c7,a8aca78207487fdfc60d140d810f1bdb016c8cdc..c18f43fee878b99a685674cfd7989fcda95c96c9
  #include <grub/mm.h>
  #include <grub/env.h>
  #include <grub/video.h>
 +#include <grub/gfxterm.h>
  #include <grub/bitmap.h>
  #include <grub/command.h>
 +#include <grub/extcmd.h>
 +#include <grub/bitmap_scale.h>
  
- #define DEFAULT_VIDEO_MODE "auto"
+ #define DEFAULT_VIDEO_MODE    "auto"
  #define DEFAULT_BORDER_WIDTH  10
  
  #define DEFAULT_STANDARD_COLOR  0x07
@@@ -258,8 -236,10 +259,10 @@@ grub_virtual_screen_setup (unsigned in
  
    set_term_color (virtual_screen.term_color);
  
 -  grub_video_set_active_render_target (GRUB_VIDEO_RENDER_TARGET_DISPLAY);
 +  grub_video_set_active_render_target (render_target);
  
+   virtual_screen.bg_color_display = grub_video_map_rgba(0, 0, 0, 0);
    /* Clear out text buffer. */
    for (i = 0; i < virtual_screen.columns * virtual_screen.rows; i++)
      clear_char (&(virtual_screen.text_buffer[i]));
@@@ -1182,18 -952,10 +1182,14 @@@ static grub_extcmd_t background_image_c
  
  GRUB_MOD_INIT(term_gfxterm)
  {
- #ifdef GRUB_MACHINE_MIPS_YEELOONG
-   grub_term_register_output_active ("gfxterm", &grub_video_term);
- #else
    grub_term_register_output ("gfxterm", &grub_video_term);
- #endif
 -  cmd = grub_register_command ("background_image",
 -                             grub_gfxterm_background_image_cmd,
 -                             0, "Load background image for active terminal.");
 +  background_image_cmd_handle =
 +    grub_register_extcmd ("background_image",
 +                          grub_gfxterm_background_image_cmd,
 +                          GRUB_COMMAND_FLAG_BOTH,
 +                          "[-m (stretch|normal)] FILE",
 +                          "Load background image for active terminal.",
 +                          background_image_cmd_options);
  }
  
  GRUB_MOD_FINI(term_gfxterm)
Simple merge
Simple merge
index 7eb26072c0c32db0d31f6fef8bdf7dac622b3006,62d2fe321553b5d8a14c133899d3544a0ada21ac..dc87d6162c70e8d14a2d5063ae76217244036d07
@@@ -22,21 -22,12 +22,20 @@@ bindir=@bindir
  libdir=@libdir@
  . ${libdir}/grub/grub-mkconfig_lib
  
- . ${bindir}/gettext.sh
  export TEXTDOMAIN=@PACKAGE@
 -export TEXTDOMAINDIR=@localedir@
 +export TEXTDOMAINDIR=@LOCALEDIR@
 +
 +CLASS="--class os"
  
  case "${GRUB_DISTRIBUTOR}" in
 -  Debian)     OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;;
 -  *)          OS="FreeBSD" ;;
 +  Debian)
 +      OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD"
 +      CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]') --class gnu-kfreebsd --class gnu ${CLASS}"
 +  ;;
 +  *)
 +      OS="FreeBSD"
 +      CLASS="--class freebsd --class bsd ${CLASS}"
 +  ;;
  esac
  
  kfreebsd_entry ()
@@@ -46,7 -37,7 +45,7 @@@
    recovery="$3"       # not used yet
    args="$4"   # not used yet
    title="$(gettext "%s, with kFreeBSD %s")"
-   printf "menuentry \"${title}\" ${CLASS} {" ${os} ${version}
 -  printf "menuentry \"${title}\" {\n" "${os}" "${version}"
++  printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
    save_default_entry | sed -e "s/^/\t/"
    if [ -z "${prepare_boot_cache}" ]; then
      prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
index 74d8806419969ab77f9a21aa0b7aacf75bf259bd,b1c75a25bd2169381a2feaf8e56eb930fd98fa19..8d5379fd66e42e9645debf6b6627cf8422be11f2
@@@ -22,11 -22,8 +22,10 @@@ bindir=@bindir
  libdir=@libdir@
  . ${libdir}/grub/grub-mkconfig_lib
  
- . ${bindir}/gettext.sh
  export TEXTDOMAIN=@PACKAGE@
 -export TEXTDOMAINDIR=@localedir@
 +export TEXTDOMAINDIR=@LOCALEDIR@
 +
 +CLASS="--class gnu-linux --class gnu --class os"
  
  if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
    OS=GNU/Linux
@@@ -61,8 -57,17 +60,17 @@@ linux_entry (
    else
      title="$(gettext "%s, with Linux %s")"
    fi
-   printf "menuentry \"${title}\" ${CLASS} {" ${os} ${version}
 -  printf "menuentry \"${title}\" {\n" "${os}" "${version}"
++  printf "menuentry \"${title}\" ${CLASS} {\n" "${os}" "${version}"
    save_default_entry | sed -e "s/^/\t/"
+   # Use ELILO's generic "efifb" when it's known to be available.
+   # FIXME: We need an interface to select vesafb in case efifb can't be used.
+   if grep -qx "CONFIG_FB_EFI=y" /boot/config-${version} 2> /dev/null ; then
+     cat << EOF
+       set gfxpayload=keep
+ EOF
+   fi
    if [ -z "${prepare_boot_cache}" ]; then
      prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
    fi
Simple merge
Simple merge