Retrieving label from menu item



I wrote a small program that parses a source code development tree (directory structure on disk) and then places each source file into menu items. I use the following code to set the menu and connect the signal to the button press event so that when the user clicks on the name of a file that file is opened in the source code editor:

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));

This is easy code but inefficient because the path to the file is a string that is not being freed. The path is necessary for the editor to know what file to launch. However, I have that information in menu_label. My question then is: how can the label string on the menu item be retrieved?

I tried looking at the value returned from :

gtk_label_get(GTK_LABEL(file_name_label), label_string);

and although it core dumps (which I expected since file_name_label is not a GTK_LABEL) it seems to be able to extract the string from the object.

Is there any other way to achieve this?

Thanks.

--
Marco Quezada
Aerospaceo Engineero
NLX Corporation
22626 Sally Ride Dr.
Sterling, VA, 20164
mquezada nlxcorp com
703-234-2100 x1028
http://www.nlxcorp.com





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