Daniel Brötzmann pushed to branch mainwindow at gajim / gajim


Commits:
a3946bd2 by wurstsalat at 2021-03-10T18:08:30+01:00
StatusSelector: Use 'show circles' for icons

- - - - -


4 changed files:

- gajim/common/const.py
- gajim/gtk/avatar.py
- gajim/gtk/status_selector.py
- gajim/gtk/tooltips.py


Changes:

=====================================
gajim/common/const.py
=====================================
@@ -24,7 +24,7 @@ class RowHeaderType(IntEnum):
 
 class AvatarSize(IntEnum):
     TAB = 16
-    STATUS_CIRCLE = 24
+    SHOW_CIRCLE = 24
     ROSTER = 32
     ACCOUNT_SIDE_BAR = 40
     WORKSPACE = 40


=====================================
gajim/gtk/avatar.py
=====================================
@@ -150,6 +150,9 @@ def add_status_to_avatar(surface, show):
 
 @lru_cache(maxsize=128)
 def get_show_circle(show, size, scale):
+    if not isinstance(show, str):
+        show = show.value
+
     size = size * scale
     center = size / 2
     radius = size / 3
@@ -157,7 +160,7 @@ def get_show_circle(show, size, scale):
     surface = cairo.ImageSurface(cairo.Format.ARGB32, size, size)
     context = cairo.Context(surface)
 
-    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))
 
@@ -166,7 +169,7 @@ def get_show_circle(show, size, scale):
     context.arc(center, center, radius, 0, 2 * pi)
     context.fill()
 
-    if show.value == 'dnd':
+    if show == 'dnd':
         line_length = radius * 0.65
         context.move_to(center - line_length, center)
         context.line_to(center + line_length, center)


=====================================
gajim/gtk/status_selector.py
=====================================
@@ -17,12 +17,13 @@
 
 from gajim.common import app
 from gajim.common import ged
+from gajim.common.const import AvatarSize
 from gajim.common.helpers import get_uf_show
 from gajim.common.helpers import get_global_show
 from gajim.common.helpers import statuses_unified
 from gajim.common.i18n import _
 
-from .util import get_icon_name
+from .avatar import get_show_circle
 
 
 class StatusSelector(Gtk.MenuButton):
@@ -33,8 +34,11 @@ def __init__(self, compact=False):
         self._create_popover()
 
         self._current_show_icon = Gtk.Image()
-        self._current_show_icon.set_from_icon_name(
-            get_icon_name('offline'), Gtk.IconSize.MENU)
+        surface = get_show_circle(
+            'offline',
+            AvatarSize.SHOW_CIRCLE,
+            self.get_scale_factor())
+        self._current_show_icon.set_from_surface(surface)
 
         box = Gtk.Box(spacing=6)
         box.add(self._current_show_icon)
@@ -77,8 +81,9 @@ def _create_popover(self):
                                              Gtk.IconSize.MENU)
                 show_label.set_text_with_mnemonic(_('_Change Status Message'))
             else:
-                show_icon.set_from_icon_name(get_icon_name(item),
-                                             Gtk.IconSize.MENU)
+                surface = get_show_circle(
+                    item, AvatarSize.SHOW_CIRCLE, self.get_scale_factor())
+                show_icon.set_from_surface(surface)
                 show_label.set_text_with_mnemonic(
                     get_uf_show(item, use_mnemonic=True))
 
@@ -118,8 +123,10 @@ def update(self, *args, **kwargs):
         # self.show()
         show = get_global_show()
         uf_show = get_uf_show(show)
-        self._current_show_icon.set_from_icon_name(
-            get_icon_name(show), Gtk.IconSize.MENU)
+
+        surface = get_show_circle(
+            show, AvatarSize.SHOW_CIRCLE, self.get_scale_factor())
+        self._current_show_icon.set_from_surface(surface)
         if statuses_unified():
             self._current_show_icon.set_tooltip_text(_('Status: %s') % uf_show)
             if not self._compact:


=====================================
gajim/gtk/tooltips.py
=====================================
@@ -197,7 +197,7 @@ def _build_resource_grid(self, resources, scale):
         row_num = 0
         for contact in resources:
             show_surface = get_show_circle(
-                contact.show, AvatarSize.STATUS_CIRCLE, scale)
+                contact.show, AvatarSize.SHOW_CIRCLE, scale)
             show_image = Gtk.Image.new_from_surface(show_surface)
             show_image.set_halign(Gtk.Align.START)
             show_image.set_valign(Gtk.Align.CENTER)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/a3946bd20e51014cf437867d2dfbca89c7348e19

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/a3946bd20e51014cf437867d2dfbca89c7348e19
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