获取错误Xlib:显示“:24.0”时缺少扩展名“RANDR”。 GTK

时间:2016-04-22 04:32:53

标签: c arrays button gtk parameter-passing

我收到此错误并且不确定原因...请看看我的按钮阵列,也许我搞砸了那里,我不确定... 我得到的错误是:Xlib: extension "RANDR" missing on display ":24.0". 之后没有任何反应,这意味着我的程序根本没有运行....

#include <gtk/gtk.h>

/* Our new improved callback.  The data passed to this function
 * is printed to stdout. */
static void callback (GtkWidget *widget, gpointer data)
{
    system ((gchar *) data);
}


/* another callback */
static gboolean delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
{
    gtk_main_quit ();
    return FALSE;
}

int main (int argc, char *argv[])
{
    /* GtkWidget is the storage type for widgets */
    GtkWidget *window;

    GtkWidget *box1;

    /* This is called in all GTK applications. Arguments are parsed
    * from the command line and are returned to the application. */
    gtk_init (&argc, &argv);

    /* Create a new window */
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

    /* This is a new call, which just sets the title of our
    * new window to "My Assignments" */
    gtk_window_set_title (GTK_WINDOW (window), "My Assignments");

    /* Here we just set a handler for delete_event that immediately
    * exits GTK. */
    g_signal_connect (window, "delete-event",
    G_CALLBACK (delete_event), NULL);

    /* Sets the border width of the window. */
    gtk_container_set_border_width (GTK_CONTAINER (window), 50);

    /* We create a box to pack widgets into.  This is described in detail
    * in the "packing" section. The box is not really visible, it
    * is just used as a tool to arrange widgets. */
    box1 = gtk_vbox_new (FALSE,0);

    /* Put the box into the main window. */
    gtk_container_add (GTK_CONTAINER (window), box1);

    /*array is here*/
    GtkWidget *button[2];
    int i;
    for (i=0; i<2; i++)
    {
        button[i]=gtk_button_new();
    }

    button[0] = gtk_button_new_with_label ("Run shellscript");

    g_signal_connect (button[0], "clicked",
    G_CALLBACK (callback), "shellscript");

    gtk_box_pack_start (GTK_BOX (box1), button[0], TRUE, TRUE, 0);

    gtk_widget_show(button[0]);

    button[1] = gtk_button_new_with_label ("Run program2 ");

    g_signal_connect (button[1], "clicked",
    G_CALLBACK (callback), "program");

    gtk_box_pack_start (GTK_BOX (box1), button[1], TRUE, TRUE, 0);

    gtk_widget_show(button[1]);

    gtk_widget_show (box1);
    /* Rest in gtk_main and wait for the fun to begin! */
    gtk_main ();

    return 0;
}

0 个答案:

没有答案