Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 06-11-2009, 06:44 AM   #1
LQ Newbie
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
Question GTK-Critical error compiling a smart program (with menu)

First time sorry for my english is not soo good, i try to compile the next source :

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

gint destroyapp (GtkWidget *widget, gpointer gdata)
 return (FALSE);
gint ClosingAppWindow (GtkWidget *widget, gpointer gdata)
 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);

 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);

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

 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 !

Last edited by clarci; 06-11-2009 at 06:47 AM.
Old 06-18-2009, 03:58 PM   #2
Registered: Jul 2005
Location: maryland
Distribution: Ubuntu 9.04
Posts: 88

Rep: Reputation: 17
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.



critical, gtk, widget

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:03 PM
compiling gaim/ gtk error (two versions of gtk) webazoid Linux - Software 0 07-06-2004 06:05 PM
gtk error when tsclient drop down menu is clicked taoweijia Linux - Software 0 06-21-2004 08:10 PM
help with error compiling gtk+-2.4.0 Metal Martian Linux - Newbie 3 05-11-2004 09:04 AM
compiling kino, gtk test program cant run vance Linux - Software 1 06-02-2003 04:36 AM

All times are GMT -5. The time now is 06:42 AM.

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