Re: Problem passing widget through functions!!
- From: TORRI Vincent <Vincent Torri math u-bordeaux fr>
- To: Satan Devil <very709394bad yahoo com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Problem passing widget through functions!!
- Date: Thu, 5 Jun 2003 08:45:18 +0200 (CEST)
On Wed, 4 Jun 2003, Satan Devil wrote:
The code below display 1 button.
From the code below, Why can't I remove "main_vbox =
gtk_vbox_new(FALSE, 0);" and put it in add_something()
as "w = gtk_vbox_new(FALSE, 0);". Logically, it should
work but it doesn't. The function add_something() is
ONLY PASSING pointer.
thanx!
The code below is working but is not what I want.
What I want is comment main_vbox = gtk_vbox_new(FALSE,
0); and uncomment //w = gtk_vbox_new(FALSE, 0);
// Compile : g++ -o test test.cpp `gtk-config --cflags
--libs`
#include <gtk/gtk.h>
#include <string> // string
#include <iostream> // cout
using std::cout;
using std::string;
class TEST
{
private:
GtkWidget *window, *main_vbox;
public:
TEST();
void add_something(GtkWidget *w);
};
TEST::TEST()
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),
"delete_event", GTK_SIGNAL_FUNC(gtk_main_quit),
NULL);
gtk_window_set_title(GTK_WINDOW(window), "Notebook");
gtk_widget_set_usize(GTK_WIDGET(window), 800, 600);
gtk_container_border_width(GTK_CONTAINER(window), 3);
gtk_widget_show(window);
main_vbox = gtk_vbox_new(FALSE, 0);// Don't want to
write this here!
add_something(main_vbox);
// Add a button to main_vbox.
GtkWidget *bb = gtk_button_new_with_label("Button");
gtk_box_pack_start(GTK_BOX(main_vbox), bb, TRUE,
TRUE, 20);// Connect to main_vbox
gtk_widget_show(bb);
}
void TEST::add_something(GtkWidget *w)
{
//w = gtk_vbox_new(FALSE, 0); // Want to pass
main_vbox here but not working
I am not a C++ expert, but why do you want to pass main_vbox, as it is an
element of the class TEST ??
gtk_container_add(GTK_CONTAINER(window), w); // Link
main_vbox to window.
Here, you use window without passing it.
regards
Vincent TORRI
gtk_widget_show(w);
}
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
TEST test;
gtk_main();
return(0);
}
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
--
TORRI Vincent
Mathematiques Appliquees Bordeaux
Institut de Mathematiques
Universite Bordeaux 1
351 cours de la liberation
33 405 Talence cedex - France
Tel : 33 (0)5 40 00 21 42
Fax : 33 (0)5 40 00 26 26
--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]