Top |
ThunarxPropertyPageProviderThunarxPropertyPageProvider — The interface to extensions that provide additional property pages |
To add a property page to the file properties dialog, extensions must implement the
ThunarxPropertyPageProvider interface. This interface has only one virtualmethod, get_pages
, that is passed a list of ThunarxFileInfo objects and returns a list
of ThunarxPropertyPage objects.
GList * thunarx_property_page_provider_get_pages (ThunarxPropertyPageProvider *provider
,GList *files
);
Returns the list of ThunarxPropertyPages that provider
has to offer for files
.
Extensions that implement this interface, must first check whether they support all the
ThunarxFileInfos in the list of files
. Most extensions will probably only support
ThunarxPropertyPages for exactly one file of a certain type. For example an MP3-Tag
editor property page will most probably support only a single audio file, and so the method
would be implemented like this
1 2 3 4 5 6 7 8 9 10 11 |
GList* tag_provider_get_pages (ThunarxPropertyPageProvider *property_page_provider, GList *files) { if (g_list_length (files) != 1) return NULL; else if (!thunarx_file_info_has_mime_type (files->data, "audio/mp3")) return NULL; else return g_list_append (NULL, tag_page_new (files->data)); } |
where tag_page_new()
allocates a new TagPage instance for a ThunarxFileInfo object
passed to it. See the description of the ThunarxPropertyPage class for additional
information about the TagPage example class.
As a special note, this method automatically takes a reference on the
provider
for every ThunarxPropertyPage object returned from the real implementation
of this method in provider
. This is to make sure that the extension stays
in memory for atleast the time that the pages are used. If the extension
wants to stay in memory for a longer time, it'll need to take care of this
itself (e.g. by taking an additional reference on the provider
itself,
that's released at a later time).
The caller is responsible to free the returned list of pages using something like this when no longer needed:
1 2 |
g_list_foreach (list, (GFunc) g_object_ref_sink, NULL); g_list_free_full (list, g_object_unref); |
[skip]
provider |
||
files |
the list of ThunarxFileInfos for which a properties dialog will be displayed. |
[element-type ThunarxFileInfo] |
the list of
ThunarxPropertyPages that provider
has to offer for files
.
[transfer full][element-type ThunarxPropertyPage]
typedef struct _ThunarxPropertyPageProvider ThunarxPropertyPageProvider;