gajim.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2026
October
September
August
July
June
May
April
March
February
January
2025
December
November
October
September
August
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
List overview
Download
Commits
----- 2026 -----
October 2026
September 2026
August 2026
July 2026
June 2026
May 2026
April 2026
March 2026
February 2026
January 2026
----- 2025 -----
December 2025
November 2025
October 2025
September 2025
August 2025
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
commits@gajim.org
17632 discussions
Start a n
N
ew thread
[Git][gajim/gajim][master] Contacts: Return always BareContact for get_real_contact()
by Philipp Hörist (ï¼ lovetox)
10 Jan '22
10 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 734ef1da by lovetox at 2022-01-10T14:18:26+01:00 Contacts: Return always BareContact for get_real_contact() - - - - - 1 changed file: - gajim/common/modules/contacts.py Changes: ===================================== gajim/common/modules/contacts.py ===================================== @@ -659,7 +659,8 @@ def get_real_contact(self) -> Optional[BareContact]: jid = self._presence.real_jid if jid is None: return None - return self._client.get_module('Contacts').get_contact(jid) + return self._client.get_module('Contacts').get_contact( + jid.new_as_bare()) @property def affiliation(self) -> Affiliation: View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/734ef1da0cc1f3ed99a15c10d9b891d2…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/734ef1da0cc1f3ed99a15c10d9b891d2…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 3 commits: SideBarSwitcher: Refactor
by Philipp Hörist (ï¼ lovetox)
10 Jan '22
10 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 8bdfd833 by lovetox at 2022-01-09T23:52:04+01:00 SideBarSwitcher: Refactor - Add type annotations - Add posibility to hide all rows at start - - - - - bee1a5a7 by lovetox at 2022-01-10T14:14:37+01:00 Contacts: Add new methods - get_address() - get_real_contact() - resource property - - - - - 0f0c2db4 by lovetox at 2022-01-10T14:14:43+01:00 ContactInfo: Refactor Dialog - Add type annotations - Simplify code and make it more readable - - - - - 6 changed files: - gajim/common/modules/contacts.py - gajim/data/gui/contact_info.ui - gajim/gtk/builder.pyi - gajim/gtk/contact_info.py - gajim/gtk/sidebar_switcher.py - pyrightconfig.json Changes: ===================================== gajim/common/modules/contacts.py ===================================== @@ -213,6 +213,9 @@ def is_groupchat(self) -> bool: def is_pm_contact(self) -> bool: return False + def get_address(self, _prefer_real: bool = True) -> JID: + return self._jid + def force_chatstate_update(self) -> None: for contact in self._resources.values(): contact.notify('chatstate-update') @@ -417,6 +420,10 @@ def supports(self, requested_feature: str) -> bool: return False return CommonContact.supports(self, requested_feature) + @property + def resource(self) -> str: + return self._jid.resource + @property def identity_type(self) -> Optional[str]: disco_info = app.storage.cache.get_last_disco_info(self._jid) @@ -592,6 +599,16 @@ def __init__(self, logger: logging.Logger, jid: JID, account: str) -> None: self._presence = UNKNOWN_MUC_PRESENCE + @property + def resource(self) -> str: + return self._jid.resource + + def get_address(self, prefer_real: bool = True) -> JID: + jid = self._presence.real_jid + if jid is None or not prefer_real: + return self._jid + return jid + def supports(self, requested_feature: str) -> bool: if not self.is_available: return False @@ -638,6 +655,12 @@ def name(self) -> str: def real_jid(self) -> Optional[JID]: return self._presence.real_jid + def get_real_contact(self) -> Optional[BareContact]: + jid = self._presence.real_jid + if jid is None: + return None + return self._client.get_module('Contacts').get_contact(jid) + @property def affiliation(self) -> Affiliation: return self._presence.affiliation ===================================== gajim/data/gui/contact_info.ui ===================================== @@ -2,6 +2,174 @@ <!-- Generated with glade 3.38.2 --> <interface> <requires lib="gtk+" version="3.24"/> + <!-- n-columns=2 n-rows=6 --> + <object class="GtkGrid" id="devices_grid"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="row-spacing">6</property> + <property name="column-spacing">12</property> + <property name="column-homogeneous">True</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Status</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="priority_label"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="label" translatable="yes">Priority</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="software_label"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="label" translatable="yes">Software</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="system_label"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="label" translatable="yes">Operating System</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="time_label"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="label" translatable="yes">Local Time</property> + <property name="xalign">1</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">5</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="status_value"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="priority_value"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="software_value"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="system_value"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="time_value"> + <property name="can-focus">False</property> + <property name="no-show-all">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">5</property> + </packing> + </child> + <child> + <object class="GtkBox" id="resource_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-bottom">12</property> + <property name="spacing">12</property> + <child> + <object class="GtkLabel" id="resource_label"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <style> + <class name="bold16"/> + </style> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + <property name="width">2</property> + </packing> + </child> + </object> <object class="GtkListStore" id="groups_model"> <columns> <!-- column-name is_in_group --> @@ -20,6 +188,8 @@ <property name="height-request">450</property> <property name="visible">True</property> <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="orientation">vertical</property> <child> <object class="GtkRevealer" id="header_revealer"> @@ -171,8 +341,7 @@ <object class="GtkGrid" id="group_chat_grid"> <property name="can-focus">False</property> <property name="no-show-all">True</property> - <property name="halign">center</property> - <property name="row-spacing">6</property> + <property name="row-spacing">12</property> <property name="column-spacing">12</property> <property name="column-homogeneous">True</property> <child> @@ -180,6 +349,7 @@ <property name="visible">True</property> <property name="can-focus">False</property> <property name="halign">end</property> + <property name="margin-end">18</property> <property name="label" translatable="yes">Role</property> <style> <class name="dim-label"/> @@ -206,6 +376,7 @@ <property name="visible">True</property> <property name="can-focus">False</property> <property name="halign">end</property> + <property name="margin-end">18</property> <property name="label" translatable="yes">Affiliation</property> <style> <class name="dim-label"/> @@ -711,42 +882,15 @@ <property name="visible">True</property> <property name="can-focus">False</property> <child> - <object class="GtkBox"> + <object class="GtkBox" id="devices_box"> <property name="visible">True</property> <property name="can-focus">False</property> <property name="halign">center</property> <property name="border-width">18</property> - <property name="spacing">12</property> - <child> - <!-- n-columns=1 n-rows=1 --> - <object class="GtkGrid" id="devices_grid"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="row-spacing">6</property> - <property name="column-spacing">12</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> + <property name="orientation">vertical</property> + <property name="spacing">24</property> <child> - <object class="GtkSpinner" id="devices_spinner"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="halign">end</property> - <property name="valign">start</property> - <property name="active">True</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> + <placeholder/> </child> </object> </child> ===================================== gajim/gtk/builder.pyi ===================================== @@ -595,6 +595,18 @@ class ChatPanedBuilder(Builder): class ContactInfoBuilder(Builder): + devices_grid: Gtk.Grid + priority_label: Gtk.Label + software_label: Gtk.Label + system_label: Gtk.Label + time_label: Gtk.Label + status_value: Gtk.Label + priority_value: Gtk.Label + software_value: Gtk.Label + system_value: Gtk.Label + time_value: Gtk.Label + resource_box: Gtk.Box + resource_label: Gtk.Label groups_model: Gtk.ListStore main_grid: Gtk.Grid header_revealer: Gtk.Revealer @@ -627,8 +639,7 @@ class ContactInfoBuilder(Builder): scrolledwindow_annotation: Gtk.ScrolledWindow textview_annotation: Gtk.TextView devices_stack: Gtk.Stack - devices_grid: Gtk.Grid - devices_spinner: Gtk.Spinner + devices_box: Gtk.Box class GroupchatInfoScrolledBuilder(Builder): ===================================== gajim/gtk/contact_info.py ===================================== @@ -1,4 +1,3 @@ -# # This file is part of Gajim. # # Gajim is free software; you can redistribute it and/or modify @@ -13,26 +12,36 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. -import logging +from __future__ import annotations + +from typing import Optional +from typing import Union +import logging from enum import IntEnum from gi.repository import Gtk -from gi.repository import GLib from gi.repository import Gdk +from gi.repository import GObject +from nbxmpp.task import Task from nbxmpp.errors import StanzaError -from nbxmpp.structs import AnnotationNote +from nbxmpp.structs import AnnotationNote, SoftwareVersionResult from nbxmpp.modules.vcard4 import VCard from gajim.common import app from gajim.common import ged from gajim.common.const import AvatarSize +from gajim.common.events import SubscribedPresenceReceived +from gajim.common.events import UnsubscribedPresenceReceived from gajim.common.helpers import get_uf_affiliation from gajim.common.helpers import get_uf_role from gajim.common.helpers import get_uf_show from gajim.common.i18n import _ from gajim.common.ged import EventHelper +from gajim.common.modules.contacts import BareContact +from gajim.common.modules.contacts import ResourceContact +from gajim.common.modules.contacts import GroupchatParticipant from .dialogs import ConfirmationDialog from .dialogs import DialogButton @@ -44,13 +53,21 @@ log = logging.getLogger('gajim.gui.contact_info') +ContactT = Union[BareContact, GroupchatParticipant] +DeviceContactT = Union[ResourceContact, GroupchatParticipant] + + class Column(IntEnum): IN_GROUP = 0 GROUP_NAME = 1 class ContactInfo(Gtk.ApplicationWindow, EventHelper): - def __init__(self, account, contact, page=None): + def __init__(self, + account: str, + contact: ContactT, + page: Optional[str] = None) -> None: + Gtk.ApplicationWindow.__init__(self) EventHelper.__init__(self) self.set_application(app.app) @@ -69,147 +86,172 @@ def __init__(self, account, contact, page=None): self._ui = get_builder('contact_info.ui') - side_bar_switcher = SideBarSwitcher() - side_bar_switcher.set_stack(self._ui.main_stack) - self._ui.main_grid.attach(side_bar_switcher, 0, 0, 1, 1) - self._ui.main_stack.connect('notify', self._on_stack_child_changed) + self._tasks: list[Task] = [] + self._devices: dict[str, DeviceGrid] = {} - self._ui.name_entry.set_text(contact.name) + self._switcher = SideBarSwitcher() + self._switcher.set_stack(self._ui.main_stack, rows_visible=False) + self._ui.main_grid.attach(self._switcher, 0, 0, 1, 1) + self._ui.main_stack.connect('notify::visible-child-name', + self._on_stack_child_changed) + self._ui.name_entry.set_text(contact.name) if contact.is_in_roster: self._ui.edit_name_button.show() - self._fill_groups_page() - if contact.is_gateway: - side_bar_switcher.hide_row('settings') - side_bar_switcher.hide_row('devices') - else: - self._fill_settings_page() - else: - side_bar_switcher.hide_row('settings') - side_bar_switcher.hide_row('groups') - side_bar_switcher.hide_row('notes') - if contact.is_pm_contact: - if contact.real_jid is None: - side_bar_switcher.hide_row('devices') - else: - side_bar_switcher.hide_row('devices') + + self._load_avatar() + self._fill_information_page() + self._fill_settings_page() + self._fill_device_info() + self._fill_groups_page() + self._fill_note_page() if page is not None: - # Jump to specific page if parameter is supplied - side_bar_switcher.set_row(page) + self._switcher.set_row(page) - self._tasks = [] + self._ui.connect_signals(self) + self.connect('key-press-event', self._on_key_press) + self.connect('destroy', self._on_destroy) # pylint: disable=line-too-long + connect_destroy(self._ui.tree_selection, 'changed', self._on_group_selection_changed) + connect_destroy(self._ui.toggle_renderer, 'toggled', self._on_group_toggled) + connect_destroy(self._ui.text_renderer, 'edited', self._on_group_name_edited) + self.register_events([ ('subscribed-presence-received', ged.GUI1, self._on_subscribed_presence_received), ('unsubscribed-presence-received', ged.GUI1, self._on_unsubscribed_presence_received), ]) # pylint: enable=line-too-long - self._load_avatar() + self.add(self._ui.main_grid) + self.show_all() - self._ui.contact_name_label.set_text(contact.name) - self._ui.contact_jid_label.set_text(str(contact.jid)) - self._ui.contact_jid_label.set_tooltip_text(str(contact.jid)) - - self._update_timeout_id = None - self._time = 0 - self._devices = {} - self._received_devices = set() - self._received_times = set() - - if contact.is_pm_contact: - if contact.real_jid is not None: - self._devices_grid = DevicesGrid(self._ui.devices_grid) - self._query_devices() - - self._ui.contact_jid_label.set_text( - str(contact.real_jid.bare)) - self._ui.contact_jid_label.set_tooltip_text( - str(contact.real_jid.bare)) - self._ui.role_label.set_text(get_uf_role(contact.role)) - self._ui.affiliation_label.set_text( - get_uf_affiliation(contact.affiliation)) - self._ui.group_chat_grid.show() + def _on_key_press(self, _widget: ContactInfo, event: Gdk.EventKey) -> None: + if event.keyval == Gdk.KEY_Escape: + self.destroy() + + def _on_stack_child_changed(self, + _widget: Gtk.Stack, + pspec: GObject.ParamSpec) -> None: - self._vcard_grid = VCardGrid(account) + name = self._ui.main_stack.get_visible_child_name() + self._ui.header_revealer.set_reveal_child(name != 'information') + + def _on_destroy(self, _widget: ContactInfo) -> None: + for task in self._tasks: + task.cancel() + + if self.contact.is_in_roster: + self._save_annotation() + + for device_grid in self._devices.values(): + device_grid.destroy() + self._devices.clear() + + self.unregister_events() + app.check_finalize(self) + + def _fill_information_page(self) -> None: + self._vcard_grid = VCardGrid(self.account) + self._vcard_grid.set_column_homogeneous(True) self._ui.vcard_box.add(self._vcard_grid) self._client.get_module('VCard4').request_vcard( - jid=contact.jid, + jid=self.contact.jid, callback=self._on_vcard_received) - if contact.is_in_roster: - self._devices_grid = DevicesGrid(self._ui.devices_grid) - self._query_devices() + jid = str(self.contact.get_address()) - note = self._client.get_module('Annotations').get_note(contact.jid) - if note is not None: - self._ui.textview_annotation.get_buffer().set_text(note.data) + self._ui.contact_name_label.set_text(self.contact.name) + self._ui.contact_jid_label.set_text(jid) + self._ui.contact_jid_label.set_tooltip_text(jid) - self._ui.connect_signals(self) - self.connect('key-press-event', self._on_key_press) - self.connect('destroy', self._on_destroy) + if isinstance(self.contact, GroupchatParticipant): + self._ui.role_label.set_text(get_uf_role(self.contact.role)) + self._ui.affiliation_label.set_text( + get_uf_affiliation(self.contact.affiliation)) + self._ui.group_chat_grid.show() - connect_destroy(self._ui.tree_selection, - 'changed', - self._on_group_selection_changed) - connect_destroy(self._ui.toggle_renderer, - 'toggled', - self._on_group_toggled) - connect_destroy(self._ui.text_renderer, - 'edited', - self._on_group_name_edited) + self._switcher.set_row_visible('information', True) - self.add(self._ui.main_grid) - self.show_all() + def _fill_note_page(self) -> None: + if not self.contact.is_in_roster: + return - def _on_key_press(self, _widget, event): - if event.keyval == Gdk.KEY_Escape: - self.destroy() + note = self._client.get_module('Annotations').get_note(self.contact.jid) + if note is not None: + self._ui.textview_annotation.get_buffer().set_text(note.data) - def _on_stack_child_changed(self, *args): - if self._ui.main_stack.get_visible_child_name() == 'information': - self._ui.header_revealer.set_reveal_child(False) + self._switcher.set_row_visible('notes', True) + + def _fill_settings_page(self) -> None: + if not isinstance(self.contact, BareContact): + return + + if self.contact.subscription in ('from', 'both'): + self._ui.from_subscription_switch.set_state(True) + + if self.contact.subscription in ('to', 'both'): + self._ui.to_subscription_stack.set_visible_child_name('checkmark') + + elif self.contact.ask == 'subscribe': + self._ui.to_subscription_stack.set_visible_child_name('request') + self._ui.request_stack.set_visible_child_name('requested') else: - self._ui.header_revealer.set_reveal_child(True) + self._ui.to_subscription_stack.set_visible_child_name('request') + self._ui.request_stack.set_visible_child_name('cross') - def _on_destroy(self, _widget): - for task in self._tasks: - task.cancel() - self._tasks.clear() + self._switcher.set_row_visible('settings', True) - if self.contact.is_in_roster: - self._save_annotation() + def _fill_groups_page(self) -> None: + if not isinstance(self.contact, BareContact): + return - if self._update_timeout_id is not None: - GLib.source_remove(self._update_timeout_id) + if not self.contact.is_in_roster: + return - self.unregister_events() - app.check_finalize(self) + model = self._ui.groups_treeview.get_model() + model.set_sort_column_id(Column.GROUP_NAME, Gtk.SortType.ASCENDING) + groups = self._client.get_module('Roster').get_groups() + for group in groups: + is_in_group = group in self.contact.groups + model.append([is_in_group, group]) - def _save_annotation(self): - buffer_ = self._ui.textview_annotation.get_buffer() - new_annotation = buffer_.get_property('text') - note = self._client.get_module('Annotations').get_note( - self.contact.jid) - if note is None or new_annotation != note.data: - new_note = AnnotationNote( - jid=self.contact.jid, data=new_annotation) - self._client.get_module('Annotations').set_note(new_note) + self._switcher.set_row_visible('groups', True) + + def _fill_device_info(self) -> None: + if isinstance(self.contact, GroupchatParticipant): + contact = self.contact.get_real_contact() + if contact is None: + return + else: + contact = self.contact + + contacts = list(contact.iter_resources()) + if not contacts: + return + + for contact in contacts: + device_grid = DeviceGrid(contact) + self._devices[contact.resource] = device_grid + self._ui.devices_box.add(device_grid.widget) + self._query_device(contact) + + self._ui.devices_stack.set_visible_child_name('devices') + self._switcher.set_row_visible('devices', True) + + def _query_device(self, contact: DeviceContactT) -> None: + jid = contact.get_address() + + task = self._client.get_module('SoftwareVersion').request_software_version( + jid, callback=self._set_os_info, user_data=jid.resource) + self._tasks.append(task) - def _update_timer(self): - # Timeout for EntityTime in milliseconds, used to stop the spinner - self._time += 100 - devices_complete = self._received_devices == set(self._devices.keys()) - times_complete = self._received_times == set(self._devices.keys()) - if devices_complete and times_complete or self._time == 10000: - self._ui.devices_spinner.stop() - self._update_timeout_id = None - return False - return True - - def _on_vcard_received(self, task): + task = self._client.get_module('EntityTime').request_entity_time( + jid, callback=self._set_entity_time, user_data=jid.resource) + self._tasks.append(task) + + def _on_vcard_received(self, task: Task) -> None: try: vcard = task.finish() except StanzaError as err: @@ -218,7 +260,7 @@ def _on_vcard_received(self, task): self._vcard_grid.set_vcard(vcard) - def _load_avatar(self): + def _load_avatar(self) -> None: scale = self.get_scale_factor() surface_1 = self.contact.get_avatar(AvatarSize.VCARD, scale, @@ -229,39 +271,7 @@ def _load_avatar(self): self._ui.avatar_image.set_from_surface(surface_1) self._ui.header_image.set_from_surface(surface_2) - def _query_devices(self): - self._update_timeout_id = GLib.timeout_add(100, self._update_timer) - - if self.contact.is_pm_contact: - self._query_device(self.contact) - else: - for contact in self.contact.iter_resources(): - self._query_device(contact) - - def _query_device(self, contact): - self._devices[contact.jid.resource] = { - 'status': contact.show, - 'message': contact.status - } - if not contact.is_pm_contact: - self._devices[contact.jid.resource]['priority'] = str( - contact.priority) - - self._rebuild_devices_grid() - - jid = contact.jid - if contact.is_pm_contact and contact.real_jid is not None: - jid = contact.real_jid - - task = self._client.get_module('SoftwareVersion').request_software_version( - jid, callback=self._set_os_info, user_data=contact) - self._tasks.append(task) - - task = self._client.get_module('EntityTime').request_entity_time( - jid, callback=self._set_entity_time, user_data=contact) - self._tasks.append(task) - - def _set_os_info(self, task): + def _set_os_info(self, task: Task) -> None: self._tasks.remove(task) try: @@ -270,15 +280,11 @@ def _set_os_info(self, task): log.warning('Could not retrieve software version: %s', err) return - contact = task.get_user_data() - self._devices[contact.jid.resource]['client'] = '%s %s' % ( - result.name, result.version) - if result.os is not None: - self._devices[contact.jid.resource]['os'] = result.os - self._received_devices.add(contact.jid.resource) - self._rebuild_devices_grid() + resource = task.get_user_data() + device_grid = self._devices[resource] + device_grid.set_software(result) - def _set_entity_time(self, task): + def _set_entity_time(self, task: Task) -> None: self._tasks.remove(task) try: @@ -287,53 +293,37 @@ def _set_entity_time(self, task): log.warning('Could not retrieve entity time: %s', err) return - contact = task.get_user_data() + resource = task.get_user_data() - self._devices[contact.jid.resource]['time'] = entity_time - self._received_times.add(contact.jid.resource) - self._rebuild_devices_grid() + device_grid = self._devices[resource] + device_grid.set_entity_time(entity_time) - def _rebuild_devices_grid(self): - self._ui.devices_stack.set_visible_child_name('devices') - self._devices_grid.clear() - for key, client in self._devices.items(): - self._devices_grid.add_header(_('Device "%s"') % key) - - if client.get('status'): - self._devices_grid.add_value( - _('Status'), get_uf_show(client['status'].value)) - if client.get('message'): - self._devices_grid.add_value( - _('Status Message'), client['message']) - if client.get('priority'): - self._devices_grid.add_value( - _('Priority'), client['priority']) - if client.get('client'): - self._devices_grid.add_value( - _('Software'), client['client']) - if client.get('os'): - self._devices_grid.add_value( - _('Operating Sytem'), client['os']) - if client.get('time'): - self._devices_grid.add_value( - _('Local Time'), client['time']) - self._ui.devices_grid.show_all() + def _save_annotation(self) -> None: + buffer_ = self._ui.textview_annotation.get_buffer() + new_annotation = buffer_.get_property('text') + note = self._client.get_module('Annotations').get_note( + self.contact.jid) + if note is None or new_annotation != note.data: + new_note = AnnotationNote( + jid=self.contact.jid, data=new_annotation) + self._client.get_module('Annotations').set_note(new_note) - def _on_edit_name_toggled(self, widget): - if widget.get_active(): - self._ui.name_entry.set_sensitive(True) + def _on_edit_name_toggled(self, widget: Gtk.ToggleButton) -> None: + active = widget.get_active() + self._ui.name_entry.set_sensitive(active) + if active: self._ui.name_entry.grab_focus() - else: - self._ui.name_entry.set_sensitive(False) - name = GLib.markup_escape_text(self._ui.name_entry.get_text()) + name = self._ui.name_entry.get_text() self._client.get_module('Roster').set_item(self.contact.jid, name) self._ui.contact_name_label.set_text(name) - def _on_name_entry_activate(self, _widget, *args): + def _on_name_entry_activate(self, _widget: Gtk.Entry) -> None: self._ui.edit_name_button.set_active(False) - def _on_from_subscription_switch_toggled(self, switch, state): + def _on_from_subscription_switch_toggled(self, + switch: Gtk.Switch, + state: bool) -> int: def _stop_sharing(): self._client.get_module('Presence').unsubscribed(self.contact.jid) switch.set_state(state) @@ -355,50 +345,40 @@ def _stop_sharing(): transient_for=self).show() return Gdk.EVENT_STOP - def _on_to_subscription_button_clicked(self, *args): + def _on_to_subscription_button_clicked(self, _widget: Gtk.Button) -> None: # Save auto_auth if switch for disclosing presence is active self._client.get_module('Presence').subscribe( self.contact.jid, auto_auth=self._ui.from_subscription_switch.get_state()) self._ui.request_stack.set_visible_child_name('requested') - def _on_subscribed_presence_received(self, _event): + def _on_subscribed_presence_received(self, + _event: SubscribedPresenceReceived + ) -> None: + self._ui.to_subscription_stack.set_visible_child_name('checkmark') - def _on_unsubscribed_presence_received(self, _event): + def _on_unsubscribed_presence_received(self, + _event: UnsubscribedPresenceReceived + ) -> None: + self._ui.to_subscription_stack.set_visible_child_name('request') self._ui.request_stack.set_visible_child_name('cross') - def _fill_settings_page(self): - if self.contact.subscription in ('from', 'both'): - self._ui.from_subscription_switch.set_state(True) - if self.contact.subscription in ('to', 'both'): - self._ui.to_subscription_stack.set_visible_child_name('checkmark') - elif self.contact.ask == 'subscribe': - self._ui.to_subscription_stack.set_visible_child_name('request') - self._ui.request_stack.set_visible_child_name('requested') - else: - self._ui.to_subscription_stack.set_visible_child_name('request') - self._ui.request_stack.set_visible_child_name('cross') - - def _fill_groups_page(self): - model = self._ui.groups_treeview.get_model() - model.set_sort_column_id(Column.GROUP_NAME, Gtk.SortType.ASCENDING) - groups = self._client.get_module('Roster').get_groups() - for group in groups: - is_in_group = group in self.contact.groups - model.append([is_in_group, group]) - - def _on_group_selection_changed(self, *args): + def _on_group_selection_changed(self, _widget: Gtk.TreeSelection) -> None: selection = self._ui.groups_treeview.get_selection() (_model, iter_) = selection.get_selected() self._ui.group_remove_button.set_sensitive(bool(iter_)) - def _on_group_name_edited(self, _renderer, path, new_name): + def _on_group_name_edited(self, + _renderer: Gtk.CellRendererText, + path: str, + new_name: str) -> None: if new_name == '': return model = self._ui.groups_treeview.get_model() + assert model is not None selected_iter_ = model.get_iter(path) old_name = model[selected_iter_][Column.GROUP_NAME] @@ -412,9 +392,10 @@ def _on_group_name_edited(self, _renderer, path, new_name): model.set_value(selected_iter_, Column.GROUP_NAME, new_name) self._client.get_module('Roster').rename_group(old_name, new_name) - def _on_group_remove_button_clicked(self, *args): + def _on_group_remove_button_clicked(self, _widget: Gtk.Button) -> int: selection = self._ui.groups_treeview.get_selection() - (model, iter_) = selection.get_selected() + model, iter_ = selection.get_selected() + assert iter_ is not None group = model[iter_][Column.GROUP_NAME] def _remove_group(): @@ -431,11 +412,15 @@ def _remove_group(): transient_for=self).show() return Gdk.EVENT_STOP - def _on_group_toggled(self, _renderer, path): + def _on_group_toggled(self, + _renderer: Gtk.CellRendererToggle, + path: str) -> None: + model = self._ui.groups_treeview.get_model() + assert model is not None model[path][Column.IN_GROUP] = not model[path][Column.IN_GROUP] - groups = set() + groups: set[str] = set() iter_ = model.get_iter_first() while iter_: if model.get_value(iter_, Column.IN_GROUP): @@ -444,9 +429,10 @@ def _on_group_toggled(self, _renderer, path): self._client.get_module('Roster').set_groups(self.contact.jid, groups) - def _on_group_add_button_clicked(self, *args): + def _on_group_add_button_clicked(self, _widget: Gtk.Button) -> None: default_name = _('New Group') model = self._ui.groups_treeview.get_model() + assert model is not None # Check if default_name group already exists iter_ = model.get_iter_first() @@ -461,42 +447,60 @@ def _on_group_add_button_clicked(self, *args): self._ui.groups_treeview.set_cursor(path, column, True) -class DevicesGrid: - def __init__(self, grid): - self._grid = grid - self._row_num = 0 - - def clear(self): - row = 0 - while self._grid.get_child_at(0, row): - self._grid.remove_row(row) - self._row_num = 0 - - def add_value(self, name, value): - self._grid.insert_row(self._row_num) - - label = Gtk.Label(label=name) - label.get_style_context().add_class('dim-label') - label.set_valign(Gtk.Align.START) - label.set_halign(Gtk.Align.END) - label.set_margin_start(12) - self._grid.attach(label, 0, self._row_num, 1, 1) - - label = Gtk.Label(label=value) - label.set_valign(Gtk.Align.START) - label.set_halign(Gtk.Align.START) - label.set_line_wrap(True) - label.set_xalign(0) - self._grid.attach(label, 1, self._row_num, 1, 1) - self._row_num += 1 - - def add_header(self, text): - self._grid.insert_row(self._row_num) - - label = Gtk.Label(label=text) - label.get_style_context().add_class('bold16') - if self._row_num > 0: - label.set_margin_top(12) - label.set_halign(Gtk.Align.START) - self._grid.attach(label, 0, self._row_num, 2, 1) - self._row_num += 1 +class DeviceGrid: + def __init__(self, contact: DeviceContactT) -> None: + self._contact = contact + self._ui = get_builder('contact_info.ui', ['devices_grid']) + self._spinner = Gtk.Spinner() + self._spinner.start() + + self._ui.resource_label.set_text(_('Device "%s"') % contact.resource) + self._ui.status_value.set_text(get_uf_show(contact.show.value)) + self._set_priority() + + self._ui.resource_box.add(self._spinner) + self._ui.devices_grid.show_all() + + self._waiting_for_info = 2 + + @property + def widget(self) -> Gtk.Grid: + return self._ui.devices_grid + + def _set_priority(self) -> None: + if not isinstance(self._contact, ResourceContact): + return + + self._ui.priority_value.set_text(str(self._contact.priority)) + self._ui.priority_value.show() + self._ui.priority_label.show() + + def set_entity_time(self, entity_time: str) -> None: + self._ui.time_value.set_text(entity_time) + self._ui.time_value.show() + self._ui.time_label.show() + + self._check_complete() + + def set_software(self, software: SoftwareVersionResult) -> None: + software_string = '%s %s' % (software.name, software.version) + self._ui.software_value.set_text(software_string) + self._ui.software_value.show() + self._ui.software_label.show() + if software.os is not None: + self._ui.system_value.set_text(software.os) + self._ui.system_value.show() + self._ui.system_label.show() + + self._check_complete() + + def _check_complete(self) -> None: + self._waiting_for_info -= 1 + if not self._waiting_for_info: + self._spinner.stop() + + def destroy(self) -> None: + self._spinner.stop() + del self._spinner + del self._ui + del self._contact ===================================== gajim/gtk/sidebar_switcher.py ===================================== @@ -12,9 +12,15 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. +from __future__ import annotations + +from typing import Optional +from typing import cast from gi.repository import Gtk +from gajim.common import app + class SideBarSwitcher(Gtk.ListBox): def __init__(self): @@ -22,45 +28,69 @@ def __init__(self): self.set_vexpand(True) self.get_style_context().add_class('settings-menu') self.connect('row-activated', self._on_row_activated) - self._stack = None + self._stack = cast(Gtk.Stack, None) + self._rows: dict[str, Row] = {} + + self.connect('destroy', self._destroy) - def set_stack(self, stack): + def set_stack(self, stack: Gtk.Stack, rows_visible: bool = True) -> None: self._stack = stack for page in self._stack.get_children(): - attributes = ['name', 'title', 'icon-name'] - properties = self._stack.child_get(page, *attributes) - self.add(Row(*properties)) + name = self._stack.child_get_property(page, 'name') + if name is None: + raise ValueError('unnamed child') + title = self._stack.child_get_property(page, 'title') + if title is None: + raise ValueError('no title on child') + icon_name = self._stack.child_get_property(page, 'icon-name') + + row = Row(name, title, icon_name, rows_visible) + + self.add(row) + self._rows[name] = row self._select_first_row() - def hide_row(self, name): - for row in self.get_children(): - if row.name == name: - row.set_no_show_all(True) - row.hide() - break - - def set_row(self, name): - for row in self.get_children(): - if row.name == name: - self.select_row(row) - self._stack.set_visible_child_name(name) - break - - def _on_row_activated(self, _listbox, row): + def set_row_visible(self, name: str, state: bool) -> None: + row = self._rows.get(name) + if row is None: + raise ValueError + row.set_visible(state) + + def set_row(self, name: str) -> None: + row = self._rows.get(name) + if row is None: + raise ValueError + self.select_row(row) + self._stack.set_visible_child_name(name) + + def _on_row_activated(self, _listbox: SideBarSwitcher, row: Row): self._stack.set_visible_child_name(row.name) def _select_first_row(self): self.select_row(self.get_row_at_index(0)) + def _destroy(self, _widget: SideBarSwitcher) -> None: + for row in self._rows.values(): + row.destroy() + self._rows.clear() + del self._stack + app.check_finalize(self) + class Row(Gtk.ListBoxRow): - def __init__(self, name, title, icon_name): + def __init__(self, + name: str, + title: str, + icon_name: Optional[str], + visible: bool) -> None: + Gtk.ListBoxRow.__init__(self) self.name = name + box = Gtk.Box() - if icon_name: + if icon_name is not None: image = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU) image.get_style_context().add_class('dim-label') box.add(image) @@ -69,3 +99,7 @@ def __init__(self, name, title, icon_name): label.set_xalign(0) box.add(label) self.add(box) + + self.show_all() + self.set_no_show_all(True) + self.set_visible(visible) ===================================== pyrightconfig.json ===================================== @@ -37,6 +37,7 @@ "gajim/gtk/conversation/rows/widgets.py", "gajim/gtk/conversation/scrolled.py", "gajim/gtk/notification.py", + "gajim/gtk/side_bar_switcher.py", "gajim/gtk/status_message_selector.py", "gajim/gtk/status_selector.py", ], View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0654533e62d1ac872f27a3000d21718…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0654533e62d1ac872f27a3000d21718…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] Add server shutdown notification
by Philipp Hörist (ï¼ lovetox)
09 Jan '22
09 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 0654533e by lovetox at 2022-01-09T15:18:06+01:00 Add server shutdown notification - - - - - 3 changed files: - gajim/common/client.py - gajim/gtk/application.py - gajim/gtk/notification.py Changes: ===================================== gajim/common/client.py ===================================== @@ -277,6 +277,12 @@ def _on_disconnected(self, app.settings.set_account_setting(self._account, 'resource', 'gajim.$rand') + if error == 'system-shutdown': + app.ged.raise_event( + Notification(account=self._account, + type='server-shutdown', + title=_('Server Shutdown'), + text=text or _('The server was shut down.'))) elif domain == StreamError.SASL: self._reconnect = False ===================================== gajim/gtk/application.py ===================================== @@ -719,7 +719,8 @@ def _on_open_event_action(_action: Gio.SimpleAction, if params.type in ('connection-failed', 'subscription-request', 'unsubscribed', - 'group-chat-invitation'): + 'group-chat-invitation', + 'server-shutdown'): app.window.show_account_page(params.account) ===================================== gajim/gtk/notification.py ===================================== @@ -72,6 +72,7 @@ _notification_backend = None + class NotificationBackend(EventHelper): def __init__(self) -> None: EventHelper.__init__(self) @@ -94,6 +95,7 @@ def _on_our_show(self, event: events.ShowChanged) -> None: if not app.account_is_connected(event.account): return self._withdraw(['connection-failed', event.account]) + self._withdraw(['server-shutdown', event.account]) def _send(self, event: events.Notification) -> None: raise NotImplementedError @@ -232,6 +234,7 @@ class Linux(NotificationBackend): _action_types = [ 'connection-failed', + 'server-shutdown', 'file-transfer', 'group-chat-invitation', 'incoming-call', @@ -322,8 +325,8 @@ def _add_actions(self, def _make_notification_id(self, event: events.Notification) -> Optional[str]: - if event.type == 'connection-failed': - return self._make_id(['connection-failed', event.account]) + if event.type in ('connection-failed', 'server-shutdown'): + return self._make_id([event.type, event.account]) if event.type == 'incoming-message': return self._make_id(['new-message', event.account, str(event.jid)]) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/0654533e62d1ac872f27a3000d217181…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/0654533e62d1ac872f27a3000d217181…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] Chats: Add remove history option
by Philipp Hörist (ï¼ lovetox)
09 Jan '22
09 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: e236e904 by lovetox at 2022-01-09T08:11:12+01:00 Chats: Add remove history option - - - - - 5 changed files: - gajim/common/storage/archive.py - gajim/gtk/application.py - gajim/gtk/controls/groupchat.py - gajim/gtk/menus.py - gajim/gtk/structs.py Changes: ===================================== gajim/common/storage/archive.py ===================================== @@ -1349,13 +1349,9 @@ def reset_archive_infos(self, jid: str) -> None: log.info('Reset message archive info: %s', jid) self._delayed_commit() - def remove_chat_history(self, - account: str, - jid: str, - groupchat: bool = False - ) -> None: + def remove_history(self, account: str, jid: JID) -> None: """ - Remove chat history for a specific chat. + Remove history for a specific chat. If it's a group chat, remove last MAM ID as well. """ account_id = self.get_account_id(account) @@ -1363,15 +1359,19 @@ def remove_chat_history(self, sql = 'DELETE FROM logs WHERE account_id = ? AND jid_id = ?' self._con.execute(sql, (account_id, jid_id)) + self._delayed_commit() + log.info('Removed history for: %s', jid) + + def forget_jid_data(self, account: str, jid: JID) -> None: + jid_id = self.get_jid_id(jid) sql = 'DELETE FROM jids WHERE jid_id = ?' self._con.execute(sql, (jid_id,)) - if groupchat: - sql = 'DELETE FROM last_archive_message WHERE jid_id = ?' - self._con.execute(sql, (jid_id,)) + sql = 'DELETE FROM last_archive_message WHERE jid_id = ?' + self._con.execute(sql, (jid_id,)) self._delayed_commit() - log.info('Removed chat history for: %s', jid) + log.info('Forgot data for: %s', jid) def _cleanup_chat_history(self) -> None: """ ===================================== gajim/gtk/application.py ===================================== @@ -75,7 +75,9 @@ from gajim.gui.dialogs import ShortcutsWindow from gajim.gui.about import AboutDialog from gajim.gui.discovery import ServiceDiscoveryWindow +from gajim.gui.structs import ForgetGroupchatActionParams from gajim.gui.structs import OpenEventActionParams +from gajim.gtk.structs import RemoveHistoryActionParams ActionListT = list[tuple[str, @@ -380,8 +382,9 @@ def add_actions(self) -> None: ('copy-text', 's', self._on_copy_text_action), ('open-link', 'as', self._on_open_link_action), ('open-mail', 's', self._on_open_mail_action), + ('remove-history', 'a{sv}', self._on_remove_history_action), ('create-groupchat', 's', self._on_create_groupchat_action), - ('forget-groupchat', 'as', self._on_forget_groupchat_action), + ('forget-groupchat', 'a{sv}', self._on_forget_groupchat_action), ('groupchat-join', 'as', self._on_groupchat_join_action), ] @@ -775,20 +778,35 @@ def _on_open_chat_action(_action: Gio.SimpleAction, account, jid = param.get_strv() app.interface.start_chat_from_jid(account, jid) + @staticmethod + def _on_remove_history_action(_action: Gio.SimpleAction, + param: GLib.Variant) -> None: + + params = RemoveHistoryActionParams.from_variant(param) + + if params.jid is not None: + app.storage.archive.remove_history(params.account, params.jid) + control = app.window.get_control(params.account, params.jid) + if control is not None: + control.reset_view() + else: + for control in app.window.get_controls(params.account): + control.reset_view() + @staticmethod def _on_forget_groupchat_action(_action: Gio.SimpleAction, param: GLib.Variant) -> None: - account, jid = param.unpack() - room_jid = JID.from_string(jid) + + params = ForgetGroupchatActionParams.from_variant(param) window = get_app_window('StartChatDialog') - window.remove_row(account, str(room_jid)) + window.remove_row(params.account, str(params.jid)) - client = app.get_client(account) - client.get_module('MUC').leave(room_jid) - client.get_module('Bookmarks').remove(room_jid) + client = app.get_client(params.account) + client.get_module('MUC').leave(params.jid) + client.get_module('Bookmarks').remove(params.jid) - app.storage.archive.remove_chat_history( - account, str(room_jid), groupchat=True) + app.storage.archive.remove_history(params.account, params.jid) + app.storage.archive.forget_jid_data(params.account, params.jid) @staticmethod def _on_groupchat_join_action(_action: Gio.SimpleAction, ===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -191,7 +191,7 @@ def __init__(self, account: str, jid: JID) -> None: self.control_menu = get_groupchat_menu(self.control_id, self.account, - self.room_jid) + self.contact.jid) self.xml.settings_menu.set_menu_model(self.control_menu) ===================================== gajim/gtk/menus.py ===================================== @@ -41,6 +41,8 @@ from gajim.common.const import URIAction from gajim.common.structs import URI +from gajim.gui.structs import ForgetGroupchatActionParams +from gajim.gui.structs import RemoveHistoryActionParams from gajim.gui.const import ControlType @@ -52,7 +54,7 @@ def get_singlechat_menu(control_id: str, client = app.get_client(account) is_self_contact = jid.bare == client.get_own_jid().bare - singlechat_menu: List[Any] = [ + singlechat_menu: list[tuple[str, Any]] = [ (_('Send File'), [ ('win.send-file-httpupload-', _('Upload File…')), ('win.send-file-jingle-', _('Send File Directly…')) @@ -66,7 +68,8 @@ def get_singlechat_menu(control_id: str, ('win.add-to-roster-', _('Add to Contact List…')), ('win.block-contact-', _('Block Contact…')), ('win.start-call-', _('Start Call…')), - ('win.information-', _('Information')) + ('win.information-', _('Information')), + ('app.remove-history', _('Remove History')) ] if is_self_contact: @@ -90,7 +93,7 @@ def build_chatstate_menu() -> Gio.Menu: menu.append(label, action) return menu - def build_menu(preset): + def build_menu(preset: list[tuple[str, Any]]): menu = Gio.Menu() for item in preset: if isinstance(item[1], str): @@ -116,6 +119,12 @@ def build_menu(preset): menuitem.set_action_and_target_value(action_name, variant_dict) menu.append_item(menuitem) + elif action_name == 'app.remove-history': + params = RemoveHistoryActionParams(account=account, jid=jid) + menuitem = Gio.MenuItem.new(label, action_name) + menuitem.set_action_and_target_value(action_name, + params.to_variant()) + menu.append_item(menuitem) else: menu.append(label, action_name + control_id) else: @@ -130,7 +139,7 @@ def build_menu(preset): return build_menu(singlechat_menu) -def get_groupchat_menu(control_id: str, account: str, jid: str) -> Gio.Menu: +def get_groupchat_menu(control_id: str, account: str, jid: JID) -> Gio.Menu: groupchat_menu = [ ('win.information-', _('Information')), ('win.groupchat-settings-', _('Settings…')), @@ -140,6 +149,7 @@ def get_groupchat_menu(control_id: str, account: str, jid: str) -> Gio.Menu: ('win.request-voice-', _('Request Voice')), ('win.execute-command-', _('Execute Command…')), ('win.search-history', _('Search…')), + ('app.remove-history', _('Remove History')) ] def build_menu(preset: list[tuple[str, str]]) -> Gio.Menu: @@ -154,7 +164,7 @@ def build_menu(preset: list[tuple[str, str]]) -> Gio.Menu: elif action_name == 'app.browse-history': menuitem = Gio.MenuItem.new(label, action_name) dict_ = {'account': GLib.Variant('s', account), - 'jid': GLib.Variant('s', jid)} + 'jid': GLib.Variant('s', str(jid))} variant_dict = GLib.Variant('a{sv}', dict_) menuitem.set_action_and_target_value( action_name, variant_dict) @@ -166,6 +176,13 @@ def build_menu(preset: list[tuple[str, str]]) -> Gio.Menu: menuitem.set_action_and_target_value( action_name, GLib.Variant('s', '')) menu.append_item(menuitem) + + elif action_name == 'app.remove-history': + params = RemoveHistoryActionParams(account=account, jid=jid) + menuitem = Gio.MenuItem.new(label, action_name) + menuitem.set_action_and_target_value(action_name, + params.to_variant()) + menu.append_item(menuitem) else: menu.append(label, action_name + control_id) @@ -485,10 +502,7 @@ def get_subscription_menu(account: str, jid: str) -> Gio.Menu: return menu -def get_start_chat_row_menu(account: str, - jid: Union[JID, str] - ) -> Gio.Menu: - jid = str(jid) +def get_start_chat_row_menu(account: str, jid: JID) -> Gio.Menu: menu_items: List[Tuple[str, str]] = [ ('forget-groupchat', _('Forget this Group Chat')), ] @@ -497,8 +511,8 @@ def get_start_chat_row_menu(account: str, action, label = item action = f'app.{action}' menuitem = Gio.MenuItem.new(label, action) - variant_list = GLib.Variant('as', [account, jid]) - menuitem.set_action_and_target_value(action, variant_list) + params = ForgetGroupchatActionParams(account=account, jid=jid) + menuitem.set_action_and_target_value(action, params.to_variant()) menu.append_item(menuitem) return menu ===================================== gajim/gtk/structs.py ===================================== @@ -29,3 +29,15 @@ class OpenEventActionParams(VariantMixin): sub_type: Optional[str] account: str jid: Optional[JID] + + +@dataclass +class RemoveHistoryActionParams(VariantMixin): + account: str + jid: Optional[JID] = None + + +@dataclass +class ForgetGroupchatActionParams(VariantMixin): + account: str + jid: JID View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e236e90498c6507ec887433a8958005d…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/e236e90498c6507ec887433a8958005d…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] Remove dialog_messages module
by Philipp Hörist (ï¼ lovetox)
08 Jan '22
08 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 810711d3 by lovetox at 2022-01-08T17:42:03+01:00 Remove dialog_messages module - Remove InformationEvent - - - - - 6 changed files: - gajim/common/events.py - gajim/common/jingle_rtp.py - gajim/common/modules/bytestream.py - gajim/common/zeroconf/connection_zeroconf.py - − gajim/dialog_messages.py - gajim/gui_interface.py Changes: ===================================== gajim/common/events.py ===================================== @@ -640,15 +640,6 @@ class UnsubscribedPresenceReceived(ApplicationEvent): jid: str -@dataclass -class InformationEvent(ApplicationEvent): - name: str = field(init=False, default='information-event') - dialog_name: str - args: Optional[Any] = None - kwargs: Optional[dict[str, Any]] = None - popup: bool = False - - @dataclass class FileRequestReceivedEvent(ApplicationEvent): name: str = field(init=False, default='file-request-received') ===================================== gajim/common/jingle_rtp.py ===================================== @@ -39,7 +39,6 @@ from gajim.common.jingle_content import contents from gajim.common.jingle_content import JingleContent from gajim.common.jingle_content import JingleContentSetupException -from gajim.common.events import InformationEvent from gajim.common.jingle_session import FailedApplication @@ -125,17 +124,9 @@ def make_bin_from_config(self, config_key, pipeline, text): gst_bin = Gst.parse_bin_from_description(pipeline, True) return gst_bin except GLib.Error as err: - app.ged.raise_event( - InformationEvent( - conn=self.session.connection, - level='error', - pri_txt=_('%s configuration error') % text, - sec_txt=_('Couldn’t set up %(text)s. Check your ' - 'configuration.\nPipeline:\n%(pipeline)s\n' - 'Error:\n%(error)s') % { - 'text': text, - 'pipeline': pipeline, - 'error': str(err)})) + log.error('Couldn’t set up %s. Check your ' + 'configuration. Pipeline: %s' + 'Error: %s', text, pipeline, err) raise JingleContentSetupException def add_remote_candidates(self, candidates): @@ -235,6 +226,7 @@ def _on_gst_message(self, _bus, message): log.error('Farstream error #%d!\nMessage: %s', message.get_structure().get_value('error-no'), message.get_structure().get_value('error-msg')) + elif message.type == Gst.MessageType.ERROR: # TODO: Fix it to fallback to videotestsrc anytime an error occur, # or raise an error, Jingle way @@ -243,12 +235,6 @@ def _on_gst_message(self, _bus, message): debug_msg = message.get_structure().get_value('debug') log.error(gerror_msg) log.error(debug_msg) - if not self.stream_failed_once: - app.ged.raise_event( - InformationEvent( - dialog_name='gstreamer-error', - kwargs={'error': gerror_msg, 'debug': debug_msg})) - sink_pad = self.p2psession.get_property('sink-pad') # Remove old source ===================================== gajim/common/modules/bytestream.py ===================================== @@ -38,7 +38,6 @@ from gajim.common.events import FileRequestError from gajim.common.file_props import FilesProp from gajim.common.socks5 import Socks5SenderClient -from gajim.common.events import InformationEvent from gajim.common.modules.base import BaseModule @@ -323,7 +322,7 @@ def _add_local_ips_as_streamhosts_to_query(self, query, file_props): port = app.settings.get('file_transfers_port') self._add_streamhosts_to_query(query, sender, port, my_ips) except socket.gaierror: - app.ged.raise_event(InformationEvent(dialog_name='wrong-host')) + log.error('wrong host, invalid local address?') def _add_addiditional_streamhosts_to_query(self, query, file_props): sender = file_props.sender ===================================== gajim/common/zeroconf/connection_zeroconf.py ===================================== @@ -44,7 +44,6 @@ from gajim.common.zeroconf import client_zeroconf from gajim.common.zeroconf import zeroconf from gajim.common.zeroconf.connection_handlers_zeroconf import ConnectionHandlersZeroconf -from gajim.common.events import InformationEvent log = logging.getLogger('gajim.c.connection_zeroconf') @@ -380,8 +379,7 @@ def _on_name_conflictCB(self, alt_name): alt_name=alt_name)) def _on_error(self, message): - app.ged.raise_event(InformationEvent( - dialog_name='avahi-error', args=message)) + log.warning('avahi error: %s', message) def connect(self, show='online', msg=''): self.get_config_values_or_default() ===================================== gajim/dialog_messages.py deleted ===================================== @@ -1,67 +0,0 @@ -# Copyright (C) 2017 Philipp Hörist <philipp AT
hoerist.com
> -# -# This file is part of Gajim. -# -# Gajim is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Gajim is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. - -from collections import namedtuple - -from gi.repository import GLib - -from gajim.common.app import app -from gajim.common.i18n import _ -from gajim.gui.dialogs import ErrorDialog - -Message = namedtuple('Message', ['title', 'text', 'dialog']) - -messages = { - 'gstreamer-error': Message( - _('GStreamer Error'), - _('Error: %(error)s\nDebug: %(debug)s'), - ErrorDialog), - - 'wrong-host': Message( - _('Wrong Host'), - _('Invalid local address? :-O'), - ErrorDialog), - - 'avahi-error': Message( - _('Avahi Error'), - _('%s\nLink-local messaging might not work properly.'), - ErrorDialog), - } - - -def get_dialog(dialog_name, *args, **kwargs): - message = messages.get(dialog_name, None) - if message is None: - raise ValueError('Dialog %s does not exist' % dialog_name) - - # Set transient window - transient_for = kwargs.get('transient_for', None) - if transient_for is None: - transient_for = app.get_active_window() - else: - del kwargs['transient_for'] - - if args: - message_text = message.text % args - elif kwargs: - message_text = message.text % kwargs - else: - message_text = message.text - dialog = message.dialog(message.title, - GLib.markup_escape_text(message_text), - transient_for=transient_for) - return dialog ===================================== gajim/gui_interface.py ===================================== @@ -58,8 +58,6 @@ from nbxmpp import Hashes2 from nbxmpp import JID -from gajim.dialog_messages import get_dialog - from gajim.common import app from gajim.common import ged from gajim.common import exceptions @@ -95,8 +93,6 @@ from gajim.gui.avatar import AvatarStorage from gajim.gui.dialogs import DialogButton from gajim.gui.dialogs import ErrorDialog -from gajim.gui.dialogs import WarningDialog -from gajim.gui.dialogs import InformationDialog from gajim.gui.dialogs import ConfirmationDialog from gajim.gui.dialogs import InputDialog from gajim.gui.filechoosers import FileChooserDialog @@ -201,7 +197,6 @@ def __init__(self): def _create_core_handlers_list(self) -> None: # pylint: disable=line-too-long self.handlers = { - 'information': [self.handle_event_information], 'iq-error-received': [self.handle_event_iq_error], 'plain-connection': [self.handle_event_plain_connection], 'http-auth-received': [self.handle_event_http_auth], @@ -235,30 +230,6 @@ def _register_core_handlers(self) -> None: prio, event_handler) - @staticmethod - def handle_event_information(event): - if not event.popup: - return - - if event.dialog_name is not None: - get_dialog(event.dialog_name, *event.args, **event.kwargs) - return - - if event.level == 'error': - cls = ErrorDialog - elif event.level == 'warn': - cls = WarningDialog - elif event.level == 'info': - cls = InformationDialog - else: - return - - cls(event.pri_txt, GLib.markup_escape_text(event.sec_txt)) - - @staticmethod - def raise_dialog(name, *args, **kwargs): - get_dialog(name, *args, **kwargs) - @staticmethod def handle_event_iq_error(event): ctrl = app.window.get_control(event.account, event.properties.jid.bare) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/810711d34e1679c4eb220eb29c32d05e…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/810711d34e1679c4eb220eb29c32d05e…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 3 commits: Accounts: Add type annotations
by Philipp Hörist (ï¼ lovetox)
08 Jan '22
08 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 84e80350 by lovetox at 2022-01-08T17:01:17+01:00 Accounts: Add type annotations - - - - - c917c5d1 by lovetox at 2022-01-08T17:02:03+01:00 AccountPage: Add type annotations - - - - - df3d4ac6 by lovetox at 2022-01-08T17:03:02+01:00 Util: Fix return type Use Any for now, real types create an import cycle - - - - - 4 changed files: - gajim/gtk/account_page.py - gajim/gtk/accounts.py - gajim/gtk/util.py - pyrightconfig.json Changes: ===================================== gajim/gtk/account_page.py ===================================== @@ -12,7 +12,7 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. -from typing import Any +from __future__ import annotations from gi.repository import Gdk from gi.repository import Gio @@ -21,6 +21,7 @@ from gajim.common import app from gajim.common import ged from gajim.common.const import AvatarSize +from gajim.common.events import ApplicationEvent from gajim.common.events import SubscribePresenceReceived from gajim.common.events import UnsubscribedPresenceReceived from gajim.common.events import MucInvitation @@ -35,6 +36,7 @@ from .util import open_window from .util import EventHelper + ROSTER_MENU_DICT = { 'show-offline': _('Show Offline Contacts'), 'sort-by-show': _('Sort by Status'), @@ -91,7 +93,7 @@ def __init__(self, account: str) -> None: self.show_all() self.connect('destroy', self._on_destroy) - def _on_destroy(self, *args: Any) -> None: + def _on_destroy(self, _widget: AccountPage) -> None: app.check_finalize(self) def _on_edit_profile(self, _button: Gtk.Button) -> None: @@ -149,5 +151,5 @@ def _muc_invitation_declined(self, event: MucDecline) -> None: return self._notification_manager.add_invitation_declined(event) - def process_event(self, event): + def process_event(self, event: ApplicationEvent) -> None: self._roster.process_event(event) ===================================== gajim/gtk/accounts.py ===================================== @@ -12,6 +12,10 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. +from __future__ import annotations + +from typing import Any + import sys import locale import logging @@ -42,7 +46,7 @@ class AccountsWindow(Gtk.ApplicationWindow): - def __init__(self): + def __init__(self) -> None: Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) @@ -74,7 +78,10 @@ def __init__(self): self.show_all() - def _on_menu_activated(self, _listbox, account, name): + def _on_menu_activated(self, + _listbox: Gtk.ListBox, + account: str, + name: str) -> None: if name == 'back': self._settings.set_page('add-account') self._check_relogin() @@ -83,21 +90,23 @@ def _on_menu_activated(self, _listbox, account, name): else: self._settings.set_page(name) - def _on_key_press(self, _widget, event): + def _on_key_press(self, + _widget: AccountsWindow, + event: Gdk.EventKey) -> None: if event.keyval == Gdk.KEY_Escape: self.destroy() - def _on_destroy(self, *args): + def _on_destroy(self, _widget: AccountsWindow) -> None: self._check_relogin() - def update_account_label(self, account): + def update_account_label(self, account: str) -> None: self._accounts[account].update_account_label() - def update_proxy_list(self): + def update_proxy_list(self) -> None: for account in self._accounts: self._settings.update_proxy_list(account) - def _check_relogin(self): + def _check_relogin(self) -> None: for account, r_settings in self._need_relogin.items(): settings = self._get_relogin_settings(account) active = app.settings.get_account_setting(account, 'active') @@ -107,7 +116,7 @@ def _check_relogin(self): self._relog(account) break - def _relog(self, account): + def _relog(self, account: str) -> None: if not app.account_is_connected(account): return @@ -132,7 +141,7 @@ def relog(): transient_for=self).show() @staticmethod - def _get_relogin_settings(account): + def _get_relogin_settings(account: str) -> list[Any]: if account == app.ZEROCONF_ACC_NAME: settings = ['zeroconf_first_name', 'zeroconf_last_name', 'zeroconf_jabber_id', 'zeroconf_email'] @@ -140,37 +149,37 @@ def _get_relogin_settings(account): settings = ['client_cert', 'proxy', 'resource', 'use_custom_host', 'custom_host', 'custom_port'] - values = [] + values: list[Any] = [] for setting in settings: values.append(app.settings.get_account_setting(account, setting)) return values @staticmethod - def on_remove_account(account): + def on_remove_account(account: str) -> None: if app.settings.get_account_setting(account, 'is_zeroconf'): # Should never happen as button is insensitive return open_window('RemoveAccount', account=account) - def remove_account(self, account): + def remove_account(self, account: str) -> None: del self._need_relogin[account] self._accounts[account].remove() - def add_account(self, account, initial=False): + def add_account(self, account: str, initial: bool = False) -> None: self._need_relogin[account] = self._get_relogin_settings(account) self._accounts[account] = Account(account, self._menu, self._settings) if not initial: self._accounts[account].show() - def select_account(self, account): + def select_account(self, account: str) -> None: try: self._accounts[account].select() except KeyError: log.warning('select_account() failed, account %s not found', account) - def enable_account(self, account, state): + def enable_account(self, account: str, state: bool) -> None: self._accounts[account].enable_account(state) ===================================== gajim/gtk/util.py ===================================== @@ -774,7 +774,7 @@ def get_app_window(name: str, return None -def open_window(name: str, **kwargs: Any) -> Gtk.Window: +def open_window(name: str, **kwargs: Any) -> Any: window = get_app_window(name, kwargs.get('account'), kwargs.get('jid')) ===================================== pyrightconfig.json ===================================== @@ -16,6 +16,7 @@ "gajim/common/regex.py", "gajim/common/sound.py", "gajim/common/storage/", + "gajim/gtk/account_page.py", "gajim/gtk/app_side_bar.py", "gajim/gtk/chat_filter.py", "gajim/gtk/chat_page.py", View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/2f99b1f64ac73f8b3e05b436c664c41…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/2f99b1f64ac73f8b3e05b436c664c41…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 5 commits: Settings: Add notification_timeout as IntSetting
by Philipp Hörist (ï¼ lovetox)
08 Jan '22
08 Jan '22
Philipp Hörist pushed to branch master at gajim / gajim Commits: 78d02128 by lovetox at 2022-01-08T14:41:24+01:00 Settings: Add notification_timeout as IntSetting - - - - - f06ba0fc by lovetox at 2022-01-08T14:41:24+01:00 Add VariantMixin This Mixin serializes dataclasses to GLib.Variant - - - - - e95ce79a by lovetox at 2022-01-08T14:41:24+01:00 Add constants - - - - - 995c0e69 by lovetox at 2022-01-08T14:41:24+01:00 Contacts: Always return list for groups attr - - - - - 2f99b1f6 by lovetox at 2022-01-08T14:45:48+01:00 Notifications: Refactor - Split code into various backends - Rename attributes on Notification dataclass - - - - - 15 changed files: - gajim/common/client.py - gajim/common/const.py - gajim/common/events.py - gajim/common/modules/contacts.py - gajim/common/setting_values.py - gajim/common/structs.py - gajim/gtk/application.py - gajim/gtk/call_widget.py - gajim/gtk/controls/base.py - gajim/gtk/filetransfer.py - gajim/gtk/notification.py - gajim/gtk/notification_manager.py - + gajim/gtk/structs.py - gajim/gui_interface.py - pyrightconfig.json Changes: ===================================== gajim/common/client.py ===================================== @@ -293,7 +293,7 @@ def _on_password(password: str) -> None: app.ged.raise_event( Notification(account=self._account, - notif_type='connection-failed', + type='connection-failed', title=_('Authentication failed'), text=text or error)) ===================================== gajim/common/const.py ===================================== @@ -32,6 +32,10 @@ from gajim.common.i18n import Q_ +STOP_EVENT = True +PROPAGATE_EVENT = False + + class EncryptionData(NamedTuple): additional_data: Any = None ===================================== gajim/common/events.py ===================================== @@ -89,11 +89,11 @@ class PasswordRequired(ApplicationEvent): class Notification(ApplicationEvent): name: str = field(init=False, default='notification') account: str - notif_type: str + type: str title: str text: str jid: Optional[Union[JID, str]] = None - notif_detail: Optional[str] = None + sub_type: Optional[str] = None sound: Optional[str] = None icon_name: Optional[str] = None ===================================== gajim/common/modules/contacts.py ===================================== @@ -384,8 +384,11 @@ def subscription(self): return self._get_roster_attr('subscription') @property - def groups(self): - return self._get_roster_attr('groups') + def groups(self) -> list[str]: + groups = self._get_roster_attr('groups') + if groups is None: + return [] + return groups @property def is_subscribed(self) -> bool: ===================================== gajim/common/setting_values.py ===================================== @@ -109,6 +109,7 @@ class _ACCOUNT_DEFAULT: 'mainwin_width', 'mainwin_x_position', 'mainwin_y_position', + 'notification_timeout', 'notification_position_x', 'notification_position_y', 'preview_max_file_size', ===================================== gajim/common/structs.py ===================================== @@ -12,13 +12,20 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. +from __future__ import annotations + +from typing import Any from typing import Dict +from typing import Type +from typing import TypeVar from typing import NamedTuple from typing import Optional from typing import Union import time from dataclasses import dataclass +from dataclasses import fields +from gi.repository import GLib from nbxmpp.protocol import JID from nbxmpp.const import Role @@ -32,6 +39,9 @@ from gajim.common.const import URIAction +_T = TypeVar('_T') + + class URI(NamedTuple): type: URIType action: Optional[URIAction] = None @@ -234,3 +244,68 @@ def from_presence(cls, properties): affiliation=Affiliation.NONE, role=Role.NONE, real_jid=None) + +class VariantMixin: + + _type_to_variant_funcs = { + JID: str, + } + + _variant_to_type_funcs = { + 'JID': JID.from_string, + } + + def _get_type_and_variant_string(self, + field_type: str) -> tuple[Type[Any], str]: + variant_str = '' + if 'Optional' in field_type: + variant_str = 'm' + + if 'str' in field_type: + return str, f'{variant_str}s' + + if 'int' in field_type: + return str, f'{variant_str}i' + + if 'JID' in field_type: + return JID, f'{variant_str}s' + + raise ValueError('unknown type: %s' % field_type) + + def to_variant(self) -> GLib.Variant: + __types = {} + vdict = {} + for field in fields(self): + value = getattr(self, field.name) + field_t, variant_str = self._get_type_and_variant_string(field.type) + if value is None: + vdict[field.name] = GLib.Variant(variant_str, value) + continue + + if not isinstance(value, field_t): + raise ValueError('invalid type: %s is not a %s' % (value, + field_t)) + + conversion_func = self._type_to_variant_funcs.get(field_t) + if conversion_func is not None: + value = conversion_func(value) + __types[field.name] = field_t.__name__ + + vdict[field.name] = GLib.Variant(variant_str, value) + + if __types: + vdict['__types'] = GLib.Variant('a{ss}', __types) + return GLib.Variant('a{sv}', vdict) + + @classmethod + def from_variant(cls: Type[_T], variant: GLib.Variant) -> _T: + vdict = variant.unpack() + __types = vdict.pop('__types', None) + if __types is not None: + for field_name, value_t_name in __types.items(): + value = vdict[field_name] + conversion_func = cls._variant_to_type_funcs.get(value_t_name) + if conversion_func is None: + raise ValueError('no conversion for: %s' % value_t_name) + vdict[field_name] = conversion_func(value) + return cls(**vdict) ===================================== gajim/gtk/application.py ===================================== @@ -70,11 +70,12 @@ from gajim.gui import menus from gajim.gui.builder import get_builder from gajim.gui.util import load_user_iconsets +from gajim.gui.util import open_window +from gajim.gui.util import get_app_window from gajim.gui.dialogs import ShortcutsWindow from gajim.gui.about import AboutDialog from gajim.gui.discovery import ServiceDiscoveryWindow -from gajim.gui.util import open_window -from gajim.gui.util import get_app_window +from gajim.gui.structs import OpenEventActionParams ActionListT = list[tuple[str, @@ -210,7 +211,11 @@ def _startup(self, _application: GajimApplication) -> None: builder = get_builder('application_menu.ui') self.set_menubar(cast(Gio.Menu, builder.get_object('menubar'))) + from gajim.gui import notification + notification.init() + from gajim.gui_interface import Interface + self.interface = Interface() self.interface.run(self) self.add_actions() @@ -706,9 +711,23 @@ def _on_file_transfer_action(_action: Gio.SimpleAction, @staticmethod def _on_open_event_action(_action: Gio.SimpleAction, param: GLib.Variant) -> None: - dict_ = param.unpack() - app.interface.handle_event( - dict_['account'], dict_['jid'], dict_['notif_detail']) + params = OpenEventActionParams.from_variant(param) + + if params.type in ('connection-failed', + 'subscription-request', + 'unsubscribed', + 'group-chat-invitation'): + + app.window.show_account_page(params.account) + + elif params.type in ('incoming-message', + 'incoming-call', + 'file-transfer'): + + assert params.jid is not None + app.window.select_chat(params.account, params.jid) + + app.window.present_with_time(Gtk.get_current_event_time()) @staticmethod def _on_mark_as_read_action(_action: Gio.SimpleAction, ===================================== gajim/gtk/call_widget.py ===================================== @@ -247,7 +247,7 @@ def _on_jingle_request(self, event): app.ged.raise_event( Notification(account=self._account, jid=self._contact.jid, - notif_type='incoming-call', + type='incoming-call', title=_('Incoming Call'), text=_('%s is calling') % self._contact.name)) ===================================== gajim/gtk/controls/base.py ===================================== @@ -1301,8 +1301,8 @@ def _notify(self, app.ged.raise_event( Notification(account=self.account, jid=self.contact.jid, - notif_type='incoming-message', - notif_detail=msg_type, + type='incoming-message', + sub_type=msg_type, title=title, text=text, sound=sound)) ===================================== gajim/gtk/filetransfer.py ===================================== @@ -188,8 +188,8 @@ def _file_completed(self, event): app.ged.raise_event( Notification(account=event.account, jid=event.jid, - notif_type='file-transfer', - notif_detail='file-completed', + type='file-transfer', + sub_type='file-completed', title=_('File Transfer Completed'), text=_('File: %s') % event.file_props.name)) @@ -210,8 +210,8 @@ def _file_send_error(self, event): app.ged.raise_event( Notification(account=event.account, jid=event.jid, - notif_type='file-transfer', - notif_detail='file-send-error', + type='file-transfer', + sub_type='file-send-error', title=_('File Transfer Failed'), text=_('File: %s') % event.file_props.name)) @@ -226,9 +226,9 @@ def _file_request_error(self, event): return if errno in (-4, -5): - notif_detail = 'file-error' + sub_type = 'file-error' else: - notif_detail = 'file-request-error' + sub_type = 'file-request-error' if app.window.is_chat_active(account, event.jid): return @@ -237,8 +237,8 @@ def _file_request_error(self, event): app.ged.raise_event( Notification(account=account, jid=event.jid, - notif_type='file-transfer', - notif_detail=notif_detail, + type='file-transfer', + sub_type=sub_type, title=_('File Transfer Failed'), text=text)) @@ -264,8 +264,8 @@ def _file_request_received(self, event): app.ged.raise_event( Notification(account=account, jid=event.jid, - notif_type='file-transfer', - notif_detail='file-request-received', + type='file-transfer', + sub_type='file-request-received', title=_('File Offered'), text=text)) ===================================== gajim/gtk/notification.py ===================================== @@ -26,6 +26,7 @@ from __future__ import annotations +from typing import Any from typing import Optional from typing import Union @@ -49,10 +50,11 @@ from gajim.common.helpers import play_sound from gajim.common.ged import EventHelper -from .util import add_css_to_widget from .builder import get_builder +from .util import add_css_to_widget from .util import get_monitor_scale_factor from .util import get_total_screen_geometry +from .structs import OpenEventActionParams log = logging.getLogger('gajim.gui.notification') @@ -68,52 +70,17 @@ } -class Notification(EventHelper): - """ - Handle notifications - """ +_notification_backend = None + +class NotificationBackend(EventHelper): def __init__(self) -> None: EventHelper.__init__(self) - self._dbus_available: bool = False - self._daemon_capabilities = ['actions'] - self._win32_active_popup = None - - self._detect_dbus_caps() self.register_events([ ('notification', ged.GUI2, self._on_notification), ('our-show', ged.GUI2, self._on_our_show) ]) - def _detect_dbus_caps(self) -> None: - if sys.platform in ('win32', 'darwin'): - return - - if app.is_flatpak(): - self._dbus_available = True - return - - def on_proxy_ready(_source: Gio.DBusProxy, - res: Gio.AsyncResult) -> None: - try: - proxy = Gio.DBusProxy.new_finish(res) - self._daemon_capabilities = proxy.GetCapabilities() - except GLib.Error as error: - log.warning('Notifications D-Bus not available: %s', error) - else: - self._dbus_available = True - log.info('Notifications D-Bus connected') - - log.info('Connecting to Notifications D-Bus') - Gio.DBusProxy.new_for_bus(Gio.BusType.SESSION, - Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS, - None, - 'org.freedesktop.Notifications', - '/org/freedesktop/Notifications', - 'org.freedesktop.Notifications', - None, - on_proxy_ready) - def _on_notification(self, event: events.Notification) -> None: if event.sound is not None: play_sound(event.sound, event.account) @@ -121,154 +88,62 @@ def _on_notification(self, event: events.Notification) -> None: if not allow_showing_notification(event.account): return - notif_detail = event.notif_detail or event.notif_type - - if event.icon_name is not None: - icon_name = event.icon_name - else: - icon_name = NOTIFICATION_ICONS.get(notif_detail, 'mail-unread') - - self._issue_notification( - event.notif_type, - event.account, - event.jid, - notif_detail=notif_detail, - title=event.title, - text=event.text, - icon_name=icon_name) + self._send(event) def _on_our_show(self, event: events.ShowChanged) -> None: - if app.account_is_connected(event.account): - self._withdraw('connection-failed', event.account) - - def _issue_notification(self, - notif_type: str, - account: str, - jid: Optional[Union[str, JID]], - notif_detail: str = '', - title: str = '', - text: str = '', - icon_name: Optional[str] = None, - timeout: int = -1 - ) -> None: - """ - Notify a user of an event using GNotification and GApplication under - Linux, Use PopupNotificationWindow under Windows - """ - if jid is not None: - jid = str(jid) - - if icon_name is None: - icon_name = 'mail-message-new' - - if timeout < 0: - timeout = app.settings.get('notification_timeout') - - title = GLib.markup_escape_text(title) - text = GLib.markup_escape_text(text) - - if sys.platform == 'win32': - self._withdraw() - self._win32_active_popup = PopupNotification( - notif_type, - account, - jid, - notif_detail, - title, - text, - icon_name, - timeout) - self._win32_active_popup.connect('destroy', self._on_popup_destroy) + if not app.account_is_connected(event.account): return + self._withdraw(['connection-failed', event.account]) - if not self._dbus_available: - return + def _send(self, event: events.Notification) -> None: + raise NotImplementedError - icon = Gio.ThemedIcon.new(icon_name) + def _withdraw(self, details: list[Any]) -> None: + raise NotImplementedError - notification = Gio.Notification() - if title is not None: - notification.set_title(title) - if text is not None: - notification.set_body(text) - notif_id = None - if notif_type in ( - 'incoming-message', - 'file-transfer', - 'group-chat-invitation', - 'subscription-request', - 'unsubscribed', - 'incoming-call', - 'connection-failed'): - if 'actions' in self._daemon_capabilities: - # Create Variant Dict - dict_ = {'account': GLib.Variant('s', account), - 'jid': GLib.Variant('s', jid), - 'notif_detail': GLib.Variant('s', notif_detail)} - variant_dict = GLib.Variant('a{sv}', dict_) - - # Add 'Open' action button to notification - action = f'app.{account}-open-event' - notification.add_button_with_target( - _('Open'), action, variant_dict) - notification.set_default_action_and_target( - action, variant_dict) - - if notif_type == 'incoming-message': - # Add 'Mark as Read' action button to notification - action = f'app.{account}-mark-as-read' - notification.add_button_with_target( - _('Mark as Read'), action, variant_dict) - - # Only one notification per JID - if notif_type == 'connection-failed': - notif_id = self._make_id('connection-failed', account) - elif notif_type == 'incoming-message': - if app.desktop_env == 'gnome': - icon = self._get_avatar_for_notification(account, jid) - notif_id = self._make_id('new-message', account, jid) - notification.set_icon(icon) - notification.set_priority(Gio.NotificationPriority.NORMAL) +class DummyBackend(NotificationBackend): - app.app.send_notification(notif_id, notification) + def _send(self, event: events.Notification) -> None: + pass - @staticmethod - def _get_avatar_for_notification(account: str, - jid: str - ) -> GdkPixbuf.Pixbuf: - scale = get_monitor_scale_factor() - client = app.get_client(account) - contact = client.get_module('Contacts').get_contact(jid) - return app.interface.get_avatar( - contact, AvatarSize.NOTIFICATION, scale, pixbuf=True) + def _withdraw(self, details: list[Any]) -> None: + pass - def _on_popup_destroy(self, *args): - self._win32_active_popup = None - def _withdraw(self, *args): - if sys.platform == 'win32': - if self._win32_active_popup is not None: - self._win32_active_popup.destroy() - elif self._dbus_available: - app.app.withdraw_notification(self._make_id(*args)) +class Windows(NotificationBackend): + def __init__(self): + NotificationBackend.__init__(self) + self._active_notification = None - @staticmethod - def _make_id(*args): - return ','.join(map(str, args)) + def _send(self, event: events.Notification) -> None: + timeout = app.settings.get('notification_timeout') + self._withdraw() + self._win32_active_popup = PopupNotification(event, timeout) + + def _on_popup_destroy(_widget: Gtk.Window) -> None: + self._win32_active_popup = None + + self._win32_active_popup.connect('destroy', _on_popup_destroy) + + def _withdraw(self, *args: Any) -> None: + if self._win32_active_popup is not None: + self._win32_active_popup.destroy() class PopupNotification(Gtk.Window): - def __init__(self, - notif_type: str, - account: str, - jid: Optional[str], - notif_detail: str, - title: str, - text: str, - icon_name: str, - timeout: int - ) -> None: + + _background_class = { + 'incoming-message': '.gajim-notify-message', + 'file-error': '.gajim-notify-error', + 'file-send-error': '.gajim-notify-error', + 'file-request-error': '.gajim-notify-error', + 'file-completed': '.gajim-notify-success', + 'file-stopped': '.gajim-notify-success', + 'group-chat-invitation': '.gajim-notify-invite', + } + + def __init__(self, event: events.Notification, timeout: int) -> None: Gtk.Window.__init__(self) self.set_type_hint(Gdk.WindowTypeHint.NOTIFICATION) self.set_focus_on_map(False) @@ -277,48 +152,19 @@ def __init__(self, self.set_decorated(False) self._timeout_id: Optional[int] = None - self._account = account - self._jid = jid - self._notif_type = notif_type + self._event = event self._ui = get_builder('popup_notification_window.ui') self.add(self._ui.eventbox) - if notif_detail == 'incoming-message': - bg_color = app.css_config.get_value('.gajim-notify-message', - StyleAttr.COLOR) - elif notif_detail in ('file-error', - 'file-send-error', - 'file-request-error'): - bg_color = app.css_config.get_value('.gajim-notify-error', - StyleAttr.COLOR) - elif notif_detail in ('file-completed', 'file-stopped'): - bg_color = app.css_config.get_value('.gajim-notify-success', - StyleAttr.COLOR) - elif notif_detail == 'group-chat-invitation': - bg_color = app.css_config.get_value('.gajim-notify-invite', - StyleAttr.COLOR) - else: - bg_color = app.css_config.get_value('.gajim-notify-other', - StyleAttr.COLOR) - - bar_class = ''' - .popup-bar { - background-color: %s - }''' % bg_color - add_css_to_widget(self._ui.color_bar, bar_class) - self._ui.color_bar.get_style_context().add_class('popup-bar') - - self._ui.event_type_label.set_markup(title) - - if not text: - client = app.get_client(account) - contact = client.get_module('Contacts').get_contact(jid) - text = contact.name - escaped_text = GLib.markup_escape_text(text) - self._ui.event_description_label.set_markup(escaped_text) - + self._add_background_color(event) + icon_name = self._get_icon_name(event) self._ui.image.set_from_icon_name(icon_name, Gtk.IconSize.DIALOG) + self._ui.event_type_label.set_text(event.title) + self._ui.event_description_label.set_text(event.text) + + if timeout > 0: + self._timeout_id = GLib.timeout_add_seconds(timeout, self.destroy) self.move(*self._get_window_pos()) @@ -326,8 +172,24 @@ def __init__(self, self.connect('button-press-event', self._on_button_press) self.connect('destroy', self._on_destroy) self.show_all() - if timeout > 0: - self._timeout_id = GLib.timeout_add_seconds(timeout, self.destroy) + + def _get_icon_name(self, event: events.Notification) -> str: + if event.icon_name is not None: + return event.icon_name + icon_name = event.sub_type or event.type + return NOTIFICATION_ICONS.get(icon_name, 'mail-unread') + + def _add_background_color(self, event: events.Notification) -> None: + event_type = event.sub_type or event.type + css_class = self._background_class.get(event_type, + '.gajim-notify-other') + bg_color = app.css_config.get_value(css_class, StyleAttr.COLOR) + bar_class = ''' + .popup-bar { + background-color: %s + }''' % bg_color + add_css_to_widget(self._ui.color_bar, bar_class) + self._ui.color_bar.get_style_context().add_class('popup-bar') @staticmethod def _get_window_pos() -> tuple[int, int]: @@ -348,10 +210,169 @@ def _on_button_press(self, event: Gdk.EventButton ) -> None: if event.button == 1: - app.interface.handle_event( - self._account, self._jid, self._notif_type) + jid = self._event.jid + if jid is not None and isinstance(jid, str): + jid = JID.from_string(jid) + + params = OpenEventActionParams(type=self._event.type, + sub_type=self._event.sub_type, + account=self._event.account, + jid=jid) + app.app.activate_action(f'app.{self._event.account}-open-event', + params.to_variant()) + self.destroy() def _on_destroy(self, _widget: Gtk.Window) -> None: if self._timeout_id is not None: GLib.source_remove(self._timeout_id) + + +class Linux(NotificationBackend): + + _action_types = [ + 'connection-failed', + 'file-transfer', + 'group-chat-invitation', + 'incoming-call', + 'incoming-message', + 'subscription-request', + 'unsubscribed', + ] + + def __init__(self): + NotificationBackend.__init__(self) + self._dbus_available: bool = False + self._daemon_capabilities = ['actions'] + self._detect_dbus_caps() + + def _detect_dbus_caps(self) -> None: + if app.is_flatpak(): + self._dbus_available = True + return + + def on_proxy_ready(_source: Gio.DBusProxy, + res: Gio.AsyncResult) -> None: + try: + proxy = Gio.DBusProxy.new_finish(res) + self._daemon_capabilities = proxy.GetCapabilities() # type: ignore + except GLib.Error as error: + log.warning('Notifications D-Bus not available: %s', error) + else: + self._dbus_available = True + log.info('Notifications D-Bus connected') + + log.info('Connecting to Notifications D-Bus') + Gio.DBusProxy.new_for_bus(Gio.BusType.SESSION, + Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS, + None, + 'org.freedesktop.Notifications', + '/org/freedesktop/Notifications', + 'org.freedesktop.Notifications', + None, + on_proxy_ready) + + def _send(self, event: events.Notification) -> None: + if not self._dbus_available: + return + + notification = Gio.Notification() + if event.title is not None: + notification.set_title(GLib.markup_escape_text(event.title)) + notification.set_body(GLib.markup_escape_text(event.text)) + notification.set_priority(Gio.NotificationPriority.NORMAL) + + icon = self._make_icon(event) + notification.set_icon(icon) + + self._add_actions(event, notification) + notification_id = self._make_notification_id(event) + + app.app.send_notification(notification_id, notification) + + def _add_actions(self, + event: events.Notification, + notification: Gio.Notification) -> None: + + if event.type not in self._action_types: + return + + if 'actions' not in self._daemon_capabilities: + return + + jid = event.jid + if jid is not None and isinstance(jid, str): + jid = JID.from_string(jid) + + params = OpenEventActionParams(type=event.type, + sub_type=event.sub_type, + account=event.account, + jid=jid) + + action = f'app.{event.account}-open-event' + notification.add_button_with_target( + _('Open'), action, params.to_variant()) + notification.set_default_action_and_target( + action, params.to_variant()) + + if event.type == 'incoming-message': + action = f'app.{event.account}-mark-as-read' + notification.add_button_with_target( + _('Mark as Read'), action, params.to_variant()) + + def _make_notification_id(self, + event: events.Notification) -> Optional[str]: + if event.type == 'connection-failed': + return self._make_id(['connection-failed', event.account]) + + if event.type == 'incoming-message': + return self._make_id(['new-message', event.account, str(event.jid)]) + + return None + + @staticmethod + def _get_avatar_for_notification(account: str, + jid: Union[JID, str]) -> GdkPixbuf.Pixbuf: + scale = get_monitor_scale_factor() + client = app.get_client(account) + contact = client.get_module('Contacts').get_contact(jid) + return app.interface.get_avatar(contact, + AvatarSize.NOTIFICATION, + scale, + pixbuf=True) + + def _make_icon(self, event: events.Notification) -> Gio.Icon: + if (event.type == 'incoming-message' and app.desktop_env == 'gnome'): + assert event.jid is not None + return self._get_avatar_for_notification(event.account, event.jid) + + if event.icon_name is not None: + return Gio.ThemedIcon.new(event.icon_name) + + icon_name = event.sub_type or event.type + icon_name = NOTIFICATION_ICONS.get(icon_name, 'mail-unread') + return Gio.ThemedIcon.new(icon_name) + + def _withdraw(self, details: list[Any]) -> None: + if not self._dbus_available: + return + notification_id = self._make_id(details) + app.app.withdraw_notification(notification_id) + + @staticmethod + def _make_id(details: list[Any]) -> str: + return ','.join(map(str, details)) + + +def get_notification_backend() -> NotificationBackend: + if sys.platform == 'win32': + return Windows() + + if sys.platform == 'darwin': + return DummyBackend() + return Linux() + + +def init() -> None: + global _notification_backend # pylint: disable=global-statement + _notification_backend = get_notification_backend() ===================================== gajim/gtk/notification_manager.py ===================================== @@ -173,7 +173,7 @@ def add_subscription_request(self, app.ged.raise_event( Notification(account=self._account, jid=event.jid, - notif_type='subscription-request', + type='subscription-request', title=_('Subscription Request'), text=text)) elif row.type == 'unsubscribed': @@ -193,7 +193,7 @@ def add_unsubscribed(self, app.ged.raise_event( Notification(account=self._account, jid=event.jid, - notif_type='unsubscribed', + type='unsubscribed', title=_('Contact Unsubscribed'), text=text)) elif row.type == 'subscribe': @@ -216,7 +216,7 @@ def add_invitation_received(self, event: MucInvitation) -> None: app.ged.raise_event( Notification(account=self._account, jid=jid, - notif_type='group-chat-invitation', + type='group-chat-invitation', title=_('Group Chat Invitation'), text=text)) ===================================== gajim/gtk/structs.py ===================================== @@ -0,0 +1,31 @@ +# This file is part of Gajim. +# +# Gajim is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; version 3 only. +# +# Gajim is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. + +from __future__ import annotations + +from typing import Optional + +from dataclasses import dataclass + +from nbxmpp.protocol import JID + +from gajim.common.structs import VariantMixin + + +@dataclass +class OpenEventActionParams(VariantMixin): + type: str + sub_type: Optional[str] + account: str + jid: Optional[JID] ===================================== gajim/gui_interface.py ===================================== @@ -33,6 +33,7 @@ from __future__ import annotations +from typing import Any from typing import Dict from typing import Optional from typing import Union @@ -92,7 +93,6 @@ from gajim.common.modules.httpupload import HTTPFileTransfer from gajim.gui.avatar import AvatarStorage -from gajim.gui.notification import Notification from gajim.gui.dialogs import DialogButton from gajim.gui.dialogs import ErrorDialog from gajim.gui.dialogs import WarningDialog @@ -144,8 +144,6 @@ def __init__(self): app.proxy65_manager = proxy65_manager.Proxy65Manager(app.idlequeue) - app.notification = Notification() - self._create_core_handlers_list() self._register_core_handlers() @@ -237,26 +235,6 @@ def _register_core_handlers(self) -> None: prio, event_handler) - def handle_event(self, account: str, jid: str, notif_detail: str) -> None: - jid = JID.from_string(jid) - - if notif_detail in ('connection-lost', 'connection-failed'): - app.window.show_account_page(account) - elif notif_detail == 'private-chat-message': - app.window.select_chat(account, jid) - elif notif_detail in ('chat-message', 'group-chat-message'): - app.window.select_chat(account, jid.bare) - elif notif_detail == 'incoming-call': - app.window.select_chat(account, jid.bare) - elif notif_detail == 'file-request-received': - app.window.select_chat(account, jid.bare) - elif notif_detail in ('subscription-request', - 'unsubscribed', - 'group-chat-invitation'): - app.window.show_account_page(account) - - app.window.present_with_time(Gtk.get_current_event_time()) - @staticmethod def handle_event_information(event): if not event.popup: @@ -983,7 +961,7 @@ def get_avatar(self, scale: int, show: Optional[str] = None, pixbuf: bool = False, - style: str = 'circle'): + style: str = 'circle') -> Any: if pixbuf: return self.avatar_storage.get_pixbuf( contact, size, scale, show, style=style) ===================================== pyrightconfig.json ===================================== @@ -35,6 +35,7 @@ "gajim/gtk/conversation/rows/scroll_hint.py", "gajim/gtk/conversation/rows/widgets.py", "gajim/gtk/conversation/scrolled.py", + "gajim/gtk/notification.py", "gajim/gtk/status_message_selector.py", "gajim/gtk/status_selector.py", ], View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5477bd0308b5e4574aa38ee67104f00…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/5477bd0308b5e4574aa38ee67104f00…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 5 commits: Preview: Simplify additional data access
by Daniel Brötzmann (ï¼ wurstsalat)
08 Jan '22
08 Jan '22
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: bfedea86 by wurstsalat at 2022-01-08T00:48:30+01:00 Preview: Simplify additional data access - - - - - fb1ec43c by wurstsalat at 2022-01-08T00:48:51+01:00 AccountPage: Typing - - - - - c6fc0dce by wurstsalat at 2022-01-08T00:49:16+01:00 NotificationManager: Typing - - - - - 45c5d555 by wurstsalat at 2022-01-08T01:21:23+01:00 Util: Typing - - - - - 5477bd03 by wurstsalat at 2022-01-08T01:21:54+01:00 Fix false exception type for GLib.Error - - - - - 6 changed files: - gajim/common/jingle_rtp.py - gajim/common/preview.py - gajim/gtk/account_page.py - gajim/gtk/filechoosers.py - gajim/gtk/notification_manager.py - gajim/gtk/util.py Changes: ===================================== gajim/common/jingle_rtp.py ===================================== @@ -124,7 +124,7 @@ def make_bin_from_config(self, config_key, pipeline, text): try: gst_bin = Gst.parse_bin_from_description(pipeline, True) return gst_bin - except GLib.GError as err: + except GLib.Error as err: app.ged.raise_event( InformationEvent( conn=self.session.connection, ===================================== gajim/common/preview.py ===================================== @@ -200,10 +200,7 @@ def _create_session(account: str) -> Tuple[ def _accept_uri(urlparts: ParseResult, uri: str, additional_data: AdditionalDataDict) -> bool: - try: - oob_url = additional_data['gajim']['oob_url'] - except (KeyError, AttributeError): - oob_url = None + oob_url = additional_data.get_value('gajim', 'oob_url') # geo if urlparts.scheme == 'geo': ===================================== gajim/gtk/account_page.py ===================================== @@ -12,12 +12,19 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. +from typing import Any + +from gi.repository import Gdk from gi.repository import Gio from gi.repository import Gtk from gajim.common import app from gajim.common import ged from gajim.common.const import AvatarSize +from gajim.common.events import SubscribePresenceReceived +from gajim.common.events import UnsubscribedPresenceReceived +from gajim.common.events import MucInvitation +from gajim.common.events import MucDecline from gajim.common.i18n import _ from .roster import Roster @@ -84,22 +91,22 @@ def __init__(self, account: str) -> None: self.show_all() self.connect('destroy', self._on_destroy) - def _on_destroy(self, *args): + def _on_destroy(self, *args: Any) -> None: app.check_finalize(self) - def _on_edit_profile(self, _button): + def _on_edit_profile(self, _button: Gtk.Button) -> None: open_window('ProfileWindow', account=self._account) - def _on_account_settings(self, _button): + def _on_account_settings(self, _button: Gtk.Button) -> None: window = open_window('AccountsWindow') window.select_account(self._account) - def _on_search_changed(self, widget): + def _on_search_changed(self, widget: Gtk.SearchEntry) -> None: text = widget.get_text().lower() self._roster.set_search_string(text) @staticmethod - def _on_button_release(paned, event): + def _on_button_release(paned: Gtk.Paned, event: Gdk.EventButton) -> None: if event.window != paned.get_handle_window(): return position = paned.get_position() @@ -120,22 +127,24 @@ def update(self) -> None: self._status_selector.update() - def _subscribe_received(self, event): + def _subscribe_received(self, event: SubscribePresenceReceived) -> None: if event.account != self._account: return self._notification_manager.add_subscription_request(event) - def _unsubscribed_received(self, event): + def _unsubscribed_received(self, + event: UnsubscribedPresenceReceived + ) -> None: if event.account != self._account: return self._notification_manager.add_unsubscribed(event) - def _muc_invitation_received(self, event): + def _muc_invitation_received(self, event: MucInvitation) -> None: if event.account != self._account: return self._notification_manager.add_invitation_received(event) - def _muc_invitation_declined(self, event): + def _muc_invitation_declined(self, event: MucDecline) -> None: if event.account != self._account: return self._notification_manager.add_invitation_declined(event) ===================================== gajim/gtk/filechoosers.py ===================================== @@ -77,7 +77,7 @@ def _update_preview(self, filechooser): try: pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size( path_to_file, *self._preivew_size) - except GLib.GError: + except GLib.Error: preview.clear() return filechooser.get_preview_widget().set_from_pixbuf(pixbuf) ===================================== gajim/gtk/notification_manager.py ===================================== @@ -12,6 +12,11 @@ # You should have received a copy of the GNU General Public License # along with Gajim. If not, see <
http://www.gnu.org/licenses/
>. +from __future__ import annotations +from typing import Any +from typing import Optional +from typing import Union + from gi.repository import Gio from gi.repository import GLib from gi.repository import Gtk @@ -23,6 +28,10 @@ from gajim.common.const import AvatarSize from gajim.common.i18n import _ from gajim.common.events import Notification +from gajim.common.events import SubscribePresenceReceived +from gajim.common.events import UnsubscribedPresenceReceived +from gajim.common.events import MucInvitation +from gajim.common.events import MucDecline from gajim.common.helpers import get_groupchat_name from gajim.common.helpers import get_muc_context @@ -31,7 +40,7 @@ class NotificationManager(Gtk.ListBox): - def __init__(self, account): + def __init__(self, account: str) -> None: Gtk.ListBox.__init__(self) self._account = account self._client = app.get_client(account) @@ -51,10 +60,10 @@ def __init__(self, account): self._add_actions() self.connect('destroy', self._on_destroy) - def _on_destroy(self, *args): + def _on_destroy(self, *args: Any) -> None: self._remove_actions() - def _add_actions(self): + def _add_actions(self) -> None: actions = [ ('subscription-accept', self._on_subscription_accept), ('subscription-deny', self._on_subscription_deny), @@ -68,7 +77,7 @@ def _add_actions(self): act.connect('activate', func) app.window.add_action(act) - def update_actions(self): + def update_actions(self) -> None: online = app.account_is_connected(self._account) blocking_support = self._client.get_module('Blocking').supported @@ -83,7 +92,7 @@ def update_actions(self): f'subscription-report-{self._account}').set_enabled( online and blocking_support) - def _remove_actions(self): + def _remove_actions(self) -> None: actions = [ 'subscription-accept', 'subscription-deny', @@ -93,7 +102,10 @@ def _remove_actions(self): for action in actions: app.window.remove_action(f'{action}-{self._account}') - def _on_subscription_accept(self, _action, param): + def _on_subscription_accept(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: jid = param.get_string() row = self._get_notification_row(jid) self._client.get_module('Presence').subscribed(jid) @@ -102,38 +114,53 @@ def _on_subscription_accept(self, _action, param): if not contact.is_in_roster: open_window('AddContact', account=self._account, jid=jid, nick=contact.name) - self.remove(row) + if row is not None: + self.remove(row) - def _on_subscription_block(self, _action, param): + def _on_subscription_block(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: jid = param.get_string() self._deny_request(jid) self._client.get_module('Blocking').block([jid]) row = self._get_notification_row(jid) - self.remove(row) + if row is not None: + self.remove(row) - def _on_subscription_report(self, _action, param): + def _on_subscription_report(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: jid = param.get_string() self._deny_request(jid) self._client.get_module('Blocking').block([jid], report='spam') row = self._get_notification_row(jid) - self.remove(row) + if row is not None: + self.remove(row) - def _on_subscription_deny(self, _action, param): + def _on_subscription_deny(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: jid = param.get_string() self._deny_request(jid) row = self._get_notification_row(jid) - self.remove(row) + if row is not None: + self.remove(row) - def _deny_request(self, jid): + def _deny_request(self, jid: str) -> None: self._client.get_module('Presence').unsubscribed(jid) - def _get_notification_row(self, jid): - for child in self.get_children(): - if child.jid == jid: - return child + def _get_notification_row(self, jid: str) -> Optional[NotificationRow]: + for row in self.get_children(): + if row.jid == jid: + return row return None - def add_subscription_request(self, event): + def add_subscription_request(self, + event: SubscribePresenceReceived + ) -> None: row = self._get_notification_row(event.jid) if row is None: self.add(SubscriptionRequestRow( @@ -152,7 +179,9 @@ def add_subscription_request(self, event): elif row.type == 'unsubscribed': self.remove(row) - def add_unsubscribed(self, event): + def add_unsubscribed(self, + event: UnsubscribedPresenceReceived + ) -> None: row = self._get_notification_row(event.jid) if row is None: self.add(UnsubscribedRow(self._account, event.jid)) @@ -170,8 +199,8 @@ def add_unsubscribed(self, event): elif row.type == 'subscribe': self.remove(row) - def add_invitation_received(self, event): - row = self._get_notification_row(event.muc) + def add_invitation_received(self, event: MucInvitation) -> None: + row = self._get_notification_row(str(event.muc)) if row is None: self.add(InvitationReceivedRow(self._account, event)) @@ -191,24 +220,25 @@ def add_invitation_received(self, event): title=_('Group Chat Invitation'), text=text)) - def add_invitation_declined(self, event): - row = self._get_notification_row(event.muc) + def add_invitation_declined(self, event: MucDecline) -> None: + row = self._get_notification_row(str(event.muc)) if row is None: self.add(InvitationDeclinedRow(self._account, event)) class NotificationRow(Gtk.ListBoxRow): - def __init__(self, account, jid): + def __init__(self, account: str, jid: str) -> None: Gtk.ListBoxRow.__init__(self) self._account = account self._client = app.get_client(account) self.jid = jid + self.type = '' self.grid = Gtk.Grid(column_spacing=12) self.add(self.grid) @staticmethod - def _generate_label(): + def _generate_label() -> Gtk.Label: label = Gtk.Label() label.set_halign(Gtk.Align.START) label.set_hexpand(True) @@ -217,7 +247,7 @@ def _generate_label(): label.set_max_width_chars(30) return label - def _generate_avatar_image(self, jid): + def _generate_avatar_image(self, jid: Union[str, JID]) -> Gtk.Image: contact = self._client.get_module('Contacts').get_contact(jid) surface = contact.get_avatar( AvatarSize.ROSTER, self.get_scale_factor(), add_show=False) @@ -227,7 +257,12 @@ def _generate_avatar_image(self, jid): class SubscriptionRequestRow(NotificationRow): - def __init__(self, account, jid, text, user_nick=None): + def __init__(self, + account: str, + jid: str, + text: str, + user_nick: Optional[str] = None + ) -> None: NotificationRow.__init__(self, account, jid) self.type = 'subscribe' @@ -264,7 +299,7 @@ def __init__(self, account, jid, text, user_nick=None): more_button = Gtk.MenuButton() more_button.set_valign(Gtk.Align.CENTER) more_button.add(more_image) - subscription_menu = get_subscription_menu(self._account, self.jid) + subscription_menu = get_subscription_menu(self._account, str(self.jid)) more_button.set_menu_model(subscription_menu) self.grid.attach(more_button, 4, 1, 1, 2) @@ -272,7 +307,7 @@ def __init__(self, account, jid, text, user_nick=None): class UnsubscribedRow(NotificationRow): - def __init__(self, account, jid): + def __init__(self, account: str, jid: str) -> None: NotificationRow.__init__(self, account, jid) self.type = 'unsubscribed' @@ -310,13 +345,13 @@ def __init__(self, account, jid): self.show_all() - def _on_dismiss(self, _button): + def _on_dismiss(self, _button: Gtk.Button) -> None: self.destroy() class InvitationReceivedRow(NotificationRow): - def __init__(self, account, event): - NotificationRow.__init__(self, account, event.muc) + def __init__(self, account: str, event: MucInvitation) -> None: + NotificationRow.__init__(self, account, str(event.muc)) self.type = 'invitation-received' self._event = event @@ -358,21 +393,21 @@ def __init__(self, account, event): self.show_all() - def _on_show_invitation(self, _button): + def _on_show_invitation(self, _button: Gtk.Button) -> None: open_window('GroupChatInvitation', account=self._account, event=self._event) self.destroy() - def _on_decline_invitation(self, _button): + def _on_decline_invitation(self, _button: Gtk.Button) -> None: self._client.get_module('MUC').decline( self.jid, self._event.from_) self.destroy() class InvitationDeclinedRow(NotificationRow): - def __init__(self, account, event): - NotificationRow.__init__(self, account, event.muc) + def __init__(self, account: str, event: MucDecline) -> None: + NotificationRow.__init__(self, account, str(event.muc)) self.type = 'invitation-declined' jid = event.from_.bare @@ -407,5 +442,5 @@ def __init__(self, account, event): self.show_all() - def _on_dismiss(self, _button): + def _on_dismiss(self, _button: Gtk.Button) -> None: self.destroy() ===================================== gajim/gtk/util.py ===================================== @@ -145,7 +145,7 @@ def nick_matching(nick: str) -> bool: return matches + other_nicks -def set_urgency_hint(window: Any, setting: bool) -> None: +def set_urgency_hint(window: Gtk.Window, setting: bool) -> None: if app.settings.get('use_urgency_hint'): window.set_urgency_hint(setting) @@ -205,9 +205,9 @@ def load_icon_pixbuf(icon_name: str, return icon_info.load_icon() -def get_app_icon_list(scale_widget: Any) -> List[GdkPixbuf.Pixbuf]: +def get_app_icon_list(scale_widget: Gtk.Widget) -> list[GdkPixbuf.Pixbuf]: scale = scale_widget.get_scale_factor() - pixbufs = [] + pixbufs: list[GdkPixbuf.Pixbuf] = [] for size in (16, 32, 48, 64, 128): pixbuf = load_icon_pixbuf('org.gajim.Gajim', size=size, scale=scale) if pixbuf is not None: @@ -247,8 +247,8 @@ def load_user_iconsets() -> None: icon_theme.append_search_path(str(path)) -def get_available_iconsets() -> List[str]: - iconsets = [] +def get_available_iconsets() -> list[str]: + iconsets: list[str] = [] for iconset in GajimIconSet: iconsets.append(iconset.value) @@ -263,7 +263,7 @@ def get_available_iconsets() -> List[str]: return iconsets -def get_total_screen_geometry() -> Tuple[int, int]: +def get_total_screen_geometry() -> tuple[int, int]: total_width = 0 total_height = 0 display = Gdk.Display.get_default() @@ -630,7 +630,7 @@ def get_pixbuf_from_data(file_data: bytes) -> Optional[GdkPixbuf.Pixbuf]: pixbufloader.write(file_data) pixbufloader.close() pixbuf = pixbufloader.get_pixbuf() - except GLib.GError: + except GLib.Error: pixbufloader.close() log.warning('loading avatar using pixbufloader failed, trying to ' @@ -686,7 +686,7 @@ def load_pixbuf(path: Union[str, Path], return GdkPixbuf.Pixbuf.new_from_file_at_scale( str(path), size, size, True) - except GLib.GError: + except GLib.Error: try: with open(path, 'rb') as im_handle: img = Image.open(im_handle) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/203e63d4a2756126cd49922a49cbd98…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/203e63d4a2756126cd49922a49cbd98…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] GUI Interface: Typing
by Daniel Brötzmann (ï¼ wurstsalat)
07 Jan '22
07 Jan '22
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 203e63d4 by wurstsalat at 2022-01-08T00:01:00+01:00 GUI Interface: Typing - - - - - 1 changed file: - gajim/gui_interface.py Changes: ===================================== gajim/gui_interface.py ===================================== @@ -76,6 +76,7 @@ from gajim.common.events import FileHashError from gajim.common.events import FileProgress from gajim.common.events import FileError +from gajim.common.events import MucAdded from gajim.common.zeroconf import connection_zeroconf from gajim.common.helpers import ask_for_status_message from gajim.common.structs import OutgoingMessage @@ -599,7 +600,7 @@ def __compare_hashes(account: str, file_props: FileProp) -> None: session.end_session() def send_httpupload(self, - chat_control: ControlType, + chat_control: ControlType, path: Optional[str] = None ) -> None: if path is not None: @@ -711,11 +712,11 @@ def start_chat_from_jid(account: str, app.app.activate_action('start-chat', GLib.Variant('s', str(jid))) @staticmethod - def _on_muc_added(event): - if app.window.chat_exists(event.account, event.jid): + def _on_muc_added(event: MucAdded) -> None: + if app.window.chat_exists(event.account, JID.from_string(event.jid)): return - app.window.add_group_chat(event.account, event.jid) + app.window.add_group_chat(event.account, JID.from_string(event.jid)) @staticmethod def create_account(account: str, View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/203e63d4a2756126cd49922a49cbd981…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/203e63d4a2756126cd49922a49cbd981…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 4 commits: BaseControl: Typing
by Daniel Brötzmann (ï¼ wurstsalat)
07 Jan '22
07 Jan '22
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 0ebc5ff9 by wurstsalat at 2022-01-07T23:51:53+01:00 BaseControl: Typing - - - - - 020ae6f1 by wurstsalat at 2022-01-07T23:52:21+01:00 Types: Add BaseControl to ControlType - - - - - bd8d0a97 by wurstsalat at 2022-01-07T23:53:33+01:00 Notifications: Use AvatarSize const - - - - - d161c1f0 by wurstsalat at 2022-01-07T23:55:10+01:00 GUI Interface: Typing - - - - - 4 changed files: - gajim/gtk/controls/base.py - gajim/gtk/notification.py - gajim/gtk/types.py - gajim/gui_interface.py Changes: ===================================== gajim/gtk/controls/base.py ===================================== @@ -114,7 +114,7 @@ class BaseControl(ChatCommandProcessor, CommandTools, EventHelper): A base class containing a banner, ConversationView, MessageInputTextView """ - _type = None # type: ControlType + _type: Optional[ControlType] = None def __init__(self, widget_name: str, account: str, jid: JID) -> None: EventHelper.__init__(self) @@ -208,7 +208,7 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None: self.msg_textview.connect('key-press-event', self._on_message_textview_key_press_event) self.msg_textview.connect('populate-popup', - self.on_msg_textview_populate_popup) + self._on_msg_textview_populate_popup) self.msg_textview.get_buffer().connect( 'changed', self._on_message_tv_buffer_changed) @@ -255,7 +255,7 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None: # XEP-0172 User Nickname # TODO: - self.user_nick = None + self.user_nick: Optional[str] = None self.command_hits: List[str] = [] self.last_key_tabs: bool = False @@ -264,7 +264,7 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None: self._client.get_module('Chatstate').set_active(self.contact) - self.encryption = self.get_encryption_state() + self.encryption: Optional[str] = self.get_encryption_state() self.conversation_view.encryption_enabled = self.encryption is not None # PluginSystem: adding GUI extension point for BaseControl @@ -283,10 +283,10 @@ def __init__(self, widget_name: str, account: str, jid: JID) -> None: # to properly use the super, because of the old code. CommandTools.__init__(self) - def _connect_contact_signals(self): + def _connect_contact_signals(self) -> None: raise NotImplementedError - def _get_action(self, name: str) -> Gio.Action: + def _get_action(self, name: str) -> Gio.SimpleAction: return app.window.lookup_action(f'{name}{self.control_id}') def process_event(self, event): @@ -329,7 +329,10 @@ def _on_message_updated(self, event): self.conversation_view.show_message_retraction( event.properties.moderation.stanza_id, text) - def _on_conversation_view_key_press(self, _listbox, event): + def _on_conversation_view_key_press(self, + _listbox: ConversationView, + event: Gdk.EventKey + ) -> int: if event.get_state() & Gdk.ModifierType.SHIFT_MASK: if event.keyval in (Gdk.KEY_Page_Down, Gdk.KEY_Page_Up): return Gdk.EVENT_PROPAGATE @@ -395,7 +398,7 @@ def allow_shutdown(self, method, on_response_yes, on_response_no): """ on_response_yes(self) - def focus(self): + def focus(self) -> None: raise NotImplementedError def draw_banner(self) -> None: @@ -432,22 +435,11 @@ def repaint_themed_widgets(self) -> None: """ self.draw_banner() - def _update_toolbar(self): + def _update_toolbar(self) -> None: """ Derived types MAY implement this """ - def get_tab_label(self, chatstate): - """ - Return a suitable tab label string. Returns a tuple such as: (label_str, - color) either of which can be None if chatstate is given that means we - have HE SENT US a chatstate and we want it displayed - - Derivded classes MUST implement this. - """ - # Return a markup'd label and optional Gtk.Color in a tuple like: - # return (label_str, None) - def set_session(self, session): oldsession = None if hasattr(self, 'session'): @@ -577,7 +569,10 @@ def mark_as_read(self, send_marker: bool = True) -> None: self._type) self.last_msg_id = None - def change_encryption(self, action, param): + def change_encryption(self, + action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: encryption = param.get_string() if encryption == 'disabled': encryption = None @@ -622,16 +617,16 @@ def set_lock_image(self) -> None: self.xml.authentication_button.set_visible(visible) self.xml.lock_image.set_sensitive(visible) - def _on_authentication_button_clicked(self, _button): + def _on_authentication_button_clicked(self, _button: Gtk.Button) -> None: app.plugin_manager.extension_point( 'encryption_dialog' + self.encryption, self) - def set_encryption_state(self, encryption): + def set_encryption_state(self, encryption: Optional[str]) -> None: self.encryption = encryption self.conversation_view.encryption_enabled = encryption is not None self.contact.settings.set('encryption', self.encryption or '') - def get_encryption_state(self): + def get_encryption_state(self) -> Optional[str]: state = self.contact.settings.get('encryption') if not state: return None @@ -668,7 +663,7 @@ def set_speller(self) -> None: spell_checker.connect('notify::language', self.on_language_changed) - def get_speller_language(self): + def get_speller_language(self) -> Optional[Gspell.Language]: lang = self.contact.settings.get('speller_language') if not lang: # use the default one @@ -680,7 +675,7 @@ def get_speller_language(self): gspell_lang = Gspell.language_get_default() return gspell_lang - def on_language_changed(self, checker, _param): + def on_language_changed(self, checker: Gspell.Checker, _param: Any) -> None: gspell_lang = checker.get_language() self.contact.settings.set('speller_language', gspell_lang.get_code()) @@ -716,7 +711,10 @@ def shutdown(self) -> None: self.unregister_events() - def on_msg_textview_populate_popup(self, _textview, menu): + def _on_msg_textview_populate_popup(self, + _textview: MessageInputTextView, + menu: Gtk.Widget + ) -> None: """ Override the default context menu and we prepend an option to switch languages @@ -754,17 +752,19 @@ def paste_clipboard_as_quote(self, _item: Gtk.MenuItem) -> None: return self.insert_as_quote(text) - def on_quote(self, _widget, text): + def on_quote(self, _widget: Gtk.Widget, text: str) -> None: self.insert_as_quote(text) - def on_mention(self, _widget, name): + def on_mention(self, _widget: Gtk.Widget, name: str) -> None: gc_refer_to_nick_char = app.settings.get('gc_refer_to_nick_char') text = f'{name}{gc_refer_to_nick_char} ' message_buffer = self.msg_textview.get_buffer() message_buffer.insert_at_cursor(text) GLib.idle_add(self.msg_textview.grab_focus) - def _on_message_textview_paste_event(self, _texview): + def _on_message_textview_paste_event(self, + _texview: MessageInputTextView + ) -> None: clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) image = clipboard.wait_for_image() if image is not None: @@ -824,7 +824,7 @@ def _get_pref_ft_method(self) -> Optional[str]: return 'jingle' return None - def _start_filetransfer(self, path): + def _start_filetransfer(self, path: str) -> None: method = self._get_pref_ft_method() if method is None: return @@ -836,7 +836,10 @@ def _start_filetransfer(self, path): app.interface.instances['file_transfers'].send_file( self.account, self.contact, path) - def _on_send_file(self, action, _param): + def _on_send_file(self, + action: Gio.SimpleAction, + _param: Optional[GLib.Variant] + ) -> None: name = action.get_name() if 'httpupload' in name: app.interface.send_httpupload(self) @@ -857,7 +860,10 @@ def _on_send_file(self, action, _param): app.interface.instances['file_transfers'].show_file_send_request( self.account, self.contact) - def _on_message_textview_key_press_event(self, textview, event): + def _on_message_textview_key_press_event(self, + textview: MessageInputTextView, + event: Gdk.EventKey + ) -> bool: # pylint: disable=too-many-nested-blocks if event.keyval == Gdk.KEY_space: self.space_pressed = True @@ -978,7 +984,10 @@ def _on_message_textview_key_press_event(self, textview, event): return False - def _on_autoscroll_changed(self, _widget, autoscroll): + def _on_autoscroll_changed(self, + _widget: ScrolledView, + autoscroll: bool + ) -> None: if not autoscroll: self._jump_to_end_button.toggle(True) return @@ -986,23 +995,41 @@ def _on_autoscroll_changed(self, _widget, autoscroll): self._jump_to_end_button.toggle(False) app.window.mark_as_read(self.account, self.contact.jid) - def _on_jump_to_end(self, _button): + def _on_jump_to_end(self, _button: Gtk.Button) -> None: self.scroll_to_end(force=True) self._jump_to_end_button.reset_unread_count() - def _on_drag_data_received(self, widget, context, x_coord, y_coord, - selection, target_type, timestamp): + def _on_drag_data_received(self, + widget: Gtk.Widget, + context: Gdk.DragContext, + x_coord: int, + y_coord: int, + selection: Gtk.SelectionData, + target_type: int, + timestamp: int + ) -> None: """ Derived types SHOULD implement this """ - def _on_drag_leave(self, *args): + def _on_drag_leave(self, + _widget: Gtk.Widget, + _context: Gdk.DragContext, + _time: int + ) -> None: self.xml.drop_area.set_no_show_all(True) self.xml.drop_area.hide() - def _on_drag_motion(self, *args): + def _on_drag_motion(self, + _widget: Gtk.Widget, + _context: Gdk.DragContext, + _x_coord: int, + _y_coord: int, + _time: int + ) -> bool: self.xml.drop_area.set_no_show_all(False) self.xml.drop_area.show_all() + return True def drag_data_file_transfer(self, selection: Gtk.SelectionData) -> None: # we may have more than one file dropped @@ -1017,7 +1044,7 @@ def drag_data_file_transfer(self, selection: Gtk.SelectionData) -> None: self._start_filetransfer(path) - def get_seclabel(self): + def get_seclabel(self) -> Optional[str]: idx = self.xml.label_selector.get_active() if idx == -1: return None @@ -1032,7 +1059,7 @@ def get_seclabel(self): def get_our_nick(self) -> str: return app.nicks[self.account] - def _on_send_message(self, *args): + def _on_send_message(self, *args: Any) -> None: self.msg_textview.replace_emojis() message = self.msg_textview.get_text() self.send_message(message) @@ -1086,7 +1113,9 @@ def send_message(self, self.msg_textview.clear() - def _on_message_tv_buffer_changed(self, textbuffer): + def _on_message_tv_buffer_changed(self, + textbuffer: Gtk.TextBuffer + ) -> None: has_text = self.msg_textview.has_text() app.window.lookup_action( f'send-message-{self.control_id}').set_enabled(has_text) @@ -1095,7 +1124,8 @@ def _on_message_tv_buffer_changed(self, textbuffer): app.plugin_manager.extension_point( 'typing' + self.encryption, self) - self._client.get_module('Chatstate').set_keyboard_activity(self.contact) + self._client.get_module('Chatstate').set_keyboard_activity( + self.contact) if not has_text: self._client.get_module('Chatstate').set_chatstate_delayed( self.contact, Chatstate.ACTIVE) @@ -1301,7 +1331,7 @@ def set_emoticon_popover(self) -> None: self.xml.emoticons_button.connect('clicked', self._on_emoticon_button_clicked) - def _on_emoticon_button_clicked(self, _widget): + def _on_emoticon_button_clicked(self, _widget: Gtk.Button) -> None: # Present GTK emoji chooser (not cross platform compatible) self.msg_textview.emit('insert-emoji') self.xml.emoticons_button.set_property('active', False) @@ -1315,7 +1345,7 @@ def _on_formatting_menuitem_activate(self, def _style_changed(self, *args): self.update_text_tags() - def update_text_tags(self): + def update_text_tags(self) -> None: self.conversation_view.update_text_tags() def set_control_active(self, state: bool) -> None: ===================================== gajim/gtk/notification.py ===================================== @@ -42,6 +42,7 @@ from gajim.common import app from gajim.common import ged from gajim.common import events +from gajim.common.const import AvatarSize from gajim.common.const import StyleAttr from gajim.common.i18n import _ from gajim.common.helpers import allow_showing_notification @@ -239,7 +240,8 @@ def _get_avatar_for_notification(account: str, scale = get_monitor_scale_factor() client = app.get_client(account) contact = client.get_module('Contacts').get_contact(jid) - return app.interface.get_avatar(contact, 32, scale, pixbuf=True) + return app.interface.get_avatar( + contact, AvatarSize.NOTIFICATION, scale, pixbuf=True) def _on_popup_destroy(self, *args): self._win32_active_popup = None ===================================== gajim/gtk/types.py ===================================== @@ -18,6 +18,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: + from .controls.base import BaseControl from .controls.chat import ChatControl from .controls.private import PrivateChatControl from .controls.groupchat import GroupchatControl @@ -38,6 +39,7 @@ ControlType = Union [ + 'BaseControl', 'ChatControl', 'PrivateChatControl', 'GroupchatControl' ===================================== gajim/gui_interface.py ===================================== @@ -57,32 +57,38 @@ from nbxmpp import Hashes2 from nbxmpp import JID -from gajim.common import app -from gajim.common.dbus import logind -from gajim.common.dbus import music_track -from gajim.common.events import AccountDisabled, AccountEnabled, FileCompleted, FileHashError -from gajim.common.events import FileProgress -from gajim.common.events import FileError - -from gajim.gui import menus from gajim.dialog_messages import get_dialog +from gajim.common import app +from gajim.common import ged +from gajim.common import exceptions from gajim.common import idle -from gajim.common.zeroconf import connection_zeroconf from gajim.common import proxy65_manager from gajim.common import socks5 from gajim.common import helpers from gajim.common import passwords + +from gajim.common.dbus import logind +from gajim.common.dbus import music_track +from gajim.common.events import AccountEnabled +from gajim.common.events import AccountDisabled +from gajim.common.events import FileCompleted +from gajim.common.events import FileHashError +from gajim.common.events import FileProgress +from gajim.common.events import FileError +from gajim.common.zeroconf import connection_zeroconf from gajim.common.helpers import ask_for_status_message from gajim.common.structs import OutgoingMessage from gajim.common.i18n import _ from gajim.common.client import Client from gajim.common.preview import PreviewManager -from gajim.common.const import Display +from gajim.common.const import Display, FTState from gajim.common.file_props import FileProp -from gajim.common import ged -from gajim.common import exceptions +from gajim.common.modules.contacts import GroupchatContact +from gajim.common.modules.contacts import GroupchatParticipant +from gajim.common.modules.contacts import BareContact +from gajim.common.modules.httpupload import HTTPFileTransfer from gajim.gui.avatar import AvatarStorage from gajim.gui.notification import Notification @@ -95,13 +101,17 @@ from gajim.gui.filechoosers import FileChooserDialog from gajim.gui.filetransfer import FileTransfersWindow from gajim.gui.main import MainWindow +from gajim.gui.menus import build_accounts_menu from gajim.gui.util import get_app_window from gajim.gui.util import get_app_windows from gajim.gui.util import get_color_for_account from gajim.gui.util import open_window +from gajim.gui.types import ControlType log = logging.getLogger('gajim.interface') +ContactT = Union[BareContact, GroupchatContact, GroupchatParticipant] + class Interface: def __init__(self): @@ -189,7 +199,7 @@ def __init__(self): self._network_status_changed) self._network_state: bool = self._network_monitor.get_network_available() - def _create_core_handlers_list(self): + def _create_core_handlers_list(self) -> None: # pylint: disable=line-too-long self.handlers = { 'information': [self.handle_event_information], @@ -209,7 +219,7 @@ def _create_core_handlers_list(self): } # pylint: enable=line-too-long - def _register_core_handlers(self): + def _register_core_handlers(self) -> None: """ Register core handlers in Global Events Dispatcher (GED). @@ -297,7 +307,7 @@ def handle_event_plain_connection(event): @staticmethod def handle_event_http_auth(event): # ('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg)) - def _response(_account, answer): + def _response(answer: str) -> None: event.conn.get_module('HTTPAuth').build_http_auth_answer( event.stanza, answer) @@ -321,10 +331,10 @@ def _response(_account, answer): [DialogButton.make('Cancel', text=_('_No'), callback=_response, - args=[event, 'no']), + args=['no']), DialogButton.make('Accept', callback=_response, - args=[event, 'yes'])]).show() + args=['yes'])]).show() @staticmethod def handle_event_client_cert_passphrase(event): @@ -588,7 +598,10 @@ def __compare_hashes(account: str, file_props: FileProp) -> None: if session: session.end_session() - def send_httpupload(self, chat_control, path=None): + def send_httpupload(self, + chat_control: ControlType, + path: Optional[str] = None + ) -> None: if path is not None: self._send_httpupload(chat_control, path) return @@ -598,11 +611,14 @@ def send_httpupload(self, chat_control, path=None): select_multiple=True, transient_for=app.window) - def _on_file_dialog_ok(self, chat_control, paths): + def _on_file_dialog_ok(self, + chat_control: ControlType, + paths: list[str] + ) -> None: for path in paths: self._send_httpupload(chat_control, path) - def _send_httpupload(self, chat_control, path): + def _send_httpupload(self, chat_control: ControlType, path: str) -> None: client = app.get_client(chat_control.account) try: transfer = client.get_module('HTTPUpload').make_transfer( @@ -620,7 +636,11 @@ def _send_httpupload(self, chat_control, path): chat_control.add_file_transfer(transfer) client.get_module('HTTPUpload').start_transfer(transfer) - def _on_http_upload_state_changed(self, transfer, _signal_name, state): + def _on_http_upload_state_changed(self, + transfer: HTTPFileTransfer, + _signal_name: str, + state: FTState + ) -> None: # Note: This has to be a bound method in order to connect the signal if state.is_finished: uri = transfer.get_transformed_uri() @@ -638,7 +658,10 @@ def _on_http_upload_state_changed(self, transfer, _signal_name, state): client = app.get_client(transfer.account) client.send_message(message) - def _on_cancel_upload(self, transfer, _signal_name): + def _on_cancel_upload(self, + transfer: HTTPFileTransfer, + _signal_name: str + ) -> None: # Note: This has to be a bound method in order to connect the signal client = app.get_client(transfer.account) client.get_module('HTTPUpload').cancel_transfer(transfer) @@ -648,7 +671,7 @@ def create_groupchat(account: str, room_jid: str, config: Dict[str, Union[str, bool]] ) -> None: - if app.window.chat_exists(account, room_jid): + if app.window.chat_exists(account, JID.from_string(room_jid)): log.error('Trying to create groupchat ' 'which is already added as chat') return @@ -667,18 +690,18 @@ def show_add_join_groupchat(account: str, client.get_module('MUC').join( jid, nick=nickname, password=password) - app.window.add_group_chat(account, jid, select=True) + app.window.add_group_chat(account, JID.from_string(jid), select=True) @staticmethod def start_chat_from_jid(account: str, jid: str, message: Optional[str] = None ) -> None: - jid = JID.from_string(jid) - if app.window.chat_exists(account, jid): - app.window.select_chat(account, jid) + jid_ = JID.from_string(jid) + if app.window.chat_exists(account, jid_): + app.window.select_chat(account, jid_) if message is not None: - control = app.window.get_control(account, jid) + control = app.window.get_control(account, jid_) if control is None: return control.msg_textview.insert_text(message) @@ -779,7 +802,7 @@ def enable_account(self, account: str) -> None: app.block_signed_in_notifications[account] = True app.settings.set_account_setting(account, 'active', True) - menus.build_accounts_menu() + build_accounts_menu() app.app.update_app_actions_state() app.ged.raise_event(AccountEnabled(account=account)) @@ -799,7 +822,7 @@ def disable_account(self, account: str) -> None: app.settings.set_account_setting(account, 'roster_version', '') app.settings.set_account_setting(account, 'active', False) - menus.build_accounts_menu() + build_accounts_menu() app.app.update_app_actions_state() app.ged.raise_event(AccountDisabled(account=account)) @@ -954,12 +977,12 @@ def save_avatar(self, data: bytes) -> Optional[str]: return self.avatar_storage.save_avatar(data) def get_avatar(self, - contact, - size, - scale, - show=None, - pixbuf=False, - style='circle'): + contact: ContactT, + size: int, + scale: int, + show: Optional[str] = None, + pixbuf: bool = False, + style: str = 'circle'): if pixbuf: return self.avatar_storage.get_pixbuf( contact, size, scale, show, style=style) @@ -1010,7 +1033,10 @@ def _on_delete(win, _event): view.updateNamespace({'gajim': app}) app.ipython_window = window - def _network_status_changed(self, monitor, _param): + def _network_status_changed(self, + monitor: Gio.NetworkMonitor, + _network_available: bool + ) -> None: connected = monitor.get_network_available() if connected == self._network_state: return View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0b5f4816d6ea99fda06de73778fc4a0…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0b5f4816d6ea99fda06de73778fc4a0…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
← Newer
1
...
202
203
204
205
206
207
208
...
1764
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
Results per page:
10
25
50
100
200