Deskmenu
Deskmenu is a small desktop app launcher. By default is shows couple of apps and launches them when selected. Written in plain Ano script, no C involved.
Deskmenu demonstrates how to attach menu to widget and external command calling in widget callback function, as well how to set some window attributes, like borderless and keep-above.
User interface
Menu pops up by pressing middle mouse button, or alternatively keep <ctrl> key pressed while pressing left mouse button.
Compilation
Easiest way to get Deskmenu running is to go to examples directory in package root, and run:
$ ./build.sh gui_deskmenu
build.sh script compiles Ano script, menu and widget definitions to C, copies source files in place and pops up instructions what to do next. Follow them. Check also examples/README for more info.
Screenshots
Preview
; ; This little application pops up a launcher menu. ; ; @ANO_SCRIPT_NAME gui_deskmenu ; @ANO_SCRIPT_VERSION 0.0.2 ; @ANO_SCRIPT_DESCRIPTION Simple application launcher menu ; ; @ANO_FLAGS_VAR_NAME_SUBS [x] ; @ANO_FLAGS_VAR_WARN_UNUSED [ ] ; ; Copyright (c) 2016-2023, Jani Salonen <salojan at goto10 piste co> ; All rights reserved. ; ; Global uninitialized variables var [handle] handle_window_main ; Initialize windowing system window_init ; Open main window window_open (NULL, NULL, \ [handle] @0, [uint] 1, [uint] 0, [uint] 0, \ [int] -1, [int] -1, [uint] 200, [uint] 40, \ NULL, NULL, NULL, NULL, NULL, NULL, \ NULL, NULL, "cb_destroy", \ NULL, NULL, NULL, "cb_open") end callback cb_open (_hnd) { mov handle_window_main (_hnd) ; Window to above all others, 1 = above, 1 = set window_set_attrs (handle_window_main, 1, 1) ; Window border off, 3 = border, 0 = unset window_set_attrs (handle_window_main, 3, 0) ; Map main window window_map (handle_window_main) } callback cb_destroy { window_close (handle_window_main) exit } callback cb_button_press (_x, _y, _x_root, _y_root, _state, _button) { } callback cb_exit (_item, _position, _tag, _flag) { jmp "cb_destroy" } callback cb_launch (_item, _position, _tag, _flag) { ; Internet menu cmp _tag (1) jne "cb_launch_1" call "cb_launch_it" ("firefox") end : "cb_launch_1" cmp _tag (2) jne "cb_launch_2" call "cb_launch_it" ("opera") end : "cb_launch_2" ; Multimedia menu cmp _tag (10) jne "cb_launch_10" call "cb_launch_it" ("vlc") end : "cb_launch_10" } function cb_launch_it (_app) { ; Execute the application exec (_app) }
; ; Copyright (c) 2016-2023, Jani Salonen <salojan at goto10 piste co> ; All rights reserved. ; ; @WIDGET_USE_BOUNDING_BOXES no ; window "1" { set "0" { widget "background" { name "background" state enable color "rgb:#000000" } widget "block" { name "launcher" state enable position x = 0, y = 0 size width = 200, height = 40 color "rgba:#ffffddff" border color = rgba:#5aa6bbff, thickness = 2 ; This empty callback is needed for menu to pop up action buttonpress = cb_button_press } widget "label" { name "label" state enable position x = 100, y = 4 label "MMB to start", \ charset = UTF-8, size = 12, \ color = rgb:#441111, \ justification = center } } }
; ; Copyright (c) 2016-2023, Jani Salonen <salojan at goto10 piste co> ; All rights reserved. ; ; ; container_type "name" { ; window "1" { widget "launcher" { ; ; menu "name" { optional_icon ; menu "Internet" { examples/datafiles/dm_inet.tga ; ; type "name", id, callback_func, flags, optional_icon ; item "Firefox", 1, cb_launch, none, examples/datafiles/dm_inet_ff.tga item "Opera", 2, cb_launch, none, examples/datafiles/dm_inet_op.tga } menu "Multimedia" { examples/datafiles/dm_mm.tga item "VLC Player", 10, cb_launch, none, examples/datafiles/dm_mm_vlc.tga } menu "Session" { examples/datafiles/dm_ss.tga item "Exit Deskmenu", 20, cb_exit, none, examples/datafiles/dm_ss_exit.tga } } }
Copyright © 2023, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.