From a41f471bd645c6581ca0db28a8a07eb963f9e109 Mon Sep 17 00:00:00 2001 From: Diaz Urbaneja Victor Diego Alenjandro Date: Sat, 30 Jan 2021 20:04:33 -0400 Subject: [PATCH] added src/moonterm-menu.lua and removed src/moonterm-popover.lua removed headerbar popover added new menu --- moonterm.lua | 2 +- src/moonterm-app.lua | 9 +------- src/moonterm-menu.lua | 46 ++++++++++++++++++++++++++++++++++++++++ src/moonterm-popover.lua | 30 -------------------------- 4 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 src/moonterm-menu.lua delete mode 100644 src/moonterm-popover.lua diff --git a/moonterm.lua b/moonterm.lua index efdf926..eb5ddc1 100644 --- a/moonterm.lua +++ b/moonterm.lua @@ -26,8 +26,8 @@ dir = ('%s/moonterm'):format(GLib.get_user_config_dir()) conf = inifile:load(('%s/moonterm.ini'):format(dir)) -- MoonTerm -require('src.moonterm-popover') require('src.moonterm-app') +require('src.moonterm-menu') require('src.moonterm-dialog') require('src.moonterm-keybinds') diff --git a/src/moonterm-app.lua b/src/moonterm-app.lua index 3142032..705e28a 100644 --- a/src/moonterm-app.lua +++ b/src/moonterm-app.lua @@ -26,14 +26,7 @@ main_window = Gtk.Window { headerbar = Gtk.HeaderBar { title = 'MoonTerm', subtitle = 'a minimalist and customizable terminal in lua', - show_close_button = true, - Gtk.MenuButton { - visible = true, - can_focus = false, - popover = popover_menu, - on_clicked = function () popover_menu:show_all() end, - Gtk.Image({icon_name = "gtk-justify-fill"}) - } + show_close_button = true } interpreter = utils:path_name(conf.moonterm.interpreter)['name'] diff --git a/src/moonterm-menu.lua b/src/moonterm-menu.lua new file mode 100644 index 0000000..3e5fc4a --- /dev/null +++ b/src/moonterm-menu.lua @@ -0,0 +1,46 @@ +--[[-- + @package MoonTerm + @filename moonterm-menu.lua + @version 1.0 + @autor Diaz Urbaneja Victor Diego Alejandro + @date 30.01.2021 19:54:09 -04 +]] + +function main_window:on_button_press_event(event) + if (event.type == 'BUTTON_PRESS' and event.button == 3) then + menu = Gtk.Menu { + Gtk.ImageMenuItem { + label = "Preferences", + image = Gtk.Image { + stock = "gtk-preferences" + }, + on_activate = function() + dialog_config:show_all() + end + }, + Gtk.ImageMenuItem { + label = "About Moonterm", + image = Gtk.Image { + stock = "gtk-about" + }, + on_activate = function() + about_window:run() + about_window:hide() + end + }, + Gtk.SeparatorMenuItem {}, + Gtk.ImageMenuItem { + label = "Quit", + image = Gtk.Image { + stock = "gtk-quit" + }, + on_activate = function() + app:quit() + end + } + } + menu:attach_to_widget(main_window, null) + menu:show_all() + menu:popup(nil, nil, nil, event.button, event.time) + end +end diff --git a/src/moonterm-popover.lua b/src/moonterm-popover.lua deleted file mode 100644 index 2838eb4..0000000 --- a/src/moonterm-popover.lua +++ /dev/null @@ -1,30 +0,0 @@ ---[[-- - @package MoonTerm - @filename moonterm-popover.lua - @version 1.0 - @autor Diaz Urbaneja Victor Diego Alejandro - @date 22.01.2021 01:40:09 -04 -]] - -popover_menu = Gtk.Popover({ - Gtk.Box { - orientation = 'VERTICAL', - Gtk.ModelButton { - id = 'btn_preferences', - label = "Preferences", - can_focus = false, - on_clicked = function () dialog_config:show_all() end, - }, - Gtk.ModelButton { - label = "About Moonterm", - can_focus = false, - on_clicked = function () about_window:run() about_window:hide() end, - }, - Gtk.Separator{}, - Gtk.ModelButton { - can_focus = false, - label = "Quit", - on_clicked = function () app:quit() end, - }, - }, -}) \ No newline at end of file