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

Commits:

4 changed files:

Changes:

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

  • gajim/gtk/avatar.py
    ... ... @@ -150,6 +150,9 @@ def add_status_to_avatar(surface, show):
    150 150
     
    
    151 151
     @lru_cache(maxsize=128)
    
    152 152
     def get_show_circle(show, size, scale):
    
    153
    +    if not isinstance(show, str):
    
    154
    +        show = show.value
    
    155
    +
    
    153 156
         size = size * scale
    
    154 157
         center = size / 2
    
    155 158
         radius = size / 3
    
    ... ... @@ -157,7 +160,7 @@ def get_show_circle(show, size, scale):
    157 160
         surface = cairo.ImageSurface(cairo.Format.ARGB32, size, size)
    
    158 161
         context = cairo.Context(surface)
    
    159 162
     
    
    160
    -    css_color = get_css_show_class(show.value)
    
    163
    +    css_color = get_css_show_class(show)
    
    161 164
         color = convert_rgb_string_to_float(
    
    162 165
             app.css_config.get_value(css_color, StyleAttr.COLOR))
    
    163 166
     
    
    ... ... @@ -166,7 +169,7 @@ def get_show_circle(show, size, scale):
    166 169
         context.arc(center, center, radius, 0, 2 * pi)
    
    167 170
         context.fill()
    
    168 171
     
    
    169
    -    if show.value == 'dnd':
    
    172
    +    if show == 'dnd':
    
    170 173
             line_length = radius * 0.65
    
    171 174
             context.move_to(center - line_length, center)
    
    172 175
             context.line_to(center + line_length, center)
    

  • gajim/gtk/status_selector.py
    ... ... @@ -17,12 +17,13 @@
    17 17
     
    
    18 18
     from gajim.common import app
    
    19 19
     from gajim.common import ged
    
    20
    +from gajim.common.const import AvatarSize
    
    20 21
     from gajim.common.helpers import get_uf_show
    
    21 22
     from gajim.common.helpers import get_global_show
    
    22 23
     from gajim.common.helpers import statuses_unified
    
    23 24
     from gajim.common.i18n import _
    
    24 25
     
    
    25
    -from .util import get_icon_name
    
    26
    +from .avatar import get_show_circle
    
    26 27
     
    
    27 28
     
    
    28 29
     class StatusSelector(Gtk.MenuButton):
    
    ... ... @@ -33,8 +34,11 @@ def __init__(self, compact=False):
    33 34
             self._create_popover()
    
    34 35
     
    
    35 36
             self._current_show_icon = Gtk.Image()
    
    36
    -        self._current_show_icon.set_from_icon_name(
    
    37
    -            get_icon_name('offline'), Gtk.IconSize.MENU)
    
    37
    +        surface = get_show_circle(
    
    38
    +            'offline',
    
    39
    +            AvatarSize.SHOW_CIRCLE,
    
    40
    +            self.get_scale_factor())
    
    41
    +        self._current_show_icon.set_from_surface(surface)
    
    38 42
     
    
    39 43
             box = Gtk.Box(spacing=6)
    
    40 44
             box.add(self._current_show_icon)
    
    ... ... @@ -77,8 +81,9 @@ def _create_popover(self):
    77 81
                                                  Gtk.IconSize.MENU)
    
    78 82
                     show_label.set_text_with_mnemonic(_('_Change Status Message'))
    
    79 83
                 else:
    
    80
    -                show_icon.set_from_icon_name(get_icon_name(item),
    
    81
    -                                             Gtk.IconSize.MENU)
    
    84
    +                surface = get_show_circle(
    
    85
    +                    item, AvatarSize.SHOW_CIRCLE, self.get_scale_factor())
    
    86
    +                show_icon.set_from_surface(surface)
    
    82 87
                     show_label.set_text_with_mnemonic(
    
    83 88
                         get_uf_show(item, use_mnemonic=True))
    
    84 89
     
    
    ... ... @@ -118,8 +123,10 @@ def update(self, *args, **kwargs):
    118 123
             # self.show()
    
    119 124
             show = get_global_show()
    
    120 125
             uf_show = get_uf_show(show)
    
    121
    -        self._current_show_icon.set_from_icon_name(
    
    122
    -            get_icon_name(show), Gtk.IconSize.MENU)
    
    126
    +
    
    127
    +        surface = get_show_circle(
    
    128
    +            show, AvatarSize.SHOW_CIRCLE, self.get_scale_factor())
    
    129
    +        self._current_show_icon.set_from_surface(surface)
    
    123 130
             if statuses_unified():
    
    124 131
                 self._current_show_icon.set_tooltip_text(_('Status: %s') % uf_show)
    
    125 132
                 if not self._compact:
    

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