Last active
February 9, 2021 08:13
-
-
Save diazvictor/c48b35d18d983115dcf95bdecc1260c0 to your computer and use it in GitHub Desktop.
StatusIcon – A Simple Tray Icon Application Using LGI (Lua + Gtk)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local lgi = require('lgi') | |
local Gtk = lgi.require('Gtk', '3.0') | |
function message (title) | |
--[[ | |
Function to display messages to the user. | |
]] | |
-- Create Window | |
local window = Gtk.Dialog { | |
title = title, | |
default_width = 200, | |
default_height = 200, | |
on_response = Gtk.Widget.destroy, | |
buttons = { | |
{ Gtk.STOCK_OK, Gtk.ResponseType.NONE }, | |
}, | |
} | |
-- Window Center | |
window:set_position(Gtk.WindowPosition.CENTER) | |
-- Run window | |
window:run() | |
window:hide() | |
end | |
-- Create StatusIcon | |
statusicon = Gtk.StatusIcon() | |
-- Set icon name | |
statusicon:set_from_icon_name("gtk-about") | |
-- Create Menu | |
function make_menu(event_button, event_time) | |
menu = Gtk.Menu { | |
Gtk.ImageMenuItem { | |
label = "Open App", | |
on_activate = function() | |
message("Open Application") | |
end | |
}, | |
Gtk.ImageMenuItem { | |
label = "Close App", | |
on_activate = function() | |
message("Close Application") | |
Gtk.main_quit() | |
end | |
} | |
} | |
menu:show_all() | |
menu:popup(nil, nil, nil, event_button, event_time) | |
end | |
function statusicon:on_activate() | |
message("Application") | |
end | |
function statusicon:on_popup_menu(ev, time) | |
make_menu(ev, time) | |
end | |
Gtk.main() |
como le dejo un dislike???
compartiendo y dandome una estrellita
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
como le dejo un dislike???