导航

managerLogin.c

Posted on 2015-01-20 13:40  Super_pan  阅读(138)  评论(0编辑  收藏  举报
#include <gtk/gtk.h>
 
void do_button1(GtkWidget *widget,gpointer data )
{
    //const gchar*uname;
    //uname=(gchar*)malloc(sizeof(gchar));
    //uname=gtk_entry_get_text(GTK_ENTRY(name));    /*获得录入构件正文*/
    //g_print(“Name:%s/n”,uname);
}
 
void do_button2(GtkWidget *widget,gpointer data )
{
    gtk_widget_hide(data);
}
 
int managerLogin(char* s)
{
   GtkWidget *window;
   GtkWidget *name;
   GtkWidget *password;
   GtkWidget *label1;
   GtkWidget *label2;
   GtkWidget *button1;
   GtkWidget *button2;
   GtkWidget *fixed = gtk_fixed_new();             //新建任意布局
   //GtkWidget *image = gtk_image_new_from_file("managerLogin.png");
 
   window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window),s);
   gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS );      //窗体居中
   gtk_window_set_default_size(GTK_WINDOW(window),370,250);
 
   label1=gtk_label_new("账  号");
   gtk_widget_set_size_request(label1,66,33);
   name= gtk_entry_new();
   gtk_widget_set_size_request(name,165,33);
 
   label2=gtk_label_new("密  码");
   gtk_widget_set_size_request(label2,66,33);
   password= gtk_entry_new();
   gtk_widget_set_size_request(password,165,33);
   gtk_entry_set_visibility(GTK_ENTRY(password),FALSE);      //密码不可见
 
   button1= gtk_button_new_with_label("登陆");          //登录
   gtk_widget_set_size_request(button1,66,33);
   button2= gtk_button_new_with_label("取消");          //取消
   gtk_widget_set_size_request(button2,66,33);
 
   g_signal_connect (G_OBJECT(button1),"clicked",G_CALLBACK(do_button1),(gpointer)window);
   g_signal_connect (G_OBJECT(button2),"clicked",G_CALLBACK(do_button2),(gpointer)window);
 
   //gtk_fixed_put(GTK_FIXED(fixed),image, 0, 0);         //添加窗体背景图片
   gtk_fixed_put(GTK_FIXED(fixed),label1, 54,41);
   gtk_fixed_put(GTK_FIXED(fixed),name,142,41);
   gtk_fixed_put(GTK_FIXED(fixed),label2,54,90);   
   gtk_fixed_put(GTK_FIXED(fixed),password,142,90);
   gtk_fixed_put(GTK_FIXED(fixed),button1,85, 154);
   gtk_fixed_put(GTK_FIXED(fixed),button2,202, 154);
 
   gtk_container_add(GTK_CONTAINER(window),fixed);
   gtk_widget_show_all(window);
 
   gtk_main ();

   return 0;
}