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] 3 commits: GroupChatInfo: Improve layout and args
by Daniel Brötzmann (ï¼ wurstsalat)
23 Dec '21
23 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 4c5cd191 by wurstsalat at 2021-12-23T20:57:19+01:00 GroupChatInfo: Improve layout and args - - - - - 50fdeece by wurstsalat at 2021-12-23T20:59:48+01:00 GroupchatControl: Improve layout - - - - - 6115adf4 by wurstsalat at 2021-12-23T21:01:11+01:00 Rework groupchat invitations - - - - - 12 changed files: - gajim/data/gui/groupchat_control.ui - gajim/data/gui/groupchat_info_scrolled.ui - − gajim/data/gui/groupchat_invite.ui - + gajim/data/gui/groupchat_inviter.ui - gajim/data/style/gajim.css - gajim/gtk/add_contact.py - + gajim/gtk/contacts_flowbox.py - gajim/gtk/controls/groupchat.py - gajim/gtk/groupchat_info.py - gajim/gtk/groupchat_invitation.py - gajim/gtk/groupchat_invite.py → gajim/gtk/groupchat_inviter.py - test/gtk/groupchat_info.py Changes: ===================================== gajim/data/gui/groupchat_control.ui ===================================== @@ -184,7 +184,6 @@ <property name="spacing">3</property> <child> <object class="GtkBox" id="textview_box"> - <property name="width-request">0</property> <property name="visible">True</property> <property name="can-focus">False</property> <property name="margin-end">4</property> @@ -619,7 +618,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -708,24 +707,6 @@ <property name="top-attach">2</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -745,7 +726,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -843,24 +824,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -880,7 +843,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -969,24 +932,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -1006,7 +951,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=2 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -1079,27 +1024,6 @@ <property name="top-attach">0</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -1119,7 +1043,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=4 --> + <!-- n-columns=1 n-rows=4 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -1239,30 +1163,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -1282,7 +1182,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -1370,24 +1270,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -1407,7 +1289,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid" id="info_grid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -1477,24 +1359,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> <style> <class name="margin-18"/> </style> @@ -1517,7 +1381,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=4 --> + <!-- n-columns=1 n-rows=4 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -1625,30 +1489,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -1668,7 +1508,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=4 --> + <!-- n-columns=1 n-rows=4 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -1776,30 +1616,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -1819,7 +1635,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=6 --> + <!-- n-columns=1 n-rows=6 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -1960,42 +1776,6 @@ <property name="top-attach">3</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -2015,7 +1795,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -2104,24 +1884,6 @@ <property name="top-attach">2</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -2141,7 +1903,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=2 --> <object class="GtkGrid" id="invite_grid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -2201,27 +1963,6 @@ <child> <placeholder/> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -2241,7 +1982,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid" id="settings_grid"> <property name="name">settings_grid</property> <property name="visible">True</property> @@ -2330,24 +2071,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> <style> <class name="margin-18"/> </style> @@ -2431,7 +2154,7 @@ </packing> </child> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=2 n-rows=2 --> <object class="GtkGrid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -2491,21 +2214,6 @@ <property name="top-attach">1</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> @@ -2599,7 +2307,7 @@ <property name="can-focus">False</property> <property name="orientation">vertical</property> <child> - <!-- n-columns=3 n-rows=3 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid" id="avatar_selector_grid"> <property name="name">settings_grid</property> <property name="visible">True</property> @@ -2689,24 +2397,6 @@ <child> <placeholder/> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> <packing> <property name="expand">False</property> ===================================== gajim/data/gui/groupchat_info_scrolled.ui ===================================== @@ -2,7 +2,7 @@ <!-- Generated with glade 3.38.2 --> <interface> <requires lib="gtk+" version="3.20"/> - <!-- n-columns=3 n-rows=10 --> + <!-- n-columns=2 n-rows=10 --> <object class="GtkGrid" id="info_grid"> <property name="visible">True</property> <property name="can-focus">False</property> @@ -82,6 +82,7 @@ <property name="wrap">True</property> <property name="wrap-mode">word-char</property> <property name="selectable">True</property> + <property name="max-width-chars">40</property> <property name="xalign">0</property> </object> <packing> @@ -95,6 +96,10 @@ <property name="no-show-all">True</property> <property name="halign">start</property> <property name="valign">start</property> + <property name="wrap">True</property> + <property name="wrap-mode">word-char</property> + <property name="max-width-chars">40</property> + <property name="xalign">0</property> </object> <packing> <property name="left-attach">1</property> @@ -151,6 +156,9 @@ <property name="no-show-all">True</property> <property name="halign">start</property> <property name="valign">start</property> + <property name="wrap">True</property> + <property name="max-width-chars">40</property> + <property name="xalign">0</property> </object> <packing> <property name="left-attach">1</property> @@ -159,7 +167,6 @@ </child> <child> <object class="GtkLinkButton" id="logs"> - <property name="label" translatable="yes">button</property> <property name="can-focus">True</property> <property name="receives-default">True</property> <property name="no-show-all">True</property> @@ -237,6 +244,7 @@ <property name="wrap">True</property> <property name="wrap-mode">word-char</property> <property name="selectable">True</property> + <property name="max-width-chars">40</property> <property name="xalign">0</property> <signal name="activate-link" handler="_on_activate_subject_link" swapped="no"/> </object> @@ -254,7 +262,7 @@ <property name="selectable">True</property> <property name="ellipsize">end</property> <property name="single-line-mode">True</property> - <property name="max-width-chars">40</property> + <property name="max-width-chars">30</property> <style> <class name="large-header"/> </style> @@ -285,12 +293,13 @@ <property name="spacing">12</property> <child> <object class="GtkLabel" id="address"> - <property name="width-request">240</property> + <property name="width-request">200</property> <property name="visible">True</property> <property name="can-focus">False</property> <property name="halign">start</property> <property name="selectable">True</property> <property name="ellipsize">middle</property> + <property name="single-line-mode">True</property> <property name="max-width-chars">30</property> <property name="xalign">0</property> </object> @@ -332,35 +341,5 @@ <property name="top-attach">2</property> </packing> </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> </object> </interface> ===================================== gajim/data/gui/groupchat_invite.ui deleted ===================================== @@ -1,238 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.22.1 --> -<interface> - <requires lib="gtk+" version="3.20"/> - <object class="GtkListStore" id="account_store"> - <columns> - <!-- column-name icon --> - <column type="GdkPixbuf"/> - <!-- column-name account --> - <column type="gchararray"/> - <!-- column-name account_label --> - <column type="gchararray"/> - </columns> - </object> - <object class="GtkBox" id="contacts_placeholder"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="orientation">vertical</property> - <property name="spacing">12</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">avatar-default-symbolic</property> - <property name="icon_size">6</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">No contacts left. -You can also type an XMPP address.</property> - <property name="justify">center</property> - <property name="wrap">True</property> - <property name="max_width_chars">35</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkGrid" id="invite_grid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="vexpand">True</property> - <property name="row_spacing">6</property> - <property name="column_spacing">24</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Invitees</property> - <style> - <class name="bold16"/> - </style> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Contacts</property> - <style> - <class name="bold16"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="vexpand">True</property> - <property name="orientation">vertical</property> - <child> - <object class="GtkScrolledWindow" id="invitees"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - <property name="hscrollbar_policy">never</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkViewport"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkListBox" id="invitees_listbox"> - <property name="name">StartChatListBox</property> - <property name="width_request">300</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">False</property> - <property name="selection_mode">browse</property> - </object> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="vexpand">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkSearchEntry" id="search_entry"> - <property name="width_request">300</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="is_focus">True</property> - <property name="hexpand">True</property> - <property name="primary_icon_name">edit-find-symbolic</property> - <property name="primary_icon_activatable">False</property> - <property name="primary_icon_sensitive">False</property> - <property name="placeholder_text" translatable="yes">Search contacts...</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkScrolledWindow" id="scrolledwindow"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">never</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkViewport"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkListBox" id="contacts_listbox"> - <property name="name">StartChatListBox</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="vexpand">True</property> - <property name="selection_mode">browse</property> - </object> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - </object> - <object class="GtkBox" id="invitees_placeholder"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="halign">center</property> - <property name="valign">center</property> - <property name="orientation">vertical</property> - <property name="spacing">12</property> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">contact-new-symbolic</property> - <property name="icon_size">6</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Click on contacts you would like to invite to this group chat.</property> - <property name="justify">center</property> - <property name="wrap">True</property> - <property name="max_width_chars">35</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> -</interface> ===================================== gajim/data/gui/groupchat_inviter.ui ===================================== @@ -0,0 +1,179 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface> + <requires lib="gtk+" version="3.24"/> + <object class="GtkListStore" id="account_store"> + <columns> + <!-- column-name icon --> + <column type="GdkPixbuf"/> + <!-- column-name account --> + <column type="gchararray"/> + <!-- column-name account_label --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkBox" id="invite_box"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Invite Contacts</property> + <style> + <class name="bold16"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSearchEntry" id="search_entry"> + <property name="width-request">300</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="has-focus">True</property> + <property name="is-focus">True</property> + <property name="hexpand">True</property> + <property name="primary-icon-name">edit-find-symbolic</property> + <property name="primary-icon-activatable">False</property> + <property name="primary-icon-sensitive">False</property> + <property name="placeholder-text" translatable="yes">Search contacts...</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="hscrollbar-policy">never</property> + <property name="shadow-type">in</property> + <property name="min-content-height">100</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <child> + <object class="GtkListBox" id="contacts_listbox"> + <property name="name">StartChatListBox</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="vexpand">True</property> + <property name="selection-mode">browse</property> + <child type="placeholder"> + <object class="GtkBox" id="contacts_placeholder"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="halign">center</property> + <property name="valign">center</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="icon-name">avatar-default-symbolic</property> + <property name="icon_size">6</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">No contacts left. +You can also type an XMPP address.</property> + <property name="justify">center</property> + <property name="wrap">True</property> + <property name="max-width-chars">35</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-top">6</property> + <property name="label" translatable="yes">Invitees</property> + <style> + <class name="bold"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Click on contacts you would like to invite to this group chat.</property> + <property name="justify">center</property> + <property name="wrap">True</property> + <property name="max-width-chars">42</property> + <style> + <class name="dim-label"/> + </style> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="invitees_scrolled"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="shadow-type">in</property> + <property name="min-content-height">100</property> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">5</property> + </packing> + </child> + </object> +</interface> ===================================== gajim/data/style/gajim.css ===================================== @@ -635,6 +635,20 @@ .start-chat-row { padding: 10px 20px 10px 10px; } .start-chat-row:not(.activatable) label { color: @insensitive_fg_color; } .start-chat-row:focus { outline: none; } +/* ContactFlowBox */ +.contact-flowbox-item { + background-color: alpha(@borders, 0.4); + border-radius: 12px; + padding: 6px; +} +.contact-flowbox-item button { + background: none; + border: 1px solid alpha(@borders, 0.4); +} +.contact-flowbox-item button:hover { + border: 1px solid @borders; +} + /* GroupChatRoster */ .groupchat-roster { border-left: 1px solid; border-color: @borders; } ===================================== gajim/gtk/add_contact.py ===================================== @@ -477,7 +477,7 @@ def __init__(self) -> None: heading.set_justify(Gtk.Justification.CENTER) self.pack_start(heading, False, True, 0) - self._info_box = GroupChatInfoScrolled(options={'minimal': True}) + self._info_box = GroupChatInfoScrolled(minimal=True) self.pack_start(self._info_box, True, True, 0) self.show_all() ===================================== gajim/gtk/contacts_flowbox.py ===================================== @@ -0,0 +1,105 @@ +# +# 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 typing import List + +from gi.repository import GObject +from gi.repository import Gtk +from gi.repository import Pango + +from gajim.common import app +from gajim.common.const import AvatarSize +from gajim.common.i18n import _ + + +class ContactItem(Gtk.FlowBoxChild): + def __init__(self, account: str, jid: str) -> None: + Gtk.FlowBoxChild.__init__(self) + self.set_size_request(150, -1) + + self.account = account + self.jid = jid + + client = app.get_client(account) + contact = client.get_module('Contacts').get_contact(jid) + + surface = contact.get_avatar( + AvatarSize.ROSTER, self.get_scale_factor()) + avatar_image = Gtk.Image.new_from_surface(surface) + + name_label = Gtk.Label(label=contact.name) + name_label.set_tooltip_text(contact.name) + name_label.set_ellipsize(Pango.EllipsizeMode.END) + name_label.set_max_width_chars(12) + name_label.get_style_context().add_class('bold') + + remove_button = Gtk.Button.new_from_icon_name( + 'window-close', Gtk.IconSize.BUTTON) + remove_button.set_valign(Gtk.Align.CENTER) + remove_button.set_halign(Gtk.Align.END) + remove_button.set_hexpand(True) + remove_button.set_relief(Gtk.ReliefStyle.NONE) + remove_button.set_tooltip_text(_('Remove')) + remove_button.connect('clicked', self._on_remove) + + box = Gtk.Box(spacing=6) + box.set_valign(Gtk.Align.CENTER) + box.add(avatar_image) + box.add(name_label) + box.add(remove_button) + box.get_style_context().add_class('contact-flowbox-item') + self.add(box) + self.show_all() + + def _on_remove(self, _button: Gtk.Button) -> None: + self.get_parent().on_contact_removed(self) + + +class ContactsFlowBox(Gtk.FlowBox): + + __gsignals__ = { + 'contact-removed': (GObject.SignalFlags.RUN_LAST, None, (str, str)) + } + + def __init__(self) -> None: + Gtk.FlowBox.__init__(self) + self.set_column_spacing(6) + self.set_row_spacing(3) + self.set_selection_mode(Gtk.SelectionMode.NONE) + self.set_valign(Gtk.Align.START) + self.show_all() + + def clear(self) -> None: + def _remove(item): + self.remove(item) + item.destroy() + self.foreach(_remove) + + def add_contact(self, account: str, jid: str) -> None: + contact_item = ContactItem(account, jid) + self.add(contact_item) + + def has_contacts(self) -> bool: + return bool(self.get_child_at_index(0) is not None) + + def get_contact_jids(self) -> List[str]: + contacts = [] + for contact in self.get_children(): + contacts.append(contact.jid) + return contacts + + def on_contact_removed(self, row: ContactItem) -> None: + account = row.account + jid = row.jid + row.destroy() + self.emit('contact-removed', account, jid) ===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -75,7 +75,7 @@ from gajim.gui.avatar_selector import AvatarSelector from gajim.gui.dataform import DataFormWidget from gajim.gui.groupchat_info import GroupChatInfoScrolled -from gajim.gui.groupchat_invite import GroupChatInvite +from gajim.gui.groupchat_inviter import GroupChatInviter from gajim.gui.groupchat_settings import GroupChatSettings from gajim.gui.groupchat_roster import GroupchatRoster from gajim.gui.groupchat_state import GroupchatState @@ -166,7 +166,7 @@ def __init__(self, account: str, jid: JID) -> None: # MUC Info self._subject_data = None - self._muc_info_box = GroupChatInfoScrolled(self.account, {'width': 600}) + self._muc_info_box = GroupChatInfoScrolled(self.account) self.xml.info_box.add(self._muc_info_box) # Groupchat settings @@ -180,7 +180,7 @@ def __init__(self, account: str, jid: JID) -> None: self.xml.quick_invite_button.set_action_name( f'win.invite-{self.control_id}') - self._invite_box = GroupChatInvite(self.room_jid) + self._invite_box = GroupChatInviter(self.room_jid) self.xml.invite_grid.attach(self._invite_box, 0, 0, 1, 1) self._invite_box.connect('listbox-changed', self._on_invite_ready) ===================================== gajim/gtk/groupchat_info.py ===================================== @@ -12,8 +12,6 @@ # 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 typing import Dict from typing import List from typing import Optional @@ -106,21 +104,21 @@ class GroupChatInfoScrolled(Gtk.ScrolledWindow): def __init__(self, account: Optional[str] = None, - options: Optional[Dict[str, Any]] = None + width: Optional[int] = 300, + minimal: Optional[bool] = False ) -> None: Gtk.ScrolledWindow.__init__(self) - if options is None: - options = {} - - self._minimal = options.get('minimal', False) - - self.set_size_request(options.get('width', 400), -1) + self.set_size_request(width, -1) self.set_halign(Gtk.Align.CENTER) - if self._minimal: + self._minimal = minimal + + if minimal: self.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) else: self.set_vexpand(True) + self.set_hexpand(True) + self.set_propagate_natural_width(True) self.set_min_content_height(400) self.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) ===================================== gajim/gtk/groupchat_invitation.py ===================================== @@ -44,7 +44,7 @@ def __init__(self, account, event): main_box.set_valign(Gtk.Align.FILL) main_box.get_style_context().add_class('padding-18') - muc_info_box = GroupChatInfoScrolled(account, {'minimal': True}) + muc_info_box = GroupChatInfoScrolled(account, minimal=True) muc_info_box.set_from_disco_info(event.info) main_box.add(muc_info_box) ===================================== gajim/gtk/groupchat_invite.py → gajim/gtk/groupchat_inviter.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 List +from typing import Optional + import locale from gi.repository import Gdk @@ -21,66 +25,154 @@ from gi.repository import Pango from gajim.common import app +from gajim.common import types from gajim.common.i18n import _ from gajim.common.const import AvatarSize +from gajim.common.const import Direction from gajim.common.helpers import validate_jid from .builder import get_builder +from .contacts_flowbox import ContactsFlowBox from .util import AccountBadge -class GroupChatInvite(Gtk.Box): +class ContactRow(Gtk.ListBoxRow): + def __init__(self, + account: str, + contact: Optional[types.BareContact], + jid: str, + name: str, + show_account: bool + ) -> None: + Gtk.ListBoxRow.__init__(self) + self.get_style_context().add_class('start-chat-row') + self.account = account + self.jid = jid + + self._contact = contact + self._name = name + self._show_account = show_account + + self._account_label = app.get_account_label(account) + self.is_new: bool = jid == '' + + grid = Gtk.Grid() + grid.set_column_spacing(12) + grid.set_size_request(260, -1) + + image = self._get_avatar_image(contact) + image.set_size_request(AvatarSize.ROSTER, AvatarSize.ROSTER) + grid.add(image) + + box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) + box.set_hexpand(True) + + if self._name is None: + self._name = _('Invite New Contact') + + self._name_label = Gtk.Label(label=self._name) + self._name_label.set_ellipsize(Pango.EllipsizeMode.END) + self._name_label.set_xalign(0) + self._name_label.set_width_chars(20) + self._name_label.set_halign(Gtk.Align.START) + self._name_label.get_style_context().add_class('bold16') + name_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) + name_box.add(self._name_label) + + if show_account: + account_badge = AccountBadge(account) + account_badge.set_halign(Gtk.Align.END) + account_badge.set_valign(Gtk.Align.START) + account_badge.set_hexpand(True) + name_box.add(account_badge) + box.add(name_box) + + self._jid_label = Gtk.Label(label=str(jid)) + self._jid_label.set_tooltip_text(str(jid)) + self._jid_label.set_ellipsize(Pango.EllipsizeMode.END) + self._jid_label.set_xalign(0) + self._jid_label.set_width_chars(22) + self._jid_label.set_halign(Gtk.Align.START) + self._jid_label.get_style_context().add_class('dim-label') + box.add(self._jid_label) + + grid.add(box) + + self.add(grid) + self.show_all() + + def _get_avatar_image(self, contact: types.BareContact) -> Gtk.Image: + if self.is_new: + icon_name = 'avatar-default' + return Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.DND) + + scale = self.get_scale_factor() + surface = contact.get_avatar(AvatarSize.ROSTER, scale) + return Gtk.Image.new_from_surface(surface) + + def update_jid(self, jid: str) -> None: + self.jid = jid + self._jid_label.set_text(jid) + + def get_search_text(self): + if self._contact is None: + return str(self.jid) + if self._show_account: + return f'{self._name} {self.jid} {self._account_label}' + return f'{self._name} {self.jid}' + + +class GroupChatInviter(Gtk.Box): __gsignals__ = { 'listbox-changed': (GObject.SignalFlags.RUN_LAST, None, (bool,)) } - def __init__(self, room_jid): + def __init__(self, room_jid: str) -> None: Gtk.Box.__init__(self) - self.set_size_request(-1, 300) - self._ui = get_builder('groupchat_invite.ui') - self.add(self._ui.invite_grid) + self.set_size_request(-1, 250) + self._ui = get_builder('groupchat_inviter.ui') + self.add(self._ui.invite_box) + + self._invitees_box = ContactsFlowBox() + self._invitees_box.connect('contact-removed', self._on_invitee_removed) + self._ui.invitees_scrolled.add(self._invitees_box) self._ui.contacts_listbox.set_filter_func(self._filter_func, None) self._ui.contacts_listbox.set_sort_func(self._sort_func, None) - self._ui.contacts_listbox.set_placeholder(self._ui.contacts_placeholder) - self._ui.contacts_listbox.connect('row-activated', - self._on_contacts_row_activated) + self._ui.contacts_listbox.connect( + 'row-activated', self._on_contacts_row_activated) - self._ui.invitees_listbox.set_sort_func(self._sort_func, None) - self._ui.invitees_listbox.set_placeholder( - self._ui.invitees_placeholder) - self._ui.invitees_listbox.connect('row-activated', - self._on_invitees_row_activated) + self._room_jid = room_jid self._new_contact_row_visible = False - self._room_jid = room_jid + self._new_contact_rows: dict[str, Optional[ContactRow]] = {} + self._accounts: list[list[str]] = [] - self._ui.search_entry.connect('search-changed', - self._on_search_changed) - self._ui.search_entry.connect('next-match', - self._select_new_match, 'next') - self._ui.search_entry.connect('previous-match', - self._select_new_match, 'prev') + self._ui.search_entry.connect( + 'search-changed', self._on_search_changed) + self._ui.search_entry.connect( + 'next-match', self._select_new_match, Direction.NEXT) + self._ui.search_entry.connect( + 'previous-match', self._select_new_match, Direction.PREV) self._ui.search_entry.connect( 'stop-search', lambda *args: self._ui.search_entry.set_text('')) - self._ui.search_entry.connect('activate', - self._on_search_activate) + self._ui.search_entry.connect( + 'activate', self._on_search_activate) self.connect('key-press-event', self._on_key_press) self._ui.connect_signals(self) self.show_all() - def _add_accounts(self): + def _add_accounts(self) -> None: for account in self._accounts: self._ui.account_store.append([None, *account]) - def _add_contacts(self): + def _add_contacts(self) -> None: show_account = len(self._accounts) > 1 for account, _label in self._accounts: - self.new_contact_rows[account] = None + self._new_contact_rows[account] = None client = app.get_client(account) for contact in client.get_module('Roster').iter_contacts(): - # Exclude group chats if contact.is_groupchat: continue @@ -88,12 +180,18 @@ def _add_contacts(self): if contact.jid == client.get_own_jid().bare: continue - row = ContactRow(account, contact, contact.jid, - contact.name, show_account) + row = ContactRow(account, + contact, + str(contact.jid), + contact.name, + show_account) self._ui.contacts_listbox.add(row) - def _on_contacts_row_activated(self, listbox, row): - if row.new: + def _on_contacts_row_activated(self, + listbox: Gtk.ListBox, + row: Gtk.ListBoxRow + ) -> None: + if row.is_new: jid = row.jid try: validate_jid(jid) @@ -104,35 +202,42 @@ def _on_contacts_row_activated(self, listbox, row): self._ui.search_entry.set_icon_tooltip_text( Gtk.EntryIconPosition.SECONDARY, str(error)) return + self._ui.search_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, None) - show_account = len(self._accounts) > 1 - row = ContactRow( - row.account, None, '', None, show_account) - row.update_jid(jid) - self._remove_new_jid_row() - else: + self._remove_new_contact_row() + + self._invitees_box.add_contact(row.account, row.jid) + + if not row.is_new: listbox.remove(row) - self._ui.invitees_listbox.add(row) - self._ui.invitees_listbox.unselect_row(row) - self._ui.search_entry.set_text('') + row.destroy() + self._ui.search_entry.set_text('') GLib.timeout_add(50, self._select_first_row) self._ui.search_entry.grab_focus() - invitable = self._ui.invitees_listbox.get_row_at_index(0) is not None + invitable = self._invitees_box.has_contacts() self.emit('listbox-changed', invitable) - def _on_invitees_row_activated(self, listbox, row): - listbox.remove(row) - if not row.new: - self._ui.contacts_listbox.add(row) - self._ui.contacts_listbox.unselect_row(row) + def _on_invitee_removed(self, + flowbox: ContactsFlowBox, + account: str, + jid: str + ) -> None: + show_account = len(self._accounts) > 1 + client = app.get_client(account) + contact = client.get_module('Contacts').get_contact(jid) + row = ContactRow(account, + contact, + str(contact.jid), + contact.name, + show_account) + self._ui.contacts_listbox.add(row) self._ui.search_entry.grab_focus() - invitable = listbox.get_row_at_index(0) is not None - self.emit('listbox-changed', invitable) + self.emit('listbox-changed', flowbox.has_contacts()) - def _on_key_press(self, _widget, event): + def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> int: if event.keyval == Gdk.KEY_Down: self._ui.search_entry.emit('next-match') return Gdk.EVENT_STOP @@ -151,50 +256,59 @@ def _on_key_press(self, _widget, event): return Gdk.EVENT_PROPAGATE - def _on_search_activate(self, _entry): + def _on_search_activate(self, _entry: Gtk.SearchEntry) -> None: row = self._ui.contacts_listbox.get_selected_row() if row is not None and row.get_child_visible(): row.emit('activate') - def _on_search_changed(self, entry): + def _on_search_changed(self, entry: Gtk.SearchEntry) -> None: search_text = entry.get_text() if '@' in search_text: - self._add_new_jid_row() - self._update_new_jid_rows(search_text) + self._add_new_contact_row() + self._update_new_contact_rows(search_text) else: - self._remove_new_jid_row() + self._remove_new_contact_row() self._ui.contacts_listbox.invalidate_filter() - def _add_new_jid_row(self): + def _add_new_contact_row(self) -> None: if self._new_contact_row_visible: return - for account in self.new_contact_rows: + + for account in self._new_contact_rows: show_account = len(self._accounts) > 1 - row = ContactRow(account, None, '', None, show_account) - self.new_contact_rows[account] = row + row = ContactRow(account, + None, + '', + None, + show_account) + self._new_contact_rows[account] = row self._ui.contacts_listbox.add(row) row.get_parent().show_all() self._new_contact_row_visible = True - def _remove_new_jid_row(self): + def _remove_new_contact_row(self) -> None: if not self._new_contact_row_visible: return - for row in self.new_contact_rows.values(): + + for row in self._new_contact_rows.values(): self._ui.contacts_listbox.remove(row) self._new_contact_row_visible = False - def _update_new_jid_rows(self, search_text): - for row in self.new_contact_rows.values(): + def _update_new_contact_rows(self, search_text: str) -> None: + for row in self._new_contact_rows.values(): row.update_jid(search_text) - def _select_new_match(self, _entry, direction): + def _select_new_match(self, + _entry: Gtk.SearchEntry, + direction: Direction + ) -> None: selected_row = self._ui.contacts_listbox.get_selected_row() if selected_row is None: return index = selected_row.get_index() - if direction == 'next': + if direction == Direction.NEXT: index += 1 else: index -= 1 @@ -207,31 +321,37 @@ def _select_new_match(self, _entry, direction): self._ui.contacts_listbox.select_row(new_selected_row) new_selected_row.grab_focus() return - if direction == 'next': + if direction == Direction.NEXT: index += 1 else: index -= 1 - def _select_first_row(self): + def _select_first_row(self) -> None: first_row = self._ui.contacts_listbox.get_row_at_y(0) self._ui.contacts_listbox.select_row(first_row) - def _scroll_to_first_row(self): + def _scroll_to_first_row(self) -> None: self._ui.scrolledwindow.get_vadjustment().set_value(0) - def _filter_func(self, row, _user_data): + def _filter_func(self, + row: ContactRow, + _user_data: Optional[object] + ) -> bool: search_text = self._ui.search_entry.get_text().lower() search_text_list = search_text.split() row_text = row.get_search_text().lower() for text in search_text_list: if text not in row_text: GLib.timeout_add(50, self._select_first_row) - return None + return False GLib.timeout_add(50, self._select_first_row) return True @staticmethod - def _sort_func(row1, row2, _user_data): + def _sort_func(row1: ContactRow, + row2: ContactRow, + _user_data: Optional[object] + ) -> int: name1 = row1.get_search_text() name2 = row2.get_search_text() account1 = row1.account @@ -243,101 +363,29 @@ def _sort_func(row1, row2, _user_data): return locale.strcoll(name1.lower(), name2.lower()) - def load_contacts(self): - self._ui.contacts_listbox.foreach(self._ui.contacts_listbox.remove) - self._ui.invitees_listbox.foreach(self._ui.invitees_listbox.remove) + def _reset(self) -> None: + def _remove(row): + self.remove(row) + row.destroy() + self._ui.contacts_listbox.foreach(_remove) + self._invitees_box.clear() + + def load_contacts(self) -> None: + self._reset() + self._accounts = app.get_enabled_accounts_with_labels() - self.new_contact_rows = {} + self._new_contact_rows = {} self._add_accounts() + self._add_contacts() + first_row = self._ui.contacts_listbox.get_row_at_index(0) self._ui.contacts_listbox.select_row(first_row) self._ui.search_entry.grab_focus() self.emit('listbox-changed', False) - def focus_search_entry(self): + def focus_search_entry(self) -> None: self._ui.search_entry.grab_focus() - def get_invitees(self): - invitees = [] - for row in self._ui.invitees_listbox.get_children(): - invitees.append(row.jid) - return invitees - - -class ContactRow(Gtk.ListBoxRow): - def __init__(self, account, contact, jid, name, show_account): - Gtk.ListBoxRow.__init__(self) - self.get_style_context().add_class('start-chat-row') - self.account = account - self.account_label = app.get_account_label(account) - self.show_account = show_account - self.jid = jid - self.contact = contact - self.name = name - self.new = jid == '' - - grid = Gtk.Grid() - grid.set_column_spacing(12) - grid.set_size_request(260, -1) - - image = self._get_avatar_image(contact) - image.set_size_request(AvatarSize.ROSTER, AvatarSize.ROSTER) - grid.add(image) - - box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) - box.set_hexpand(True) - - if self.name is None: - self.name = _('Invite New Contact') - - self.name_label = Gtk.Label(label=self.name) - self.name_label.set_ellipsize(Pango.EllipsizeMode.END) - self.name_label.set_xalign(0) - self.name_label.set_width_chars(20) - self.name_label.set_halign(Gtk.Align.START) - self.name_label.get_style_context().add_class('bold16') - name_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) - name_box.add(self.name_label) - - if show_account: - account_badge = AccountBadge(account) - account_badge.set_halign(Gtk.Align.END) - account_badge.set_valign(Gtk.Align.START) - account_badge.set_hexpand(True) - name_box.add(account_badge) - box.add(name_box) - - self.jid_label = Gtk.Label(label=str(jid)) - self.jid_label.set_tooltip_text(str(jid)) - self.jid_label.set_ellipsize(Pango.EllipsizeMode.END) - self.jid_label.set_xalign(0) - self.jid_label.set_width_chars(22) - self.jid_label.set_halign(Gtk.Align.START) - self.jid_label.get_style_context().add_class('dim-label') - box.add(self.jid_label) - - grid.add(box) - - self.add(grid) - self.show_all() - - def _get_avatar_image(self, contact): - if self.new: - icon_name = 'avatar-default' - return Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.DND) - - scale = self.get_scale_factor() - surface = contact.get_avatar(AvatarSize.ROSTER, scale) - return Gtk.Image.new_from_surface(surface) - - def update_jid(self, jid): - self.jid = jid - self.jid_label.set_text(jid) - - def get_search_text(self): - if self.contact is None: - return str(self.jid) - if self.show_account: - return '%s %s %s' % (self.name, self.jid, self.account_label) - return '%s %s' % (self.name, self.jid) + def get_invitees(self) -> List[str]: + return self._invitees_box.get_contact_jids() ===================================== test/gtk/groupchat_info.py ===================================== @@ -100,7 +100,7 @@ def __init__(self): spacing=18) self._main_box.set_valign(Gtk.Align.FILL) - self._muc_info_box = GroupChatInfoScrolled(None) + self._muc_info_box = GroupChatInfoScrolled() self._muc_info_box.set_vexpand(True) self._main_box.add(self._muc_info_box) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0e932b85f2d17902c5d03c63e9faf9e…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0e932b85f2d17902c5d03c63e9faf9e…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] Styling: Fix linting suggestions
by Daniel Brötzmann (ï¼ wurstsalat)
23 Dec '21
23 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 0e932b85 by wurstsalat at 2021-12-23T12:56:27+01:00 Styling: Fix linting suggestions - - - - - 1 changed file: - gajim/common/styling.py Changes: ===================================== gajim/common/styling.py ===================================== @@ -199,7 +199,7 @@ def process(text: Union[str, bytes], nested: bool = False) -> ParsingResult: for line in block.text.splitlines(keepends=True): block.spans += _parse_line(line, offset, offset_bytes) block.uris += _parse_uris(line, offset, offset_bytes) - block.emojis += _parse_emojis(line, offset, offset_bytes) + block.emojis += _parse_emojis(line, offset) offset += len(line) offset_bytes += len(line.encode()) @@ -320,20 +320,19 @@ def make(match: Match[str], is_address: bool) -> BaseUri: return uris -def _parse_emojis(line: str, offset: int, offset_bytes: int) -> list[Emoji]: +def _parse_emojis(line: str, offset: int) -> list[Emoji]: emojis: list[Emoji] = [] def make(match: Match[str]) -> Emoji: return _make_emoji(line, match.start(), match.end() - 1, - offset, - offset_bytes) - + offset) + for match in EMOJI_RX.finditer(line): emoji = make(match) emojis.append(emoji) - + return emojis @@ -417,8 +416,7 @@ def _make_link(line: str, def _make_emoji(line: str, start: int, end: int, - offset: int, - offset_bytes: int) -> Emoji: + offset: int) -> Emoji: text = line[start:end + 1] start += offset end += offset + 1 View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/0e932b85f2d17902c5d03c63e9faf9e4…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/0e932b85f2d17902c5d03c63e9faf9e4…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: Add emoji parsing for Windows
by Daniel Brötzmann (ï¼ wurstsalat)
23 Dec '21
23 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: ee5e4ef0 by wurstsalat at 2021-12-23T12:22:52+01:00 Add emoji parsing for Windows - - - - - 482e4fea by wurstsalat at 2021-12-23T12:28:53+01:00 MessageInput: Rename buffer var - - - - - 3 changed files: - gajim/common/styling.py - gajim/gtk/conversation/plain_widget.py - gajim/gtk/message_input.py Changes: ===================================== gajim/common/styling.py ===================================== @@ -24,6 +24,8 @@ from gi.repository import GLib +from gajim.gui.emoji_data import emoji_data + PRE = '`' STRONG = '*' STRIKE = '~' @@ -47,6 +49,8 @@ ADDRESS_RX = r'(\b(?P<protocol>(xmpp|mailto)+:)?[\w-]*@(.*?\.)+[\w]+([\?].*?(?=([\s\),]|$)))?)' ADDRESS_RX = re.compile(ADDRESS_RX) +EMOJI_RX = emoji_data.get_regex() +EMOJI_RX = re.compile(EMOJI_RX) SD = 0 SD_POS = 1 @@ -90,6 +94,11 @@ class MailAddress(BaseUri): name: str = field(default='mailadr', init=False) +@dataclass +class Emoji(StyleObject): + name: str = field(default='emoji', init=False) + + @dataclass class Block(StyleObject): @@ -105,6 +114,7 @@ class PlainBlock(Block): name: str = field(default='plain', init=False) spans: list[Span] = field(default_factory=list) uris: list[BaseUri] = field(default_factory=list) + emojis: list[Emoji] = field(default_factory=list) @dataclass @@ -189,6 +199,7 @@ def process(text: Union[str, bytes], nested: bool = False) -> ParsingResult: for line in block.text.splitlines(keepends=True): block.spans += _parse_line(line, offset, offset_bytes) block.uris += _parse_uris(line, offset, offset_bytes) + block.emojis += _parse_emojis(line, offset, offset_bytes) offset += len(line) offset_bytes += len(line.encode()) @@ -309,6 +320,23 @@ def make(match: Match[str], is_address: bool) -> BaseUri: return uris +def _parse_emojis(line: str, offset: int, offset_bytes: int) -> list[Emoji]: + emojis: list[Emoji] = [] + + def make(match: Match[str]) -> Emoji: + return _make_emoji(line, + match.start(), + match.end() - 1, + offset, + offset_bytes) + + for match in EMOJI_RX.finditer(line): + emoji = make(match) + emojis.append(emoji) + + return emojis + + def _handle_pre_span(line: str, index: int, offset: int, @@ -386,6 +414,19 @@ def _make_link(line: str, text=text) +def _make_emoji(line: str, + start: int, + end: int, + offset: int, + offset_bytes: int) -> Emoji: + text = line[start:end + 1] + start += offset + end += offset + 1 + return Emoji(start=start, + end=end, + text=text) + + def _is_span_empty(sd: str, index: int, stack: list[tuple[str, int]]) -> bool: start_sd = stack[-1][SD] if start_sd != sd: ===================================== gajim/gtk/conversation/plain_widget.py ===================================== @@ -31,6 +31,9 @@ from gajim.common.structs import URI from gajim.common.styling import PlainBlock +from gajim.gui.emoji_data import emoji_pixbufs +from gajim.gui.emoji_data import get_emoji_pixbuf + from gajim.gui_menu_builder import get_conv_action_context_menu from gajim.gui_menu_builder import get_conv_uri_context_menu @@ -205,6 +208,33 @@ def print_text_with_styling(self, block: PlainBlock) -> None: end_iter = buffer_.get_iter_at_offset(uri.end) buffer_.apply_tag_by_name(uri.name, start_iter, end_iter) + for emoji in block.emojis: + start_iter = buffer_.get_iter_at_offset(emoji.start) + end_iter = buffer_.get_iter_at_offset(emoji.end) + if emoji_pixbufs.complete: + # Only search for pixbuf if loading is completed + pixbuf = get_emoji_pixbuf(emoji.text) + if pixbuf is None: + buffer_.insert(end_iter, emoji.text) + else: + pixbuf = pixbuf.copy() + anchor = buffer_.create_child_anchor(end_iter) + anchor.plaintext = emoji.text + img = Gtk.Image.new_from_pixbuf(pixbuf) + img.show() + self.add_child_at_anchor(img, anchor) + buffer_.delete( + buffer_.get_iter_at_offset(emoji.start), + buffer_.get_iter_at_offset(emoji.end)) + else: + # Set marks and save them so we can replace emojis + # once loading is complete + start_mark = buffer_.create_mark(None, end_iter, True) + buffer_.insert(end_iter, emoji.text) + end_mark = buffer_.create_mark(None, end_iter, True) + emoji_pixbufs.append_marks( + self, start_mark, end_mark, emoji.text) + def add_action_phrase(self, text: str) -> None: buffer_ = self.get_buffer() buffer_.insert(buffer_.get_start_iter(), text.strip()) ===================================== gajim/gtk/message_input.py ===================================== @@ -102,11 +102,11 @@ def _on_focus_out(self, _widget, _event): return False def _clear_tags(self) -> None: - _buffer = self.get_buffer() - start, end = _buffer.get_bounds() - _buffer.remove_all_tags(start, end) + buf = self.get_buffer() + start, end = buf.get_bounds() + buf.remove_all_tags(start, end) - def _on_text_changed(self, buffer_: Gtk.TextBuffer) -> None: + def _on_text_changed(self, buf: Gtk.TextBuffer) -> None: text = self.get_text() if not text: return @@ -116,19 +116,19 @@ def _on_text_changed(self, buffer_: Gtk.TextBuffer) -> None: for block in result.blocks: if block.name == 'plain': for span in block.spans: - start_iter = buffer_.get_iter_at_offset(span.start) - end_iter = buffer_.get_iter_at_offset(span.end) - buffer_.apply_tag_by_name(span.name, start_iter, end_iter) + start_iter = buf.get_iter_at_offset(span.start) + end_iter = buf.get_iter_at_offset(span.end) + buf.apply_tag_by_name(span.name, start_iter, end_iter) def insert_text(self, text: str) -> None: self.get_buffer().insert_at_cursor(text) def insert_newline(self) -> None: - buffer_ = self.get_buffer() - buffer_.insert_at_cursor('\n') - mark = buffer_.get_insert() - iter_ = buffer_.get_iter_at_mark(mark) - if buffer_.get_end_iter().equal(iter_): + buf = self.get_buffer() + buf.insert_at_cursor('\n') + mark = buf.get_insert() + iter_ = buf.get_iter_at_mark(mark) + if buf.get_end_iter().equal(iter_): GLib.idle_add(scroll_to_end, self.get_parent()) def has_text(self) -> bool: @@ -150,63 +150,63 @@ def toggle_speller(self, activate: bool) -> None: @staticmethod def _after_paste_clipboard(textview: Gtk.TextView) -> None: - buffer_ = textview.get_buffer() - mark = buffer_.get_insert() - iter_ = buffer_.get_iter_at_mark(mark) - if iter_.get_offset() == buffer_.get_end_iter().get_offset(): + buf = textview.get_buffer() + mark = buf.get_insert() + iter_ = buf.get_iter_at_mark(mark) + if iter_.get_offset() == buf.get_end_iter().get_offset(): GLib.idle_add(scroll_to_end, textview.get_parent()) def _get_active_iters(self) -> Tuple[Gtk.TextIter, Gtk.TextIter]: - _buffer = self.get_buffer() - return_val = _buffer.get_selection_bounds() + buf = self.get_buffer() + return_val = buf.get_selection_bounds() if return_val: # if something is selected start, end = return_val[0], return_val[1] else: - start, end = _buffer.get_bounds() + start, end = buf.get_bounds() return (start, end) def apply_formatting(self, formatting: str) -> None: format_char = FORMAT_CHARS[formatting] - _buffer = self.get_buffer() + buf = self.get_buffer() start, end = self._get_active_iters() start_offset = start.get_offset() end_offset = end.get_offset() - text = _buffer.get_text(start, end, True) + text = buf.get_text(start, end, True) if text.startswith(format_char) and text.endswith(format_char): # (Selected) text begins and ends with formatting chars # -> remove them - _buffer.delete( + buf.delete( start, - _buffer.get_iter_at_offset(start_offset + 1)) - _buffer.delete( - _buffer.get_iter_at_offset(end_offset - 2), - _buffer.get_iter_at_offset(end_offset - 1)) + buf.get_iter_at_offset(start_offset + 1)) + buf.delete( + buf.get_iter_at_offset(end_offset - 2), + buf.get_iter_at_offset(end_offset - 1)) return - ext_start = _buffer.get_iter_at_offset(start_offset - 1) - ext_end = _buffer.get_iter_at_offset(end_offset + 1) - ext_text = _buffer.get_text(ext_start, ext_end, True) + ext_start = buf.get_iter_at_offset(start_offset - 1) + ext_end = buf.get_iter_at_offset(end_offset + 1) + ext_text = buf.get_text(ext_start, ext_end, True) if ext_text.startswith(format_char) and ext_text.endswith(format_char): # (Selected) text is surrounded by formatting chars -> remove them - _buffer.delete( + buf.delete( ext_start, - _buffer.get_iter_at_offset(start_offset)) - _buffer.delete( - _buffer.get_iter_at_offset(end_offset - 1), - _buffer.get_iter_at_offset(end_offset)) + buf.get_iter_at_offset(start_offset)) + buf.delete( + buf.get_iter_at_offset(end_offset - 1), + buf.get_iter_at_offset(end_offset)) return # No formatting chars found at start/end or surrounding -> add them - _buffer.insert(start, format_char, -1) - _buffer.insert( - _buffer.get_iter_at_offset(end_offset + 1), + buf.insert(start, format_char, -1) + buf.insert( + buf.get_iter_at_offset(end_offset + 1), format_char, -1) - _buffer.select_range( - _buffer.get_iter_at_offset(start_offset), - _buffer.get_iter_at_offset(end_offset + 2)) + buf.select_range( + buf.get_iter_at_offset(start_offset), + buf.get_iter_at_offset(end_offset + 2)) def replace_emojis(self) -> None: theme = app.settings.get('emoticons_theme') @@ -229,35 +229,35 @@ def _replace(anchor): _replace(iter_.get_child_anchor()) def _replace_char_at_iter(self, iter_, new_char): - buffer_ = self.get_buffer() + buf = self.get_buffer() iter_2 = iter_.copy() iter_2.forward_char() - buffer_.delete(iter_, iter_2) - buffer_.insert(iter_, new_char) + buf.delete(iter_, iter_2) + buf.insert(iter_, new_char) def insert_emoji(self, codepoint, pixbuf): - buffer_ = self.get_buffer() - if buffer_.get_char_count(): + buf = self.get_buffer() + if buf.get_char_count(): # buffer contains text - buffer_.insert_at_cursor(' ') + buf.insert_at_cursor(' ') - insert_mark = buffer_.get_insert() - insert_iter = buffer_.get_iter_at_mark(insert_mark) + insert_mark = buf.get_insert() + insert_iter = buf.get_iter_at_mark(insert_mark) if pixbuf is None: - buffer_.insert(insert_iter, codepoint) + buf.insert(insert_iter, codepoint) else: - anchor = buffer_.create_child_anchor(insert_iter) + anchor = buf.create_child_anchor(insert_iter) image = Gtk.Image.new_from_pixbuf(pixbuf) image.codepoint = codepoint image.show() self.add_child_at_anchor(image, anchor) - buffer_.insert_at_cursor(' ') + buf.insert_at_cursor(' ') def clear(self, *args): - _buffer = self.get_buffer() - start, end = _buffer.get_bounds() - _buffer.delete(start, end) + buf = self.get_buffer() + start, end = buf.get_bounds() + buf.delete(start, end) def save_undo(self, text: str) -> None: self._undo_list.append(text) @@ -266,7 +266,7 @@ def save_undo(self, text: str) -> None: self.undo_pressed = False def undo(self, *args): - _buffer = self.get_buffer() + buf = self.get_buffer() if self._undo_list: - _buffer.set_text(self._undo_list.pop()) + buf.set_text(self._undo_list.pop()) self.undo_pressed = True View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/3ca29b0389eb05e02079cd6f723e2fc…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/3ca29b0389eb05e02079cd6f723e2fc…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] LogindListener: Catch errors while trying to inhibit sleep
by Daniel Brötzmann (ï¼ wurstsalat)
22 Dec '21
22 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 3ca29b03 by wurstsalat at 2021-12-23T00:30:43+01:00 LogindListener: Catch errors while trying to inhibit sleep Fixes #10248, fixes #9767 - - - - - 1 changed file: - gajim/common/dbus/logind.py Changes: ===================================== gajim/common/dbus/logind.py ===================================== @@ -94,17 +94,24 @@ def _inhibit_sleep(self, connection): log.warning('Trying to obtain a sleep inhibitor ' 'while already holding one.') - ret, ret_fdlist = connection.call_with_unix_fd_list_sync( - 'org.freedesktop.login1', - '/org/freedesktop/login1', - 'org.freedesktop.login1.Manager', - 'Inhibit', - GLib.Variant('(ssss)', ( - 'sleep', 'org.gajim.Gajim', _('Disconnect from the network'), - 'delay' # Inhibitor will delay but not block sleep - )), - GLib.VariantType.new('(h)'), - Gio.DBusCallFlags.NONE, -1, None, None) + try: + ret, ret_fdlist = connection.call_with_unix_fd_list_sync( + 'org.freedesktop.login1', + '/org/freedesktop/login1', + 'org.freedesktop.login1.Manager', + 'Inhibit', + GLib.Variant('(ssss)', ( + 'sleep', + 'org.gajim.Gajim', + _('Disconnect from the network'), + 'delay' # Inhibitor will delay but not block sleep + )), + GLib.VariantType.new('(h)'), + Gio.DBusCallFlags.NONE, -1, None, None) + except GLib.Error as error: + log.warning( + 'Cannot obtain a sleep delay inhibitor from logind: %s', error) + return log.info('Inhibit sleep') self._inhibit_fd = ret_fdlist.get(ret.unpack()[0]) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3ca29b0389eb05e02079cd6f723e2fcd…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/3ca29b0389eb05e02079cd6f723e2fcd…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 2 commits: ChatList: Improve message preview
by Daniel Brötzmann (ï¼ wurstsalat)
22 Dec '21
22 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: cbca090e by wurstsalat at 2021-12-22T23:42:31+01:00 ChatList: Improve message preview - - - - - df4329fc by wurstsalat at 2021-12-23T00:01:48+01:00 XMLConsole: Typing - - - - - 2 changed files: - gajim/gtk/chat_list.py - gajim/gtk/xml_console.py Changes: ===================================== gajim/gtk/chat_list.py ===================================== @@ -861,9 +861,9 @@ def set_message_text(self, text = text.replace('/me', f'* {nickname}', 1) text = f'<i>{text}</i>' - # Split by newline and display last line + # Split by newline and display last line (or first, if last is newline) lines = text.split('\n') - text = lines[-1] + text = lines[-1] or lines[0] self._ui.message_label.set_markup(text) if icon is None: ===================================== gajim/gtk/xml_console.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 typing import Any +from typing import List +from typing import Optional +from typing import Tuple + import time import nbxmpp @@ -22,6 +27,7 @@ from gajim.common import app from gajim.common import ged +from gajim.common.const import Direction from gajim.common.i18n import _ from .builder import get_builder @@ -37,7 +43,7 @@ class XMLConsoleWindow(Gtk.ApplicationWindow, EventHelper): - def __init__(self): + def __init__(self) -> None: Gtk.ApplicationWindow.__init__(self) EventHelper.__init__(self) self.set_application(app.app) @@ -47,8 +53,8 @@ def __init__(self): self.set_show_menubar(False) self.set_name('XMLConsoleWindow') - self.selected_account = None - self._selected_send_account = None + self.selected_account: Optional[str] = None + self._selected_send_account: Optional[str] = None self.presence = True self.message = True self.iq = True @@ -64,7 +70,8 @@ def __init__(self): self._set_titlebar() self.add(self._ui.box) - self._ui.paned.set_position(self._ui.paned.get_property('max-position')) + self._ui.paned.set_position( + self._ui.paned.get_property('max-position')) self._combo = MaxWidthComboBoxText() self._combo.set_max_size(200) @@ -90,7 +97,7 @@ def __init__(self): self.show_all() - self.connect('key_press_event', self._on_key_press_event) + self.connect('key_press_event', self._on_key_press) self._ui.connect_signals(self) self.register_events([ @@ -99,7 +106,7 @@ def __init__(self): ('style-changed', ged.GUI1, self._on_style_changed) ]) - def _get_style_scheme(self): + def _get_style_scheme(self) -> Optional[GtkSource.StyleScheme]: if app.css_config.prefer_dark: style_scheme = self._style_scheme_manager.get_scheme( 'solarized-dark') @@ -108,22 +115,22 @@ def _get_style_scheme(self): 'solarized-light') return style_scheme - def _on_style_changed(self, *args): + def _on_style_changed(self, *args: Any) -> None: style_scheme = self._get_style_scheme() if style_scheme is not None: self._ui.sourceview.get_buffer().set_style_scheme(style_scheme) - def _on_value_change(self, combo): + def _on_value_change(self, combo: Gtk.ComboBox) -> None: self._selected_send_account = combo.get_active_id() - def _set_titlebar(self): + def _set_titlebar(self) -> None: if self.selected_account is None: title = _('All Accounts') else: title = app.get_jid_from_account(self.selected_account) self._ui.headerbar.set_subtitle(title) - def _create_tags(self): + def _create_tags(self) -> None: tags = [ 'incoming', 'outgoing', @@ -135,7 +142,7 @@ def _create_tags(self): for tag_name in tags: self._ui.sourceview.get_buffer().create_tag(tag_name) - def _on_key_press_event(self, _widget, event): + def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None: if event.keyval == Gdk.KEY_Escape: if self._ui.search_revealer.get_child_revealed(): self._ui.search_revealer.set_reveal_child(False) @@ -153,10 +160,15 @@ def _on_key_press_event(self, _widget, event): self._ui.search_toggle.set_active( not self._ui.search_revealer.get_child_revealed()) if event.keyval == Gdk.KEY_F3: - self._find(True) + self._find(Direction.NEXT) - def _on_row_activated(self, _listbox, row): + def _on_row_activated(self, + _listbox: Gtk.ListBox, + row: Gtk.ListBoxRow + ) -> None: text = row.get_child().get_text() + + # pylint: disable=line-too-long input_text = None if text == 'Presence': input_text = ( @@ -180,13 +192,14 @@ def _on_row_activated(self, _listbox, row): '<iq to="" type="get" xmlns="jabber:client">\n' '<query xmlns="
http://jabber.org/protocol/disco#info
"></query>\n' '</iq>') + # pylint: enable=line-too-long if input_text is not None: buffer_ = self._ui.input_entry.get_buffer() buffer_.set_text(input_text) self._ui.input_entry.grab_focus() - def _on_send(self, *args): + def _on_send(self, *args: Any) -> None: if not self._selected_send_account: return if not app.account_is_available(self._selected_send_account): @@ -217,13 +230,13 @@ def _on_send(self, *args): self.last_stanza = stanza buffer_.set_text('') - def _on_paste_last(self, *args): + def _on_paste_last(self, *args: Any) -> None: buffer_ = self._ui.input_entry.get_buffer() if buffer_ is not None and self.last_stanza is not None: buffer_.set_text(self.last_stanza) self._ui.input_entry.grab_focus() - def _on_input(self, button, *args): + def _on_input(self, button: Gtk.ToggleButton) -> None: if button.get_active(): self._ui.paned.get_child2().show() self._ui.send.show() @@ -238,18 +251,21 @@ def _on_input(self, button, *args): self._combo.hide() self._ui.menubutton.hide() - def _on_search_toggled(self, button): + def _on_search_toggled(self, button: Gtk.ToggleButton) -> None: self._ui.search_revealer.set_reveal_child(button.get_active()) self._ui.search_entry.grab_focus() - def _on_search_activate(self, _widget): - self._find(True) + def _on_search_activate(self, _entry: Gtk.SearchEntry) -> None: + self._find(Direction.NEXT) - def _on_search_clicked(self, button): - forward = bool(button is self._ui.search_forward) - self._find(forward) + def _on_search_clicked(self, button: Gtk.ToolButton) -> None: + if button is self._ui.search_forward: + direction = Direction.NEXT + else: + direction = Direction.PREV + self._find(direction) - def _find(self, forward): + def _find(self, direction: Direction) -> None: search_str = self._ui.search_entry.get_text() textbuffer = self._ui.sourceview.get_buffer() cursor_mark = textbuffer.get_insert() @@ -265,7 +281,7 @@ def _find(self, forward): if search_str != self.last_search: current_pos = textbuffer.get_start_iter() - if forward: + if direction == Direction.NEXT: match = current_pos.forward_search( search_str, Gtk.TextSearchFlags.VISIBLE_ONLY | @@ -287,7 +303,7 @@ def _find(self, forward): self.last_search = search_str @staticmethod - def _get_accounts(): + def _get_accounts() -> List[Tuple[str, str]]: accounts = app.get_accounts_sorted() combo_accounts = [] for account in accounts: @@ -296,8 +312,8 @@ def _get_accounts(): combo_accounts.append(('AccountWizard', 'Account Wizard')) return combo_accounts - def _on_filter_options(self, *args): - if self.filter_dialog: + def _on_filter_options(self, _button: Gtk.Button) -> None: + if self.filter_dialog is not None: self.filter_dialog.present() return @@ -337,17 +353,17 @@ def _on_filter_options(self, *args): settings, self.selected_account) self.filter_dialog.connect('destroy', self._on_filter_destroyed) - def _on_filter_destroyed(self, _win): + def _on_filter_destroyed(self, _widget: Gtk.Widget) -> None: self.filter_dialog = None - def _on_clear(self, *args): + def _on_clear(self, _button: Gtk.Button) -> None: self._ui.sourceview.get_buffer().set_text('') - def _set_account(self, value, _data): + def _set_account(self, value: str, _data: Any) -> None: self.selected_account = value self._set_titlebar() - def _on_setting(self, value, data): + def _on_setting(self, value: bool, data: str) -> None: setattr(self, data, value) value = not value table = self._ui.sourceview.get_buffer().get_tag_table() View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/318d70c0e6f6d7b290cebc7c5936485…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/318d70c0e6f6d7b290cebc7c5936485…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 4 commits: BaseControl: Prevent file transfers from being corrected
by Daniel Brötzmann (ï¼ wurstsalat)
22 Dec '21
22 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 609a03e9 by wurstsalat at 2021-12-22T23:24:48+01:00 BaseControl: Prevent file transfers from being corrected Fixes #10281 - - - - - 2518ead6 by wurstsalat at 2021-12-22T23:24:48+01:00 RemoveAccount: Typing - - - - - 7bcb6e22 by wurstsalat at 2021-12-22T23:24:48+01:00 ManageProxies: Typing - - - - - 318d70c0 by wurstsalat at 2021-12-22T23:24:48+01:00 VideoPreview: Typing - - - - - 6 changed files: - gajim/gtk/controls/base.py - gajim/gtk/controls/chat.py - gajim/gtk/controls/groupchat.py - gajim/gtk/proxies.py - gajim/gtk/remove_account.py - gajim/gtk/video_preview.py Changes: ===================================== gajim/gtk/controls/base.py ===================================== @@ -1507,12 +1507,13 @@ def scroll_messages(self, msg_type == 'sent' and not self.correcting and ( not history[pos - 1].startswith('/') or history[pos - 1].startswith('/me'))): - self.correcting = True - self.msg_textview.get_style_context().add_class( - 'gajim-msg-correcting') - message = history[pos - 1] - msg_buf.set_text(message) - return + if self.last_sent_msg is not None: + self.correcting = True + self.msg_textview.get_style_context().add_class( + 'gajim-msg-correcting') + message = history[pos - 1] + msg_buf.set_text(message) + return if self.correcting: # We were previously correcting self.msg_textview.get_style_context().remove_class( ===================================== gajim/gtk/controls/chat.py ===================================== @@ -414,7 +414,11 @@ def _on_message_sent(self, event): return if event.correct_id is None: - self.last_sent_msg = event.message_id + oob_url = event.additional_data.get_value('gajim', 'oob_url') + if oob_url == event.message: + self.last_sent_msg = None + else: + self.last_sent_msg = event.message_id message_id = event.message_id ===================================== gajim/gtk/controls/groupchat.py ===================================== @@ -1175,7 +1175,11 @@ def _on_message_sent(self, event): # we'll save sent message text when we'll receive it in # _nec_gc_message_received if event.correct_id is None: - self.last_sent_msg = event.message_id + oob_url = event.additional_data.get_value('gajim', 'oob_url') + if oob_url == event.message: + self.last_sent_msg = None + else: + self.last_sent_msg = event.message_id if self.correcting: self.correcting = False self.msg_textview.get_style_context().remove_class( ===================================== gajim/gtk/proxies.py ===================================== @@ -12,6 +12,8 @@ # 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 Gtk @@ -23,7 +25,7 @@ class ManageProxies(Gtk.ApplicationWindow): - def __init__(self): + def __init__(self) -> None: Gtk.ApplicationWindow.__init__(self) self.set_name('ManageProxies') self.set_application(app.app) @@ -45,12 +47,12 @@ def __init__(self): self._ui.connect_signals(self) self.show_all() - def _on_key_press(self, _widget, event): + def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None: if event.keyval == Gdk.KEY_Escape: self.destroy() @staticmethod - def _on_destroy(*args): + def _on_destroy(*args: Any) -> None: # Window callbacks for updating proxy comboboxes window_pref = get_app_window('Preferences') window_accounts = get_app_window('AccountsWindow') @@ -62,14 +64,14 @@ def _on_destroy(*args): if window_account_wizard is not None: window_account_wizard.update_proxy_list() - def _fill_proxies_treeview(self): + def _fill_proxies_treeview(self) -> None: model = self._ui.proxies_treeview.get_model() model.clear() for proxy in app.settings.get_proxies(): iter_ = model.append() model.set(iter_, 0, proxy) - def _init_list(self): + def _init_list(self) -> None: self._ui.remove_proxy_button.set_sensitive(False) self._ui.settings_grid.set_sensitive(False) model = Gtk.ListStore(str) @@ -82,7 +84,7 @@ def _init_list(self): self._fill_proxies_treeview() self._ui.proxytype_combobox.set_active(0) - def _on_add_proxy_button_clicked(self, _widget): + def _on_add_proxy_button_clicked(self, _button: Gtk.Button) -> None: model = self._ui.proxies_treeview.get_model() proxies = app.settings.get_proxies() i = 1 @@ -95,7 +97,7 @@ def _on_add_proxy_button_clicked(self, _widget): model.set(iter_, 0, proxy_name) self._ui.proxies_treeview.set_cursor(model.get_path(iter_)) - def _on_remove_proxy_button_clicked(self, _widget): + def _on_remove_proxy_button_clicked(self, _button: Gtk.Button) -> None: sel = self._ui.proxies_treeview.get_selection() if not sel: return @@ -110,23 +112,25 @@ def _on_remove_proxy_button_clicked(self, _widget): self._on_proxies_treeview_cursor_changed(self._ui.proxies_treeview) self._block_signal = False - def _on_useauth_toggled(self, widget): + def _on_useauth_toggled(self, checkbutton: Gtk.CheckButton) -> None: if self._block_signal: return - act = widget.get_active() + act = checkbutton.get_active() proxy = self._ui.proxyname_entry.get_text() app.settings.set_proxy_setting(proxy, 'useauth', act) self._ui.proxyuser_entry.set_sensitive(act) self._ui.proxypass_entry.set_sensitive(act) - def _on_proxies_treeview_cursor_changed(self, widget): + def _on_proxies_treeview_cursor_changed(self, + treeview: Gtk.TreeView + ) -> None: self._block_signal = True self._ui.proxyhost_entry.set_text('') self._ui.proxyport_entry.set_text('') self._ui.proxyuser_entry.set_text('') self._ui.proxypass_entry.set_text('') - sel = widget.get_selection() + sel = treeview.get_selection() if sel: (model, iter_) = sel.get_selected() else: @@ -162,11 +166,14 @@ def _on_proxies_treeview_cursor_changed(self, widget): self._block_signal = False - def _on_proxies_treeview_key_press_event(self, widget, event): + def _on_proxies_treeview_key_press_event(self, + widget: Gtk.Widget, + event: Gdk.EventKey + ) -> None: if event.keyval == Gdk.KEY_Delete: self._on_remove_proxy_button_clicked(widget) - def _on_proxyname_entry_changed(self, widget): + def _on_proxyname_entry_changed(self, entry: Gtk.Entry) -> None: if self._block_signal: return sel = self._ui.proxies_treeview.get_selection() @@ -176,7 +183,7 @@ def _on_proxyname_entry_changed(self, widget): if not iter_: return old_name = model.get_value(iter_, 0) - new_name = widget.get_text() + new_name = entry.get_text() if new_name == '': return if new_name == old_name: @@ -185,7 +192,7 @@ def _on_proxyname_entry_changed(self, widget): app.settings.rename_proxy(old_name, new_name) model.set_value(iter_, 0, new_name) - def _on_proxytype_combobox_changed(self, _widget): + def _on_proxytype_combobox_changed(self, _combobox: Gtk.ComboBox) -> None: if self._block_signal: return types = ['http', 'socks5'] @@ -195,14 +202,14 @@ def _on_proxytype_combobox_changed(self, _widget): proxy = self._ui.proxyname_entry.get_text() app.settings.set_proxy_setting(proxy, 'type', types[type_]) - def _on_proxyhost_entry_changed(self, entry): + def _on_proxyhost_entry_changed(self, entry: Gtk.Entry) -> None: if self._block_signal: return value = entry.get_text() proxy = self._ui.proxyname_entry.get_text() app.settings.set_proxy_setting(proxy, 'host', value) - def _on_proxyport_entry_changed(self, entry): + def _on_proxyport_entry_changed(self, entry: Gtk.Entry) -> None: if self._block_signal: return value = entry.get_text() @@ -213,14 +220,14 @@ def _on_proxyport_entry_changed(self, entry): proxy = self._ui.proxyname_entry.get_text() app.settings.set_proxy_setting(proxy, 'port', value) - def _on_proxyuser_entry_changed(self, entry): + def _on_proxyuser_entry_changed(self, entry: Gtk.Entry) -> None: if self._block_signal: return value = entry.get_text() proxy = self._ui.proxyname_entry.get_text() app.settings.set_proxy_setting(proxy, 'user', value) - def _on_proxypass_entry_changed(self, entry): + def _on_proxypass_entry_changed(self, entry: Gtk.Entry) -> None: if self._block_signal: return value = entry.get_text() ===================================== gajim/gtk/remove_account.py ===================================== @@ -12,11 +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 typing import Any +from typing import List + import logging from gi.repository import Gtk from nbxmpp.errors import StanzaError +from nbxmpp.task import Task from gajim.common import app from gajim.common import ged @@ -33,7 +37,7 @@ class RemoveAccount(Assistant): - def __init__(self, account): + def __init__(self, account: str) -> None: Assistant.__init__(self) self.account = account @@ -83,11 +87,14 @@ def _on_account_disconnected(self, _event): self.show_page('success') app.interface.remove_account(self.account) - def _set_remove_from_server_checkbox(self): + def _set_remove_from_server_checkbox(self) -> None: enabled = self._client is not None and self._client.state.is_available self.get_page('remove_choice').set_remove_from_server(enabled) - def _on_button_clicked(self, _assistant, button_name): + def _on_button_clicked(self, + _assistant: Assistant, + button_name: str + ) -> None: page = self.get_current_page() if button_name == 'remove': if page == 'remove_choice': @@ -104,7 +111,7 @@ def _on_button_clicked(self, _assistant, button_name): if button_name == 'close': self.destroy() - def _on_remove(self, *args): + def _on_remove(self, *args: Any) -> None: if self.get_page('remove_choice').remove_from_server: self._client.set_remove_account(True) self._client.get_module('Register').unregister( @@ -119,7 +126,7 @@ def _on_remove(self, *args): self._client.disconnect(gracefully=True, reconnect=False) self._account_removed = True - def _on_remove_response(self, task): + def _on_remove_response(self, task: Task) -> None: try: task.finish() except StanzaError as error: @@ -132,12 +139,12 @@ def _on_remove_response(self, task): self._account_removed = True - def _on_destroy(self, *args): + def _on_destroy(self, *args: Any) -> None: self._destroyed = True class RemoveChoice(Page): - def __init__(self, account): + def __init__(self, account: str) -> None: Page.__init__(self) self.title = _('Remove Account') @@ -176,10 +183,10 @@ def __init__(self, account): self.show_all() @property - def remove_from_server(self): + def remove_from_server(self) -> bool: return self._server.get_active() - def set_remove_from_server(self, enabled): + def set_remove_from_server(self, enabled: bool) -> None: self._server.set_sensitive(enabled) if enabled: self._server.set_tooltip_text('') @@ -187,27 +194,27 @@ def set_remove_from_server(self, enabled): self._server.set_active(False) self._server.set_tooltip_text(_('Account has to be connected')) - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['remove'] class Error(ErrorPage): - def __init__(self): + def __init__(self) -> None: ErrorPage.__init__(self) self.set_title(_('Account Removal Failed')) self.set_heading(_('Account Removal Failed')) - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['back'] class Success(SuccessPage): - def __init__(self): + def __init__(self) -> None: SuccessPage.__init__(self) self.set_title(_('Account Removed')) self.set_heading(_('Account Removed')) self.set_text( _('Your account has has been removed successfully.')) - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['close'] ===================================== gajim/gtk/video_preview.py ===================================== @@ -12,15 +12,18 @@ # 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 Optional + import logging from gi.repository import GLib +from gi.repository import Gtk from gajim.common import app from gajim.common.i18n import _ -from . import gstreamer from .builder import get_builder +from .gstreamer import create_gtk_widget try: from gi.repository import Gst # pylint: disable=ungrouped-imports @@ -32,32 +35,32 @@ class VideoPreview: - def __init__(self): + def __init__(self) -> None: self._ui = get_builder('video_preview.ui') self._active = False - self._av_pipeline = None - self._av_src = None - self._av_sink = None - self._av_widget = None + self._av_pipeline: Optional[Gst.Pipeline] = None + self._av_src: Optional[Gst.Bin] = None + self._av_sink: Optional[Gst.Element] = None + self._av_widget: Optional[Gtk.Widget] = None @property - def widget(self): + def widget(self) -> Gtk.Box: return self._ui.video_preview_box @property - def is_active(self): + def is_active(self) -> bool: return self._active - def toggle_preview(self, value): + def toggle_preview(self, value: bool) -> None: self._active = value if value: return self._enable_preview() return self._disable_preview() - def _enable_preview(self): + def _enable_preview(self) -> None: src_name = app.settings.get('video_input_device') try: self._av_src = Gst.parse_bin_from_description(src_name, True) @@ -67,7 +70,7 @@ def _enable_preview(self): self._set_error_text() return - sink, widget, name = gstreamer.create_gtk_widget() + sink, widget, name = create_gtk_widget() if sink is None: log.error('Failed to obtain a working Gstreamer GTK+ sink, ' 'video support will be disabled') @@ -95,7 +98,7 @@ def _enable_preview(self): self._av_src.link(self._av_sink) self._av_pipeline.set_state(Gst.State.PLAYING) - def _disable_preview(self): + def _disable_preview(self) -> None: if self._av_pipeline is not None: self._av_pipeline.set_state(Gst.State.NULL) if self._av_src is not None: @@ -112,7 +115,7 @@ def _disable_preview(self): self._av_widget = None self._av_pipeline = None - def _set_sink_text(self, sink_name): + def _set_sink_text(self, sink_name: str) -> None: text = '' if sink_name == 'gtkglsink': text = _('<span color="green" font-weight="bold">' @@ -124,10 +127,10 @@ def _set_sink_text(self, sink_name): self._ui.video_source_label.set_markup(text) - def _set_error_text(self): + def _set_error_text(self) -> None: self._ui.video_source_label.set_text( _('Something went wrong. Video feature disabled.')) - def refresh(self): + def refresh(self) -> None: self.toggle_preview(False) self.toggle_preview(True) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/2bc5f87ea5945e056da9802d0025991…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/2bc5f87ea5945e056da9802d0025991…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 3 commits: App: Add type annotations
by Philipp Hörist (ï¼ lovetox)
22 Dec '21
22 Dec '21
Philipp Hörist pushed to branch master at gajim / gajim Commits: ca989dd3 by lovetox at 2021-12-22T23:19:15+01:00 App: Add type annotations - - - - - 2ab1f193 by lovetox at 2021-12-22T23:19:29+01:00 Refactor load_icon() - - - - - 2bc5f87e by lovetox at 2021-12-22T23:20:43+01:00 Update pyrightconfig.json - - - - - 8 changed files: - gajim/common/app.py - gajim/gtk/app_side_bar.py - gajim/gtk/avatar.py - gajim/gtk/history_sync.py - gajim/gtk/preview.py - gajim/gtk/util.py - gajim/plugins/gui.py - pyrightconfig.json Changes: ===================================== gajim/common/app.py ===================================== @@ -26,6 +26,7 @@ from __future__ import annotations +import typing from typing import Any from typing import NamedTuple from typing import Optional @@ -52,6 +53,10 @@ from gajim.common.i18n import LANG from gajim.common.const import Display +if typing.TYPE_CHECKING: + from gajim.gui.main import MainWindow + from gajim.application import GajimApplication + interface = cast(types.InterfaceT, None) thread_interface = lambda *args: None # Interface to run a thread and then a callback @@ -62,8 +67,8 @@ avatar_cache: dict[str, dict[str, Any]] = {} bob_cache: dict[str, bytes] = {} ipython_window = None -app = None # Gtk.Application -window = None # MainWindow +app = None # type: GajimApplication +window = None # type: MainWindow ged = ged_module.GlobalEventsDispatcher() # Global Events Dispatcher nec = cast(types.NetworkEventsControllerT, None) ===================================== gajim/gtk/app_side_bar.py ===================================== @@ -18,7 +18,7 @@ from gajim.common import app from .app_page import AppPage -from .util import load_icon +from .util import load_icon_surface class AppSideBar(Gtk.ListBox): @@ -62,7 +62,7 @@ def __init__(self) -> None: self._unread_label.set_halign(Gtk.Align.END) self._unread_label.set_valign(Gtk.Align.START) - surface = load_icon('org.gajim.Gajim', self, 32) + surface = load_icon_surface('org.gajim.Gajim', 32) image = Gtk.Image.new_from_surface(surface) image.get_style_context().add_class('app-sidebar-image') ===================================== gajim/gtk/avatar.py ===================================== @@ -39,7 +39,7 @@ from .const import DEFAULT_WORKSPACE_COLOR from .util import load_pixbuf -from .util import load_icon +from .util import load_icon_pixbuf from .util import text_to_color from .util import scale_with_ratio from .util import get_css_show_class @@ -190,7 +190,7 @@ def get_icon_avatar(size: int, surface = cairo.ImageSurface(cairo.Format.ARGB32, width, height) context = cairo.Context(surface) - pixbuf = load_icon(icon_name, scale=scale, size=size, pixbuf=True) + pixbuf = load_icon_pixbuf(icon_name, size=size, scale=scale) Gdk.cairo_set_source_pixbuf( context, pixbuf, ===================================== gajim/gtk/history_sync.py ===================================== @@ -28,7 +28,7 @@ from gajim.common.const import ArchiveState from gajim.common.helpers import event_filter -from .util import load_icon +from .util import load_icon_surface from .util import EventHelper log = logging.getLogger('gajim.gui.history_sync') @@ -233,7 +233,7 @@ def __init__(self, assistant): self.count = 0 self.received = 0 - surface = load_icon('folder-download-symbolic', self, size=64) + surface = load_icon_surface('folder-download-symbolic', size=64) image = Gtk.Image.new_from_surface(surface) self.progress = Gtk.ProgressBar() ===================================== gajim/gtk/preview.py ===================================== @@ -39,8 +39,7 @@ from .preview_audio import AudioWidget from .builder import get_builder from .util import get_cursor -from .util import get_monitor_scale_factor -from .util import load_icon +from .util import load_icon_pixbuf log = logging.getLogger('gajim.gui.preview') @@ -75,10 +74,7 @@ def update(self, preview: Preview, data: Optional[GdkPixbufType]) -> None: self._ui.progressbar.hide() if preview.is_geo_uri: - data = load_icon('map', - size=preview.size, - scale=get_monitor_scale_factor(), - pixbuf=True) + data = load_icon_pixbuf('map', size=preview.size) if isinstance(data, GdkPixbuf.PixbufAnimation): image = Gtk.Image.new_from_animation(data) ===================================== gajim/gtk/util.py ===================================== @@ -158,16 +158,13 @@ def icon_exists(name: str) -> bool: return _icon_theme.has_icon(name) -def load_icon(icon_name: str, - widget: Optional[Any] = None, - size: int = 16, - pixbuf: bool = False, - scale: Optional[int] = None, - flags: Gtk.IconLookupFlags = Gtk.IconLookupFlags.FORCE_SIZE - ) -> Optional[Union[GdkPixbuf.Pixbuf, cairo.Surface]]: +def load_icon_info(icon_name: str, + size: int, + scale: Optional[int], + flags: Gtk.IconLookupFlags) -> Optional[Gtk.IconInfo]: - if widget is not None: - scale = widget.get_scale_factor() + if scale is None: + scale = app.window.get_scale_factor() if not scale: log.warning('Could not determine scale factor') @@ -179,18 +176,42 @@ def load_icon(icon_name: str, if iconinfo is None: log.info('No icon found for %s', icon_name) return None - if pixbuf: - return iconinfo.load_icon() - return iconinfo.load_surface(None) + return iconinfo except GLib.GError as error: log.error('Unable to load icon %s: %s', icon_name, str(error)) return None +def load_icon_surface( + icon_name: str, + size: int = 16, + scale: Optional[int] = None, + flags: Gtk.IconLookupFlags = Gtk.IconLookupFlags.FORCE_SIZE, + ) -> Optional[cairo.Surface]: + + icon_info = load_icon_info(icon_name, size, scale, flags) + if icon_info is None: + return None + return icon_info.load_surface(None) + + +def load_icon_pixbuf(icon_name: str, + size: int = 16, + scale: Optional[int] = None, + flags: Gtk.IconLookupFlags = Gtk.IconLookupFlags.FORCE_SIZE, + ) -> Optional[GdkPixbuf.Pixbuf]: + + icon_info = load_icon_info(icon_name, size, scale, flags) + if icon_info is None: + return None + return icon_info.load_icon() + + def get_app_icon_list(scale_widget: Any) -> List[GdkPixbuf.Pixbuf]: + scale = scale_widget.get_scale_factor() pixbufs = [] for size in (16, 32, 48, 64, 128): - pixbuf = load_icon('org.gajim.Gajim', scale_widget, size, pixbuf=True) + pixbuf = load_icon_pixbuf('org.gajim.Gajim', size=size, scale=scale) if pixbuf is not None: pixbufs.append(pixbuf) return pixbufs ===================================== gajim/plugins/gui.py ===================================== @@ -43,7 +43,7 @@ from gajim.gui.dialogs import ConfirmationDialog from gajim.gui.filechoosers import ArchiveChooserDialog from gajim.gui.builder import get_builder -from gajim.gui.util import load_icon +from gajim.gui.util import load_icon_pixbuf @unique @@ -96,7 +96,7 @@ def __init__(self): activatable=Column.ACTIVATABLE) self._ui.installed_plugins_treeview.append_column(col) - self.def_icon = load_icon('preferences-desktop', self, pixbuf=True) + self.def_icon = load_icon_pixbuf('preferences-desktop') # connect signal for selection change selection = self._ui.installed_plugins_treeview.get_selection() ===================================== pyrightconfig.json ===================================== @@ -12,6 +12,7 @@ "typeCheckingMode": "strict", "include": [ "gajim/gtk/chat_filter.py", + "gajim/gtk/app_side_bar.py", "gajim/common/cert_store.py" ], } View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/6ed10e0464c88cdd446d4a757b47a50…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/6ed10e0464c88cdd446d4a757b47a50…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 3 commits: ManageSounds: Refactor and improve type annotations
by Philipp Hörist (ï¼ lovetox)
22 Dec '21
22 Dec '21
Philipp Hörist pushed to branch master at gajim / gajim Commits: 17140198 by lovetox at 2021-12-22T22:30:54+01:00 ManageSounds: Refactor and improve type annotations - - - - - a41061c7 by lovetox at 2021-12-22T22:30:54+01:00 Remove unused code - - - - - 6ed10e04 by lovetox at 2021-12-22T22:30:54+01:00 Windows: Fix module loading - - - - - 6 changed files: - gajim/common/modules/__init__.py - gajim/common/modules/bookmarks.py - gajim/common/modules/contacts.py - gajim/common/modules/ibb.py - gajim/common/modules/jingle.py - gajim/gtk/manage_sounds.py Changes: ===================================== gajim/common/modules/__init__.py ===================================== @@ -45,7 +45,10 @@ def register_modules(client: Client) -> None: _modules[client.account] = {} path = Path(__file__).parent - for module in path.glob('*.py'): + for module in path.iterdir(): + if module.suffix not in ['.py', '.pyc']: + continue + if module.name.startswith('__'): continue ===================================== gajim/common/modules/bookmarks.py ===================================== @@ -296,7 +296,3 @@ def _remove_timeouts(self): def cleanup(self): self._remove_timeouts() - - -def get_instance(*args, **kwargs): - return Bookmarks(*args, **kwargs), 'Bookmarks' ===================================== gajim/common/modules/contacts.py ===================================== @@ -18,7 +18,6 @@ from typing import Iterator from typing import Optional from typing import Union -from typing import Tuple import logging from functools import partial @@ -669,7 +668,3 @@ def set_state(self, state, presence) -> None: def update_avatar(self, *args) -> None: app.interface.avatar_storage.invalidate_cache(self._jid) self.notify('user-avatar-update') - - -def get_instance(*args: Any, **kwargs: Any) -> Tuple[Contacts, str]: - return Contacts(*args, **kwargs), 'Contacts' ===================================== gajim/common/modules/ibb.py ===================================== @@ -233,7 +233,3 @@ def _on_data_result(self, task): file_props = task.get_user_data() self.send_data(file_props) - - -def get_instance(*args, **kwargs): - return IBB(*args, **kwargs), 'IBB' ===================================== gajim/common/modules/jingle.py ===================================== @@ -295,7 +295,3 @@ def get_jingle_session(self, jid, sid=None, media=None): if session.peerjid == jid and session.get_content(media): return session return None - - -def get_instance(*args, **kwargs): - return Jingle(*args, **kwargs), 'Jingle' ===================================== gajim/gtk/manage_sounds.py ===================================== @@ -12,7 +12,12 @@ # 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 cast + import os +from enum import IntEnum from gi.repository import Gdk from gi.repository import Gtk @@ -26,6 +31,24 @@ from .builder import get_builder +SOUNDS = { + 'attention_received': _('Attention Message Received'), + 'first_message_received': _('Message Received'), + 'contact_connected': _('Contact Connected'), + 'contact_disconnected': _('Contact Disconnected'), + 'message_sent': _('Message Sent'), + 'muc_message_highlight': _('Group Chat Message Highlight'), + 'muc_message_received': _('Group Chat Message Received'), +} + + +class Column(IntEnum): + ENABLED = 0 + NAME = 1 + PATH = 2 + CONFIG = 3 + + class ManageSounds(Gtk.ApplicationWindow): def __init__(self, transient_for: Gtk.Window) -> None: Gtk.ApplicationWindow.__init__(self) @@ -65,47 +88,44 @@ def _on_row_changed(model: Gtk.TreeModel, path: Gtk.TreePath, iter_: Gtk.TreeIter ) -> None: - sound_event = model[iter_][3] + + sound_event = model[iter_][Column.CONFIG] app.settings.set_soundevent_setting(sound_event, 'enabled', - bool(model[path][0])) + model[path][Column.ENABLED]) app.settings.set_soundevent_setting(sound_event, 'path', - model[iter_][2]) + model[iter_][Column.PATH]) def _on_toggle(self, _cell: Gtk.CellRendererToggle, path: Gtk.TreePath ) -> None: + if self._ui.filechooser.get_filename() is None: return + model = self._ui.sounds_treeview.get_model() - model[path][0] = not model[path][0] + assert model is not None + + model[path][Column.ENABLED] = not model[path][Column.ENABLED] def _fill_sound_treeview(self) -> None: - model = self._ui.sounds_treeview.get_model() + model = cast(Gtk.ListStore, self._ui.sounds_treeview.get_model()) model.clear() - sounds_dict = { - 'attention_received': _('Attention Message Received'), - 'first_message_received': _('Message Received'), - 'contact_connected': _('Contact Connected'), - 'contact_disconnected': _('Contact Disconnected'), - 'message_sent': _('Message Sent'), - 'muc_message_highlight': _('Group Chat Message Highlight'), - 'muc_message_received': _('Group Chat Message Received'), - } - - for sound_event, sound_name in sounds_dict.items(): + for sound_event, sound_name in SOUNDS.items(): settings = app.settings.get_soundevent_settings(sound_event) - model.append((settings['enabled'], + model.append([settings['enabled'], sound_name, settings['path'], - sound_event)) + sound_event]) def _on_cursor_changed(self, treeview: Gtk.TreeView) -> None: model, iter_ = treeview.get_selection().get_selected() - path_to_snd_file = check_soundfile_path(model[iter_][2]) + assert iter_ is not None + + path_to_snd_file = check_soundfile_path(model[iter_][Column.PATH]) if path_to_snd_file is None: self._ui.filechooser.unselect_all() else: @@ -113,26 +133,31 @@ def _on_cursor_changed(self, treeview: Gtk.TreeView) -> None: def _on_file_set(self, button: Gtk.FileChooserButton) -> None: model, iter_ = self._ui.sounds_treeview.get_selection().get_selected() + assert iter_ is not None filename = button.get_filename() + assert filename is not None + directory = os.path.dirname(filename) app.settings.set('last_sounds_dir', directory) path_to_snd_file = strip_soundfile_path(filename) - # set new path to sounds_model - model[iter_][2] = str(path_to_snd_file) - # set the sound to enabled - model[iter_][0] = True + model[iter_][Column.PATH] = str(path_to_snd_file) + model[iter_][Column.ENABLED] = True def _on_clear(self, _button: Gtk.Button) -> None: self._ui.filechooser.unselect_all() model, iter_ = self._ui.sounds_treeview.get_selection().get_selected() - model[iter_][2] = '' - model[iter_][0] = False + assert iter_ is not None + + model[iter_][Column.PATH] = '' + model[iter_][Column.ENABLED] = False def _on_play(self, _button: Gtk.Button) -> None: model, iter_ = self._ui.sounds_treeview.get_selection().get_selected() - snd_event_config_name = model[iter_][3] + assert iter_ is not None + + snd_event_config_name = model[iter_][Column.CONFIG] play_sound(snd_event_config_name, None, force=True) def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None: View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/d26bb93410500ee2995588485e646ed…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/d26bb93410500ee2995588485e646ed…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 6 commits: AccountWizard: Typing
by Daniel Brötzmann (ï¼ wurstsalat)
22 Dec '21
22 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: 813143be by wurstsalat at 2021-12-22T21:04:46+01:00 AccountWizard: Typing - - - - - 89450395 by wurstsalat at 2021-12-22T21:08:18+01:00 AppSideBar: Typing - - - - - 51ad2f92 by wurstsalat at 2021-12-22T21:26:30+01:00 AvatarSelector: Typing - - - - - 7c145ffa by wurstsalat at 2021-12-22T21:37:07+01:00 ChangePassword: Typing - - - - - ca9aee26 by wurstsalat at 2021-12-22T21:45:48+01:00 ChatListStack: Typing - - - - - d26bb934 by wurstsalat at 2021-12-22T21:56:04+01:00 AddContact: List connected accounts only - - - - - 6 changed files: - gajim/gtk/account_wizard.py - gajim/gtk/add_contact.py - gajim/gtk/app_side_bar.py - gajim/gtk/avatar_selector.py - gajim/gtk/change_password.py - gajim/gtk/chat_list_stack.py Changes: ===================================== gajim/gtk/account_wizard.py ===================================== @@ -12,8 +12,9 @@ # 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 Optional +from typing import Any from typing import List +from typing import Optional from typing import Tuple from typing import Union @@ -35,6 +36,7 @@ from nbxmpp.errors import StanzaError from nbxmpp.errors import MalformedStanzaError from nbxmpp.errors import RegisterStanzaError +from nbxmpp.task import Task from gajim.common import app from gajim.common import configpaths @@ -101,7 +103,7 @@ def __init__(self) -> None: def get_currenct_method(self) -> str: return self._method - def _on_button_clicked(self, _page, button_name): + def _on_button_clicked(self, _page: Gtk.Widget, button_name: str) -> None: if button_name == 'login': if self.get_page('login').is_advanced(): self.show_page('advanced', @@ -112,7 +114,10 @@ def _on_button_clicked(self, _page, button_name): elif button_name == 'signup': self.show_page('signup', Gtk.StackTransitionType.SLIDE_LEFT) - def _on_assistant_button_clicked(self, _assistant, button_name): + def _on_assistant_button_clicked(self, + _assistant: Assistant, + button_name: str + ) -> None: page = self.get_current_page() if button_name == 'login': @@ -185,7 +190,10 @@ def _on_assistant_button_clicked(self, _assistant, button_name): elif page == 'redirect': self.show_page('login', Gtk.StackTransitionType.SLIDE_RIGHT) - def _on_page_changed(self, _assistant, page_name): + def _on_page_changed(self, + _assistant: Assistant, + page_name: str + ) -> None: if page_name == 'signup': self._method = page_name self.get_page('signup').focus() @@ -240,13 +248,19 @@ def _disconnect(self) -> None: self._client = None @staticmethod - def _on_stanza_sent(_client, _signal_name, stanza): + def _on_stanza_sent(_client: Client, + _signal_name: str, + stanza: Any + ) -> None: app.nec.push_incoming_event(NetworkEvent('stanza-sent', account='AccountWizard', stanza=stanza)) @staticmethod - def _on_stanza_received(_client, _signal_name, stanza): + def _on_stanza_received(_client: Client, + _signal_name: str, + stanza: Any + ) -> None: app.nec.push_incoming_event(NetworkEvent('stanza-received', account='AccountWizard', stanza=stanza)) @@ -304,7 +318,7 @@ def _register_with_server(self, ignore_all_errors: bool = False) -> None: self._client.connect() - def _on_login_successful(self, client, _signal_name): + def _on_login_successful(self, client: Client, _signal_name: str) -> None: account = self._generate_account_name(client.domain) proxy_name = None if client.proxy is not None: @@ -319,11 +333,14 @@ def _on_login_successful(self, client, _signal_name): self.get_page('success').set_account(account) self.show_page('success', Gtk.StackTransitionType.SLIDE_LEFT) - def _on_connected(self, client, _signal_name): + def _on_connected(self, client: Client, _signal_name: str) -> None: client.get_module('Register').request_register_form( callback=self._on_register_form) - def _on_anonymous_supported(self, client, _signal_name): + def _on_anonymous_supported(self, + client: Client, + _signal_name: str + ) -> None: account = self._generate_account_name(client.domain) proxy_name = None if client.proxy is not None: @@ -339,7 +356,7 @@ def _on_anonymous_supported(self, client, _signal_name): self.get_page('success').set_account(account) self.show_page('success', Gtk.StackTransitionType.SLIDE_LEFT) - def _on_disconnected(self, client, _signal_name): + def _on_disconnected(self, client: Client, _signal_name: str) -> None: domain, error, text = client.get_error() if domain == StreamError.SASL: if error == 'anonymous-not-supported': @@ -380,7 +397,10 @@ def _on_disconnected(self, client, _signal_name): self._client.destroy() self._client = None - def _on_connection_failed(self, _client, _signal_name): + def _on_connection_failed(self, + _client: Client, + _signal_name: str + ) -> None: self._show_error_page(_('Connection failed'), _('Connection failed'), _('Gajim was not able to reach the server. ' @@ -407,7 +427,7 @@ def _generate_account_name(domain: str) -> str: i += 1 return domain - def _on_register_form(self, task): + def _on_register_form(self, task: Task) -> None: try: result = task.finish() except (StanzaError, MalformedStanzaError) as error: @@ -446,7 +466,7 @@ def _submit_form(self) -> None: form, callback=self._on_register_result) - def _on_register_result(self, task): + def _on_register_result(self, task: Task) -> None: try: task.finish() except RegisterStanzaError as error: @@ -505,7 +525,7 @@ def _set_error_text(self, 'without an error message') self._show_error_page(_('Error'), _('Error'), error_text) - def _on_destroy(self, *args): + def _on_destroy(self, *args: Any) -> None: self._disconnect() self._destroyed = True @@ -540,10 +560,10 @@ def __init__(self) -> None: def focus(self) -> None: self._ui.log_in_address_entry.grab_focus() - def _on_login(self, *args): + def _on_login(self, *args: Any) -> None: self.emit('clicked', 'login') - def _on_signup(self, *args): + def _on_signup(self, *args: Any) -> None: self.emit('clicked', 'signup') def _create_server_completion(self) -> None: @@ -558,11 +578,11 @@ def _create_server_completion(self) -> None: address_model.append((server,)) self._ui.log_in_address_entry.get_completion().set_model(address_model) - def _on_address_changed(self, entry): + def _on_address_changed(self, entry: Gtk.Entry) -> None: self._update_completion(entry) self._set_complete() - def _update_completion(self, entry): + def _update_completion(self, entry: Gtk.Entry) -> None: text = entry.get_text() if '@' not in text: self._show_icon(False) @@ -580,10 +600,10 @@ def _show_icon(self, show: bool) -> None: self._ui.log_in_address_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, icon) - def _on_address_entry_activate(self, _widget): + def _on_address_entry_activate(self, _entry: Gtk.Entry) -> None: GLib.idle_add(self._ui.log_in_password_entry.grab_focus) - def _on_password_entry_activate(self, _widget): + def _on_password_entry_activate(self, _entry: Gtk.Entry) -> None: if self._ui.log_in_button.get_sensitive(): self._ui.log_in_button.activate() @@ -605,7 +625,7 @@ def _validate_jid(self, address: str) -> bool: self._show_icon(False) return True - def _set_complete(self, *args): + def _set_complete(self, *args: Any) -> None: address = self._validate_jid(self._ui.log_in_address_entry.get_text()) password = self._ui.log_in_password_entry.get_text() self._ui.log_in_button.set_sensitive(address and password) @@ -620,7 +640,7 @@ def get_credentials(self) -> Tuple[str, str]: class Signup(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.complete: bool = False self.title: str = _('Create New Account') @@ -660,13 +680,13 @@ def _create_server_completion(self) -> None: self._ui.server_comboboxtext_sign_up_entry.get_completion().set_model( servers_model) - def _on_visit_server(self, _widget): + def _on_visit_server(self, _button: Gtk.Button) -> int: server = self._ui.server_comboboxtext_sign_up_entry.get_text().strip() server = f'https://{server}' open_uri(server) return Gdk.EVENT_STOP - def _set_complete(self, *args): + def _set_complete(self, *args: Any) -> None: try: self.get_server() except Exception: @@ -689,7 +709,7 @@ def get_server(self) -> str: self._ui.server_comboboxtext_sign_up_entry.get_text()) @staticmethod - def _on_activate_link(_label, uri): + def _on_activate_link(_label: Gtk.Label, uri: str) -> int: # We have to use this, because the default GTK handler # is not cross-platform compatible open_uri(uri) @@ -703,7 +723,7 @@ def get_default_button(self) -> str: class AdvancedSettings(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.title: str = _('Advanced settings') self.complete: bool = False @@ -719,7 +739,7 @@ def __init__(self): self.show_all() @staticmethod - def _on_proxy_manager(_widget): + def _on_proxy_manager(_button: Gtk.Button) -> None: app.app.activate_action('manage-proxies') def update_proxy_list(self) -> None: @@ -811,7 +831,7 @@ def _is_custom_host_set(self) -> bool: def _is_proxy_set(self) -> bool: return self._ui.proxies_combobox.get_active() != 0 - def _set_complete(self, *args): + def _set_complete(self, *args: Any) -> None: self.complete = False if self._is_proxy_set(): self.complete = True @@ -875,7 +895,7 @@ def set_warning(self, self._ui.trust_cert_checkbutton.set_visible( Gio.TlsCertificateFlags.UNKNOWN_CA in errors) - def _on_view_cert(self, _button): + def _on_view_cert(self, _button: Gtk.Button) -> None: open_window('CertificateDialog', account=self._domain, transient_for=self.get_toplevel(), @@ -896,9 +916,9 @@ class Form(Page): def __init__(self) -> None: Page.__init__(self) self.set_valign(Gtk.Align.FILL) - self.complete = False + self.complete: bool = False self.title: str = _('Create Account') - self._current_form = None + self._current_form: Optional[Any] = None heading = Gtk.Label(label=_('Create Account')) heading.get_style_context().add_class('large-header') @@ -914,11 +934,11 @@ def __init__(self) -> None: def has_form(self) -> bool: return self._current_form is not None - def _on_is_valid(self, _widget, is_valid): + def _on_is_valid(self, _widget: DataFormWidget, is_valid: bool) -> None: self.complete = is_valid self.update_page_complete() - def add_form(self, form): + def add_form(self, form: Any) -> None: self.remove_form() options = {'hide-fallback-fields': True, @@ -933,7 +953,7 @@ def get_credentials(self) -> Tuple[str, str]: return (self._current_form.get_form()['username'].value, self._current_form.get_form()['password'].value) - def get_submit_form(self): + def get_submit_form(self) -> Any: return self._current_form.get_submit_form() def remove_form(self) -> None: @@ -971,7 +991,7 @@ def set_redirect(self, link: str, instructions: str) -> None: self._ui.instructions.set_text(instructions) self._link = link - def _on_link_button(self, _button): + def _on_link_button(self, _button:Gtk.Button) -> None: open_uri(self._link) def get_visible_buttons(self) -> List[str]: @@ -985,9 +1005,9 @@ def __init__(self) -> None: self.set_heading(_('Account has been added successfully')) self._account: Optional[str] = None - self._our_jid = None - self._label = None - self._color = None + self._our_jid: Optional[str] = None + self._label: Optional[str] = None + self._color: Optional[str] = None self._ui = get_builder('account_wizard.ui') self.pack_start(self._ui.account_label_box, True, True, 0) @@ -1013,28 +1033,28 @@ def set_account(self, account: str) -> None: def account(self) -> Optional[str]: return self._account - def _add_css_provider(self): + def _add_css_provider(self) -> Gtk.CssProvider: context = self._ui.badge_preview.get_style_context() provider = Gtk.CssProvider() context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER) return provider - def _on_name_changed(self, entry): + def _on_name_changed(self, entry: Gtk.Entry): self._label = entry.get_text() self._ui.badge_preview.set_text(self._label or self._our_jid) self._save_config() - def _on_color_set(self, button): + def _on_color_set(self, button: Gtk.ColorButton): rgba = button.get_rgba() self._color = rgba.to_string() self._set_badge_color(self._color) self._save_config() - def _set_badge_color(self, color): + def _set_badge_color(self, color: str) -> None: css = '.badge { background-color: %s; font-size: 100%%; }' % color self._provider.load_from_data(bytes(css.encode())) - def _save_config(self): + def _save_config(self) -> None: app.settings.set_account_setting( self._account, 'account_color', self._color) if self._label: ===================================== gajim/gtk/add_contact.py ===================================== @@ -93,6 +93,7 @@ def _on_button_clicked(self, ) -> None: page = self.get_current_page() account, _ = self.get_page('address').get_account_and_jid() + assert account is not None if button_name == 'next': self._start_disco() @@ -132,6 +133,7 @@ def _start_disco(self) -> None: self.show_page('progress', Gtk.StackTransitionType.SLIDE_LEFT) account, jid = self.get_page('address').get_account_and_jid() + assert account is not None self._disco_info(account, jid) @as_task @@ -213,7 +215,7 @@ def __init__(self, account: Optional[str], jid: Optional[JID]) -> None: self._ui.account_combo.connect('changed', self._on_account_changed) self._ui.address_entry.connect('changed', self._set_complete) - accounts = app.get_enabled_accounts_with_labels() + accounts = app.get_enabled_accounts_with_labels(connected_only=True) liststore = self._ui.account_combo.get_model() for acc in accounts: liststore.append(acc) ===================================== gajim/gtk/app_side_bar.py ===================================== @@ -17,11 +17,12 @@ from gajim.common import app -from gajim.gui.util import load_icon +from .app_page import AppPage +from .util import load_icon class AppSideBar(Gtk.ListBox): - def __init__(self, app_page): + def __init__(self, app_page: AppPage) -> None: Gtk.ListBox.__init__(self) self.set_valign(Gtk.Align.START) self.set_selection_mode(Gtk.SelectionMode.SINGLE) @@ -40,15 +41,17 @@ def __init__(self, app_page): GLib.idle_add(self.unselect_all) @staticmethod - def _on_app_row_activated(_listbox, _row): + def _on_app_row_activated(_listbox: Gtk.ListBox, + _row: Gtk.ListBoxRow + ) -> None: app.window.show_app_page() - def _on_unread_count_changed(self, _app_page, count): + def _on_unread_count_changed(self, _app_page: AppPage, count: int) -> None: self._app_row.set_unread_count(count) class AppRow(Gtk.ListBoxRow): - def __init__(self): + def __init__(self) -> None: Gtk.ListBoxRow.__init__(self) self.get_style_context().add_class('workspace-sidebar-item') @@ -78,7 +81,7 @@ def __init__(self): self.add(overlay) self.show_all() - def set_unread_count(self, count): + def set_unread_count(self, count: int) -> None: if count < 1000: self._unread_label.set_text(str(count)) else: ===================================== gajim/gtk/avatar_selector.py ===================================== @@ -109,7 +109,7 @@ def prepare_crop_area(self, path: str) -> None: self._helper_label.hide() self._crop_area.show() - def _on_load_clicked(self, _button): + def _on_load_clicked(self, _button: Gtk.Button) -> None: def _on_file_selected(path): self.prepare_crop_area(path) @@ -117,8 +117,15 @@ def _on_file_selected(path): transient_for=self.get_toplevel(), modal=True) - 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: if not selection.get_data(): return @@ -184,10 +191,10 @@ def __init__(self) -> None: self._image = Gdk.Rectangle() self._crop = Gdk.Rectangle() - self._pixbuf = None - self._browse_pixbuf = None - self._color_shifted_pixbuf = None - self._current_cursor = None + self._pixbuf: Optional[GdkPixbuf.Pixbuf] = None + self._browse_pixbuf: Optional[GdkPixbuf.Pixbuf] = None + self._color_shifted_pixbuf: Optional[GdkPixbuf.Pixbuf] = None + self._current_cursor: Optional[Gdk.CursorType] = None self._scale = float(0.0) self._image.x = 0 @@ -259,7 +266,7 @@ def get_pixbuf(self) -> Optional[GdkPixbuf.Pixbuf]: return GdkPixbuf.Pixbuf.new_subpixbuf( self._browse_pixbuf, self._crop.x, self._crop.y, width, height) - def _on_draw(self, _widget, context): + def _on_draw(self, _widget: Gtk.Widget, context: cairo.Context) -> bool: if self._browse_pixbuf is None: return False @@ -342,7 +349,10 @@ def _on_draw(self, _widget, context): return False - def _on_button_press(self, _widget, event): + def _on_button_press(self, + _widget: Gtk.Widget, + event: Gdk.EventButton + ) -> bool: if self._browse_pixbuf is None: return False @@ -357,7 +367,10 @@ def _on_button_press(self, _widget, event): return False - def _on_button_release(self, _widget, _event): + def _on_button_release(self, + _widget: Gtk.Widget, + _event: Gdk.EventButton + ) -> bool: if self._browse_pixbuf is None: return False @@ -371,7 +384,10 @@ def _on_button_release(self, _widget, _event): return False - def _on_motion_notify(self, _widget, event): + def _on_motion_notify(self, + _widget: Gtk.Widget, + event: Gdk.EventMotion + ) -> bool: # pylint: disable=too-many-boolean-expressions # pylint: disable=too-many-branches # pylint: disable=too-many-statements @@ -565,7 +581,7 @@ def _on_motion_notify(self, _widget, event): return False - def _update_pixbufs(self): + def _update_pixbufs(self) -> None: allocation = self.get_allocation() width = self._browse_pixbuf.get_width() height = self._browse_pixbuf.get_height() @@ -625,7 +641,7 @@ def _update_pixbufs(self): self._image.width = dest_width self._image.height = dest_height - def _crop_to_widget(self): + def _crop_to_widget(self) -> Gdk.Rectangle: crop = Gdk.Rectangle() crop.x = self._image.x + self._crop.x * self._scale crop.y = self._image.y + self._crop.y * self._scale @@ -633,7 +649,7 @@ def _crop_to_widget(self): crop.height = self._crop.height * self._scale return crop - def _update_cursor(self, x_coord, y_coord): + def _update_cursor(self, x_coord: float, y_coord: float) -> None: region = self._active_region if self._active_region == Loc.OUTSIDE: crop = self._crop_to_widget() @@ -668,7 +684,12 @@ def _update_cursor(self, x_coord, y_coord): self._current_cursor = cursor_type @staticmethod - def _eval_radial_line(center_x, center_y, bounds_x, bounds_y, user_x): + def _eval_radial_line(center_x: float, + center_y: float, + bounds_x: int, + bounds_y: int, + user_x: int + ) -> int: slope_y = float(bounds_y - center_y) slope_x = bounds_x - center_x if slope_y == 0 or slope_x == 0: @@ -679,7 +700,11 @@ def _eval_radial_line(center_x, center_y, bounds_x, bounds_y, user_x): decision_intercept = - float(decision_slope * bounds_x) return int(decision_slope * user_x + decision_intercept) - def _find_location(self, rect, x_coord, y_coord): + def _find_location(self, + rect: Gdk.Rectangle, + x_coord: float, + y_coord: float + ) -> Loc: # pylint: disable=line-too-long location = [ [Loc.OUTSIDE, Loc.OUTSIDE, Loc.OUTSIDE, Loc.OUTSIDE, Loc.OUTSIDE], @@ -696,7 +721,7 @@ def _find_location(self, rect, x_coord, y_coord): return location[y_range][x_range] @staticmethod - def _find_range(coord, min_v, max_v): + def _find_range(coord: float, min_v: int, max_v: int) -> Range: tolerance = 12 if coord < min_v - tolerance: return Range.BELOW @@ -708,7 +733,7 @@ def _find_range(coord, min_v, max_v): return Range.UPPER return Range.ABOVE - def _generate_color_shifted_pixbuf(self): + def _generate_color_shifted_pixbuf(self) -> None: # pylint: disable=no-member surface = cairo.ImageSurface( cairo.Format.ARGB32, ===================================== gajim/gtk/change_password.py ===================================== @@ -12,12 +12,17 @@ # 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 typing import List + import logging from gi.repository import Gtk from nbxmpp.errors import StanzaError from nbxmpp.errors import ChangePasswordStanzaError +from nbxmpp.modules.dataforms import SimpleDataForm +from nbxmpp.task import Task from gajim.common import app from gajim.common.i18n import _ @@ -35,7 +40,7 @@ class ChangePassword(Assistant): - def __init__(self, account): + def __init__(self, account: str) -> None: Assistant.__init__(self) self.account = account @@ -61,7 +66,10 @@ def __init__(self, account): self.show_all() - def _on_button_clicked(self, _assistant, button_name): + def _on_button_clicked(self, + _assistant: Assistant, + button_name: str + ) -> None: page = self.get_current_page() if button_name == 'apply': self.show_page('progress', Gtk.StackTransitionType.SLIDE_LEFT) @@ -73,7 +81,7 @@ def _on_button_clicked(self, _assistant, button_name): elif button_name == 'close': self.destroy() - def _on_apply(self, next_stage=False): + def _on_apply(self, next_stage: bool = False) -> None: if next_stage: form = self.get_page('next_stage').get_submit_form() self._client.get_module('Register').change_password_with_form( @@ -84,7 +92,7 @@ def _on_apply(self, next_stage=False): password, callback=self._on_change_password) @ensure_not_destroyed - def _on_change_password(self, task): + def _on_change_password(self, task: Task) -> None: try: task.finish() except ChangePasswordStanzaError as error: @@ -101,12 +109,12 @@ def _on_change_password(self, task): passwords.save_password(self.account, password) self.show_page('success') - def _on_destroy(self, *args): + def _on_destroy(self, *args: Any) -> None: self._destroyed = True class EnterPassword(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.complete = False self.title = _('Change Password') @@ -150,7 +158,7 @@ def __init__(self): self._show_icon(False) self.show_all() - def _show_icon(self, show): + def _show_icon(self, show: bool) -> None: if show: self._password2_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, 'dialog-warning-symbolic') @@ -160,7 +168,7 @@ def _show_icon(self, show): self._password2_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, None) - def _on_changed(self, _entry): + def _on_changed(self, _entry: Gtk.Entry) -> None: password1 = self._password1_entry.get_text() if not password1: self._show_icon(True) @@ -175,19 +183,19 @@ def _on_changed(self, _entry): self._show_icon(False) self._set_complete(True) - def _set_complete(self, state): + def _set_complete(self, state: bool) -> None: self.complete = state self.update_page_complete() - def get_password(self): + def get_password(self) -> str: return self._password1_entry.get_text() - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['apply'] class NextStage(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.set_valign(Gtk.Align.FILL) self.complete = False @@ -196,11 +204,11 @@ def __init__(self): self.show_all() - def _on_is_valid(self, _widget, is_valid): + def _on_is_valid(self, _widget: Gtk.Widget, is_valid: bool) -> None: self.complete = is_valid self.update_page_complete() - def set_form(self, form): + def set_form(self, form: SimpleDataForm) -> None: if self._current_form is not None: self.remove(self._current_form) self._current_form.destroy() @@ -210,31 +218,31 @@ def set_form(self, form): self.pack_start(self._current_form, True, True, 0) self._current_form.show_all() - def get_submit_form(self): + def get_submit_form(self) -> SimpleDataForm: return self._current_form.get_submit_form() - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['apply'] class Error(ErrorPage): - def __init__(self): + def __init__(self) -> None: ErrorPage.__init__(self) self.set_title(_('Password Change Failed')) self.set_heading(_('Password Change Failed')) self.set_text( _('An error occurred while trying to change your password.')) - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['back'] class Success(SuccessPage): - def __init__(self): + def __init__(self) -> None: SuccessPage.__init__(self) self.set_title(_('Password Changed')) self.set_heading(_('Password Changed')) self.set_text(_('Your password has successfully been changed.')) - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['close'] ===================================== gajim/gtk/chat_list_stack.py ===================================== @@ -24,10 +24,10 @@ from gajim.common import app +from .chat_filter import ChatFilter from .chat_list import ChatList from .chat_list import ChatRow - HANDLED_EVENTS = [ 'message-received', 'mam-message-received', @@ -58,7 +58,10 @@ class ChatListStack(Gtk.Stack): (str, object, str)), } - def __init__(self, chat_filter, search_entry): + def __init__(self, + chat_filter: ChatFilter, + search_entry: Gtk.SearchEntry + ) -> None: Gtk.Stack.__init__(self) self.set_hexpand(True) self.set_vexpand(True) @@ -77,7 +80,7 @@ def __init__(self, chat_filter, search_entry): self._add_actions() self.show_all() - def _add_actions(self): + def _add_actions(self) -> None: actions = [ ('toggle-chat-pinned', 'as', self._toggle_chat_pinned), ('move-chat-to-workspace', 'as', self._move_chat_to_workspace), @@ -92,7 +95,7 @@ def _add_actions(self): act.connect('activate', func) app.window.add_action(act) - def _on_visible_child_name(self, _stack, _param): + def _on_visible_child_name(self, _stack: Gtk.Stack, _param: str) -> None: if self._last_visible_child_name == self.get_visible_child_name(): return @@ -125,11 +128,11 @@ def is_chat_active(self, account: str, jid: JID) -> bool: return False return chat.is_active - def _on_filter_changed(self, _filter, name): + def _on_filter_changed(self, _filter: ChatFilter, name: str) -> None: chat_list = self.get_visible_child() chat_list.set_filter(name) - def _on_search_changed(self, search_entry): + def _on_search_changed(self, search_entry: Gtk.SearchEntry) -> None: chat_list = self.get_visible_child() chat_list.set_filter_text(search_entry.get_text()) @@ -150,7 +153,10 @@ def remove_chat_list(self, workspace_id: str) -> None: self._chat_lists.pop(workspace_id) chat_list.destroy() - def _on_row_selected(self, _chat_list, row): + def _on_row_selected(self, + _chat_list: ChatList, + row: Optional[ChatRow] + ) -> None: if row is None: self.emit('chat-unselected') return @@ -188,7 +194,10 @@ def store_open_chats(self, workspace_id: str) -> None: app.settings.set_workspace_setting( workspace_id, 'open_chats', open_chats) - def _toggle_chat_pinned(self, _action, param): + def _toggle_chat_pinned(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: workspace_id, account, jid = param.unpack() jid = JID.from_string(jid) @@ -196,7 +205,10 @@ def _toggle_chat_pinned(self, _action, param): chat_list.toggle_chat_pinned(account, jid) self.store_open_chats(workspace_id) - def _move_chat_to_workspace(self, _action, param): + def _move_chat_to_workspace(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: new_workspace_id, account, jid = param.unpack() jid = JID.from_string(jid) @@ -209,7 +221,10 @@ def _move_chat_to_workspace(self, _action, param): self.store_open_chats(current_chatlist.workspace_id) self.store_open_chats(new_workspace_id) - def _mark_as_read(self, _action, param): + def _mark_as_read(self, + _action: Gio.SimpleAction, + param: GLib.Variant + ) -> None: _workspace_id, account, jid = param.unpack() self.mark_as_read(account, JID.from_string(jid)) View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0f1e4c61117b5f60e68e91f4bcd1936…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/0f1e4c61117b5f60e68e91f4bcd1936…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
[Git][gajim/gajim][master] 4 commits: AddContact: Typing
by Daniel Brötzmann (ï¼ wurstsalat)
22 Dec '21
22 Dec '21
Daniel Brötzmann pushed to branch master at gajim / gajim Commits: e348faf6 by wurstsalat at 2021-12-22T19:27:38+01:00 AddContact: Typing - - - - - 211e49ee by wurstsalat at 2021-12-22T19:28:32+01:00 AddContact: Make sure Contact can be added under any circumstances - - - - - 1ad8eddc by wurstsalat at 2021-12-22T19:46:46+01:00 Assistant: Typing - - - - - 0f1e4c61 by wurstsalat at 2021-12-22T19:57:54+01:00 AdvancedConfig: Typing - - - - - 4 changed files: - gajim/common/app.py - gajim/gtk/add_contact.py - gajim/gtk/advanced_config.py - gajim/gtk/assistant.py Changes: ===================================== gajim/common/app.py ===================================== @@ -399,12 +399,12 @@ def get_accounts_sorted() -> list[str]: def get_enabled_accounts_with_labels( exclude_local: bool = True, connected_only: bool = False, - private_storage_only: bool = False) -> list[str]: + private_storage_only: bool = False) -> list[list[str]]: """ Returns a list with [account, account_label] entries. Order by account_label """ - accounts: list[str] = [] + accounts = [] for acc in connections: if exclude_local and account_is_zeroconf(acc): continue ===================================== gajim/gtk/add_contact.py ===================================== @@ -12,9 +12,12 @@ # 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 Tuple -from typing import Optional from typing import Any +from typing import Dict +from typing import List +from typing import Optional +from typing import Tuple +from typing import Union import logging @@ -23,8 +26,11 @@ from nbxmpp import JID from nbxmpp import Namespace from nbxmpp.errors import is_error +from nbxmpp.errors import StanzaError +from nbxmpp.structs import DiscoInfo from gajim.common import app +from gajim.common import types from gajim.common.helpers import get_subscription_request_msg from gajim.common.helpers import validate_jid from gajim.common.i18n import _ @@ -45,13 +51,13 @@ class AddContact(Assistant): def __init__(self, account: Optional[str] = None, jid: Optional[JID] = None, - nick: str = None): + nick: Optional[str] = None): Assistant.__init__(self) self.account = account self.jid = jid self._nick = nick - self._result = None + self._result: Union[DiscoInfo, StanzaError, None] = None self.add_button('next', _('Next'), complete=True, css_class='suggested-action') @@ -74,14 +80,17 @@ def __init__(self, progress.set_text(_('Trying to gather information on this address…')) self.connect('button-clicked', self._on_button_clicked) + self.connect('destroy', self._on_destroy) 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_button_clicked(self, _assistant, button_name): + def _on_button_clicked(self, + _assistant: Assistant, + button_name: str + ) -> None: page = self.get_current_page() account, _ = self.get_page('address').get_account_and_jid() @@ -126,7 +135,7 @@ def _start_disco(self) -> None: self._disco_info(account, jid) @as_task - def _disco_info(self, account, address): + def _disco_info(self, account: str, address: str) -> None: _task = yield client = app.get_client(account) @@ -139,7 +148,7 @@ def _disco_info(self, account, address): log.info('Disco Info received: %s', address) self._process_info(account, result) - def _process_error(self, account, result): + def _process_error(self, account: str, result: StanzaError) -> None: log.debug('Error received: %s', result) self._result = result @@ -155,7 +164,7 @@ def _process_error(self, account, result): self.get_page('error').set_text(result.get_text()) self.show_page('error', Gtk.StackTransitionType.SLIDE_LEFT) - def _process_info(self, account, result): + def _process_info(self, account: str, result: DiscoInfo) -> None: log.debug('Info received: %s', result) self._result = result @@ -186,14 +195,8 @@ def _process_info(self, account, result): self.show_page('gateway', Gtk.StackTransitionType.SLIDE_LEFT) return - if result.has_category('client'): - self.get_page('contact').prepare(account, result) - self.show_page('contact', Gtk.StackTransitionType.SLIDE_LEFT) - return - - self.get_page('error').set_text( - _('This address does not seem to offer any gateway service.')) - self.show_page('error') + self.get_page('contact').prepare(account, result) + self.show_page('contact', Gtk.StackTransitionType.SLIDE_LEFT) class Address(Page): @@ -218,12 +221,12 @@ def __init__(self, account: Optional[str], jid: Optional[JID]) -> None: if len(accounts) > 1: self._ui.account_box.show() - if self._account is not None: + if account is not None: self._ui.account_combo.set_active_id(account) else: self._ui.account_combo.set_active(0) else: - # Set to first (and only) item; sets self._account as well + # Set to first (and only) item; sets self._account automatically self._ui.account_combo.set_active(0) if jid is not None: @@ -233,29 +236,29 @@ def __init__(self, account: Optional[str], jid: Optional[JID]) -> None: self.show_all() - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['next'] - def get_default_button(self): + def get_default_button(self) -> str: return 'next' - def get_account_and_jid(self) -> Tuple[Optional[str], Any]: + def get_account_and_jid(self) -> Tuple[str, str]: return self._account, self._ui.address_entry.get_text() def focus(self) -> None: self._ui.address_entry.grab_focus() - def _on_account_changed(self, combobox): + def _on_account_changed(self, combobox: Gtk.ComboBox) -> None: account = combobox.get_active_id() self._account = account self._set_complete() - def _show_icon(self, show): + def _show_icon(self, show: bool) -> None: icon = 'dialog-warning-symbolic' if show else None self._ui.address_entry.set_icon_from_icon_name( Gtk.EntryIconPosition.SECONDARY, icon) - def _set_complete(self, *args): + def _set_complete(self, *args: Any) -> None: if self._account is None: self.complete = False self.update_page_complete() @@ -306,26 +309,26 @@ def _validate_address(self, address: str) -> bool: class Error(ErrorPage): - def __init__(self): + def __init__(self) -> None: ErrorPage.__init__(self) self.set_title(_('Add Contact')) self.set_heading(_('An Error Occurred')) - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['back'] - def get_default_button(self): + def get_default_button(self) -> str: return 'back' class Contact(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.title = _('Add Contact') - self._result = None - self._account = None - self._contact = None + self._result: Union[DiscoInfo, StanzaError, None] = None + self._account: Optional[str] = None + self._contact: Optional[types.BareContact] = None self._ui = get_builder('add_contact.ui') self.add(self._ui.contact_grid) @@ -334,13 +337,13 @@ def __init__(self): self.show_all() - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['back', 'add'] - def get_default_button(self): + def get_default_button(self) -> str: return 'add' - def prepare(self, account, result): + def prepare(self, account: str, result: Union[DiscoInfo, StanzaError]): self._result = result self._account = account @@ -357,11 +360,11 @@ def _update_groups(self, account: str) -> None: for group in client.get_module('Roster').get_groups(): self._ui.group_combo.append_text(group) - def _on_info_clicked(self, _button): + def _on_info_clicked(self, _button: Gtk.Button) -> None: open_window( 'ContactInfo', account=self._account, contact=self._contact) - def get_subscription_data(self): + def get_subscription_data(self) -> Dict[str, Union[str, List[str], bool]]: group = self._ui.group_combo.get_child().get_text() groups = [group] if group else [] return { @@ -372,12 +375,12 @@ def get_subscription_data(self): class Gateway(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.title = _('Service Gateway') - self._account = None - self._result = None + self._account: Optional[str] = None + self._result: Optional[DiscoInfo] = None self._ui = get_builder('add_contact.ui') self.add(self._ui.gateway_box) @@ -387,13 +390,13 @@ def __init__(self): self.show_all() - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['back', 'add'] - def get_default_button(self): + def get_default_button(self) -> str: return 'add' - def prepare(self, account, result): + def prepare(self, account: str, result: DiscoInfo) -> None: self._account = account self._result = result @@ -447,22 +450,22 @@ def prepare(self, account, result): self._ui.commands_button.set_tooltip_text( _('This gateway does not support Ad-Hoc Commands.')) - def _on_register_clicked(self, _button): + def _on_register_clicked(self, _button: Gtk.Button) -> None: open_window( 'ServiceRegistration', account=self._account, address=self._result.jid) - def _on_command_clicked(self, _button): + def _on_command_clicked(self, _button: Gtk.Button) -> None: AdHocCommand(self._account, self._result.jid) class GroupChat(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self.title = _('Join Group Chat?') - self._result = None + self._result: Optional[DiscoInfo] = None heading = Gtk.Label(label=_('Join Group Chat?')) heading.get_style_context().add_class('large-header') @@ -477,13 +480,13 @@ def __init__(self): self.show_all() - def get_visible_buttons(self): + def get_visible_buttons(self) -> List[str]: return ['back', 'join'] - def get_default_button(self): + def get_default_button(self) -> str: return 'join' - def prepare(self, account, result): + def prepare(self, account: str, result: DiscoInfo) -> None: self._result = result self._info_box.set_account(account) ===================================== gajim/gtk/advanced_config.py ===================================== @@ -19,6 +19,8 @@ # 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 Optional + from enum import IntEnum from enum import unique @@ -32,6 +34,7 @@ from gajim.common.setting_values import ADVANCED_SETTINGS from gajim.common.setting_values import APP_SETTINGS + from .builder import get_builder @@ -56,7 +59,7 @@ class Column(IntEnum): class AdvancedConfig(Gtk.ApplicationWindow): - def __init__(self): + def __init__(self) -> None: Gtk.ApplicationWindow.__init__(self) self.set_application(app.app) self.set_position(Gtk.WindowPosition.CENTER) @@ -107,7 +110,7 @@ def __init__(self): self._ui.connect_signals(self) self.show_all() - def _on_key_press(self, _widget, event): + def _on_key_press(self, _widget: Gtk.Widget, event: Gdk.EventKey) -> None: if event.keyval != Gdk.KEY_Escape: return @@ -117,11 +120,18 @@ def _on_key_press(self, _widget, event): self.destroy() - def _value_column_data_callback(self, _col, cell, model, iter_, _data): + def _value_column_data_callback(self, + _col: Gtk.TreeViewColumn, + cell: Gtk.CellRenderer, + model: Gtk.TreeModel, + iter_: Gtk.TreeIter, + _data: Optional[object]): opttype = model[iter_][Column.TYPE] cell.set_property('editable', opttype != SETTING_TYPES[bool]) - def _on_treeview_selection_changed(self, treeselection): + def _on_treeview_selection_changed(self, + treeselection: Gtk.TreeSelection + ) -> None: model, iter_ = treeselection.get_selected() if not iter_: self._ui.reset_button.set_sensitive(False) @@ -133,7 +143,11 @@ def _on_treeview_selection_changed(self, treeselection): self._ui.description.set_text(desc or Q_('?config description:None')) self._ui.reset_button.set_sensitive(True) - def _on_treeview_row_activated(self, _treeview, path, _column): + def _on_treeview_row_activated(self, + _treeview: Gtk.TreeView, + path: Gtk.TreePath, + _column: Gtk.TreeViewColumn + ) -> None: modelpath = self.modelfilter.convert_path_to_child_path(path) modelrow = self.model[modelpath] setting = modelrow[Column.NAME] @@ -147,7 +161,11 @@ def _on_treeview_row_activated(self, _treeview, path, _column): app.settings.set(setting, setting_value) modelrow[Column.VALUE] = column_value - def _on_config_edited(self, _cell, path, text): + def _on_config_edited(self, + _cell: Gtk.CellRendererText, + path: str, + text: str + ) -> None: path = Gtk.TreePath.new_from_string(path) modelpath = self.modelfilter.convert_path_to_child_path(path) modelrow = self.model[modelpath] @@ -160,7 +178,7 @@ def _on_config_edited(self, _cell, path, text): app.settings.set(setting, value) modelrow[Column.VALUE] = text - def _on_reset_button_clicked(self, button): + def _on_reset_button_clicked(self, button: Gtk.Button) -> None: model, iter_ = self.treeview.get_selection().get_selected() if not iter_: return @@ -176,7 +194,7 @@ def _on_reset_button_clicked(self, button): app.settings.set(setting, default) button.set_sensitive(False) - def _fill_model(self, node=None, parent=None): + def _fill_model(self, parent=None) -> None: for category, settings in ADVANCED_SETTINGS.items(): if category != 'app': continue @@ -199,7 +217,11 @@ def _fill_model(self, node=None, parent=None): self.model.append(parent, [setting, value, type_]) - def _visible_func(self, model, treeiter, _data): + def _visible_func(self, + model: Gtk.TreeModel, + treeiter: Gtk.TreeIter, + _data: Optional[object] + ) -> bool: search_string = self._ui.search_entry.get_text().lower() if not search_string: return True @@ -211,5 +233,5 @@ def _visible_func(self, model, treeiter, _data): return True return False - def _on_search_entry_changed(self, _widget): + def _on_search_entry_changed(self, _entry: Gtk.SearchEntry) -> None: self.modelfilter.refilter() ===================================== gajim/gtk/assistant.py ===================================== @@ -12,6 +12,12 @@ # 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 Optional +from typing import Tuple + from gi.repository import Gdk from gi.repository import Gtk from gi.repository import Gio @@ -36,10 +42,10 @@ class Assistant(Gtk.ApplicationWindow, EventHelper): )) def __init__(self, - transient_for=None, - width=550, - height=400, - transition_duration=200): + transient_for: Optional[Gtk.Window] = None, + width: int = 550, + height: int = 400, + transition_duration: int = 200) -> None: Gtk.ApplicationWindow.__init__(self) EventHelper.__init__(self) self.set_application(Gio.Application.get_default()) @@ -51,8 +57,8 @@ def __init__(self, self.set_transient_for(transient_for) self.set_type_hint(Gdk.WindowTypeHint.DIALOG) - self._pages = {} - self._buttons = {} + self._pages: Dict[str, Page] = {} + self._buttons: Dict[str, Tuple[Gtk.Button, bool]] = {} self._button_visible_func = None self._ui = get_builder('assistant.ui') @@ -64,29 +70,32 @@ def __init__(self, self.connect('destroy', self.__on_destroy) self._ui.connect_signals(self) - def show_all(self): + def show_all(self) -> None: page_name = self._ui.stack.get_visible_child_name() self.emit('page-changed', page_name) Gtk.ApplicationWindow.show_all(self) - def _on_key_press_event(self, _widget, event): + def _on_key_press_event(self, + _widget: Gtk.Widget, + event: Gdk.EventKey + ) -> None: if event.keyval == Gdk.KEY_Escape: self.destroy() - def _update_page_complete(self, *args): + def _update_page_complete(self, *args: Any) -> None: page_widget = self._ui.stack.get_visible_child() for button, complete in self._buttons.values(): if complete: button.set_sensitive(page_widget.complete) - def update_title(self): + def update_title(self) -> None: self.set_title(self._ui.stack.get_visible_child().title) - def _hide_buttons(self): + def _hide_buttons(self) -> None: for button, _ in self._buttons.values(): button.hide() - def _set_buttons_visible(self): + def _set_buttons_visible(self) -> None: page_name = self._ui.stack.get_visible_child_name() if self._button_visible_func is None: buttons = self.get_page(page_name).get_visible_buttons() @@ -112,11 +121,16 @@ def _set_buttons_visible(self): def set_button_visible_func(self, func): self._button_visible_func = func - def set_default_button(self, button_name): + def set_default_button(self, button_name: str) -> None: button, _ = self._buttons[button_name] button.grab_default() - def add_button(self, name, label, css_class=None, complete=False): + def add_button(self, + name: str, + label: str, + css_class: Optional[str] = None, + complete: bool = False + ) -> None: button = Gtk.Button(label=label, can_default=True, no_show_all=True) @@ -126,13 +140,13 @@ def add_button(self, name, label, css_class=None, complete=False): self._buttons[name] = (button, complete) self._ui.action_area.pack_end(button, False, False, 0) - def add_pages(self, pages): + def add_pages(self, pages: Dict[str, Page]): self._pages = pages for name, widget in pages.items(): widget.connect('update-page-complete', self._update_page_complete) self._ui.stack.add_named(widget, name) - def add_default_page(self, name): + def add_default_page(self, name: str) -> Page: if name == 'success': page = SuccessPage() elif name == 'error': @@ -146,19 +160,22 @@ def add_default_page(self, name): self._ui.stack.add_named(page, name) return page - def get_current_page(self): + def get_current_page(self) -> str: return self._ui.stack.get_visible_child_name() - def show_page(self, name, transition=Gtk.StackTransitionType.NONE): + def show_page(self, + name: str, + transition: Gtk.StackTransitionType = Gtk.StackTransitionType.NONE + ) -> None: if self._ui.stack.get_visible_child_name() == name: return self._hide_buttons() self._ui.stack.set_visible_child_full(name, transition) - def get_page(self, name): + def get_page(self, name: str) -> Page: return self._pages[name] - def _on_visible_child_name(self, stack, _param): + def _on_visible_child_name(self, stack: Gtk.Stack, _param: str) -> None: if stack.get_visible_child_name() is None: # Happens for some reason when adding the first page return @@ -166,14 +183,14 @@ def _on_visible_child_name(self, stack, _param): self._set_buttons_visible() self.emit('page-changed', stack.get_visible_child_name()) - def __on_button_clicked(self, button): + def __on_button_clicked(self, button: Gtk.Button) -> None: for button_name, button_data in self._buttons.items(): button_ = button_data[0] if button_ == button: self.emit('button-clicked', button_name) return - def __on_destroy(self, *args): + def __on_destroy(self, *args: Any) -> None: self._pages.clear() self._buttons.clear() @@ -184,26 +201,26 @@ class Page(Gtk.Box): 'update-page-complete': (GObject.SignalFlags.RUN_LAST, None, ()), } - def __init__(self): + def __init__(self) -> None: Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.set_spacing(18) self.set_valign(Gtk.Align.CENTER) - self.title = '' - self.complete = True + self.title: str = '' + self.complete: bool = True - def get_visible_buttons(self): + def get_visible_buttons(self) -> None: return None - def get_default_button(self): + def get_default_button(self) -> None: return None - def update_page_complete(self): + def update_page_complete(self) -> None: self.emit('update-page-complete') class DefaultPage(Page): - def __init__(self, icon_name, icon_css_class): + def __init__(self, icon_name: str, icon_css_class: str) -> None: Page.__init__(self) self._heading = Gtk.Label() @@ -227,32 +244,32 @@ def __init__(self, icon_name, icon_css_class): self.pack_start(self._label, False, True, 0) self.show_all() - def set_heading(self, heading): + def set_heading(self, heading: str) -> None: self._heading.set_text(heading) - def set_text(self, text): + def set_text(self, text: str) -> None: self._label.set_text(text) - def set_title(self, title): + def set_title(self, title: str) -> None: self.title = title class ErrorPage(DefaultPage): - def __init__(self): + def __init__(self) -> None: DefaultPage.__init__(self, icon_name='dialog-error-symbolic', icon_css_class='error-color') class SuccessPage(DefaultPage): - def __init__(self): + def __init__(self) -> None: DefaultPage.__init__(self, icon_name='object-select-symbolic', icon_css_class='success-color') class ProgressPage(Page): - def __init__(self): + def __init__(self) -> None: Page.__init__(self) self._label = Gtk.Label() @@ -269,8 +286,8 @@ def __init__(self): self.show_all() - def set_text(self, text): + def set_text(self, text: str) -> None: self._label.set_text(text) - def set_title(self, title): + def set_title(self, title: str) -> None: self.title = title View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/36d4071a8ade991b562b6832da20b1f…
-- View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/compare/36d4071a8ade991b562b6832da20b1f…
You're receiving this email because of your account on
dev.gajim.org
.
1
0
0
0
← Newer
1
...
210
211
212
213
214
215
216
...
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