LinuxQuestions.org
Visit Jeremy's Blog.
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

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

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


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 06:47 AM.
 
Old 06-18-2009, 03:58 PM   #2
kike_coello
Member
 
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.

Enrique
 
  


Reply

Tags
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 01:44 PM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration