sending a pointer with a struct



/*Hello i have a problem (again) :


Im using a struct :
*/
typedef struct _list_ordervalues ordervaluesobj;
typedef struct _list_ordervalues
  {
    int running_event;
    char *sorting_string;
  };

/*and now i want that a menu sends in every row this struct to a
function called init_list
(but here is the menu implementation first : )*/


 optionmenu1_menu = gtk_menu_new ();
  res = execSQL ("select event_name,number from running_events");
  for (int a = 0; a < PQntuples (res); a++)
    {
      glade_menuitem = gtk_menu_item_new_with_label (PQgetvalue (res, a,
0));
      gtk_signal_connect (GTK_OBJECT (glade_menuitem), "activate",
     GTK_SIGNAL_FUNC (init_list), (gpointer)
structpointer->running_event = atoi (PQgetvalue (res, a, 1)));
      gtk_widget_show (glade_menuitem);
      gtk_menu_append (GTK_MENU (optionmenu1_menu), glade_menuitem);
    }
  PQclear (res);

  gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu1),
optionmenu1_menu);
  gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu1), 0);

/* Some lines later a new menu with the same struct is born: */
 optionmenu1 = gtk_option_menu_new ();
  gtk_object_set_data (GTK_OBJECT (show_runner), "optionmenu1",
optionmenu1);
  gtk_widget_show (optionmenu1);
  gtk_box_pack_start (GTK_BOX (vbox4), optionmenu1, FALSE, FALSE, 0);

  optionmenu1_menu = gtk_menu_new ();
  glade_menuitem = gtk_menu_item_new_with_label ("Startnummer");
  gtk_signal_connect (GTK_OBJECT (glade_menuitem),
        "activate",
        (GtkSignalFunc) init_list,
        structpointer->sorting_string = "order by number");
  gtk_widget_show (glade_menuitem);
  gtk_menu_append (GTK_MENU (optionmenu1_menu), glade_menuitem);
/* Here can follow some more menu entrys */
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu1),
optionmenu1_menu);
  gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu1), 0);
/
/*Here is init_list:*/
init_list (GtkWidget * widget, ordervaluesobj * order_num)
{
 g_print ("run number state : %s\n", run_number_state);
  g_print ("order string : %s\n",order_num->sorting_string);
/* After these calls  a sigsegv comes up */
}

Yes this works not but is there a better way to

implement this ????

--
Andreas Scherf
+-------------------------------------------+
I EMail   : scherfa@fh-trier.de             I
I Homepage: http://www.fh-trier.de/~scherfa I
+-------------------------------------------+





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