Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
gajim
gajim-plugins
Commits
5c1207d0
Commit
5c1207d0
authored
Sep 23, 2018
by
André
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[now_listen] Make plugin compatible with latest Gajim version
parent
e4ffa130
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
22 deletions
+24
-22
now_listen/manifest.ini
now_listen/manifest.ini
+1
-1
now_listen/now_listen.py
now_listen/now_listen.py
+23
-21
No files found.
now_listen/manifest.ini
View file @
5c1207d0
[info]
name:
Now
Listen
short_name:
now-listen
version:
0.3.
1
version:
0.3.
2
description:
Copy
tune
info
of
playing
music
to
conversation
input
box
at
cursor
position
(Alt
+
N)
authors
=
Denis Fomin <fominde@gmail.com>
homepage
=
https://dev.gajim.org/gajim/gajim-plugins/wikis/NowListenPlugin
...
...
now_listen/now_listen.py
View file @
5c1207d0
...
...
@@ -8,31 +8,28 @@ import logging
from
gajim.plugins
import
GajimPlugin
from
gajim.plugins.helpers
import
log_calls
from
gajim.plugins.gui
import
GajimPluginConfigDialog
from
gajim.plugins.gajimplugin
import
GajimPluginException
from
gajim.common
import
dbus_support
if
dbus_support
.
supported
:
from
gajim.music_track_listener
import
MusicTrackListener
from
gajim.music_track_listener
import
MusicTrackListener
log
=
logging
.
getLogger
(
'gajim.plugin_system.now_listen'
)
class
NowListenPlugin
(
GajimPlugin
):
@
log_calls
(
'NowListenPlugin'
)
def
init
(
self
):
self
.
description
=
_
(
'Copy tune info of playing music to conversation '
'input box at cursor position (Alt + N)'
)
'input box at cursor position (Alt + N)'
)
self
.
config_dialog
=
NowListenPluginConfigDialog
(
self
)
self
.
gui_extension_points
=
{
'chat_control_base'
:
(
self
.
connect_with_chat_control
,
self
.
disconnect_from_chat_control
)}
(
self
.
connect_with_chat_control
,
self
.
disconnect_from_chat_control
)}
self
.
config_default_values
=
{
'format_string'
:
(
_
(
'Now listening to: "%title" by %artist from %album'
),
''
),
'format_string_http'
:
(
_
(
'Now listening to: "%title" by %artist'
),
''
),}
(
_
(
'Now listening to: "%title" by %artist'
),
''
),
}
self
.
controls
=
[]
self
.
first_run
=
True
...
...
@@ -55,22 +52,27 @@ class NowListenPlugin(GajimPlugin):
@
log_calls
(
'NowListenPlugin'
)
def
activate
(
self
):
if
not
dbus_support
.
supported
:
raise
GajimPluginException
(
_
(
'python-dbus is missing!'
))
listener
=
MusicTrackListener
.
get
()
if
not
self
.
music_track_changed_signal
:
self
.
music_track_changed_signal
=
listener
.
connect
(
'music-track-changed'
,
self
.
music_track_changed
)
track
=
listener
.
get_playing_track
(
'org.mpris.MediaPlayer2'
)
self
.
music_track_changed
(
listener
,
track
)
try
:
listener
.
start
()
except
AttributeError
:
track
=
listener
.
get_playing_track
(
'org.mpris.MediaPlayer2'
)
self
.
music_track_changed
(
listener
,
track
)
@
log_calls
(
'NowListenPlugin'
)
def
deactivate
(
self
):
if
dbus_support
.
supported
:
listener
=
MusicTrackListener
.
get
()
if
self
.
music_track_changed_signal
:
listener
.
disconnect
(
self
.
music_track_changed_signal
)
self
.
music_track_changed_signal
=
None
listener
=
MusicTrackListener
.
get
()
if
self
.
music_track_changed_signal
:
listener
.
disconnect
(
self
.
music_track_changed_signal
)
self
.
music_track_changed_signal
=
None
try
:
listener
.
stop
()
except
AttributeError
:
pass
def
music_track_changed
(
self
,
unused_listener
,
music_track_info
,
account
=
None
):
...
...
@@ -131,9 +133,9 @@ class Base(object):
tune_string
=
format_string
.
\
replace
(
'%artist'
,
self
.
plugin
.
artist
).
\
replace
(
'%title'
,
self
.
plugin
.
title
).
\
replace
(
'%album'
,
self
.
plugin
.
album
).
\
replace
(
'%url'
,
self
.
plugin
.
url
)
replace
(
'%title'
,
self
.
plugin
.
title
).
\
replace
(
'%album'
,
self
.
plugin
.
album
).
\
replace
(
'%url'
,
self
.
plugin
.
url
)
message_buffer
=
self
.
chat_control
.
msg_textview
.
get_buffer
()
message_buffer
.
insert_at_cursor
(
tune_string
)
...
...
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