2021-11-28 12:28:57 +03:00
|
|
|
/**
|
|
|
|
* @brief Panel "Applications" menu widget
|
|
|
|
*/
|
|
|
|
#include <toaru/yutani.h>
|
|
|
|
#include <toaru/yutani-internal.h>
|
|
|
|
#include <toaru/graphics.h>
|
|
|
|
#include <toaru/hashmap.h>
|
|
|
|
#include <toaru/menu.h>
|
|
|
|
#include <toaru/text.h>
|
|
|
|
#include <toaru/panel.h>
|
|
|
|
|
|
|
|
static struct MenuList * appmenu;
|
|
|
|
|
|
|
|
static int widget_draw_appmenu(struct PanelWidget * this, gfx_context_t * ctx) {
|
|
|
|
tt_set_size(font, 16);
|
2021-11-29 09:04:17 +03:00
|
|
|
tt_draw_string(ctx, font, 0, 20, "Applications", appmenu->window ? HILIGHT_COLOR : TEXT_COLOR);
|
2021-11-28 12:28:57 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int widget_click_appmenu(struct PanelWidget * this, struct yutani_msg_window_mouse_event * evt) {
|
|
|
|
if (!appmenu->window) {
|
2021-11-29 09:04:17 +03:00
|
|
|
panel_menu_show(this,appmenu);
|
2021-11-28 12:28:57 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-08 09:35:20 +03:00
|
|
|
static int widget_onkey_appmenu(struct PanelWidget * this, struct yutani_msg_key_event * ke) {
|
|
|
|
if ((ke->event.modifiers & KEY_MOD_LEFT_ALT) &&
|
|
|
|
(ke->event.keycode == KEY_F1) &&
|
|
|
|
(ke->event.action == KEY_ACTION_DOWN)) {
|
|
|
|
panel_menu_show(this,appmenu);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-11-28 12:28:57 +03:00
|
|
|
struct PanelWidget * widget_init_appmenu(void) {
|
|
|
|
appmenu = menu_set_get_root(menu_set_from_description("/etc/panel.menu", launch_application_menu));
|
|
|
|
appmenu->flags = MENU_FLAG_BUBBLE_CENTER;
|
|
|
|
|
2021-12-08 09:35:20 +03:00
|
|
|
/* Bind Alt+F1 */
|
|
|
|
yutani_key_bind(yctx, KEY_F1, KEY_MOD_LEFT_ALT, YUTANI_BIND_STEAL);
|
|
|
|
|
2021-11-28 12:28:57 +03:00
|
|
|
struct PanelWidget * widget = widget_new();
|
2021-11-29 09:04:17 +03:00
|
|
|
widget->width = 130;
|
2021-11-28 12:28:57 +03:00
|
|
|
widget->draw = widget_draw_appmenu;
|
|
|
|
widget->click = widget_click_appmenu;
|
2021-12-08 09:35:20 +03:00
|
|
|
widget->onkey = widget_onkey_appmenu;
|
2021-11-28 12:28:57 +03:00
|
|
|
list_insert(widgets_enabled, widget);
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|