Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Briar GTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
Briar GTK
Commits
08790e70
Commit
08790e70
authored
4 years ago
by
Nico
Browse files
Options
Downloads
Patches
Plain Diff
Show unread messages counter in contact list
Fixes
#29
parent
d9767386
No related branches found
No related tags found
No related merge requests found
Pipeline
#5050
passed
4 years ago
Stage: test
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
briar-gtk/briar_gtk/containers/private_chat.py
+8
-2
8 additions, 2 deletions
briar-gtk/briar_gtk/containers/private_chat.py
briar-gtk/briar_gtk/widgets/contact_row.py
+13
-0
13 additions, 0 deletions
briar-gtk/briar_gtk/widgets/contact_row.py
with
21 additions
and
2 deletions
briar-gtk/briar_gtk/containers/private_chat.py
+
8
−
2
View file @
08790e70
...
...
@@ -99,6 +99,8 @@ class PrivateChatContainer(Container):
# Abusing idle_add function here because otherwise the message box
# is too small and scrolling cuts out messages
GLib
.
idle_add
(
self
.
_add_message
,
message
)
if
message
.
get
(
"
read
"
,
True
)
is
False
:
GLib
.
idle_add
(
private_chat
.
mark_read
,
message
[
"
id
"
])
socket_listener
=
APP
().
api
.
socket_listener
signal_id
=
socket_listener
.
connect
(
"
ConversationMessageReceivedEvent
"
,
self
.
_add_message_async
)
...
...
@@ -120,8 +122,12 @@ class PrivateChatContainer(Container):
return
"
text
"
not
in
message
def
_add_message_async
(
self
,
message
):
if
message
[
"
data
"
][
"
contactId
"
]
==
self
.
_contact_id
:
if
message
[
"
data
"
][
"
contactId
"
]
!=
self
.
_contact_id
:
return
GLib
.
idle_add
(
self
.
_add_message_and_scroll
,
message
[
"
data
"
])
if
message
[
"
data
"
].
get
(
"
read
"
,
True
)
is
False
:
private_chat
=
PrivateChat
(
APP
().
api
,
self
.
_contact_id
)
GLib
.
idle_add
(
private_chat
.
mark_read
,
message
[
"
data
"
][
"
id
"
])
def
_add_message_and_scroll
(
self
,
message
):
self
.
_add_message
(
message
)
...
...
This diff is collapsed.
Click to expand it.
briar-gtk/briar_gtk/widgets/contact_row.py
+
13
−
0
View file @
08790e70
...
...
@@ -17,6 +17,10 @@ class ContactRowWidget(Gtk.ListBoxRow):
def
_setup_view
(
self
,
contact
):
name
=
ContactRowWidget
.
_get_contact_name
(
contact
)
contact_label
=
ContactRowWidget
.
_create_contact_label
(
name
)
unread_count
=
contact
[
'
unreadCount
'
]
contact_unread_count
=
ContactRowWidget
.
_create_unread_count
(
unread_count
)
connected
=
contact
[
"
connected
"
]
contact_state
=
ContactRowWidget
.
_create_contact_state
(
connected
)
contact_box
=
ContactRowWidget
.
_create_contact_box
()
...
...
@@ -24,6 +28,7 @@ class ContactRowWidget(Gtk.ListBoxRow):
contact_box
.
pack_start
(
contact_label
,
True
,
True
,
0
)
contact_box
.
pack_end
(
contact_state
,
False
,
False
,
0
)
contact_box
.
pack_end
(
contact_unread_count
,
False
,
False
,
0
)
contact_event_box
.
add
(
contact_box
)
self
.
add
(
contact_event_box
)
...
...
@@ -45,6 +50,14 @@ class ContactRowWidget(Gtk.ListBoxRow):
contact_label
.
set_ellipsize
(
Pango
.
EllipsizeMode
.
END
)
return
contact_label
@staticmethod
def
_create_unread_count
(
unread_count
):
if
unread_count
==
0
:
return
Gtk
.
EventBox
()
return
ContactRowWidget
.
_create_contact_label
(
f
"
(
{
unread_count
}
)
"
)
@staticmethod
def
_create_contact_state
(
connected
):
file_name
=
"
contact_disconnected
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment