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
Snippets
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
25f0ee83
Commit
25f0ee83
authored
16 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[knuckles] KDE notifications. Fixes #4749
parent
5678bcb3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/dbus_support.py
+20
-6
20 additions, 6 deletions
src/common/dbus_support.py
src/notify.py
+32
-4
32 additions, 4 deletions
src/notify.py
with
52 additions
and
10 deletions
src/common/dbus_support.py
+
20
−
6
View file @
25f0ee83
...
...
@@ -113,7 +113,7 @@ class SessionBus:
session_bus
=
SessionBus
()
def
get_interface
(
interface
,
path
):
def
get_interface
(
interface
,
path
,
start_service
=
True
):
'''
Returns an interface on the current SessionBus. If the interface isn
\'
t
running, it tries to start it first.
'''
if
not
supported
:
...
...
@@ -129,7 +129,7 @@ def get_interface(interface, path):
started
=
True
if
interface
not
in
running_services
:
# try to start the service
if
dbus_iface
.
StartServiceByName
(
interface
,
dbus
.
UInt32
(
0
))
==
1
:
if
start_service
and
dbus_iface
.
StartServiceByName
(
interface
,
dbus
.
UInt32
(
0
))
==
1
:
started
=
True
else
:
started
=
False
...
...
@@ -142,10 +142,24 @@ def get_interface(interface, path):
return
None
def
get_notifications_interface
():
'''
Returns the notifications interface.
'''
return
get_interface
(
'
org.freedesktop.Notifications
'
,
'
/org/freedesktop/Notifications
'
)
def
get_notifications_interface
(
notif
=
None
):
'''
Returns the notifications interface.
:param notif: DesktopNotification instance
'''
# try to see if KDE notifications are available
iface
=
get_interface
(
'
org.kde.VisualNotifications
'
,
'
/VisualNotifications
'
,
start_service
=
False
)
if
iface
!=
None
:
if
notif
!=
None
:
notif
.
kde_notifications
=
True
return
iface
# KDE notifications don't seem to be available, falling back to
# notification-daemon
else
:
if
notif
!=
None
:
notif
.
kde_notifications
=
False
return
get_interface
(
'
org.freedesktop.Notifications
'
,
'
/org/freedesktop/Notifications
'
)
if
supported
:
class
MissingArgument
(
dbus
.
DBusException
):
...
...
This diff is collapsed.
Click to expand it.
src/notify.py
+
32
−
4
View file @
25f0ee83
...
...
@@ -481,7 +481,8 @@ class DesktopNotification:
ntype
=
'
transfer
'
elif
event_type
==
_
(
'
File Transfer Error
'
):
ntype
=
'
transfer.error
'
elif
event_type
in
(
_
(
'
File Transfer Completed
'
),
_
(
'
File Transfer Stopped
'
)):
elif
event_type
in
(
_
(
'
File Transfer Completed
'
),
_
(
'
File Transfer Stopped
'
)):
ntype
=
'
transfer.complete
'
elif
event_type
==
_
(
'
New E-mail
'
):
ntype
=
'
email.arrived
'
...
...
@@ -498,17 +499,41 @@ class DesktopNotification:
'
chat_msg_recv.png
'
))
# img to display
ntype
=
'
im
'
# Notification Type
self
.
notif
=
dbus_support
.
get_notifications_interface
()
self
.
notif
=
dbus_support
.
get_notifications_interface
(
self
)
if
self
.
notif
is
None
:
raise
dbus
.
DBusException
(
'
unable to get notifications interface
'
)
self
.
ntype
=
ntype
self
.
get_version
()
if
self
.
kde_notifications
:
self
.
attempt_notify
()
else
:
self
.
get_version
()
def
attempt_notify
(
self
):
version
=
self
.
version
timeout
=
gajim
.
config
.
get
(
'
notification_timeout
'
)
# in seconds
ntype
=
self
.
ntype
if
self
.
kde_notifications
:
notification_text
=
'
<html><img src=
"
%(image)s
"
align=left />
'
+
\
'
%(title)s<br/>%(text)s</html>
'
%
{
'
title
'
:
self
.
title
,
'
text
'
:
self
.
text
,
'
image
'
:
self
.
path_to_image
}
gajim_icon
=
os
.
path
.
abspath
(
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
gajim.png
'
))
self
.
notif
.
Notify
(
dbus
.
String
(
_
(
'
Gajim
'
)),
# app_name (string)
dbus
.
UInt32
(
0
),
# replaces_id (uint)
ntype
,
# event_id (string)
dbus
.
String
(
gajim_icon
),
# app_icon (string)
dbus
.
String
(
_
(
''
)),
# summary (string)
dbus
.
String
(
notification_text
),
# body (string)
# actions (stringlist)
(
dbus
.
String
(
'
default
'
),
dbus
.
String
(
self
.
event_type
),
dbus
.
String
(
'
ignore
'
),
dbus
.
String
(
_
(
'
Ignore
'
))),
[],
# hints (not used in KDE yet)
dbus
.
UInt32
(
timeout
*
1000
),
# timeout (int), in ms
reply_handler
=
self
.
attach_by_id
,
error_handler
=
self
.
notify_another_way
)
return
version
=
self
.
version
if
version
[:
2
]
==
[
0
,
2
]:
try
:
self
.
notif
.
Notify
(
...
...
@@ -586,6 +611,9 @@ class DesktopNotification:
self
.
notif
.
CloseNotification
(
dbus
.
UInt32
(
id_
))
self
.
notif
=
None
if
reason
==
'
ignore
'
:
return
gajim
.
interface
.
handle_event
(
self
.
account
,
self
.
jid
,
self
.
msg_type
)
def
version_reply_handler
(
self
,
name
,
vendor
,
version
,
spec_version
=
None
):
...
...
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