GTK2 with c++, without gtkmm



Hi all!

I've been just a reader of this mailing-group, but it seems to me, that
now I've got a problem which cannot be solved just after reading :)

I'm writing an application using GTK2, however I decided to use
C++ because of it's objects :) I tried not to pay attention to some
difficulties, but they return. Type matching is too strict, so after e.g:

[cut]
    hsep = gtk_hseparator_new();
    gtk_table_attach(GTK_TABLE(packTable), hsep , 0,2,2,3,
                                GTK_FILL|GTK_SHRINK, GTK_FILL, // *** HERE!
                                0,0 );
[cut]

error message is like that:
---
cannot convert `int' to `GtkAttachOptions' for argument
`7' to `gtk_table_attach (GtkTable *, GtkWidget *, unsigned int, unsigned
int, unsigned int, unsigned
int, GtkAttachOptions, GtkAttachOptions, unsigned int, unsigned int)'
---

There are also problems when try to call  g_signal_connect()
passing a static class method as a callback function.

I'm using "gpointer data" to pass extra data, because
in a static function I cannot access non-static class members.

SOMETHING LIKE AN EXAMPLE:

class Foo {
public:
    GtkWidget* button;
    static void callback(GtkWidget* widget, gpointer data);
    gint foo2;
};

[,,,]   g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (callback), (gpointer) this->foo2);

void Foo::callback(GtkWidget* widget, gpointer data
    (gint) data=5;
[...] }

... does not work - I got an errortrying to access foo2
- "invalid use of member in static member function"

works only:
[,,,]   g_signal_connect (G_OBJECT (button), "clicked",
                    G_CALLBACK (callback), (gpointer) this);
and then:
[...] ((Foo*)this)->foo2 = 5;

Is there a way to solve those problem?
Or does anyone see where I made my mistakes?

Thanks,
Waldek Maleska


----------------------------------------------------------------------
Zostan trenerem kadry skoczkow i wygraj bilet pod skocznie!
http://link.interia.pl/f16a5 





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