signal troubles



Hi there,

I'm having troubles getting my signal callback function to carry an extra argument...

I have the following code in my main program:

===========================================================

int main(argc, char **argv)
[...]
gtk_signal_connect(GTK_OBJECT(scenelist), "scene_selected", GTK_SIGNAL_FUNC(scene_clicked_signal), NULL);
[...]

and further on:

static void scene_clicked_signal(GtkWidget *widget, gint scene_num, gpointer data)
{
        GtkScene *scene;
        scene = gtk_scenelist_get_scene(GTK_SCENELIST(widget), scene_num);
g_print("Scene %d (frame %d-%d in %s, frame %d in editlist) was clicked\n",
                scene_num, scene->view_start, scene->view_end,
(char *)g_list_nth_data(GTK_SCENELIST(widget)->movie, scene->movie_num),
                scene->start_total);
}

===========================================================

In gtkscenelist.c, I did the following:

===========================================================

enum {
        SCENE_SELECTED,
        LAST_SIGNAL
};
static guint gtk_scenelist_signals[LAST_SIGNAL] = { 0 };

further on, in gtk_scenelist_init_class():
[...]
gtk_scenelist_signals[SCENE_SELECTED] = gtk_signal_new("scene_selected", GTK_RUN_FIRST, object_class->type,
                GTK_SIGNAL_OFFSET(GtkSceneListClass, scene_selected),
                gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 1,
                GTK_TYPE_INT);
gtk_object_class_add_signals(object_class, gtk_scenelist_signals, LAST_SIGNAL);
[...]

and in another function, which emits the signal:
[...]
if (scene >= 0) gtk_signal_emit_by_name(GTK_OBJECT(scenelist), "scene_selected", scene);
        if (scene >= 0) g_print("Emitted signal for scene %d\n", scene);
[...]

===========================================================

I'm getting the following output when running the program:

Scene 0 (frame 0-268 in /movies/movie.avi, frame 0 in editlist) was clicked
Emitted signal for scene 0
Scene 0 (frame 0-268 in /movies/movie.avi, frame 0 in editlist) was clicked
Emitted signal for scene 1
Scene 0 (frame 0-268 in /movies/movie.avi, frame 0 in editlist) was clicked
Emitted signal for scene 2

So, as you can see, gint scene_num in the callback function for the signal just carries no value.... Am I doing something wrong? It's (of course) supposed to carry the third argument I give to the function gtk_signal_emit_by_name();... So somewhere, I must be doing something wrong in getting this extra argument in/to the callback function... Any clue on what I'm doing wrong?

Thanks in advance :-),

Ronald





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