wip
This commit is contained in:
parent
0e367796c0
commit
46d94cf575
@ -138,6 +138,7 @@ GRUB_MOD_INIT (gfxmenu)
|
||||
{
|
||||
term->fullscreen ();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
grub_gfxmenu_try_hook = grub_gfxmenu_try;
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include <grub/gui_string_util.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/color.h>
|
||||
#include <grub/datetime.h>
|
||||
|
||||
static const char *align_options[] =
|
||||
{
|
||||
@ -33,30 +34,6 @@ static const char *align_options[] =
|
||||
0
|
||||
};
|
||||
|
||||
enum align_mode {
|
||||
align_left,
|
||||
align_center,
|
||||
align_right
|
||||
};
|
||||
|
||||
struct grub_gui_label
|
||||
{
|
||||
struct grub_gui_component comp;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
int visible;
|
||||
char *text;
|
||||
char *template;
|
||||
grub_font_t font;
|
||||
grub_video_rgba_color_t color;
|
||||
int value;
|
||||
enum align_mode align;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_label *grub_gui_label_t;
|
||||
|
||||
static void
|
||||
label_destroy (void *vself)
|
||||
{
|
||||
@ -228,6 +205,7 @@ label_set_property (void *vself, const char *name, const char *value)
|
||||
else if (grub_strcmp (name, "id") == 0)
|
||||
{
|
||||
grub_gfxmenu_timeout_unregister ((grub_gui_component_t) self);
|
||||
grub_gfxmenu_time_unregister();
|
||||
grub_free (self->id);
|
||||
if (value)
|
||||
self->id = grub_strdup (value);
|
||||
@ -237,6 +215,20 @@ label_set_property (void *vself, const char *name, const char *value)
|
||||
== 0)
|
||||
grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
|
||||
label_set_state);
|
||||
else if (self->id && grub_strcmp(self->id, GRUB_GFXMENU_DATE_COMPONENT_ID) == 0) {
|
||||
|
||||
struct grub_datetime datetime;
|
||||
grub_get_datetime(&datetime);
|
||||
//grub_gfxmenu_
|
||||
char* valtmp = grub_strdup (value);
|
||||
grub_snprintf(valtmp, 100, "%d-%02d-%02d %02d:%02d:%02d %s\n",
|
||||
datetime.year, datetime.month, datetime.day,
|
||||
datetime.hour, datetime.minute, datetime.second,
|
||||
grub_get_weekday_name(&datetime));
|
||||
value = valtmp;
|
||||
grub_gfxmenu_time_register((grub_gui_component_t)self, label_set_state);
|
||||
|
||||
}
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/datetime.h>
|
||||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
@ -134,6 +135,9 @@ grub_gfxmenu_view_destroy (grub_gfxmenu_view_t view)
|
||||
grub_gfxmenu_timeout_notifications = grub_gfxmenu_timeout_notifications->next;
|
||||
grub_free (p);
|
||||
}
|
||||
struct grub_gfxmenu_time_notify *p;
|
||||
p = grub_gfxmenu_time_notification;
|
||||
grub_free (p);
|
||||
grub_video_bitmap_destroy (view->raw_desktop_image);
|
||||
grub_video_bitmap_destroy (view->scaled_desktop_image);
|
||||
if (view->terminal_box)
|
||||
@ -258,6 +262,27 @@ update_menu_visit (grub_gui_component_t component,
|
||||
}
|
||||
}
|
||||
|
||||
struct grub_gfxmenu_time_notify * grub_gfxmenu_time_notification;
|
||||
|
||||
static void redraw_time(struct grub_gfxmenu_view *view)
|
||||
{
|
||||
struct grub_gfxmenu_time_notify* cur = grub_gfxmenu_time_notification;
|
||||
grub_gui_label_t self = (grub_gui_label_t)cur->self;
|
||||
|
||||
struct grub_datetime datetime;
|
||||
grub_get_datetime(&datetime);
|
||||
char* valtmp = grub_strdup (self->text);
|
||||
grub_snprintf(valtmp, 100, "%d-%02d-%02d %02d:%02d:%02d %s\n",
|
||||
datetime.year, datetime.month, datetime.day,
|
||||
datetime.hour, datetime.minute, datetime.second,
|
||||
grub_get_weekday_name(&datetime));
|
||||
self->text = valtmp;
|
||||
grub_video_rect_t bounds;
|
||||
cur->self->ops->get_bounds (cur->self, &bounds);
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_ENABLED);
|
||||
grub_gfxmenu_view_redraw (view, &bounds);
|
||||
}
|
||||
|
||||
/* Update any boot menu components with the current menu model and
|
||||
theme path. */
|
||||
static void
|
||||
@ -367,7 +392,7 @@ grub_gfxmenu_view_draw (grub_gfxmenu_view_t view)
|
||||
grub_video_set_area_status (GRUB_VIDEO_AREA_DISABLED);
|
||||
grub_gfxmenu_view_redraw (view, &view->screen);
|
||||
}
|
||||
|
||||
redraw_time(view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
/* The component ID identifying GUI components to be updated as the timeout
|
||||
status changes. */
|
||||
#define GRUB_GFXMENU_TIMEOUT_COMPONENT_ID "__timeout__"
|
||||
#define GRUB_GFXMENU_DATE_COMPONENT_ID "__time__"
|
||||
|
||||
typedef struct grub_gui_component *grub_gui_component_t;
|
||||
typedef struct grub_gui_container *grub_gui_container_t;
|
||||
@ -86,7 +87,31 @@ struct grub_gfxmenu_timeout_notify
|
||||
grub_gui_component_t self;
|
||||
};
|
||||
|
||||
extern struct grub_gfxmenu_timeout_notify *grub_gfxmenu_timeout_notifications;
|
||||
extern struct grub_gfxmenu_timeout_notify* grub_gfxmenu_timeout_notifications;
|
||||
|
||||
struct grub_gfxmenu_time_notify {
|
||||
grub_gfxmenu_set_state_t set_state;
|
||||
grub_gui_component_t self;
|
||||
};
|
||||
|
||||
extern struct grub_gfxmenu_time_notify* grub_gfxmenu_time_notification;
|
||||
|
||||
static inline grub_err_t grub_gfxmenu_time_register(grub_gui_component_t self,
|
||||
grub_gfxmenu_set_state_t set_state) {
|
||||
struct grub_gfxmenu_time_notify* te = grub_malloc(sizeof(*te));
|
||||
if (!te)
|
||||
return grub_errno;
|
||||
te->set_state = set_state;
|
||||
te->self = self;
|
||||
grub_gfxmenu_time_notification = te;
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
}
|
||||
static inline void grub_gfxmenu_time_unregister(void)
|
||||
{
|
||||
if(grub_gfxmenu_time_notification)
|
||||
grub_free(grub_gfxmenu_time_notification) ;
|
||||
}
|
||||
|
||||
static inline grub_err_t
|
||||
grub_gfxmenu_timeout_register (grub_gui_component_t self,
|
||||
@ -200,7 +225,28 @@ struct grub_gui_list
|
||||
struct grub_gui_component component;
|
||||
struct grub_gui_list_ops *ops;
|
||||
};
|
||||
enum align_mode {
|
||||
align_left,
|
||||
align_center,
|
||||
align_right
|
||||
};
|
||||
struct grub_gui_label
|
||||
{
|
||||
struct grub_gui_component comp;
|
||||
|
||||
grub_gui_container_t parent;
|
||||
grub_video_rect_t bounds;
|
||||
char *id;
|
||||
int visible;
|
||||
char *text;
|
||||
char *template;
|
||||
grub_font_t font;
|
||||
grub_video_rgba_color_t color;
|
||||
int value;
|
||||
enum align_mode align;
|
||||
};
|
||||
|
||||
typedef struct grub_gui_label *grub_gui_label_t;
|
||||
|
||||
/* Interfaces to concrete component classes. */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user