I am writing an application in C++ with using GTK+ (not gtkmm) so I need to compile using g++ compiler. Is it possible to compile GTK+ applications with the g++ compiler? Are GTK+ and libraries compatible with g++ compiler?
I am trying to embed GTK+ functions call in a class like follows:
#include <gtk/gtk.h>
class LoginWindow
{
public:
LoginWindow();
void on_window_destroy( GtkObject *object, gpointer user_data);
private:
GtkBuilder *builder;
GtkWidget *window;
};
LoginWindow::LoginWindow()
{
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, "login_window.glade", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "login_window"));
gtk_builder_connect_signals (builder, NULL);
g_signal_connect( GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(on_window_destroy), NULL );
g_object_unref (G_OBJECT (builder));
gtk_widget_show (window);
}
void LoginWindow::on_window_destroy (GtkObject *object, gpointer user_data)
{
gtk_main_quit ();
}
int main (int argc, char *argv[])
{
gtk_init (&argc, &argv);
LoginWindow loginWindow;
gtk_main ();
return 0;
}
Am I doing it right? I am getting compile error on line:
g_signal_connect( GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(on_window_destroy), NULL );
login_window.cpp: In constructor "LoginWindow::LoginWindow()":
login_window.cpp:27: error: invalid use of member (did you forget the "&" ?)
What is the right way of doing it?