signal connection problem
- From: Marco Quezada <mquezada nlxcorp com>
- To: GTK List <gtk-app-devel-list gnome org>
- Subject: signal connection problem
- Date: Mon, 26 Mar 2001 15:05:10 -0500
Hi, I have the following function which reads parameters from a config
file and builds a simple menu with items. Each item has a signal and a
command associated with it. The config file where these parameters are
read from looks like this:
go_main go_main activate
go_maind go_maind activate
xpc.mac xpc.mac activate
cpm.mac cpm.mac activate
Razor versions activate
END_SECTION
where the first column is the label on the menu, the second is ht
ecommand to execute and the third is the signal passed associated with
the menu item.
The section of the code that draws this menus is the following:
gchar label[100], command[100], signal[100];
while(strcmp(TEMP_STRING, "END_SECTION\n") != 0)
{
NEXT_LINE_AVAILABLE(config_file, TEMP_STRING);
if(strcmp(TEMP_STRING, "END_SECTION\n") != 0)
{
sscanf(TEMP_STRING, "%s %s %s", label, command, signal);
CHECK_FOR_SPACES_IN_STRING(label);
CHECK_FOR_SPACES_IN_STRING(command);
CHECK_FOR_SPACES_IN_STRING(signal);
run_stuff_menu_items = gtk_menu_item_new_with_label (label);
gtk_widget_ref (run_stuff_menu_items);
gtk_object_set_data_full (GTK_OBJECT (control_window), label,
run_stuff_menu_items,
(GtkDestroyNotify) gtk_widget_unref);
gtk_widget_show (run_stuff_menu_items);
gtk_container_add (GTK_CONTAINER (run_stuff_menu),
run_stuff_menu_items);
gtk_signal_connect (GTK_OBJECT (run_stuff_menu_items), signal,
GTK_SIGNAL_FUNC (on_cpmon_activate),
(gpointer) command);
}
}
My problem is that although the menus get built correctly, the data
passed by the signal connect function (command) is always the last
command on the list, i.e. versions. So if I click on say xpm.mac the
callback gets the following data passed to it:
void
on_cpmon_activate (GtkMenuItem *menuitem,
gpointer *user_data)
{
char temp_string[50];
sprintf(temp_string, "%s &", (char *)user_data);
system(temp_string);
}
And user_data is always the string "versions".
Any ideas on what's going on?
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]