From ff4e91e49c23ba7d2aa9ec8c8094154821808df7 Mon Sep 17 00:00:00 2001 From: Nico Alt <nicoalt@posteo.org> Date: Tue, 1 Sep 2020 20:00:03 +0000 Subject: [PATCH] Set urgent window flag on incoming messages and added contacts Using GTK's Window.set_urgency_hint: https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Window.html#Gtk.Window.set_urgency_hint Additional info: https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#URGENCY Closes #57. --- briar-gtk/briar_gtk/containers/main_window.py | 10 ++++++---- briar-gtk/briar_gtk/window.py | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/briar-gtk/briar_gtk/containers/main_window.py b/briar-gtk/briar_gtk/containers/main_window.py index 32a582f..c6f8e6c 100644 --- a/briar-gtk/briar_gtk/containers/main_window.py +++ b/briar-gtk/briar_gtk/containers/main_window.py @@ -191,14 +191,16 @@ class MainWindowContainer(Container): self.contacts_list_box.select_row(contact_row) # pylint: disable=unused-argument - def _refresh_contacts_async(self, message): - GLib.idle_add(self._refresh_contacts) + def _refresh_contacts_async(self, message, urgent=True): + GLib.idle_add(self._refresh_contacts, urgent) # pylint: disable=unused-argument def _refresh_contact_state(self, contact_id, connected): - self._refresh_contacts_async(None) + self._refresh_contacts_async(None, False) - def _refresh_contacts(self): + def _refresh_contacts(self, urgent): + if urgent: + APP().window.set_urgency_hint(True) self._save_selected_row() self._clear_contact_list() self._load_contacts() diff --git a/briar-gtk/briar_gtk/window.py b/briar-gtk/briar_gtk/window.py index 851664c..ab71323 100644 --- a/briar-gtk/briar_gtk/window.py +++ b/briar-gtk/briar_gtk/window.py @@ -19,6 +19,7 @@ class Window(Gtk.ApplicationWindow): self._initialize_gtk_application_window() WindowActions(self) self._setup_content() + self._setup_focus_listener() def show_main_container(self): self.current_container.destroy() @@ -37,6 +38,14 @@ class Window(Gtk.ApplicationWindow): self._resize_window(self.DEFAULT_WINDOW_SIZE) self._setup_startup_container() + def _setup_focus_listener(self): + self.connect("focus-in-event", self._on_focus_change) + self.connect("focus-out-event", self._on_focus_change) + + # pylint: disable=unused-argument + def _on_focus_change(self, widget, event): + self.set_urgency_hint(False) + def _resize_window(self, size): if not Window._size_is_valid(size): raise Exception("Couldn't resize window; invalid size parameter") -- GitLab