LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   GTK additional arguments for signals (https://www.linuxquestions.org/questions/programming-9/gtk-additional-arguments-for-signals-381280/)

bendeco13 11-08-2005 08:02 PM

GTK additional arguments for signals
 
I'm new to GTK (in c++), but I have experience in GTK for python, any ways.
I'm trying to figure out a way to pass more than one argument through signals.
Say for instance I'm trying to do this:
Code:

static void cellfunc(GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer entry, string format)
{
    string path = gtk_entry_get_text(GTK_ENTRY(entry));
    string ntxt = format_file_data(filename, format);    /* User defined function */
    g_object_set(GTK_CELL_RENDERER(cell), "text", ntxt, NULL);
}

This isn't my exact code, but I figured it was the most 'barebone' version that would make my question a little easier to understand.

Given the above code, How would I go about setting up the:
gtk_tree_view_column_set_cell_data_func()
Right now I have it setup like this, but it don't work:
gtk_tree_view_column_set_cell_data_func(GTK_TREE_VIEW_COLUMN(col), GTK_CELL_RENDERER(cell), cellfunc(dataformat), GTK_ENTRY(direntry), NULL);

Basically I'm trying to pass additional arguments to the 'cellfunc' function.
Does anyone know how I would go about this.

Thanks in advance,
Bendeco

paulsm4 11-08-2005 11:10 PM

Yes:

1. You can make your argument a pointer to a struct (a struct that contains your multiple items)
... or ...
2. You can declare a global variable (optionally making your argument an index for your global).

bendeco13 11-09-2005 12:04 AM

Quote:

1. You can make your argument a pointer to a struct (a struct that contains your multiple items)
... or ...
2. You can declare a global variable (optionally making your argument an index for your global).
I'm currently doing #2, but I'm using the functions in a seperate header file and I want it to be as universal as possible, so I was exploring for a new way to do this.
I will read into creating a struct.

Thanks for the reply.
Bendeco

I try to be as professional as possible on these forums,
BUT... I just noticed that I said "I'm currently doing #2".
HAHAHAHA:eek:


All times are GMT -5. The time now is 08:19 PM.