Re: How to change Test and icon of a button in toolbar?
- From: Harring Figueiredo <harringf yahoo com>
- To: Martin Bammer <e9525103 stud4 tuwien ac at>, gtk-app-devel-list gnome org
- Subject: Re: How to change Test and icon of a button in toolbar?
- Date: Fri, 6 Dec 2002 07:47:17 -0800 (PST)
--- Martin Bammer <e9525103 stud4 tuwien ac at> wrote:
Hi,
I have a toolbar with several buttons with text and icons. I want to change
these texts and icons during execution. How can I do that?
Greets, Martin
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Here is a code snipet that does this. (It changes only the label though --
should not be difficult to add code to change the icon.)
static GtkToolbarChild* child; /* used to change the Start/Stop button label*/
/**
* Find the GtkToolbar child once the server stars runnning. (The label is
"Start" at the beginning. and sets the static var "child" to poit to it.
*/
static void init_toolbar_child(GtkToolbar* toolbar)
{
GList* list = NULL;
g_return_if_fail(toolbar != NULL);
list = toolbar->children;
while( (child = (GtkToolbarChild*)(g_list_next(list))->data))
{
if(child->label != NULL)
{
if(!strcmp("Start", gtk_label_get_text(GTK_LABEL(child->label))))
{
break; /* found */
}
}
}
}
On the above code, all I am doing it trying to get the "child"
(GtkToolBarChild that relateds to my button on the toolbar..
In some callback the code. ( CLICK BUTTON EVENT on the toolbar ) I do:
if(gtk_toggle_button_get_active(togglebutton))
{
...
statusbar = lookup_widget(GTK_WIDGET(togglebutton) , "statusbar1");
gtk_label_set_text(GTK_LABEL(child->label), "Stop");
stop_timeout_call = TRUE;
}
else
{
gtk_label_set_text(GTK_LABEL(child->label), "Start");
stop_timeout_call = FALSE;
}
All the code above does is: IF the Label of the button was "Start", change it
to "Stop" or if it was "Stop" change it to "Start"
To figure this out, I had to look at the gtktoolbar.c
Hope this helps.
Harring.
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]