[Geany] [PATCH] plugin api request filetypes_get_from_uid()

Yura Siamashka yurand2 at xxxxx
Wed Mar 12 20:52:39 UTC 2008


On Wed, 12 Mar 2008 14:13:55 +0000
Nick Treleaven <nick.treleaven at btinternet.com> wrote:

> On Wed, 12 Mar 2008 15:14:16 +0200
> "Yura Siamashka" <yurand2 at gmail.com> wrote:
> 
> > 2008/3/12, Yura Siamashka <yurand2 at gmail.com>:
> > > > You can use GeanyData::filetypes, which is an array of filetype
> > > > pointers, to loop through each filetype.
> > > Good, but how can I get it's size? I think I can't trust
> > > GEANY_MAX_FILE_TYPES since it can be different for geany and plugin.
> > I think I can check if filetype is GEANY_FILETYPES_ALL and assume it
> > is last. Sorry no need to add anything to geany. ;-)
> 
> GEANY_FILETYPES_ALL is always one before GEANY_MAX_FILE_TYPES. This is
> the best you can do for now. I guess because of this we need to always
> increment the ABI when adding filetypes. (I'm planning on making the
> filetypes array dynamic in future, so then it would be something like
> filetypes->len.)
No need. I can calculate filetypes length checking if current filetype is last (check it's uid with FILETYPE_UID_ALL).

What about allocating filetypes as [GEANY_MAX_FILE_TYPES + 1]? Extra NULL pointer will tell array size for sure and there are glib functions for working with such data.

-- 
Yura Siamashka <yurand2 at gmail.com>



More information about the Users mailing list