Use pixmapbar only when images available
This commit is contained in:
parent
b9d28aa05f
commit
ea51afb099
1 changed files with 11 additions and 1 deletions
|
@ -46,6 +46,7 @@ struct grub_gui_progress_bar
|
||||||
|
|
||||||
char *theme_dir;
|
char *theme_dir;
|
||||||
int need_to_recreate_pixmaps;
|
int need_to_recreate_pixmaps;
|
||||||
|
int pixmapbar_available;
|
||||||
char *bar_pattern;
|
char *bar_pattern;
|
||||||
char *highlight_pattern;
|
char *highlight_pattern;
|
||||||
grub_gfxmenu_box_t bar_box;
|
grub_gfxmenu_box_t bar_box;
|
||||||
|
@ -77,6 +78,8 @@ progress_bar_is_instance (void *vself __attribute__((unused)), const char *type)
|
||||||
static int
|
static int
|
||||||
check_pixmaps (grub_gui_progress_bar_t self)
|
check_pixmaps (grub_gui_progress_bar_t self)
|
||||||
{
|
{
|
||||||
|
if (!self->pixmapbar_available)
|
||||||
|
return 0;
|
||||||
if (self->need_to_recreate_pixmaps)
|
if (self->need_to_recreate_pixmaps)
|
||||||
{
|
{
|
||||||
grub_gui_recreate_box (&self->bar_box,
|
grub_gui_recreate_box (&self->bar_box,
|
||||||
|
@ -137,6 +140,7 @@ draw_pixmap_bar (grub_gui_progress_bar_t self)
|
||||||
int bar_v_pad = bar_t_pad + bar_b_pad;
|
int bar_v_pad = bar_t_pad + bar_b_pad;
|
||||||
int tracklen = w - bar_h_pad;
|
int tracklen = w - bar_h_pad;
|
||||||
int trackheight = h - bar_v_pad;
|
int trackheight = h - bar_v_pad;
|
||||||
|
|
||||||
bar->set_content_size (bar, tracklen, trackheight);
|
bar->set_content_size (bar, tracklen, trackheight);
|
||||||
|
|
||||||
int barwidth = (tracklen
|
int barwidth = (tracklen
|
||||||
|
@ -172,12 +176,16 @@ static void
|
||||||
progress_bar_paint (void *vself, const grub_video_rect_t *region)
|
progress_bar_paint (void *vself, const grub_video_rect_t *region)
|
||||||
{
|
{
|
||||||
grub_gui_progress_bar_t self = vself;
|
grub_gui_progress_bar_t self = vself;
|
||||||
|
grub_video_rect_t vpsave;
|
||||||
|
|
||||||
if (! self->visible)
|
if (! self->visible)
|
||||||
return;
|
return;
|
||||||
if (!grub_video_have_common_points (region, &self->bounds))
|
if (!grub_video_have_common_points (region, &self->bounds))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
grub_video_rect_t vpsave;
|
if (self->end == self->start)
|
||||||
|
return;
|
||||||
|
|
||||||
grub_gui_set_viewport (&self->bounds, &vpsave);
|
grub_gui_set_viewport (&self->bounds, &vpsave);
|
||||||
|
|
||||||
if (check_pixmaps (self))
|
if (check_pixmaps (self))
|
||||||
|
@ -272,12 +280,14 @@ progress_bar_set_property (void *vself, const char *name, const char *value)
|
||||||
else if (grub_strcmp (name, "bar_style") == 0)
|
else if (grub_strcmp (name, "bar_style") == 0)
|
||||||
{
|
{
|
||||||
self->need_to_recreate_pixmaps = 1;
|
self->need_to_recreate_pixmaps = 1;
|
||||||
|
self->pixmapbar_available = 1;
|
||||||
grub_free (self->bar_pattern);
|
grub_free (self->bar_pattern);
|
||||||
self->bar_pattern = value ? grub_strdup (value) : 0;
|
self->bar_pattern = value ? grub_strdup (value) : 0;
|
||||||
}
|
}
|
||||||
else if (grub_strcmp (name, "highlight_style") == 0)
|
else if (grub_strcmp (name, "highlight_style") == 0)
|
||||||
{
|
{
|
||||||
self->need_to_recreate_pixmaps = 1;
|
self->need_to_recreate_pixmaps = 1;
|
||||||
|
self->pixmapbar_available = 1;
|
||||||
grub_free (self->highlight_pattern);
|
grub_free (self->highlight_pattern);
|
||||||
self->highlight_pattern = value ? grub_strdup (value) : 0;
|
self->highlight_pattern = value ? grub_strdup (value) : 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue