Missing gtk labels



Hello!

 

I am a newbe in using gtk. I have installed the gtk environment on my Windows XP platform. It is working fine but I have some problems. The buttons and menus I created do not have any lable. They are completely blank.

Further on I do have problems with printing out the Hello on my console when I press the button. Some chars occure: ~#Fe

Thank you for xour help.

 

 

My code looks like this:

#include <gtk/gtk.h>
#include <stdio.h>
#include <locale.h>
#include <libintl.h>


static void menuitem_response( gchar *string )
{
    printf ("%s\n", string);
}


GtkWidget * make_menu();


/* Window will be destroyed*/
static void destroy( GtkWidget *widget,
           &n! bsp;         gpointer   data )
{
    gtk_main_quit ();
}

 

int main( int   argc,
          char *argv[] )
{

    GtkWidget *window;
    GtkWidget *button;
 GtkWidget *menu;
 GtkWidget *vbox, *label;
   

    gtk_init (&argc, &argv);
   
 //setlocale(LC_CTYPE,"");
 //style  "gtk-default-iso-8859-2" {
      //  fontset = "-*-helvetica-medium-r-normal--18-*-*-*-*-*-iso8859-1,\
//                   -*-helvetica-medium-r-normal--12-*-*-*-*-*-iso8859-2"
 //}
 //class "GtkWidget" style "gtk-default-iso-8859-2" 

    window = gtk_! window_new (GTK_WINDOW_TOPLEVEL);
 gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100);
    gtk_window_set_title (GTK_WINDOW (window), "3D-Engine");
   

    g_signal_connect (G_OBJECT (window), "delete_event",
        G_CALLBACK (destroy), NULL);
   

    g_signal_connect (G_OBJECT (window), "destroy",
        G_CALLBACK (destroy), NULL);
   

   // gtk_container_set_border_width (GTK_CONTAINER (window), 10);
   

   
   
 
    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_add (GTK_CONTAINER (window), vbox);
    gtk_widget_show (vbox);


    menu = make_menu();
 gtk_box_pack_start (GTK_BOX (vbox), menu, FALSE, FALSE, 2);
 gtk_widget_show (menu);


 b! utton = gtk_button_new_with_label ("Hello");
 //button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);

    g_signal_connect (G_OBJECT (button), "clicked",
        G_CALLBACK (menuitem_response),(gpointer)"Hello");
 gtk_box_pack_end (GTK_BOX (vbox), button, TRUE, TRUE, 2);
    gtk_widget_show (button);
   
   
    gtk_widget_show (window);
   
   
    gtk_main ();
   
    return 0;
}

GtkWidget * make_menu(){
 
 GtkWidget *file_menu;
 GtkWidget *root_menu;
 GtkWidget *menu_bar;
    GtkWidget *open_item;
 GtkWidget *save_item;
 GtkWidget *quit_item;

 file_menu = gtk_menu_new ();    /* Don't need to show menus */

    /* ! Create the menu items */
    open_item = gtk_menu_it em_new_with_label (("Open"));
    save_item = gtk_menu_item_new_with_label ("Save");
    quit_item = gtk_menu_item_new_with_label ("Quit");

    /* Add them to the menu */
    gtk_menu_shell_append (GTK_MENU_SHELL (file_menu), open_item);
    gtk_menu_shell_append (GTK_MENU_SHELL (file_menu), save_item);
    gtk_menu_shell_append (GTK_MENU_SHELL (file_menu), quit_item);

    /* Attach the callback functions to the activate signal */
    g_signal_connect_swapped (G_OBJECT (open_item), "activate",
                              G_CALLBACK (menuitem_response),
                     &! nbsp;        (gpointer) "file.open");
    g_signal_connect_swapped (G_OBJECT (save_item), "activate",
                              G_CALLBACK (menuitem_response),
                              (gpointer) "file.save");
    g_signal_connect_swapped (G_OBJECT (quit_item), "activate",
                              G_CALLBACK (destroy),
                      &nb! sp;       (gpointer) "file.quit");

    /* We do need to show menu items */
    gtk_widget_show (open_item);
    gtk_widget_show (save_item);
    gtk_widget_show (quit_item);

 root_menu = gtk_menu_item_new_with_label ("File");
 gtk_widget_show (root_menu);

 gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), file_menu);

 menu_bar = gtk_menu_bar_new ();

 gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);
 
 return menu_bar;
}



Verschicken Sie romantische, coole und witzige Bilder per SMS!  
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]