2009/12/15 Vincent C. [email protected]:
Hi everyone.
I wrote an article in french on how to use Gtk::StatusIcon.
Blog du projet ZiK
I don’t have a user on this site, so I will comment here.
-
Si votre bibliothèque gtk est récente,
You might want to look which version of gtk2, and ruby gtk2 you need,
and putit in the article.
-
The mask example is not very clear, you might want to make it more
verbose :
si.signal_connect(‘scroll-event’){|icon, event|
etats_a_gerer = (Gdk:
:CONTROL_MASK|Gdk:
:SHIFT_MASK)
etat_actuel = (event.state & etat_a_gerer)
case etat_actuel
when 0
p ‘Aucun modificateur’
when Gdk:
:CONTROL_MASK
p ‘Control’
when Gdk:
:SHIFT_MASK
p ‘Shift’
when (Gdk:
:CONTROL_MASK|Gdk:
:SHIFT_MASK)
p ‘Control+Shift’
end
}
event.state est un masque représentant l’état de l’ensemble des
modificateurs, par exemple du clavier. Dans le cas présent, nous nous
intéressons seulement aux modificateurs control et shift. À cet usage,
nous filtrons les modificateurs complets avec un masque des
modificateurs que nous voulons gérer. Puis nous comparons le résultat
aux différents cas possibles.
-
You are interchanging ‘on’ and ‘nous’, it would be better to only have
one.
Nous allons maintenant voir comment
On construit un menu auquel on ajoute
-
I don’t like much your code style, but it’s very subjective :).
-
Why is ‘print_direction’ inside the case ? Don’t you want to print it,
whatever command key is pressed ?
si.signal_connect(‘activate’){si.blinking=!(si.blinking?)}
You are using ‘si’ inside the block, but it might not be available in
the context. Signals in gtk hands you back whatever you should work
on.
si.signal_connect(‘activate’){|icon| icon.blinking=!(icon.blinking?)}
il est nécessaire d’utiliser Ctrl+C récupérer la main.
Ctrl+C pour récupérer
Intérargir avec l’icône
Intéragir
La méthode embedded? permet de vérifier que la présence d’une zone de notification
vérifier la présence
L’objet event retourné lors appartient
alors (or nothing)
It’s a nice tutorial of StatusIcon otherwise, simple and to the point.
Simon