Re: Changing a GtkToolButton icon_widget on the fly
- From: James Morris <jwm art net gmail com>
- To: James <jamessteward optusnet com au>
- Cc: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Re: Changing a GtkToolButton icon_widget on the fly
- Date: Wed, 22 Jun 2011 08:47:54 +0100
On 22 June 2011 05:43, James <jamessteward optusnet com au> wrote:
Hi,
I've been trying to change the icon_widget that's displayed for a
toolbar button while the main window is displayed. I can't seem to get
the actual image to change, although the functions that call
gtk_tool_button_set_icon_widget(0 do get called. There's no warnings
either.
I do something like...
GtkWidget *eject_widget;
GtkWidget *eject_red_widget;
GtkToolButton *eject_button;
void green(void)
{
gtk_tool_button_set_icon_widget(eject_button, eject_widget);
}
void red(void)
{
gtk_tool_button_set_icon_widget(eject_button, eject_red_widget);
}
int main(int argc, char **argv)
{
<snip>
GtkBuilder *builder;
builder = gtk_builder_new();
gtk_builder_add_from_file(builder, "stridemaster.xml", NULL);
eject_widget = GTK_WIDGET(gtk_builder_get_object(builder,
"eject_tracker_image"));
eject_red_widget = GTK_WIDGET(gtk_builder_get_object(builder,
"eject_tracker_red_image"));
eject_button = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
"toolbutton_eject_tracker"));
g_object_unref(G_OBJECT(builder));
gtk_widget_show(window);
gtk_main();
<snip>
}
What am I missing?
The problem might be to do with floating versus fixed references. GTK
will usually unreference the images once it thinks they're finished
with - ie when you change the icon, it will think you no longer wish
to use the previous icon.
Try calling g_object_ref_sink on all of the widget icons once you've
created them, and then g_object_unref after you're done.
James.
Regards,
James.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]