Skip to content

Commit

Permalink
Convert About button to a Menu Bar entry
Browse files Browse the repository at this point in the history
  • Loading branch information
MattHag committed Mar 1, 2024
1 parent e53b538 commit 46e1b3a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lib/solaar/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion lib/solaar/ui/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions lib/solaar/ui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
)
Expand Down

1 comment on commit 46e1b3a

@MattHag
Copy link
Owner Author

@MattHag MattHag commented on 46e1b3a Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs check on Linux

Please sign in to comment.