Writing C++ apps with Gtk?
- From: Lars Hoss <lars hoss munich netsurf de>
- To: gnome-list gnome org
- Subject: Writing C++ apps with Gtk?
- Date: Thu, 01 Oct 1998 11:13:25 +0200
Hi,
I am working on a C++ Gtk application.
Now I have a strange prob with the callback functions.
The pointer to the widget in the callback function seems to be
somewhat incorrect?
Here's a simple example:
#include <stdio.h>
#include "toplevel.h"
TopLevel::TopLevel()
{
GtkWidget *window;
GtkWidget *button;
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
gtk_container_border_width( GTK_CONTAINER(window), 10 );
button = gtk_button_new_with_label( "C++ Test" );
gtk_signal_connect( GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(TopLevel::cbDestroy), this );
gtk_signal_connect( GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(TopLevel::cbHello), this );
gtk_container_add( GTK_CONTAINER(window), button );
gtk_widget_show(button);
gtk_widget_show(window);
}
void TopLevel::run()
{
gtk_main();
}
void TopLevel::cbHello( GtkWidget *widget, gpointer data )
{
g_print( "width:%d height:%d\n",
widget->allocation.width,
widget->allocation.height );
}
void TopLevel::cbDestroy( GtkWidget *widget, gpointer data )
{
printf( "DEBUG: called cbDestroy!\n" );
gtk_main_quit();
}
The function TopLevel::cbHello is important.
This width and height aren't the correct values, so the pointer
must be wrong?
How can I fix this?
Thanx for your help,
Lars
--
Lars Hoss
email: Lars.Hoss@munich.netsurf.de
WWW: http://www.informatik.uni-muenchen.de/~hoss
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]