Enable the import of additional file types when a plugin is activated
Gabriele Paganelli <[email protected]> Fri, 5 Apr 2019 23:28:30 +0200
| Newsgroups | gmane.comp.gnome.apps.rhythmbox.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------DD694E87633FD68A596ADCC0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Hi!
Using Rhythmbox 3.4.2 and python3.6.
My goal is to force Rhythmbox to accept file formats normally not
supported (.vgm) through a Python plugin.
I failed and I am too naive to understand what is going on in the C code.
I see running rhythmbox -d that on importing there are some messages
informing about querying for metadata, and it seems the decision on
whether to let the entry importable in the source is based on such metadata.
Also (rhythmdb.c, line 2481) the body of function
```C
static gboolean
rhythmdb_process_metadata_load (RhythmDB *db, RhythmDBEvent *event)
```
convinced me that there is no way to let in whatever file I would wish
in without digging deeper in the internal workings (by e.g. creating and
injecting bogus events or metadata).
1. Is my goal a use case for a plugin?
2. If so: any comments or suggestions?
I attach some code I wrote. The idea is to register a type in the Music
source, and then see if some of the 'MyEntryType.do_*' methods magically
trigger. (They don't.)
Thanks in advance for your time and attention.
--
-gapag
--------------DD694E87633FD68A596ADCC0
Content-Type: text/x-python;
name="vgm.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="vgm.py"
#!/usr/bin/python3.6
from gi.repository import GObject, RB, Peas
class Vgm(GObject.Object, Peas.Activatable):
object = GObject.property(type=GObject.Object)
def __init__(self):
super(Vgm, self).__init__()
def do_activate(self):
print("Plugin activated")
self.vgm_dir = ""
shell = self.object
db = shell.props.db
entry_type = MyEntryType()
db.register_entry_type(entry_type)
# since I did not know how to get a reference to
# the Music source, I use this periphrasis.
# I do actually get the right reference.
music = shell.guess_source_for_uri("file:///1234.mp3")
shell.register_entry_type_for_source(music, entry_type)
def do_deactivate(self):
del self.vgm_dir
class MyEntryType(RB.RhythmDBEntryType):
# And here I was hoping that because of the line
# shell.register_entry_type_for_source(music, entry_type)
# in Vgm.do_activate
# at least one of the below methods would trigger when scanning a
# directory
def __init__(self):
RB.RhythmDBEntryType.__init__(self, name='my-entry-type')
def do_get_playback_uri(self, entry):
print("*" * 800)
return super(MyEntryType, self).do_get_playback_uri(entry)
def do_entry_created(self, entry):
print("@" * 800)
return super(MyEntryType, self).do_entry_created(entry)
def do_cache_key_to_uri(self, entry):
print("A" * 800)
return None
def do_can_sync_metadata(self, entry):
print("B" * 800)
return None
def do_destroy_entry(self, entry):
print("C" * 800)
return None
def do_update_availability(self, entry):
print("D" * 800)
return None
def do_uri_to_cache_key(self, entry):
return None
--------------DD694E87633FD68A596ADCC0
Content-Type: text/plain; charset=UTF-8;
name=".plugin"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename=".plugin"
W1BsdWdpbl0KTG9hZGVyPXB5dGhvbjMKTW9kdWxlPXZnbQpJQWdlPTIKTmFtZT1BQUFBCkRl
c2NyaXB0aW9uPUEgcHl0aG9uIHRlc3QgcGx1Z2luCkF1dGhvcnM9bm9uZQpDb3B5cmlnaHQ9
Q29weXJpZ2h0IMKpIDIwMDcgWW91ciBuYW1lCldlYnNpdGU9aHR0cDovL3NvbWUud2Vic2l0
ZS8=
--------------DD694E87633FD68A596ADCC0
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
rhythmbox-devel mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/rhythmbox-devel
--------------DD694E87633FD68A596ADCC0--