Re: [Nautilus-list] NautilusScalableIcon: how to make one?



on 4/14/01 1:55 PM, Ryan Muldoon at rpmuldoon students wisc edu wrote:

> Hi - I'm working on Bugzilla bug #8063, which is adding a right-click
> menu to the "up" button in the toolbar.  I think I have most of my patch
> done, thanks to the very clean and easy to understand code in Nautilus
> (at least the files I've looked at).  However, the major sticking point
> that I have now is actually populating the list of parent uris for the
> menu itself.  I understand what to do conceptually, and following how
> the back_list and forward_list do has made my job easier.  From looking
> at them, I see that they are glists of NautilusBookmarks.  So I am
> trying to do the same.  So, I am trying to use
> nautilus_bookmark_new_with_icon(const char *uri, const char *name,
> NautilusScalableIcon *icon).  The first two are no problem.  The last,
> however, is proving to be a problem.  What is the constructor for a
> NautilusScalableIcon?  I tried looking at lxr.gnome.org, and asking on
> #nautilus, but I was unable to find an answer.  Any help would be
> greatly appreciated!

First, let me say how excited I am to see this question! You are really
putting your money where your mouth is, by working to implement this
feature. 

This is actually a tricky question. Given a NautilusFile object with the
proper attributes loaded, it's easy to get the scalable icon. You just call
nautilus_icon_factory_get_icon_for_file (from nautilus-icon-factory.h). But
it's not easy to get a NautilusFile object with the proper attributes
loaded. Calling nautilus_file_get (from nautilus-file.h) will get you a
NautilusFile object, given a URI, but this file won't be guaranteed to have
any attributes loaded. That's because Nautilus tries to prevent you from
locking up the UI by stat'ing all those files (imagine if the parents are on
a web server).

To get the appropriate attributes you need for the icon is a fairly
difficult task. A better option might be to not worry about this for now and
omit icons from the Up menu. Once you have everything else working, you can
consider turning the icons back on and figuring out a good rule for how to
get the appropriate attributes loaded. Unfortunately, the
NautilusBookmarkMenuItem doesn't currently have a way to omit the icon, so
you'll have to add that.

Another option is to not use nautilus_icon_factory_get_icon_for_file, and
always use a folder icon, which will probably always be OK, if not perfect.
To do that you would call nautilus_scalable_icon_new_from_text_pieces,
passing "i-directory" for the name, NULL for modifier and embedded text, and
FALSE for anti-aliased (it's actually a bug that there's an anti-aliased
parameter, I'll fix that).

    -- Darin






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]