GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error creating new window

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
lautarox
Familiar Face


Joined: 28 Aug 2008
Posts: 24

PostPosted: Thu Aug 28, 2008 11:11 pm    Post subject: Error creating new window Reply with quote

I'm getting this error when I try to create a new window with a table..
If I have some old code plz tell me, cause I've learned gtk+ from a 1.2 guide =P
Thanks

Code: (Plaintext)
1
2
3
4
5
6
7
(pbclient:19237): Gtk-CRITICAL **: gtk_window_set_default_size: assertion `GTK_IS_WINDOW (window)' failed

(pbclient:19237): Gtk-CRITICAL **: gtk_window_set_title: assertion `GTK_IS_WINDOW (window)' failed

(pbclient:19237): Gtk-CRITICAL **: gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed

(pbclient:19237): Gtk-CRITICAL **: gtk_widget_show_all: assertion `GTK_IS_WIDGET (widget)' failed


This is the function..

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void callback_main_button_build( GtkObject *object ) {

GtkWidget *frame_build;
GtkWidget *table;
GtkWidget *button_build;
GtkWidget *text_id;
GtkWidget *text_passwd;
GtkWidget *text_name;
GtkWidget *text_place;
GtkWidget *text_keyname;
GtkWidget *label_id;
GtkWidget *label_passwd;
GtkWidget *label_name;
GtkWidget *label_place;
GtkWidget *label_keyname;
 
table = gtk_table_new(6, 2, FALSE);
label_id = gtk_label_new("ID:");
label_passwd = gtk_label_new("Passwd:");
label_name = gtk_label_new("Name:");
label_place = gtk_label_new("Place:");
label_keyname = gtk_label_new("Keyname:");
text_id = gtk_entry_new();
text_passwd = gtk_entry_new();
text_name = gtk_entry_new();
text_place = gtk_entry_new();
text_keyname = gtk_entry_new();
button_build = gtk_button_new_with_label ("Build");
frame_build = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(frame_build), 250, 200);
gtk_window_set_title(GTK_WINDOW(frame_build), "Build Card");
gtk_container_add(GTK_CONTAINER(frame_build), table);
gtk_table_attach_defaults(GTK_TABLE(table), label_id, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(table), text_id, 1, 2, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(table), label_place, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(table), text_place, 1, 2, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(table), label_name, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(table), text_name, 1, 2, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(table), label_passwd, 0, 1, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(table), text_passwd, 1, 2, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(table), label_keyname, 0, 1, 4, 5);
gtk_table_attach_defaults(GTK_TABLE(table), text_keyname, 1, 2, 4, 5);
gtk_table_attach_defaults(GTK_TABLE(table), button_build, 0, 1, 5, 6);
gtk_widget_show_all(frame_build);
}


And I'm calling it with..

Code: (C)
1
2

g_signal_connect(G_OBJECT(menu_main_settings_edit), "activate", G_CALLBACK(callback_main_button_settings), NULL);
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Fri Aug 29, 2008 3:51 am    Post subject: Reply with quote

I've modified it to allow it to be used independently, and it works for me (using GTK 2.12.9),
does this work for you?
also, are you using GTK 1.2 or 2.x?

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <gtk/gtk.h>

void create_window(void)
{
    GtkWidget *frame_build;
    GtkWidget *table;
    GtkWidget *button_build;
    GtkWidget *text_id;
    GtkWidget *text_passwd;
    GtkWidget *text_name;
    GtkWidget *text_place;
    GtkWidget *text_keyname;
    GtkWidget *label_id;
    GtkWidget *label_passwd;
    GtkWidget *label_name;
    GtkWidget *label_place;
    GtkWidget *label_keyname;

    table = gtk_table_new(6, 2, FALSE);
    label_id = gtk_label_new("ID:");
    label_passwd = gtk_label_new("Passwd:");
    label_name = gtk_label_new("Name:");
    label_place = gtk_label_new("Place:");
    label_keyname = gtk_label_new("Keyname:");
    text_id = gtk_entry_new();
    text_passwd = gtk_entry_new();
    text_name = gtk_entry_new();
    text_place = gtk_entry_new();
    text_keyname = gtk_entry_new();
    button_build = gtk_button_new_with_label ("Build");
    frame_build = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(frame_build), 250, 200);
    gtk_window_set_title(GTK_WINDOW(frame_build), "Build Card");
    gtk_container_add(GTK_CONTAINER(frame_build), table);
    gtk_table_attach_defaults(GTK_TABLE(table), label_id, 0, 1, 0, 1);
    gtk_table_attach_defaults(GTK_TABLE(table), text_id, 1, 2, 0, 1);
    gtk_table_attach_defaults(GTK_TABLE(table), label_place, 0, 1, 1, 2);
    gtk_table_attach_defaults(GTK_TABLE(table), text_place, 1, 2, 1, 2);
    gtk_table_attach_defaults(GTK_TABLE(table), label_name, 0, 1, 2, 3);
    gtk_table_attach_defaults(GTK_TABLE(table), text_name, 1, 2, 2, 3);
    gtk_table_attach_defaults(GTK_TABLE(table), label_passwd, 0, 1, 3, 4);
    gtk_table_attach_defaults(GTK_TABLE(table), text_passwd, 1, 2, 3, 4);
    gtk_table_attach_defaults(GTK_TABLE(table), label_keyname, 0, 1, 4, 5);
    gtk_table_attach_defaults(GTK_TABLE(table), text_keyname, 1, 2, 4, 5);
    gtk_table_attach_defaults(GTK_TABLE(table), button_build, 0, 1, 5, 6);
    gtk_widget_show_all(frame_build);
}

int main(int argc, char **argv)
{
    gtk_init(&argc, &argv);

    create_window();

    gtk_main();

    return 0;
}


If you're using 2.x, I'd recommend reading the GTK 2.0 tutorial rather than the 1.2 one:
http://library.gnome.org/devel/gtk-tutorial/stable/
you can also find other documentation here:
http://www.gtk.org/documentation.html
Back to top
lautarox
Familiar Face


Joined: 28 Aug 2008
Posts: 24

PostPosted: Fri Aug 29, 2008 4:30 pm    Post subject: Reply with quote

Yes, but I'm using it to create another window, on a menu clicking and I'm getting that error
I'm using now gtk+ 2.0
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Fri Aug 29, 2008 4:38 pm    Post subject: Reply with quote

can you post more/all of the code so that I can get a better idea of what's happening? thanks...
Back to top
lautarox
Familiar Face


Joined: 28 Aug 2008
Posts: 24

PostPosted: Fri Aug 29, 2008 5:21 pm    Post subject: Reply with quote

This is the one that's causing problems =S

Code: (C)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
void callback_main_button_settings( GtkObject *object ) {
GtkWidget *frame_settings;
GtkWidget *button_change;
GtkWidget *button_cancel;
GtkWidget *text_place;
GtkWidget *text_passwd;
GtkWidget *label_passwd;
GtkWidget *label_place;
GtkWidget *table_settings;
table_settings = gtk_table_new(3, 2, FALSE);
label_place = gtk_label_new("Place:");
label_passwd = gtk_label_new("Password:");
text_place = gtk_entry_new();
text_passwd = gtk_entry_new();
button_change = gtk_button_new_with_label ("Change");
button_cancel = gtk_button_new_with_label ("Cancel");
gtk_window_set_default_size(GTK_WINDOW(frame_settings), 400, 300);
gtk_window_set_title(GTK_WINDOW(frame_settings), "Change settings");
gtk_container_add(GTK_CONTAINER(frame_settings), table_settings);
gtk_table_attach_defaults(GTK_TABLE(table_settings), label_place, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(table_settings), text_place, 1, 2, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(table_settings), label_passwd, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(table_settings), text_passwd, 1, 2, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(table_settings), button_change, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(table_settings), button_cancel, 1, 2, 2, 3);
gtk_widget_show_all(frame_settings);
}
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 643
Location: Falun, WI USA

PostPosted: Fri Aug 29, 2008 5:29 pm    Post subject: Reply with quote

well, if that's your actual code, then the problem is coming from the fact that you never create frame_settings using gtk_window_new,
it's referenced a few times (starting on line 17 of the snippet) but it's never initialized.
if you compile with -Wall, gcc will probably tell you that
Back to top
lautarox
Familiar Face


Joined: 28 Aug 2008
Posts: 24

PostPosted: Fri Aug 29, 2008 5:38 pm    Post subject: Reply with quote

Lol, you are right, thanks =P
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP