Re: Menu Item Labels
- From: Carlos Pereira <carlos pehoe civil ist utl pt>
- To: gtk-app-devel-list gnome org
- Subject: Re: Menu Item Labels
- Date: Wed, 28 Nov 2001 02:07:29 GMT
Are you sure you want to connect to "button_press_event"?
You can use this signal:
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (handler_function), data);
Your callback will be like this:
void handler_function (GtkWidget *widget, gpointer data)
and widget is the menu_item, which you can in turn
cast to bin and get the child, which is the label,
label = GTK_BIN (widget)->child;
Now you can get the text inside with:
gtk_label_get (label, &string);
Carlos
If a menu item is created in the following manner:
file_name_label = gtk_menu_item_new_with_label (menu_label);
gtk_menu_append (GTK_MENU (toolbar_alpha_submenus), file_name_label);
gtk_widget_show (file_name_label);
gtk_signal_connect_object (GTK_OBJECT (file_name_label),
"button_press_event",
GTK_SIGNAL_FUNC (edit_this_file), (gpointer)
g_strdup (path));
is there a way to extract the menu's label text string (menu_label) when
the "button_press_event" signal is emitted? In this case, menu_label is
the name of a file and when the user clicks on that menu I'd like to
retrieve the file the user clicked on to be able to do some processing
with it.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]