[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNUstep's GTK theme now changes when user selects a new theme...
From: |
Richard Frith-Macdonald |
Subject: |
Re: GNUstep's GTK theme now changes when user selects a new theme... |
Date: |
Tue, 6 Mar 2012 09:38:14 +0000 |
On 6 Mar 2012, at 08:34, Eric Wasylishen wrote:
> Hi Greg,
> I think I fixed the problem.. the GTK theme was forgetting to remove the
> existing slider/radio/switch images by calling -setName: nil, so the
> replacement images weren't being registered since [NSImage setName:] does
> nothing if the name is already in use.
>
> In the longer term I'd like to come up with a more clearly defined API on
> NSImage for updating system images programatically. Currently GSTheme uses
> the +_setImagePath:name: method used when loading image files in theme
> bundles.
>
> Maybe something like:
>
> +[NSImage registerThemeImage: (NSImage *)anImageGeneratedByTheTheme
> forName: (NSString *)aName];
>
> This could use the same type of trick that +_setImagePath:name: does of
> reusing the existing registered NSImage instance, removing all of its reps,
> and copying in the reps from anImageGeneratedByTheTheme.
The way it's *intended* to work is that you simply reactivate the theme to make
things aware of changes to things like images (like when switching a theme or
moving to a new version of a theme).
The rationale for that is that, when you change an image, you want anything
using that image to redraw (and if the image size changed, you may need layout
adjustments to be done), so you want the theme activation notification sent out
for everything to update as necessary.
By that rationale, there shouldn't be any need for extra API to register a
theme image ... the existing load/activate mechanisms should be used ... the
theme should simply set system images during activation.
Now, I don't know if there's some particular circumstance where an additional
API is needed... but if there was, I think it should be part of GSTheme (not
NSImage), and should work with the existing image management mechanisms (i.e.
changing theme should revert the effect automatically, and reactivating the
theme should restore the effect automatically).
The current theme documentation says:
The standard -activate method replaces existing system images,
colors, interface style settings and other user defaults settings
with versions stored in the theme bundle.<br />
If a subclass wishes to dynamically provide these resources rather
than supplying them as static information in the bundle, it may
update the in-memory information after the normal operation has
taken place. This should be done by the theme registering itsself
as an observer of GSThemeWillActivateNotification and adding the
resources just before the theme becomes active.<br />
Cleanup may be done in response to a GSThemeWillDeactivateNotification
(called before the default cleanup) or a
GSThemeDidDeactivateNotification (called after the default cleanup).