From 46e1b3a3514cd1f8e90e195b49a2dfbbec9e2db2 Mon Sep 17 00:00:00 2001 From: Matthias Hagmann <16444067+MattHag@users.noreply.github.com> Date: Fri, 1 Mar 2024 02:26:51 +0100 Subject: [PATCH] Convert About button to a Menu Bar entry Related #2349 --- lib/solaar/ui/__init__.py | 12 ++++++++++++ lib/solaar/ui/about.py | 2 +- lib/solaar/ui/window.py | 3 --- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/solaar/ui/__init__.py b/lib/solaar/ui/__init__.py index e383dfcf37..a0f4084b54 100644 --- a/lib/solaar/ui/__init__.py +++ b/lib/solaar/ui/__init__.py @@ -28,6 +28,7 @@ from solaar.ui.window import find_device from . import common, diversion_rules, notify, tray, window +from .about import show_window as _show_about_window gi.require_version("Gtk", "3.0") from gi.repository import Gio, GLib, Gtk # NOQA: E402 @@ -102,6 +103,17 @@ def run_loop(startup_hook, shutdown_hook, use_tray, show_window): application.connect("activate", _activate) application.connect("shutdown", _shutdown, shutdown_hook) + # Add the menu bar to the application menu + app_menu = Gio.Menu() + + about_action = Gio.SimpleAction.new("about", None) + about_action.connect("activate", _show_about_window) + application.add_action(about_action) + + app_menu.append("About", "app.about") + + application.set_app_menu(app_menu) + application.register() if application.get_is_remote(): print(_("Another Solaar process is already running so just expose its window")) diff --git a/lib/solaar/ui/about.py b/lib/solaar/ui/about.py index 427c2dfac7..6c50c9ef17 100644 --- a/lib/solaar/ui/about.py +++ b/lib/solaar/ui/about.py @@ -98,7 +98,7 @@ def _hide(dialog, event): return about -def show_window(trigger=None): +def show_window(trigger=None, *args, **kwargs): global _dialog if _dialog is None: _dialog = _create() diff --git a/lib/solaar/ui/window.py b/lib/solaar/ui/window.py index fb86d4972a..e63ed33f18 100644 --- a/lib/solaar/ui/window.py +++ b/lib/solaar/ui/window.py @@ -32,7 +32,6 @@ from . import action as _action from . import config_panel as _config_panel from . import icons as _icons -from .about import show_window as _show_about_window from .common import ui_async as _ui_async from .diversion_rules import show_window as _show_diversion_window @@ -319,8 +318,6 @@ def _create_window_layout(): bottom_buttons_box.set_spacing(20) quit_button = _new_button(_("Quit %s") % NAME, "application-exit", _SMALL_BUTTON_ICON_SIZE, clicked=destroy) bottom_buttons_box.add(quit_button) - about_button = _new_button(_("About %s") % NAME, "help-about", _SMALL_BUTTON_ICON_SIZE, clicked=_show_about_window) - bottom_buttons_box.add(about_button) diversion_button = _new_button( _("Rule Editor"), "", _SMALL_BUTTON_ICON_SIZE, clicked=lambda *_trigger: _show_diversion_window(_model) )