Skip to content

Commit

Permalink
Adapters: Set accels to close
Browse files Browse the repository at this point in the history
  • Loading branch information
infirit committed Dec 10, 2022
1 parent f45dd42 commit 84b1c81
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions blueman/main/Adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def do_quit(_: object) -> bool:
logging.error('Error: the selected adapter does not exist')
self.notebook.show_all()

close_action = Gio.SimpleAction.new("quit", None)
close_action.connect("activate", self._simple_actions)
self.add_action(close_action)

def do_activate(self) -> None:
def app_release(_plug: Gtk.Plug, _event: Gdk.Event) -> bool:
self.release()
Expand All @@ -99,13 +103,23 @@ def app_release(_plug: Gtk.Plug, _event: Gdk.Event) -> bool:

self.window.present_with_time(Gtk.get_current_event_time())

def do_startup(self) -> None:
Gtk.Application.do_startup(self)
self.set_accels_for_action("app.quit", ["<Ctrl>w", "Escape"])

def on_property_changed(self, _adapter: Adapter, name: str, value: Any, path: str) -> None:
hci_dev = os.path.basename(path)
if name == "Discoverable" and value == 0:
self.tabs[hci_dev]["hidden_radio"].set_active(True)
elif name == "Alias":
self.tabs[hci_dev]["label"].set_text(value)

def _simple_actions(self, action: Gio.Action, _val: Optional[Any]) -> None:
name = action.get_name()
logging.debug(f"Action: {name}")
if name == "quit":
self.quit()

def on_adapter_added(self, _manager: Manager, adapter_path: str) -> None:
hci_dev = os.path.basename(adapter_path)
if hci_dev not in self._adapters:
Expand Down

0 comments on commit 84b1c81

Please sign in to comment.