Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gajim
gajim
Commits
78b06833
Commit
78b06833
authored
Jun 15, 2019
by
Philipp Hörist
Browse files
Notifications: Detect DE and set icons accordingly
parent
b2aa7352
Changes
2
Show whitespace changes
Inline
Side-by-side
gajim/common/app.py
View file @
78b06833
...
...
@@ -314,6 +314,20 @@ def detect_dependencies():
log
(
'gajim'
).
info
(
'Used language: %s'
,
LANG
)
def
detect_desktop_env
():
if
sys
.
platform
in
(
'win32'
,
'darwin'
):
return
sys
.
platform
desktop
=
os
.
environ
.
get
(
'XDG_CURRENT_DESKTOP'
)
if
desktop
is
None
:
return
None
if
'gnome'
in
desktop
.
lower
():
return
'gnome'
return
desktop
desktop_env
=
detect_desktop_env
()
def
get_an_id
():
return
str
(
uuid
.
uuid4
())
...
...
gajim/gtk/notification.py
View file @
78b06833
...
...
@@ -42,7 +42,6 @@
from
gajim.gtk.util
import
get_icon_name
from
gajim.gtk.util
import
get_monitor_scale_factor
from
gajim.gtk.util
import
get_total_screen_geometry
from
gajim.gtk.util
import
load_icon
log
=
logging
.
getLogger
(
'gajim.gtk.notification'
)
...
...
@@ -142,7 +141,7 @@ def popup(self, event_type, jid, account, type_='', icon_name=None,
"""
if
icon_name
is
None
:
icon_name
=
'
gajim-chat_msg_recv
'
icon_name
=
'
mail-message-new
'
if
timeout
<
0
:
timeout
=
app
.
config
.
get
(
'notification_timeout'
)
...
...
@@ -158,8 +157,7 @@ def popup(self, event_type, jid, account, type_='', icon_name=None,
if
not
self
.
_dbus_available
:
return
scale
=
get_monitor_scale_factor
()
icon_pixbuf
=
load_icon
(
icon_name
,
size
=
48
,
pixbuf
=
True
,
scale
=
scale
)
icon
=
Gio
.
ThemedIcon
.
new
(
icon_name
)
notification
=
Gio
.
Notification
()
if
title
is
not
None
:
...
...
@@ -202,16 +200,23 @@ def popup(self, event_type, jid, account, type_='', icon_name=None,
_
(
'New Single Message'
),
_
(
'New Private Message'
),
_
(
'New Group Chat Message'
)):
avatar
=
app
.
contacts
.
get_avatar
(
account
,
jid
)
if
avatar
:
icon_pixbuf
=
avatar
if
app
.
desktop_env
==
'gnome'
:
icon
=
self
.
_get_avatar_for_notification
(
account
,
jid
)
notif_id
=
self
.
_make_id
(
'new-message'
,
account
,
jid
)
notification
.
set_icon
(
icon
_pixbuf
)
notification
.
set_icon
(
icon
)
notification
.
set_priority
(
Gio
.
NotificationPriority
.
NORMAL
)
app
.
app
.
send_notification
(
notif_id
,
notification
)
@
staticmethod
def
_get_avatar_for_notification
(
account
,
jid
):
scale
=
get_monitor_scale_factor
()
contact
=
app
.
contacts
.
get_contact
(
account
,
jid
)
if
contact
is
None
:
return
None
return
app
.
interface
.
get_avatar
(
contact
,
16
,
scale
,
pixbuf
=
True
)
def
_on_popup_destroy
(
self
,
*
args
):
self
.
_win32_active_popup
=
None
...
...
Daniel Brötzmann
@wurstsalat
mentioned in issue
#9718 (closed)
·
Jun 21, 2019
mentioned in issue
#9718 (closed)
mentioned in issue #9718
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment