Problem with menu program



My menu.c program is given below

 

#include <stdio.h>

#include <unistd.h>

#include <gtk/gtk.h>

 

static gboolean button_press (GtkWidget *, GdkEvent *);

static void menuitem_response (gchar *);

 

//int main( int   argc,

  //        char **argv )

int main()

{

 

    GtkWidget *window;

    GtkWidget *menu;

    GtkWidget *menu_bar;

    GtkWidget *root_menu;

    GtkWidget *menu_items;

    GtkWidget *vbox;

    GtkWidget *button;

    char buf[128];

    int i;

 

    //gtk_init (&argc, &argv);

    gtk_init (NULL, NULL);

 

    /* create a new window */

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    //gtk_window_set_position (GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS);

    gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100);

   

    gtk_window_set_title (GTK_WINDOW (window), "GTK Menu Test");

   

    //g_signal_connect (G_OBJECT (window), "delete_event",

      //                G_CALLBACK (gtk_main_quit), NULL);

 

    menu = gtk_menu_new ();

 

    for (i = 0; i < 3; i++)

        {

                 sprintf (buf, "Test-undermenu - %d", i);

   

                 menu_items = gtk_menu_item_new_with_label (buf);

 

                 gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);

 

                 g_signal_connect_swapped (G_OBJECT (menu_items), "activate",

                                      G_CALLBACK (menuitem_response),

                                      (gpointer) g_strdup (buf));

                 gtk_widget_show (menu_items);

        }

 

   

    root_menu = gtk_menu_item_new_with_label ("Root Menu");

 

    gtk_widget_show (root_menu);

   

    gtk_menu_item_set_submenu (GTK_MENU_ITEM (root_menu), menu);

 

    vbox = gtk_vbox_new (FALSE, 0);

    gtk_container_add (GTK_CONTAINER (window), vbox);

    gtk_widget_show (vbox);

   

    menu_bar = gtk_menu_bar_new ();

    gtk_box_pack_start (GTK_BOX (vbox), menu_bar, FALSE, FALSE, 2);

    gtk_widget_show (menu_bar);

 

    button = gtk_button_new_with_label ("press me");

    g_signal_connect_swapped (G_OBJECT (button), "event",

                              G_CALLBACK (button_press),

                              G_OBJECT (menu));

    gtk_box_pack_end (GTK_BOX (vbox), button, TRUE, TRUE, 2);

   

    gtk_widget_show (button);

 

    gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), root_menu);

   

    gtk_widget_show (window);

 

    sleep (4);

    gtk_main ();

    return 0;

}

 

 

static gboolean button_press( GtkWidget *widget,

                              GdkEvent *event )

{

 

    if (event->type == GDK_BUTTON_PRESS) {

        GdkEventButton *bevent = (GdkEventButton *) event;

        gtk_menu_popup (GTK_MENU (widget), NULL, NULL, NULL, NULL,

                        bevent->button, bevent->time);

        return TRUE;

    }

 

    return FALSE;

}

 

 

 

static void menuitem_response( gchar *string )

{

    printf ("%s\n", string);

}

 

 

When I run the executable then I get following messages.

 

(*) DirectFB/Config: Parsing config file '/etc/directfbrc'.

 

       ---------------------- DirectFB v0.9.24 ---------------------

             (c) 2000-2002  convergence integrated media GmbH 

             (c) 2002-2004  convergence GmbH                  

        -----------------------------------------------------------

 

(*) DirectFB/Core: Single Application Core. (2006-12-29 05:00)

# # directfb-linux-xscale <Unofficial Build> Copyright (C) 2005 Intel Corporation

(*) DirectFB/Graphics: Intel GDL 12.0 (Intel)

(*) DirectFB/Core/WM: Default 0.2 (Convergence GmbH)

 (!!!)  *** UNIMPLEMENTED [fusion_reactor_set_lock] *** [reactor.c:797]

 

(<unknown>:1375): Gdk-CRITICAL **: gdk_drawable_set_colormap: assertion `cmap == NULL || gdk_drawable_get_depth (drawable) == cmap->visual->depth' failed

(*) Direct/Thread: Running 'EventBufferFeed' (MESSAGING, 1377)...

 

(<unknown>:1378): Gdk-DirectFB-WARNING **: gdk_window_set_keep_above() not implemented.

 

 

(<unknown>:1378): Gdk-DirectFB-WARNING **: gdk_window_set_keep_below() not implemented.

 

Gdk-DirectFB-ERROR **: file gdkkeys-directfb.c: line 1980 (gdk_keymap_get_for_display): assertion failed: (gdisplay->keymap != NULL)

aborting...

(!) [ 1378:    0.000] --> Caught signal 6 (sent by pid 1378, uid 0) <--

Killed 

 

 

Any idea about this?

 

Regards,

Ashish

 

 



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