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
5a5937d9
Commit
5a5937d9
authored
16 years ago
by
js
Browse files
Options
Downloads
Patches
Plain Diff
Really fix #4517.
parent
d310ce1d
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/dialogs.py
+5
-4
5 additions, 4 deletions
src/dialogs.py
src/notify.py
+31
-21
31 additions, 21 deletions
src/notify.py
with
36 additions
and
25 deletions
src/dialogs.py
+
5
−
4
View file @
5a5937d9
...
@@ -2038,10 +2038,11 @@ class PopupNotificationWindow:
...
@@ -2038,10 +2038,11 @@ class PopupNotificationWindow:
if
not
text
:
if
not
text
:
text
=
gajim
.
get_name_from_jid
(
account
,
jid
)
# default value of text
text
=
gajim
.
get_name_from_jid
(
account
,
jid
)
# default value of text
if
not
title
:
if
not
title
:
title
=
event_type
title
=
''
event_type_label
.
set_markup
(
event_type_label
.
set_markup
(
'
<span foreground=
"
black
"
weight=
"
bold
"
>%s</span>
'
%
title
)
'
<span foreground=
"
black
"
weight=
"
bold
"
>%s</span>
'
%
gobject
.
markup_escape_text
(
title
))
# set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ]
# set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ]
self
.
window
.
modify_bg
(
gtk
.
STATE_NORMAL
,
gtk
.
gdk
.
color_parse
(
'
black
'
))
self
.
window
.
modify_bg
(
gtk
.
STATE_NORMAL
,
gtk
.
gdk
.
color_parse
(
'
black
'
))
...
@@ -2075,8 +2076,8 @@ class PopupNotificationWindow:
...
@@ -2075,8 +2076,8 @@ class PopupNotificationWindow:
popup_bg_color
=
gtk
.
gdk
.
color_parse
(
bg_color
)
popup_bg_color
=
gtk
.
gdk
.
color_parse
(
bg_color
)
close_button
.
modify_bg
(
gtk
.
STATE_NORMAL
,
popup_bg_color
)
close_button
.
modify_bg
(
gtk
.
STATE_NORMAL
,
popup_bg_color
)
eventbox
.
modify_bg
(
gtk
.
STATE_NORMAL
,
popup_bg_color
)
eventbox
.
modify_bg
(
gtk
.
STATE_NORMAL
,
popup_bg_color
)
event_description_label
.
set_markup
(
event_description_label
.
set_markup
(
'
<span foreground=
"
black
"
>%s</span>
'
%
'
<span foreground=
"
black
"
>%s</span>
'
%
text
)
gobject
.
markup_escape_text
(
text
)
)
# set the image
# set the image
image
.
set_from_file
(
path_to_image
)
image
.
set_from_file
(
path_to_image
)
...
...
This diff is collapsed.
Click to expand it.
src/notify.py
+
31
−
21
View file @
5a5937d9
...
@@ -320,13 +320,26 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
...
@@ -320,13 +320,26 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
'''
Notifies a user of an event. It first tries to a valid implementation of
'''
Notifies a user of an event. It first tries to a valid implementation of
the Desktop Notification Specification. If that fails, then we fall back to
the Desktop Notification Specification. If that fails, then we fall back to
the older style PopupNotificationWindow method.
'''
the older style PopupNotificationWindow method.
'''
# escape text like <3
text
=
gobject
.
markup_escape_text
(
text
)
# default image
title
=
gobject
.
markup_escape_text
(
title
)
if
not
path_to_image
:
path_to_image
=
os
.
path
.
abspath
(
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
chat_msg_recv.png
'
))
# img to display
# Try Growl first, as we might have D-Bus and notification daemon running
# on OS X for some reason.
if
USER_HAS_GROWL
:
osx
.
growler
.
notify
(
event_type
,
jid
,
account
,
msg_type
,
path_to_image
,
title
,
text
)
return
# Try to show our popup via D-Bus and notification daemon
if
gajim
.
config
.
get
(
'
use_notif_daemon
'
)
and
dbus_support
.
supported
:
if
gajim
.
config
.
get
(
'
use_notif_daemon
'
)
and
dbus_support
.
supported
:
try
:
try
:
DesktopNotification
(
event_type
,
jid
,
account
,
msg_type
,
DesktopNotification
(
event_type
,
jid
,
account
,
msg_type
,
path_to_image
,
title
,
text
)
path_to_image
,
gobject
.
markup_escape_text
(
title
),
gobject
.
markup_escape_text
(
text
))
return
# sucessfully did D-Bus Notification procedure!
return
# sucessfully did D-Bus Notification procedure!
except
dbus
.
DBusException
,
e
:
except
dbus
.
DBusException
,
e
:
# Connection to D-Bus failed
# Connection to D-Bus failed
...
@@ -334,21 +347,23 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
...
@@ -334,21 +347,23 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
except
TypeError
,
e
:
except
TypeError
,
e
:
# This means that we sent the message incorrectly
# This means that we sent the message incorrectly
gajim
.
log
.
debug
(
str
(
e
))
gajim
.
log
.
debug
(
str
(
e
))
# we failed to speak to notification daemon via D-Bus
if
USER_HAS_PYNOTIFY
:
# try via libnotify
# Ok, that failed. Let's try pynotify, which also uses notification daemon
if
gajim
.
config
.
get
(
'
use_notif_daemon
'
)
and
USER_HAS_PYNOTIFY
:
if
not
text
and
event_type
==
'
new_message
'
:
if
not
text
and
event_type
==
'
new_message
'
:
# empty text for new_message means do_preview = False
# empty text for new_message means do_preview = False
text
=
gajim
.
get_name_from_jid
(
account
,
jid
)
# default value of text
# -> default value for text
if
not
title
:
_text
=
gobject
.
markup_escape_text
(
title
=
event_type
gajim
.
get_name_from_jid
(
account
,
jid
))
# default image
else
:
if
not
path_to_image
:
_text
=
gobject
.
markup_escape_text
(
text
)
path_to_image
=
os
.
path
.
abspath
(
os
.
path
.
join
(
gajim
.
DATA_DIR
,
'
pixmaps
'
,
'
events
'
,
'
chat_msg_recv.png
'
))
# img to display
if
not
title
:
_title
=
''
else
:
_title
=
gobject
.
markup_escape_text
(
title
)
notification
=
pynotify
.
Notification
(
title
,
text
)
notification
=
pynotify
.
Notification
(
_
title
,
_
text
)
timeout
=
gajim
.
config
.
get
(
'
notification_timeout
'
)
*
1000
# make it ms
timeout
=
gajim
.
config
.
get
(
'
notification_timeout
'
)
*
1000
# make it ms
notification
.
set_timeout
(
timeout
)
notification
.
set_timeout
(
timeout
)
...
@@ -367,13 +382,8 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
...
@@ -367,13 +382,8 @@ def popup(event_type, jid, account, msg_type='', path_to_image=None,
except
gobject
.
GError
,
e
:
except
gobject
.
GError
,
e
:
# Connection to notification-daemon failed, see #2893
# Connection to notification-daemon failed, see #2893
gajim
.
log
.
debug
(
str
(
e
))
gajim
.
log
.
debug
(
str
(
e
))
# try os/x growl
if
USER_HAS_GROWL
:
osx
.
growler
.
notify
(
event_type
,
jid
,
account
,
msg_type
,
path_to_image
,
title
,
text
)
return
#
go
old
style
#
Either nothing succeeded or the user wants
old
-
style
notifications
instance
=
dialogs
.
PopupNotificationWindow
(
event_type
,
jid
,
account
,
instance
=
dialogs
.
PopupNotificationWindow
(
event_type
,
jid
,
account
,
msg_type
,
path_to_image
,
title
,
text
)
msg_type
,
path_to_image
,
title
,
text
)
gajim
.
interface
.
roster
.
popup_notification_windows
.
append
(
instance
)
gajim
.
interface
.
roster
.
popup_notification_windows
.
append
(
instance
)
...
...
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