Re: GTK2 with c++, without gtkmm



On Thu, 2002-12-12 at 22:08, Progss wrote:
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]

GTK_FILL is a GtkAttachOptions, GTK_SHRINK is a GtkAttachOptions, but
GTK_FILL | GTK_SHRINK is not a GtkAttachOptions (its integer value
doesn't match any of the GtkAttachOptions enumeration).  That's why a
C++ is complaining.

To solve the problem, just add an explicit cast to the GTK_FILL |
GTK_SHRINK part.


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);

it should be (gpointer) &this->foo2

this->foo2 is an integer (for example 0), and not a valid address.

Cheers,

-- 
Joaquín Cuenca Abela
cuenca pacaterie u-psud fr




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