Hi,

Am Montag, den 06.02.2006, 16:53 -0200 schrieb Felipe Monteiro de
Carvalho:
> Hello,
> 
> Now the TrayIcon component is fully working for Gtk2!!!

Very nice :)


> 
> A patch is attached.

well done :)

Let me do minor nitpicking as always though:

- to free the gtk_tooltips thing, call 
g_object_ref(Tips);
gtk_object_sink(Tips);
[.....everything else here]
g_object_unref(Tips);

This particular weird sequence (that I get wrong half of the time - I
had to look it up right now) is required because GtkTooltips derives
from GtkObject, which has what is called a "floating reference".

Usually (with f.e. GtkLabel), someone - i.e. gtk_container_add - will
claim that reference and all is well - therefore, for example the label
will be freed by "the system".

But the gtk tooltips object is kind of weird in that regard since it is
(seemingly?) not added anywhere. Hence you have to get rid of the
initial reference by "sinking" it. 

*However*, if someone would have claimed it after all [like the evil
system], by now it would be gone and you would be accessing an invalid
pointer (with the gtk_object_sink call...) (this is why you usually
can't just sink it at the end and be done with - and this is why
not-sinked-by-anyone is dangerous).

*breathes in*
Therefore,
you have to first
- gtk_tooltips_new <-- you already have that :)
- g_object_ref(Tips)  <-- increment reference count on object so it
stays around and doesn't commit suicide in the next line:
- gtk_object_sink(Tips) <- ok I claimed the initial reference so stop
begging to be noticed :)

... do everything else with the tips object in between here ...

- g_object_unref(Tips) <-- decrement reference count on object. It
dropped to zero, so it was freed too.

Whoever thought up GtkTooltips was _really_ whacko :) (oh, if he just
derived it from GObject... but nooo)

=======

- The comment on motion_cb is wrong ;)

- about that GDK_SCREEN_XSCREEN that just SEEMS to want to annoy us
eternally, anyone knows what the X function is called to get a X Screen
number from a X Window directly? :)

- Don't register for all events (with gtk_widget_add_events) if you
don't need them. X is slow enough as is ;) 

I wanted to also tell the following but I changed my mind, so please
ignore the following block unless you are _really_ bored :)
==============================================================
(and yes, it *will* tell you over and over again that you moved your
mouse 0.000001mm to the right - or actually, it was tiny vibrations
caused by the ventilation in your room - if you get my drift :)) - and
it *will* use interprocess communication on every single one of them. 

I recommend using only GDK_POINTER_MOTION_HINT_MASK which will send you
_one_ mousemove until you ask for more (by calling
gdk_window_get_pointer).
In motion_cb, check if OnMouseMove is assigned and if so, call
gdk_window_get_pointer (and don't if it is not).
Should make it a little bit less demanding :)

Then again, here we get into the area of totally useless nitpicking.
It's also fine if you keep it as is :)
==============================================================


> 
> One little problem: The gtk2 tray icon requires gdk2x11, and this unit 
> is on a package that needs to be installed. The Package cannot be added 
> as a pre-requisite because the software is also used on Windows and 
> without a package.
> 
> I recommend that gdk2x11 is put on Free Pascal Source. It worked without 
> any problems for the tray icon.


> thanks,
> 
> Felipe

cheers,
  Danny


_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to