#include<gtk/gtk.h>
static GtkWidget *entry;
void on_button_clicked(GtkButton *button,gpointer data)
{
const gchar *command;
command=gtk_entry_get_text(GTK_ENTRY(entry));
system(command);
}
int main(int argc,char *argv[])
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *scrolledwin;
GtkWidget *text;
GtkWidget *box;
GtkWidget *label;
gtk_init(&argc,&argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
gtk_window_set_title(GTK_WINDOW(window),"one qualifided window");
gtk_window_set_default_size(GTK_WINDOW(window),500,100);
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
text=gtk_text_view_new();
box=gtk_hbox_new(FALSE,0);
label=gtk_label_new("请输入:");
gtk_box_pack_start(GTK_BOX(box),label,FALSE,FALSE,0);
entry=gtk_entry_new();
gtk_box_pack_start(GTK_BOX(box),entry,FALSE,FALSE,0);
button=gtk_button_new_with_label("执行");
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(on_button_clicked),NULL);
gtk_box_pack_start(GTK_BOX(box),button,FALSE,FALSE,0);
//scrolledwin=gtk_scrolled_window_new(NULL,NULL);
// gtk_box_pack_start(GTK_BOX(box),scrolledwin,TRUE,TRUE,0);
//gtk_container_add(GTK_CONTAINER(scrolledwin),text);
//gtk_text_view_set_editable(GTK_TEXT_VIEW(text),TRUE);
gtk_container_add(GTK_CONTAINER(window),box);
gtk_widget_show_all(window);
gtk_main();
return FALSE;
}
图