Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
-
5731c0ec
by wurstsalat at 2021-02-05T21:25:02+01:00
3 changed files:
Changes:
| ... | ... | @@ -61,11 +61,11 @@ |
| 61 | 61 |
/* Workspace sidebar */
|
| 62 | 62 |
.workspace-sidebar {
|
| 63 | 63 |
background: transparent;
|
| 64 |
- margin-left: 12px;
|
|
| 65 |
- margin-right: 12px;
|
|
| 64 |
+ margin-left: 12px;
|
|
| 65 |
+ margin-right: 6px;
|
|
| 66 | 66 |
}
|
| 67 | 67 |
.workspace-sidebar-item {
|
| 68 |
- padding-top: 6px;
|
|
| 68 |
+ padding-top: 0px;
|
|
| 69 | 69 |
padding-bottom: 6px;
|
| 70 | 70 |
}
|
| 71 | 71 |
.workspace-sidebar-item:selected,
|
| ... | ... | @@ -80,6 +80,8 @@ |
| 80 | 80 |
}
|
| 81 | 81 |
.workspace-sidebar-item image {
|
| 82 | 82 |
border-radius: 9px;
|
| 83 |
+ margin-top: 6px;
|
|
| 84 |
+ margin-right: 6px;
|
|
| 83 | 85 |
}
|
| 84 | 86 |
|
| 85 | 87 |
/* Account sidebar */
|
| ... | ... | @@ -242,6 +242,10 @@ def update_time(self): |
| 242 | 242 |
|
| 243 | 243 |
def _update_unread(self):
|
| 244 | 244 |
print('Update unread', self.account, self.jid, self._unread_count)
|
| 245 |
+ if self._unread_count < 1000:
|
|
| 246 |
+ self._ui.unread_label.set_text(str(self._unread_count))
|
|
| 247 |
+ else:
|
|
| 248 |
+ self._ui.unread_label.set_text('999+')
|
|
| 245 | 249 |
self._ui.unread_label.set_text(str(self._unread_count))
|
| 246 | 250 |
self._ui.unread_label.set_visible(bool(self._unread_count))
|
| 247 | 251 |
|
| ... | ... | @@ -92,15 +92,51 @@ def __init__(self, workspace_id): |
| 92 | 92 |
CommonWorkspace.__init__(self, workspace_id)
|
| 93 | 93 |
|
| 94 | 94 |
self.sort_index = 0
|
| 95 |
+ self._unread_count = 0
|
|
| 96 |
+ |
|
| 97 |
+ self._unread_label = Gtk.Label()
|
|
| 98 |
+ self._unread_label.get_style_context().add_class(
|
|
| 99 |
+ 'unread-counter')
|
|
| 100 |
+ self._unread_label.set_no_show_all(True)
|
|
| 101 |
+ self._unread_label.set_halign(Gtk.Align.END)
|
|
| 102 |
+ self._unread_label.set_valign(Gtk.Align.START)
|
|
| 95 | 103 |
|
| 96 | 104 |
self._image = WorkspaceAvatar(workspace_id)
|
| 97 | 105 |
self._image.set_halign(Gtk.Align.CENTER)
|
| 98 |
- self.add(self._image)
|
|
| 106 |
+ |
|
| 107 |
+ overlay = Gtk.Overlay()
|
|
| 108 |
+ overlay.add(self._image)
|
|
| 109 |
+ overlay.add_overlay(self._unread_label)
|
|
| 110 |
+ |
|
| 111 |
+ self.add(overlay)
|
|
| 99 | 112 |
self.show_all()
|
| 100 | 113 |
|
| 114 |
+ @property
|
|
| 115 |
+ def is_active(self):
|
|
| 116 |
+ return (self.is_selected() and
|
|
| 117 |
+ self.get_toplevel().get_property('is-active'))
|
|
| 118 |
+ |
|
| 101 | 119 |
def update_avatar(self):
|
| 102 | 120 |
self._image.update()
|
| 103 | 121 |
|
| 122 |
+ def _update_unread(self):
|
|
| 123 |
+ print('Update unread', self.workspace_id, self._unread_count)
|
|
| 124 |
+ if self._unread_count < 1000:
|
|
| 125 |
+ self._unread_label.set_text(str(self._unread_count))
|
|
| 126 |
+ else:
|
|
| 127 |
+ self._unread_label.set_text('999+')
|
|
| 128 |
+ self._unread_label.set_visible(bool(self._unread_count))
|
|
| 129 |
+ |
|
| 130 |
+ def add_unread(self):
|
|
| 131 |
+ if self.is_active:
|
|
| 132 |
+ return
|
|
| 133 |
+ self._unread_count += 1
|
|
| 134 |
+ self._update_unread()
|
|
| 135 |
+ |
|
| 136 |
+ def reset_unread(self):
|
|
| 137 |
+ self._unread_count = 0
|
|
| 138 |
+ self._update_unread()
|
|
| 139 |
+ |
|
| 104 | 140 |
|
| 105 | 141 |
class AddWorkspace(CommonWorkspace):
|
| 106 | 142 |
def __init__(self, workspace_id):
|