操作系统课程设计报告 - 图文

G_CALLBACK(value_changed_callback), label); g_signal_connect(GTK_OBJECT(window), \

G_CALLBACK(gtk_main_quit), NULL);

gtk_widget_show_all(window); }

void create_CPU(GtkWidget* button, gpointer i) {

GtkWidget *window;

GtkWidget *drawing_area;

window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW(window), \ drawing_area = gtk_drawing_area_new ();

gtk_container_add (GTK_CONTAINER(window), drawing_area);

gtk_signal_connect(GTK_OBJECT (window), \

g_signal_connect( drawing_area, \ G_CALLBACK(Repaint), NULL );

gtk_drawing_area_size (GTK_DRAWING_AREA(drawing_area), 200, 100);

gtk_widget_show (drawing_area); gtk_widget_show_all(window);

timer = gtk_timeout_add (1000, Repaint, (gpointer) drawing_area); }

void select_row_callback(GtkWidget *clist,gint row,gint column,GdkEventButton *event,gpointer data)/*设置select_row信号的回调函数*/ {

gchar *text=NULL;

gtk_clist_get_text(GTK_CLIST(clist),row,column,&text); printf(\ }

void GetProInfo(void) {

char pp_info[50]; char buf_name[50]; char text1[4][50]; int i=0; int k=0;

strcpy(buf_name,\

strcpy(buf_name+strlen(\ strcpy(buf_name+strlen(buf_name),\ GetInfo(buf_name,pp_info); while(pp_info[i]!=' ') {

text1[0][i]=pp_info[i]; i++;

36

}

text1[0][i]='\\0';

//printf(\ while(pp_info[i]!='(') i++; i++;

while(pp_info[i]!=')') {

text1[1][k++]=pp_info[i++]; }

text1[1][k]='\\0';

//printf(\ i=i+2; k=0;

text1[2][0]=pp_info[i]; text1[2][1]='\\0';

//printf(\ i=i+2;

while(pp_info[i]!=' ') {

text1[3][k++]=pp_info[i++]; }

text1[3][k]='\\0';

//printf(\ }

void ShotDown(GtkWidget* button, gpointer i) {

system(\ return 0; }

void Open_it(GtkWidget* button1, gpointer aa) {

pid_t p1;

GtkTextIter start; GtkTextIter end;

gchar *text;

/* Obtain iters for the start and end of points of the buffer */ gtk_text_buffer_get_start_iter (buffer, &start); gtk_text_buffer_get_end_iter (buffer, &end);

/* Get the entire buffer text. */

text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); char buf[300]; strcpy(buf,\

strcpy(buf+strlen(buf),(char *)text); if((p1=fork()) == 0) {

execv(buf,NULL); }

p1=wait(&p1); }

37

void NewPro(GtkWidget* button1, gpointer aa) {

char buf0[300]; int i;

GtkWidget *window; GtkWidget *button; GtkWidget *box;

GtkWidget *text_view;

window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request(window,200,150);

g_signal_connect(GTK_OBJECT(window),\

box=gtk_vbox_new(FALSE,0); gtk_widget_show(box);

text_view=gtk_text_view_new();/*创建文本框构件*/ gtk_container_add(GTK_CONTAINER(window),box);

gtk_box_pack_start(GTK_BOX(box),text_view,FALSE,FALSE,0); buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_view)); gtk_widget_show(text_view);

button=gtk_button_new_with_label(\

gtk_box_pack_start(GTK_BOX(box),button,FALSE,FALSE,5);

gtk_signal_connect(GTK_OBJECT(button),\

gtk_widget_show_all(window); gtk_main(); }

int main(int argc, char* argv[]) { GtkWidget *window, *viewport, *vbox, *button; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window),\ g_signal_connect(G_OBJECT(window),\ G_CALLBACK(gtk_main_quit),NULL); gtk_container_set_border_width(GTK_CONTAINER(window),10); viewport = gtk_viewport_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(window),viewport); vbox = gtk_vbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(viewport),vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox),10); button = gtk_button_new_with_label(\ gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,3); g_signal_connect(G_OBJECT(button),\ G_CALLBACK(create_FindPro),GINT_TO_POINTER(2));

button = gtk_button_new_with_label(\ gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,3);

38

g_signal_connect(G_OBJECT(button),\ G_CALLBACK(create_CPU),NULL); button = gtk_button_new_with_label(\ gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,3); g_signal_connect(G_OBJECT(button),\ G_CALLBACK(create_MM),GINT_TO_POINTER(1)); button = gtk_button_new_with_label(\ gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,3); g_signal_connect(G_OBJECT(button),\ G_CALLBACK(create_sys),NULL);

button = gtk_button_new_with_label(\ gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,3); g_signal_connect(G_OBJECT(button),\ G_CALLBACK(NewPro),NULL);

button = gtk_button_new_with_label(\ gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,3); g_signal_connect(G_OBJECT(button),\ G_CALLBACK(ShotDown),NULL); gtk_widget_show_all(window); gtk_main(); return FALSE; }

39

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4