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



On 14 Apr 2001 22:07:39 -0700, Darin Adler wrote:
> 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. 
> 
I've been wanting to contribute to Nautilus, so I figured that this
would be a good way to start. ;-)

> 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).
> 
This does seem like overkill.  The NautilusFile object would only exist
for a very short period of time, solely to give me a directory icon.

> 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.

I was thinking about this, but I'd rather try and get it right the first
time, and make sure it is implemented in a way that is consistent with
the rest of Nautilus.

> 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).
> 
Your email actually came as I was about to ask this very question.  It seems 
to me that a parent uri is always going to be a directory...at least I'd
hope so.  After looking at nautilus_icon_factory_get_icon_for_file, I
realized that it was calling
nautilus_scalable_icon_new_from_text_pieces, and so that seemed like a
good function to use.  Except that I had no real idea what the modifier
argument was for.  And it did seem odd that it had an anti-aliased
parameter. ;-)  I think that I'm going to try this method....it will
probably be more efficient than other approaches anyway, not to mention
conceptually simpler for me. Hopefully I'll have a patch for all of this
soon.

    --Ryan






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