using a callback as a normal function


Is it possible to use a callback also as a normal function?
For example, I have a program that can either open files from a
FileSelection dialog or from the command line.  Instead of having two
separate functions for each, I want to have just one universal function:

void file_open(GtkWidget *widget, gint method)
        if(method == 1)
            /* do this if it is called from the cmd line */
        else if(method == 2)
            /* do this if it is called from the FileSelection */

Now say I want to use this function as a callback for a menu item:

static GtkItemFactoryEntry menu_items[] =
     {"/_File", NULL, NULL, 0, "<Branch>"},
     {"/File/_New", "<control>N", NULL, 0, NULL},
     {"/File/_Open", "<control>O", file_open, 0, NULL},

how do I pass arguments to this?


Aaron Walker

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