RE: about button's problem......
- From: =?big5?b?tsC8eSBLYXNvbiBIdWFuZw==?= <kasonhuang kinposh com cn>
- To: <John Cupitt ng-london org uk>
- Cc: <gtk-list gnome org>, <jean-christophe berthon cgey com>, <v_zahiri yahoo com>
- Subject: RE: about button's problem......
- Date: Tue, 22 Jan 2002 20:46:27 +0800
hi John:
Thanks for your help!
before i received your mail,i was thinking in the gtk source codes how to do with the problem.
maybe i could get help from the source codes.
I find in the gtk source code gtk_button_class_init() calls gtk_signal_new("enter"..............);
did someone know the gtk source codes how to handle with the problem?
Thanks in advance.
kason
-----Original Message-----
From: John Cupitt ng-london org uk [mailto:John Cupitt ng-london org uk]
Sent: Tuesday, January 22, 2002 6:55 PM
To: ¶À¼y Kason Huang
Cc: gtk-list gnome org; jean-christophe berthon cgey com;
v_zahiri yahoo com
Subject: Re: about button's problem......
¶À¼y Kason Huang wrote:
> now i want to do:my condition is being no mouse,the only terminal
controlling tool is the keyboard.(i am doing a STB project.). when a
button get focus(with keyboard) , setting the button's background to be a
color. then when the button lost focus,setting the button's background to be
another color.i do the following.
> i rewrite the testing code,but it's still not working like i expected.
Hi Kason, the best way to do this is to set the name of the widget and
then use .gtkrc to set a colour.
here's a program that does what you want:
----------------------
#include <gtk/gtk.h>
void
set_name (GtkWidget * widget, const char *name)
{
gtk_widget_set_name (widget, name);
if (GTK_IS_CONTAINER (widget))
gtk_container_foreach (GTK_CONTAINER (widget),
(GtkCallback) set_name, (char *) name);
}
static gboolean
set_name_cb (GtkWidget * widget, GdkEvent * event, gpointer client)
{
set_name (widget, (const char *) client);
return TRUE;
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *button;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
button = gtk_button_new_with_label ("foo");
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "focus_in_event",
GTK_SIGNAL_FUNC (set_name_cb), "focussed_widget");
gtk_signal_connect (GTK_OBJECT (button), "focus_out_event",
GTK_SIGNAL_FUNC (set_name_cb), "default");
button = gtk_button_new_with_label ("bar");
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (button), "focus_in_event",
GTK_SIGNAL_FUNC (set_name_cb), "focussed_widget");
gtk_signal_connect (GTK_OBJECT (button), "focus_out_event",
GTK_SIGNAL_FUNC (set_name_cb), "default");
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
-------------------------
You need to make a file called .gtkrc in your home directory, and add
this to the end:
-------------------------
style "focussed_style" = "default"
{
bg[NORMAL] = { 0.1, 0.7, 0.6 }
bg[PRELIGHT] = { 0.2, 0.8, 0.7 }
bg[ACTIVE] = { 0.1, 0.7, 0.6 }
bg[SELECTED] = { 0.1, 0.7, 0.6 }
bg[INSENSITIVE] = { 0, 0.4, 0.3 }
}
widget "*focussed_widget" style "focussed_style"
--------------------------
John
==========================================================
Coming soon:
Aelbert Cuyp 13 February - 12 May 2002
For information and tickets:
http://www.nationalgallery.org.uk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]