Philipp Hörist pushed to branch master at gajim / gajim


Commits:
addf99f0 by lovetox at 2022-02-02T13:18:35+01:00
Get rid of interface.get_avatar()

- - - - -
e3b1b2a2 by lovetox at 2022-02-02T13:19:27+01:00
Pass show always as str to add_status_to_avatar()

- - - - -
ba910b98 by lovetox at 2022-02-02T13:20:11+01:00
Add css class for connecting state

- - - - -


7 changed files:

- gajim/common/modules/contacts.py
- gajim/data/style/default-dark.css
- gajim/data/style/default.css
- gajim/gtk/avatar.py
- gajim/gtk/notification.py
- gajim/gtk/util.py
- gajim/gui_interface.py


Changes:

=====================================
gajim/common/modules/contacts.py
=====================================
@@ -318,7 +318,7 @@ def get_avatar(self,
                    default: bool = False,
                    style: str = 'circle'):
 
-        show = self.show if add_show else None
+        show = self.show.value if add_show else None
 
         transport_icon = None
         if self.is_gateway:
@@ -698,7 +698,7 @@ def get_avatar(self,
                    add_show: bool = True,
                    style: str = 'circle') -> cairo.ImageSurface:
 
-        show = self.show if add_show else None
+        show = self.show.value if add_show else None
         return app.app.avatar_storage.get_surface(
             self, size, scale, show, style=style)
 


=====================================
gajim/data/style/default-dark.css
=====================================
@@ -67,3 +67,6 @@ .gajim-status-dnd {
 .gajim-status-offline {
     color: rgb(154, 154, 154);
 }
+.gajim-status-connecting {
+    color: rgb(77, 166, 255);
+}


=====================================
gajim/data/style/default.css
=====================================
@@ -69,3 +69,6 @@ .gajim-status-dnd {
 .gajim-status-offline {
     color: rgb(154, 154, 154);
 }
+.gajim-status-connecting {
+    color: rgb(77, 166, 255);
+}


=====================================
gajim/gtk/avatar.py
=====================================
@@ -127,7 +127,7 @@ def make_workspace_avatar(letter: str,
 
 
 def add_status_to_avatar(surface: cairo.ImageSurface,
-                         show) -> cairo.ImageSurface:
+                         show: str) -> cairo.ImageSurface:
 
     width = surface.get_width()
     height = surface.get_height()
@@ -154,7 +154,7 @@ def add_status_to_avatar(surface: cairo.ImageSurface,
     context.arc(center_x, center_y, clip_radius, 0, 2 * pi)
     context.fill()
 
-    css_color = get_css_show_class(show.value)
+    css_color = get_css_show_class(show)
     color = convert_rgb_string_to_float(
         app.css_config.get_value(css_color, StyleAttr.COLOR))
 
@@ -165,7 +165,7 @@ def add_status_to_avatar(surface: cairo.ImageSurface,
     context.arc(center_x, center_y, show_radius, 0, 2 * pi)
     context.fill()
 
-    if show.value == 'dnd':
+    if show == 'dnd':
         line_length = clip_radius / 2
         context.move_to(center_x - line_length, center_y)
         context.line_to(center_x + line_length, center_y)


=====================================
gajim/gtk/notification.py
=====================================
@@ -371,10 +371,9 @@ def _get_avatar_for_notification(account: str,
         scale = get_monitor_scale_factor()
         client = app.get_client(account)
         contact = client.get_module('Contacts').get_contact(jid)
-        return app.interface.get_avatar(contact,
-                                        AvatarSize.NOTIFICATION,
-                                        scale,
-                                        pixbuf=True)
+        return contact.get_avatar(AvatarSize.NOTIFICATION,
+                                  scale,
+                                  pixbuf=True)
 
     def _make_icon(self, event: events.Notification) -> Gio.Icon:
         if (event.type == 'incoming-message' and app.desktop_env == 'gnome'):


=====================================
gajim/gtk/util.py
=====================================
@@ -616,7 +616,8 @@ def get_css_show_class(show: str) -> str:
         return '.gajim-status-away'
     if show in ('dnd', 'xa'):
         return '.gajim-status-dnd'
-    # 'offline', 'not in roster', 'requested'
+    if show == 'connecting':
+        return '.gajim-status-connecting'
     return '.gajim-status-offline'
 
 


=====================================
gajim/gui_interface.py
=====================================
@@ -75,9 +75,6 @@
 from gajim.common.const import FTState
 from gajim.common.file_props import FileProp
 
-from gajim.common.modules.contacts import GroupchatContact
-from gajim.common.modules.contacts import GroupchatParticipant
-from gajim.common.modules.contacts import BareContact
 from gajim.common.modules.httpupload import HTTPFileTransfer
 
 from gajim.gui.dialogs import ErrorDialog
@@ -91,8 +88,6 @@
 
 log = logging.getLogger('gajim.interface')
 
-ContactT = Union[BareContact, GroupchatContact, GroupchatParticipant]
-
 
 class Interface:
     def __init__(self):
@@ -693,19 +688,6 @@ def save_config() -> None:
     def save_avatar(self, data: bytes) -> Optional[str]:
         return app.app.avatar_storage.save_avatar(data)
 
-    def get_avatar(self,
-                   contact: ContactT,
-                   size: int,
-                   scale: int,
-                   show: Optional[str] = None,
-                   pixbuf: bool = False,
-                   style: str = 'circle') -> Any:
-        if pixbuf:
-            return app.app.avatar_storage.get_pixbuf(
-                contact, size, scale, show, style=style)
-        return app.app.avatar_storage.get_surface(
-            contact, size, scale, show, style=style)
-
     def avatar_exists(self, filename: str) -> bool:
         return app.app.avatar_storage.get_avatar_path(filename) is not None
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/4dd332d08d91c56a7dca53b6cd45e777cbea02b2...ba910b98c4d8f5546e8af8ac65bd76eb28a2601f

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/4dd332d08d91c56a7dca53b6cd45e777cbea02b2...ba910b98c4d8f5546e8af8ac65bd76eb28a2601f
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to