Re: GTK2 with c++, without gtkmm

Hi Waldek,

I had a similar experience using g++.  I solved it with a typecast.  GTK_FILL
is an element of an enum, so it is a gint.  The argument to gtk_table_attach is
guint, so I think for your case a cast to (guint) should take care of the

However, I feel that gtk_table_attch should accept guint as argument 7 (and
others).  I've noticed this on quite a few other functions in GTK.


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:

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

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.


class Foo {
    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?

Waldek Maleska

Zostan trenerem kadry skoczkow i wygraj bilet pod skocznie! 

gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

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