#include #include #include #include GtkWidget *xzvtterm, *xbutton, *zbutton, *xentry, *xlabel; GtkWidget *xwindow, *xtable, *xbox, *xframe; gchar *xusername; static void xf_login( GtkWidget *widget, gpointer data) { xusername = gtk_entry_get_text(GTK_ENTRY(xentry)); gtk_widget_grab_focus (xzvtterm); gtk_widget_show(xzvtterm); switch(zvt_term_forkpty(ZVT_TERM(xzvtterm), TRUE)) { case -1: perror("ERROR: unable to fork:"); exit(1); break; case 0: execlp("su","su","-",xusername,NULL); // execvp("who","who",NULL); break; } g_print(xusername); } void xf_exit(GtkButton *button, gpointer data) { zvt_term_closepty(ZVT_TERM(xzvtterm)); // gnome_appbar_set_status(GNOME_APPBAR(app_statusbar),_("Not connected")); // gnome_appbar_set_progress(GNOME_APPBAR(app_statusbar),0.0); zvt_term_reset(ZVT_TERM(xzvtterm), TRUE); } int main(int argc, char **argv) { gtk_init(&argc, &argv); // instantiate widgets xwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (xwindow), " My Secure Shell "); xtable = gtk_table_new(1,2,FALSE); // 2x2 table xbox = gtk_hbox_new( FALSE, 0); // create horizontal box xentry = gtk_entry_new (); xbutton = gtk_button_new_with_label(" Login "); zbutton = gtk_button_new_with_label(" Exit "); xlabel = gtk_label_new ("Username : "); xzvtterm = zvt_term_new_with_size(80,24); zvt_term_set_blink (ZVT_TERM (xzvtterm), TRUE); xframe = gtk_frame_new (" Secure Shell "); gtk_frame_set_label_align (GTK_FRAME (xframe), 0.5, 0.0); gtk_frame_set_shadow_type (GTK_FRAME (xframe), GTK_SHADOW_ETCHED_OUT); // pack widgets gtk_box_pack_start( GTK_BOX( xbox ), xlabel, TRUE, TRUE, 0); // pack buttons gtk_box_pack_start( GTK_BOX( xbox ), xentry, TRUE, TRUE, 0); // pack buttons gtk_box_pack_start( GTK_BOX( xbox ), xbutton, TRUE, TRUE, 0); // into boxm le gtk_box_pack_end( GTK_BOX( xbox ), zbutton, TRUE, TRUE, 0); // into boxm le // gtk_table_attach_defaults( GTK_TABLE(xtable), xbox, 0,1,0,1); // both lower quadrants gtk_table_attach( GTK_TABLE(xtable), xbox, 0,1,0,1, GTK_SHRINK,GTK_SHRINK, 10,10 ); // ULH, x1,x2,y1,y2 // URH, (table, child x1,x2,y1,y2,options, options, xpadding, ypadding) gtk_table_attach_defaults( GTK_TABLE(xtable), xzvtterm, 0,1,1,2); // both lower quadrants gtk_table_set_col_spacings( GTK_TABLE(xtable), 10 ); gtk_table_set_row_spacings( GTK_TABLE(xtable), 10 ); gtk_container_add (GTK_CONTAINER (xframe), xtable); gtk_container_add(GTK_CONTAINER (xwindow), xframe); // pack tbl into base window gtk_container_set_border_width(GTK_CONTAINER (xwindow), 20); /* gtk_widget_show (xzvtterm); gtk_widget_show(xbutton); gtk_widget_show(zbutton); gtk_widget_show(xentry); gtk_widget_show(xbox); gtk_widget_show(xtable); gtk_widget_show(xwindow); */ gtk_widget_show_all (xwindow); // event handling // g_signal_connect (G_OBJECT (xbutton), "clicked", G_CALLBACK (xf_login), NULL); gtk_signal_connect (GTK_OBJECT (xbutton),"clicked", GTK_SIGNAL_FUNC (xf_login), NULL); gtk_signal_connect (GTK_OBJECT (zbutton),"clicked", GTK_SIGNAL_FUNC (xf_exit), NULL); gtk_main (); gtk_exit(0); return 0; } /* rh8$ gcc `gnome-config --cflags --libs gtk zvt` -I /usr/include/gnome-1.0/ mysu-0.2.c rh7$ gcc `gnome-config --cflags --libs gtk zvt` term1.c $gcc `gnome-config --cflags --libs glib idl gnome gnomeui gnorba gtk zvt` mysu-0.1.c */