Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
15ab2328
Commit
15ab2328
authored
3 years ago
by
Daniel Brötzmann
Browse files
Options
Downloads
Patches
Plain Diff
AccountSideBar: Add unread counter
parent
e9cfd624
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gajim/gtk/account_side_bar.py
+24
-1
24 additions, 1 deletion
gajim/gtk/account_side_bar.py
gajim/gtk/main.py
+3
-0
3 additions, 0 deletions
gajim/gtk/main.py
gajim/gtk/notification_manager.py
+72
-37
72 additions, 37 deletions
gajim/gtk/notification_manager.py
with
99 additions
and
38 deletions
gajim/gtk/account_side_bar.py
+
24
−
1
View file @
15ab2328
...
...
@@ -60,6 +60,11 @@ def activate_account_page(self, account: str) -> None:
self
.
select_row
(
row
)
def
update_unread_count
(
self
,
account
:
str
,
count
:
int
)
->
None
:
for
row
in
cast
(
list
[
Account
],
self
.
get_children
()):
if
row
.
account
==
account
:
row
.
set_unread_count
(
count
)
break
class
Account
(
Gtk
.
ListBoxRow
):
def
__init__
(
self
,
account
:
str
)
->
None
:
...
...
@@ -75,6 +80,13 @@ def __init__(self, account: str) -> None:
self
.
_image
=
AccountAvatar
(
account
)
self
.
_unread_label
=
Gtk
.
Label
()
self
.
_unread_label
.
get_style_context
().
add_class
(
'
unread-counter
'
)
self
.
_unread_label
.
set_no_show_all
(
True
)
self
.
_unread_label
.
set_halign
(
Gtk
.
Align
.
END
)
self
.
_unread_label
.
set_valign
(
Gtk
.
Align
.
START
)
self
.
_account_color_bar
=
Gtk
.
Box
()
self
.
_account_color_bar
.
set_size_request
(
6
,
-
1
)
self
.
_account_color_bar
.
get_style_context
().
add_class
(
...
...
@@ -88,7 +100,11 @@ def __init__(self, account: str) -> None:
account_box
.
add
(
self
.
_account_color_bar
)
self
.
_update_account_color
()
self
.
add
(
account_box
)
overlay
=
Gtk
.
Overlay
()
overlay
.
add
(
account_box
)
overlay
.
add_overlay
(
self
.
_unread_label
)
self
.
add
(
overlay
)
self
.
show_all
()
def
_update_account_color
(
self
)
->
None
:
...
...
@@ -99,6 +115,13 @@ def _update_account_color(self) -> None:
self
.
_account_class
=
app
.
css_config
.
get_dynamic_class
(
self
.
account
)
context
.
add_class
(
self
.
_account_class
)
def
set_unread_count
(
self
,
count
:
int
)
->
None
:
if
count
<
1000
:
self
.
_unread_label
.
set_text
(
str
(
count
))
else
:
self
.
_unread_label
.
set_text
(
'
999+
'
)
self
.
_unread_label
.
set_visible
(
bool
(
count
))
def
update
(
self
)
->
None
:
self
.
_update_account_color
()
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/main.py
+
3
−
0
View file @
15ab2328
...
...
@@ -181,6 +181,9 @@ def _on_account_disabled(self, event: events.AccountDisabled) -> None:
self
.
_main_stack
.
remove_account_page
(
event
.
account
)
self
.
_main_stack
.
remove_chats_for_account
(
event
.
account
)
def
update_account_unread_count
(
self
,
account
:
str
,
count
:
int
)
->
None
:
self
.
_account_side_bar
.
update_unread_count
(
account
,
count
)
def
_on_client_state_changed
(
self
,
client
:
Client
,
_signal_name
:
str
,
...
...
This diff is collapsed.
Click to expand it.
gajim/gtk/notification_manager.py
+
72
−
37
View file @
15ab2328
...
...
@@ -82,16 +82,25 @@ def update_actions(self) -> None:
online
=
app
.
account_is_connected
(
self
.
_account
)
blocking_support
=
self
.
_client
.
get_module
(
'
Blocking
'
).
supported
app
.
window
.
lookup_action
(
f
'
subscription-accept-
{
self
.
_account
}
'
).
set_enabled
(
online
)
app
.
window
.
lookup_action
(
f
'
subscription-deny-
{
self
.
_account
}
'
).
set_enabled
(
online
)
app
.
window
.
lookup_action
(
f
'
subscription-block-
{
self
.
_account
}
'
).
set_enabled
(
online
and
blocking_support
)
app
.
window
.
lookup_action
(
f
'
subscription-report-
{
self
.
_account
}
'
).
set_enabled
(
online
and
blocking_support
)
sub_accept
=
app
.
window
.
lookup_action
(
f
'
subscription-accept-
{
self
.
_account
}
'
)
assert
sub_accept
is
not
None
sub_accept
.
set_enabled
(
online
)
sub_deny
=
app
.
window
.
lookup_action
(
f
'
subscription-deny-
{
self
.
_account
}
'
)
assert
sub_deny
is
not
None
sub_deny
.
set_enabled
(
online
)
sub_block
=
app
.
window
.
lookup_action
(
f
'
subscription-block-
{
self
.
_account
}
'
)
assert
sub_block
is
not
None
sub_block
.
set_enabled
(
online
and
blocking_support
)
sub_report
=
app
.
window
.
lookup_action
(
f
'
subscription-report-
{
self
.
_account
}
'
)
assert
sub_report
is
not
None
sub_report
.
set_enabled
(
online
and
blocking_support
)
def
_remove_actions
(
self
)
->
None
:
actions
=
[
...
...
@@ -103,6 +112,13 @@ def _remove_actions(self) -> None:
for
action
in
actions
:
app
.
window
.
remove_action
(
f
'
{
action
}
-
{
self
.
_account
}
'
)
def
update_unread_count
(
self
):
count
=
len
(
self
.
get_children
())
app
.
window
.
update_account_unread_count
(
self
.
_account
,
count
)
def
_on_row_destroy
(
self
,
_widget
:
Gtk
.
Widget
)
->
None
:
self
.
update_unread_count
()
def
_on_subscription_accept
(
self
,
_action
:
Gio
.
SimpleAction
,
param
:
GLib
.
Variant
...
...
@@ -116,7 +132,7 @@ def _on_subscription_accept(self,
open_window
(
'
AddContact
'
,
account
=
self
.
_account
,
jid
=
jid
,
nick
=
contact
.
name
)
if
row
is
not
None
:
self
.
remove
(
row
)
row
.
destroy
(
)
def
_on_subscription_block
(
self
,
_action
:
Gio
.
SimpleAction
,
...
...
@@ -127,7 +143,7 @@ def _on_subscription_block(self,
self
.
_client
.
get_module
(
'
Blocking
'
).
block
([
jid
])
row
=
self
.
_get_notification_row
(
jid
)
if
row
is
not
None
:
self
.
remove
(
row
)
row
.
destroy
(
)
def
_on_subscription_report
(
self
,
_action
:
Gio
.
SimpleAction
,
...
...
@@ -138,7 +154,7 @@ def _on_subscription_report(self,
self
.
_client
.
get_module
(
'
Blocking
'
).
block
([
jid
],
report
=
'
spam
'
)
row
=
self
.
_get_notification_row
(
jid
)
if
row
is
not
None
:
self
.
remove
(
row
)
row
.
destroy
(
)
def
_on_subscription_deny
(
self
,
_action
:
Gio
.
SimpleAction
,
...
...
@@ -148,7 +164,7 @@ def _on_subscription_deny(self,
self
.
_deny_request
(
jid
)
row
=
self
.
_get_notification_row
(
jid
)
if
row
is
not
None
:
self
.
remove
(
row
)
row
.
destroy
(
)
def
_deny_request
(
self
,
jid
:
str
)
->
None
:
self
.
_client
.
get_module
(
'
Presence
'
).
unsubscribed
(
jid
)
...
...
@@ -165,8 +181,13 @@ def add_subscription_request(self,
)
->
None
:
row
=
self
.
_get_notification_row
(
event
.
jid
)
if
row
is
None
:
self
.
add
(
SubscriptionRequestRow
(
self
.
_account
,
event
.
jid
,
event
.
status
,
event
.
user_nick
))
new_row
=
SubscriptionRequestRow
(
self
.
_account
,
event
.
jid
,
event
.
status
,
event
.
user_nick
)
new_row
.
connect
(
'
destroy
'
,
self
.
_on_row_destroy
)
self
.
add
(
new_row
)
contact
=
self
.
_client
.
get_module
(
'
Contacts
'
).
get_contact
(
event
.
jid
)
...
...
@@ -178,15 +199,19 @@ def add_subscription_request(self,
type
=
'
subscription-request
'
,
title
=
_
(
'
Subscription Request
'
),
text
=
text
))
self
.
update_unread_count
()
elif
row
.
type
==
'
unsubscribed
'
:
self
.
remove
(
row
)
row
.
destroy
(
)
def
add_unsubscribed
(
self
,
event
:
UnsubscribedPresenceReceived
)
->
None
:
row
=
self
.
_get_notification_row
(
event
.
jid
)
if
row
is
None
:
self
.
add
(
UnsubscribedRow
(
self
.
_account
,
event
.
jid
))
new_row
=
UnsubscribedRow
(
self
.
_account
,
event
.
jid
)
new_row
.
connect
(
'
destroy
'
,
self
.
_on_row_destroy
)
self
.
add
(
new_row
)
self
.
update_unread_count
()
contact
=
self
.
_client
.
get_module
(
'
Contacts
'
).
get_contact
(
event
.
jid
)
...
...
@@ -199,33 +224,43 @@ def add_unsubscribed(self,
title
=
_
(
'
Contact Unsubscribed
'
),
text
=
text
))
elif
row
.
type
==
'
subscribe
'
:
self
.
remove
(
row
)
row
.
destroy
(
)
def
add_invitation_received
(
self
,
event
:
MucInvitation
)
->
None
:
row
=
self
.
_get_notification_row
(
str
(
event
.
muc
))
if
row
is
None
:
self
.
add
(
InvitationReceivedRow
(
self
.
_account
,
event
))
if
row
is
not
None
:
return
if
get_muc_context
(
event
.
muc
)
==
'
public
'
:
jid
=
event
.
from_
else
:
jid
=
event
.
from_
.
bare
contact
=
self
.
_client
.
get_module
(
'
Contacts
'
).
get_contact
(
jid
)
text
=
_
(
'
%(contact)s invited you to %(chat)s
'
)
%
{
'
contact
'
:
contact
.
name
,
'
chat
'
:
event
.
info
.
muc_name
}
new_row
=
InvitationReceivedRow
(
self
.
_account
,
event
)
new_row
.
connect
(
'
destroy
'
,
self
.
_on_row_destroy
)
self
.
add
(
new_row
)
self
.
update_unread_count
()
app
.
ged
.
raise_event
(
Notification
(
account
=
self
.
_account
,
jid
=
jid
,
type
=
'
group-chat-invitation
'
,
title
=
_
(
'
Group Chat Invitation
'
),
text
=
text
))
if
get_muc_context
(
event
.
muc
)
==
'
public
'
:
jid
=
event
.
from_
else
:
jid
=
event
.
from_
.
bare
contact
=
self
.
_client
.
get_module
(
'
Contacts
'
).
get_contact
(
jid
)
text
=
_
(
'
%(contact)s invited you to %(chat)s
'
)
%
{
'
contact
'
:
contact
.
name
,
'
chat
'
:
event
.
info
.
muc_name
}
app
.
ged
.
raise_event
(
Notification
(
account
=
self
.
_account
,
jid
=
jid
,
type
=
'
group-chat-invitation
'
,
title
=
_
(
'
Group Chat Invitation
'
),
text
=
text
))
def
add_invitation_declined
(
self
,
event
:
MucDecline
)
->
None
:
row
=
self
.
_get_notification_row
(
str
(
event
.
muc
))
if
row
is
None
:
self
.
add
(
InvitationDeclinedRow
(
self
.
_account
,
event
))
if
row
is
not
None
:
return
new_row
=
InvitationDeclinedRow
(
self
.
_account
,
event
)
new_row
.
connect
(
'
destroy
'
,
self
.
_on_row_destroy
)
self
.
add
(
new_row
)
self
.
update_unread_count
()
class
NotificationRow
(
Gtk
.
ListBoxRow
):
...
...
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