Re: Ad-on hook idea



Have you looked at the gtk module system?  Every gtk (and hence gnome)
application can take a --gtk-module=... argument.  The argument will be
the name of a shared library to be dynamically loaded.  When it is loaded,
the function gtk_module_init() from the library will be called.

From that function, you would want to add some emission hooks, which will
be called whenever those signals get emitted (for any object -- not just
one).  You can do this with gtk_signal_add_emission_hook().  The signal ID
can be found with gtk_signal_lookup().

For your menu bar example, you would want to add an emission hook on the
realize signal of GtkWidget.  Whenever this hook gets called, check to see
if the widget is a GtkMenuBar (with GTK_IS_MENU_BAR), and if so, add in
your special hide/show signals.

You can get a particular gtk module to load for every GTK application by
adding it to the GTK_MODULES environment variable.

James.

--
Email: james@daa.com.au
WWW:   http://www.daa.com.au/~james/


On Mon, 15 Nov 1999 redhog@mini.dhs.org wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Follows an idea of mine. Please critisize, extend and change! And please
> tell me if this is something desired for Gtk!
> 
>  To enhance the look of Gtk, the theme system was created. This enables
> users to easily change the look and feel of Gtk programs.
>  The feature I am to describe implements something similar in
> functionality: it adds an option for users to change, not the look and
> feel, but the behaviour, of Gtk programs.
>  From the user's view, she'l see a list of installed ad-ons, an uninstall
> and an install button in some configure app (Perheaps in the gnomecc). She
> may download a new add-on, and install it, and all programs immideately
> changes their behaviour to include the functionality of the new add-on.
> Examples of possible add-ons: Changes so that a user may scroll a
> GtkScrolledWindow by klicking (with some user defined modifiers) and
> moving inside the scrolled widget, so that menus dissapears and reappears
> when the mouse leafes and reenters the window (What my GBlippie patch
> does), etc.
>  What is needed to be implemented? In order for an add-on to be able to
> hook in its functionality, it needs to know when an object (Of any type)
> is created (The rest of the functionality could easily be added as signal
> handlers connected to the signals of the newly created object). This is
> easiest achived, I think, by creating a global variable that holds an
> object, that emits a signal whenever an object is created. WHen a program
> is started, the add -ons installed are loaded as dynamically loadable
> libraries, and their init function is run. That init function then
> attaches some signal handler to that global object.
>  This solution doesn't provide for the immediately change option, but at
> leaste enables us to create some kind of add-ons. Please come up with a
> better solution!
>  What is this good for? The main reason for me coming up with this idea is
> that I failed to get my SuperCool<TM> functionality hack into the Gtk
> source tree. And I can understund the reason - the source should be cept
> clean, and not implement a huge set of strange features that only a few
> appreciates, or we will end up in some kind of enlightenment :)
>  But of course some strange peoples (strange as in "like me") wants those
> strange features. If this idea is implemented, they could just implement
> their hacks as add-ons, and distribute them as separate programs, that do
> not even depend on the version of Gtk (As a patch does), witout disturbing
> the Gtk ftp admins with a huge load of unrelevant code, and without
> cluttering the Pure GTk Code.
> With best regards,
> Egil möller
> 
> <A Href="http://www.tekmetrics.com/transcript.shtml?pid=29943">TekMetrics Online Public Transcript (e-certifications[tm])</A><Br>
> <A Href="http://mini.dhs.org/PGP%20Public%20key.asc">PGP Public key</A><Br>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v0.9.9 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> 
> iD8DBQE4MIO4HeQ6HSAJlUwRAtQvAJ9mmQ1VnwEPNzNwhs4rwEus/pQRvACfSDtB
> efwf2TKwbwPczRtsTiCsUJ0=
> =xpA2
> -----END PGP SIGNATURE-----
> 
> 
> -- 
> To unsubscribe: mail gnome-devel-list-request@gnome.org with "unsubscribe"
> as the Subject.
> 



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