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

Re: getting arguments



On Thu, 03 Feb 2000 08:44:54 -0200 (EDT), Fernando Figaro wrote:
> Hello everydoby....
> 
> 
> I would like to know how to pass some arguments from the callback in the
> factory widget...
> 
> 
> GtkItemFactoryEntry items[] = {
> .....
> {"/File/_Open","<alt>O", abrir , 0, NULL}
> .....
> }
> 
> 
> In the function abrir, I need to pass two arguments (suppose the name of file
> and a int variable).

Just use a structure with the two arguments and pass a pointer to such a
structure.

  typedef struct
  {
    int foo;
    char *bar;
  } myargs;

  myargs args_for_this_widget;

  GtkItemFactoryEntry items[] = {
  {"/File/_Open","<alt>O", abrir , &args_for_this_widget, NULL}
  };


  void abrir(GtkWiget *widget, gpointer data)
  {
    myargs *args = (myargs *)data;
    char *filename;

    assert(myargs != NULL);

    filename = myargs->bar;

  }


Erik
  
-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2785859  Fax: +31-15-2781843  Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/





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