LinuxQuestions.org
Have you heard the LinuxQuestions.org Podcast?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags , , , ,

Reply
 
Thread Tools
Old 06-11-2009, 07:44 AM   #1
clarci
LQ Newbie
 
Registered: Feb 2009
Posts: 2
Thanked: 0
Question GTK-Critical error compiling a smart program (with menu)


[Log in to get rid of this advertisement]
Hi
First time sorry for my english is not soo good, i try to compile the next source :

Code:
#include <gtk/gtk.h>
#include <glib.h>

gint destroyapp (GtkWidget *widget, gpointer gdata)
{
 gtk_main_quit();
 return (FALSE);
}
/*------------------------------------------------------------------*/
gint ClosingAppWindow (GtkWidget *widget, gpointer gdata)
{
gtk_main_quit();
 return (FALSE);
}
/*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/
int main (int argc, char *argv[])
{
 GtkWidget *window;
 GtkWidget *vbox;
 GtkWidget *menuFile = NULL;
 GtkWidget *menubar = NULL;
 GtkWidget *menu = NULL;
 GtkWidget *menuitem = NULL;

 gtk_init (&argc, &argv);
 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_signal_connect(GTK_OBJECT(window),"delete_event",GTK_SIGNAL_FUNC(destroyapp), NULL);
 vbox = gtk_vbox_new(FALSE,0);
 
 gtk_container_add(GTK_CONTAINER(window), vbox);
 gtk_window_set_default_size (GTK_WINDOW(window), 640, 200);

 /*FILE MENU*/
 menuFile = gtk_menu_item_new_with_label("File");
 gtk_menu_bar_append (GTK_MENU_BAR(menubar), menuFile);
 menu= gtk_menu_new();
 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuFile), menu);
 /*FILE MENU*/


 gtk_widget_show (vbox);
 gtk_widget_show (menu);
 gtk_widget_show (menuitem);
 gtk_widget_show (menubar);
 gtk_widget_show (window);
 gtk_widget_show(menuFile);

 gtk_main();
 return 0;
}
with commands:
g++ -Wall -g -c fdialog.c -export-dynamic `pkg-config --cflags --libs gtk+-2.0` `gtk-config --cflags` `gtk-config --libs`

g++ -o fdialog fdialog.o `pkg-config --cflags --libs gtk+-2.0` `gtk-config --cflags` `gtk-config --libs`

and it compile without errors, but when i try to run it, it can be run without menubar, and become this error message:

(fdialog:6369): Gtk-CRITICAL **: gtk_menu_shell_insert: assertion `GTK_IS_MENU_SHELL (menu_shell)' failed

(fdialog:6369): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed

(fdialog:6369): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed



is this a bug ? or how can i resolve this problem? maybe someone had the same problem.

Thanks for your help !
Robert

Last edited by clarci; 06-11-2009 at 07:47 AM..
clarci is offline  
Tag This Post , , , ,
Reply With Quote
Old 06-18-2009, 04:58 PM   #2
kike_coello
Member
 
Registered: Jul 2005
Location: maryland
Distribution: Ubuntu 9.04
Posts: 80
Thanked: 1
first of all, you have to add widgets to your boxes and then add the boxes to the final window, that's the last thing you gotta do when setting up your gui.

then you have to show only your window, which holds all your widgets, above you are showing all widgets independently.

lastly, i don't think you've added the menu widget to your window, so that might be the problem, you have declared and initialized it, but have not added to the gui.

i will post again after i have tried this myself when i get home.

hope that helps temporarily.

Enrique
kike_coello is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling error with GTK+ dantelives Linux - Software 1 06-21-2005 09:03 PM
compiling gaim/ gtk error (two versions of gtk) webazoid Linux - Software 0 07-06-2004 07:05 PM
gtk error when tsclient drop down menu is clicked taoweijia Linux - Software 0 06-21-2004 09:10 PM
help with error compiling gtk+-2.4.0 Metal Martian Linux - Newbie 3 05-11-2004 10:04 AM
compiling kino, gtk test program cant run vance Linux - Software 1 06-02-2003 05:36 AM


All times are GMT -5. The time now is 08:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration