Re: [gtk-list] Getting the label from gtk_radio_menu_item_new_with_label()

On Mon, Apr 17, 2000 at 06:29:47PM -0400, Havoc Pennington wrote:
> Andy Kahn <> writes: 
> > In looking at the option menu widget, I couldn't see an obvious way to
> > see any indication that an option menu's button widget has been
> > updated.  Is there some way to detect when this happens?
> The add/remove signals from GtkContainer may let you do this.

Yup, this did the trick!  Thanks!!

For completeness, I'm including the "final" version of the code which
implements the changes you've suggested.

thanks again,
#include <gtk/gtk.h>

static void
option_menu_cb(GtkWidget *wgt, gpointer cbdata)
	GtkWidget *child;
	GtkButton *button;
	char *str;


	g_print("option_menu_cb() entered\n");

	button = &(GTK_OPTION_MENU(wgt)->button);
	child = GTK_BIN(button)->child;
	g_print("child is 0x%x\n", child ? child : NULL);

	gtk_label_get(GTK_LABEL(child), &str);
	g_print("label str is '%s'\n", str);

main(int argc, char *argv[])
	GtkWidget *toplev, *omenu, *menu, *mitem;
	int i;
	char *texts[] = { "one", "two", "three" };

	gtk_init(&argc, &argv);

	toplev = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	omenu = gtk_option_menu_new();

	gtk_container_add(GTK_CONTAINER(toplev), omenu);
	menu = gtk_menu_new();

	for (i = 0; i < 3; i++) {
		mitem = gtk_menu_item_new_with_label(texts[i]);
		gtk_menu_append(GTK_MENU(menu), mitem);

	gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
	gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), 3);

			   "add", option_menu_cb, NULL);

	return 0;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]