赞
踩
caogaoxiang.c:
- #include <gtk/gtk.h>
- #include <string.h>
- #include "main.h"
- GtkWidget *window_receive;
- //char * name = "jack@123.com";
- /* 用于list view */
- enum ListCols
- {
- LIST_CHECKED,
- LIST_RECEIVER,
- LIST_SUBJECT,
- LIST_TIME
- };
-
- void select_show_caogao(GtkTreeSelection* select, gpointer data) //获得账号和发送时间发送给数据库
- {
- GtkTreeIter iter;
- GtkTreeModel* model;
- gchar* receiver;
- gchar* time1;
- gchar* subject;
- char buf[100]={"hiierjhejkhjkdfh"};
- //gchar* info;
- char request[50];
- int len;
- int i;
- memset(request,' ',sizeof(request));
-
- if(gtk_tree_selection_get_selected(select, &model, &iter))
- {
- gtk_tree_model_get(model, &iter, LIST_RECEIVER, &receiver,LIST_TIME,&time1,LIST_SUBJECT,&subject,-1);
- printf("%s\n",time1);
- request[0]='2';
- request[1]='3';
- len=strlen(name);
- request[2]=(char)len;
- for(i=0;i<len;i++){
- request[i+3]=name[i];
- }
- request[15]=26;
- for(i=0;i<26;i++){
- request[i+16]=time1[i];
- }
- //连接数据库,获得装有邮件内容的buf
- /**************************/
-
- window_show_caogao(receiver,subject,name,buf);///弹出邮件阅读窗口,显示邮件
-
- printf("%s\n",request);
- g_free(receiver);
- g_free(time1);
- }
- }
-
-
- GtkWidget * create_list_caogao()//创建显示草稿箱信息的列表
- {
-
- GtkWidget* vbox ;
-
- GtkTreeView* list;
- GtkListStore* list_store;
- GtkTreeIter iter;
- GtkCellRenderer* renderer;
- GtkTreeViewColumn* column;
- GtkTreeSelection* select;
- vbox = gtk_vbox_new (FALSE, 2);
-
- /* 创建ListView */
- list = gtk_tree_view_new();
- /* 创建ListView的model, 添加数据 */
- list_store = gtk_list_store_new(4,G_TYPE_BOOLEAN,
- G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
- //连接数据库,获得邮件列表
- /**************************/
-
-
- gtk_list_store_append(list_store, &iter);
- gtk_list_store_set(list_store, &iter,
- LIST_CHECKED,FALSE,
- LIST_RECEIVER, "KENBER",
- LIST_SUBJECT, "HHHHHHHHHHH",
- LIST_TIME,"2014年02月03日13时34分26秒" , -1);
- gtk_list_store_append(list_store, &iter);
- gtk_list_store_set(list_store, &iter,
- LIST_CHECKED,FALSE,
- LIST_RECEIVER, "guosiyu",
- LIST_SUBJECT, "uuuuuuu",
- LIST_TIME,"2012年02月07日13时34分26秒" , -1);
- gtk_tree_view_set_model(list, list_store);
- //g_object_unref(list_store);
-
- /* 创建ListView的View */
- renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes("选择", renderer,
- "active", LIST_CHECKED, NULL);
- column = gtk_tree_view_append_column(list, column);
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("收件人", renderer,
- "text", LIST_RECEIVER, NULL);
- column = gtk_tree_view_append_column(list, column);
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("主题", renderer,
- "text", LIST_SUBJECT, NULL);
- column = gtk_tree_view_append_column(list, column);
- column = gtk_tree_view_column_new_with_attributes("日期", renderer,
- "text", LIST_TIME, NULL);
- column = gtk_tree_view_append_column(list, column);
-
- //设置点击列表触发事件
- select = gtk_tree_view_get_selection(list);
- gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
- g_signal_connect(G_OBJECT(select), "changed",
- G_CALLBACK(select_show_caogao), NULL);
-
-
- gtk_box_pack_start(vbox, list, TRUE, TRUE, 1);
- return vbox;
- }
-
-
-
-
-
-
-
- GtkWidget *make_caogaoxiang()
- {
- // GtkWidget *window;
-
- GtkWidget *total_vbox;
- GtkWidget *table1;
-
- GtkWidget *button6;
- GtkWidget *button7;
- GtkWidget *button8;
- GtkWidget *button9;
- GtkWidget *button10;
- GtkWidget *button11;
-
- GtkWidget *label3;
- GtkWidget *label4;
- GtkWidget *entry1;
- GtkWidget *image;
- GtkWidget *vbox1;
-
-
- GtkWidget *hdimage;
- GtkWidget *label5;
- GtkWidget *label6;
- GtkWidget *label7;
- GtkWidget *label8;
- GtkWidget *label9;
-
- GtkWidget *show_box;
-
- int indx;
- GtkWidget *vbox;
- GtkWidget *scrolled_window, *clist;
-
-
- /*gtk_init (&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window), "GtkScrolledWindow");
- gtk_window_set_default_size(GTK_WINDOW(window), 320, 200);
-
- g_signal_connect_swapped(G_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit), NULL);*/
-
- total_vbox= gtk_vbox_new(FALSE,0);
- window_receive = gtk_scrolled_window_new (NULL, NULL);
-
- gtk_container_add (GTK_CONTAINER (total_vbox), window_receive);
-
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window_receive),GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
-
- table1 = gtk_table_new (15,8, TRUE);
-
- image=gtk_image_new_from_file("receive.png");
-
- label3 = gtk_label_new (g_locale_to_utf8("显示:", -1, NULL, NULL, NULL));
- label4 = gtk_label_new (g_locale_to_utf8("搜索:", -1, NULL, NULL, NULL));
-
- button6 = gtk_button_new_with_label(g_locale_to_utf8("回 复", -1, NULL, NULL, NULL));
- button7 = gtk_button_new_with_label(g_locale_to_utf8("转 发", -1, NULL, NULL, NULL));
- button8 = gtk_button_new_with_label(g_locale_to_utf8("删 除", -1, NULL, NULL, NULL));
- button9 = gtk_button_new_with_label(g_locale_to_utf8("标 记", -1, NULL, NULL, NULL));
- button10 = gtk_button_new_with_label(g_locale_to_utf8("全部信件", -1, NULL, NULL, NULL));
- button11 = gtk_button_new_with_label(g_locale_to_utf8("搜 索", -1, NULL, NULL, NULL));
- entry1 = gtk_entry_new ();
- //添加表格到窗口
- gtk_container_add(GTK_CONTAINER (window_receive), table1);
- //将元件分别添加到表格中
-
- //左半边
- gtk_table_attach (GTK_TABLE(table1), image, 4, 8, 9, 15,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
-
-
- gtk_table_attach (GTK_TABLE(table1), label3, 0, 1, 1, 2,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label4, 0, 1, 2, 3,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
-
- gtk_table_attach (GTK_TABLE(table1), button6, 0, 1, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button7, 1, 2, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button8, 2, 3, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button9, 3, 4, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button10,1, 2, 1, 2,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button11,3, 4, 2, 3,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), entry1,1, 3, 2, 3,
- GTK_FILL, GTK_FILL, 0, 0);
- //右半边
-
- hdimage=gtk_image_new_from_file("HD.png");
- label5 = gtk_label_new (g_locale_to_utf8(" 用户名: lzr", -1, NULL, NULL, NULL));
- label6 = gtk_label_new (g_locale_to_utf8(" 等级组: 小学生", -1, NULL, NULL, NULL));
- label7 = gtk_label_new (g_locale_to_utf8("个性签名:瓦格你好帅!!", -1, NULL, NULL, NULL));
- label8 = gtk_label_new (g_locale_to_utf8(" QQ : 保密 ", -1, NULL, NULL, NULL));
- label9 = gtk_label_new (g_locale_to_utf8("联系电话 : 保密 ", -1, NULL, NULL, NULL));
-
-
- gtk_table_attach (GTK_TABLE(table1), hdimage,4, 6, 0, 4,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label5, 5, 7, 1, 2,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label6, 5, 7, 2, 3,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label7, 3, 8, 4, 5,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label8, 3, 8, 5, 6,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label9, 3, 8, 6, 7,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
-
-
- //加入滚动列表框
- vbox=gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
- //gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
- gtk_table_attach (GTK_TABLE(table1), vbox,0, 4, 3, 15,
- GTK_FILL, GTK_FILL, 0, 0);
-
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
- gtk_widget_show (scrolled_window);
-
- show_box=gtk_vbox_new(FALSE, 5);
- show_box=create_list_caogao();
-
- gtk_container_add(GTK_CONTAINER(scrolled_window), show_box);
- /* gtk_signal_connect(GTK_OBJECT(clist), "select_row",
- GTK_SIGNAL_FUNC(selection_made),NULL
- );*/
-
- // gtk_widget_show_all (window);
- // gtk_main();
- return total_vbox;
-
- }
- //#include <gdk/gdkkeysyms>
- #include "main.h"
- #include <gtk/gtk.h>
- #include <stdio.h>
- #include <string.h>
- #include<stdlib.h>
- #include<sys/socket.h>
- #include<netinet/in.h>
- #include<arpa/inet.h>
- #include<netdb.h>
- #define i 10
- #define q 7
- #define p 101
- #define m 35
- /*全局变量****************************************************************************************/
- char* host_name="127.0.0.1";//"192.168.100.1";
- int port=8888;
- GtkWidget *entry1;//收件人gg
- GtkWidget *entry11;//密送gg
- GtkWidget *entry2;//主题gg
-
- char *text;
- static GtkWidget *window_color;
- static GdkColor color;
- static GtkWidget *drawarea;
- GtkWidget *view;//编辑窗口
- char name[20]="hjlhsa";//邮件地址gggggggggggggggggg
- const char *nickname="guosiyu";
- const char *weidu_number="3";
-
- //char weidu_number[10];
-
- /*函数声明*****************************************************************************************/
- int change_color ( );//改变颜色
- void on_ok_clicked (GtkButton* button, gpointer data);//改变颜色
- void cleanup();//清空重新编辑
- int change_ziti();//改变字体
- void on_font_select_ok (GtkWidget *button,GtkFontSelectionDialog *fs);
- void on_button_clicked (GtkWidget *button,gpointer userdata);
-
-
-
-
-
- /*得到收件人内容**********************************************************************gg*/
- void get_recer(char* re_name)
- {
- strcpy(re_name,gtk_entry_get_text(GTK_ENTRY(entry1)));
- }
- /*得到密送内容************************************************************************gg*/
- void get_misong(char* misong_name)
- {
- char misong[100];
- int k;
- int j=0;
- strcpy(misong,gtk_entry_get_text(GTK_ENTRY(entry11)));
- for(k=0;misong[k]!='\0';k++)
- {
- if(misong[k]==';')
- {
- misong_name[j]='*';
- j++;
- misong_name[j]=';';
- j++;
- }
- else
- {
- misong_name[j]=misong[k];
- j++;
- }
- }
- misong_name[j]='\0';
- }
- /*得到信得主题************************************************************************gg*/
- void get_title(char* title)
- {
- strcpy(title,gtk_entry_get_text(GTK_ENTRY(entry2)));
- }
- /*得到信主题内容**********************************************************************gg*/
- void get_text()
- {
- GtkTextBuffer *pTextBuffer ;
- GtkTextIter iterStart;
- GtkTextIter iterEnd;
- pTextBuffer=gtk_text_view_get_buffer(view);
- gtk_text_buffer_get_start_iter(pTextBuffer,&iterStart);
- gtk_text_buffer_get_end_iter(pTextBuffer,&iterEnd);
- text=(gchar *)gtk_text_buffer_get_text(pTextBuffer,&iterStart,&iterEnd,FALSE);
- printf("aaaaaaa\n");
- printf("%s\n",text);
- }
- /*得到本地时间***********************************************************************gg*/
- void get_time(char* time)
- {
-
- time=" ";
- }
-
-
-
- /*发送写信页面发送所有内容********************************************************************gggggggggggggggggggggg*/
- int xiexin_cbd()
- {
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- char buf[1024];
- memset(buf,0,sizeof(buf));
- /*传入数据库的各个字符串的拼接*********************************************************/
- char str[1024];//str表示拼接后的字符串
- memset(str,' ',sizeof(str));
- char time[10]="fdf";
- char re_name[100];
- char misong_name[100];
- char title[100];
- //char text[200];
- int count=0;
- int k,j;
- get_recer(re_name);
- get_misong(misong_name);
- get_title(title);
- get_text();
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- printf("%s",text);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- // get_time(time);
- //printf("str0:%s\n",str);
- str[0]='s';
- str[1]='2';//赋值2表示在发送
- str[2]=(char)strlen(name);//放发件人
- //printf("char c:%c\n",str[2]);
- for(k=0;name[k]!='\0';k++)
- {
- str[k+3]=name[k];
- }
- //printf("str:%s\n",str);
- str[15]=(char)strlen(time);//放本地时间
- for(k=0;time[k]!='\0';k++)
- {
- str[k+16]=time[k];
- }
- //printf("str:%s\n",str);
- str[42]=(char)strlen(title);//放标题
- for(k=0;title[k]!='\0';k++)
- {
- str[k+43]=title[k];
- }
- printf("str:%s\n",text);
- str[123]=(char)strlen(text);//放信的内容
- for(k=0;text[k]!='\0';k++)
- {
- str[k+124]=text[k];
- }
- printf("str:%s\n",str);
- strcat(re_name,misong_name);
- for(k=0;re_name[k]!='\0';k++)
- {
- if(re_name[k]==';')count++;
- }
- str[624]=(char)count;//收件人和密送人的总个数
- for(k=0;re_name[k]!='\0';k++)
- {
- str[k+625]=re_name[k];
- }
-
- printf("str:%s\n",str);
- printf("%d",count);
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- /*传入数据库的各个字符串的拼接结束*********************************************************/
-
-
- /*if(argc < 2)
- {
- printf("send default string.\n");
- }
- else
- {
- str=argv[1];
- }
- if((server_host_name=gethostbyname(host_name))==0)
- {
- herror("can not resoving localhost\n");
- exit(1);
- }*/
- int socket_descriptor;
- int temp_sock_descriptor;
- int size_of_addr;
- struct sockaddr_in sin;
- struct sockaddr_in pin;
- struct hostent * server_host_name;
- bzero(&pin, sizeof(pin));
- pin.sin_family=AF_INET;
- pin.sin_addr.s_addr = inet_addr("127.0.0.1");
- pin.sin_port=htons(port);
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if((socket_descriptor=socket(AF_INET, SOCK_STREAM, 0))==-1)
- {
- perror("error opening socket\n");
- exit(1);
- }
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if(connect(socket_descriptor, (void*)&pin, sizeof(pin))==-1)
- {
- perror("can not connecting to server\n");
- exit(1);
- }
-
- if(send(socket_descriptor, str, strlen(str), 0)==-1)
- {
- perror("can not send message\n");
- exit(1);
- }
-
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- memset(buf, 0, 1024);
- if(recv(socket_descriptor, buf, sizeof(buf), 0)<0)//==-1)
- {
- perror("can not receive response\n");
- exit(1);
- }
- else{
- printf("message received from server:%s\n",buf);
- }
- close(socket_descriptor);
- return 0;
-
-
- }
-
-
-
- /*草稿箱************************************************************************************/
- int caogao_cbd()
- {
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- char buf[1024];
- memset(buf,0,sizeof(buf));
- /*传入数据库的各个字符串的拼接*********************************************************/
- char str[1024];//str表示拼接后的字符串
- memset(str,' ',sizeof(str));
- char time[10]="fdf";
- char re_name[100];
- char misong_name[100];
- char title[100];
- //char text[200];
- int count=0;
- int k,j;
- get_recer(re_name);
- get_misong(misong_name);
- get_title(title);
- get_text();
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- printf("%s",text);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- // get_time(time);
- //printf("str0:%s\n",str);
- str[0]='s';
- str[1]='1';//赋值1表示在草稿箱
- str[2]=(char)strlen(name);//放发件人
- //printf("char c:%c\n",str[2]);
- for(k=0;name[k]!='\0';k++)
- {
- str[k+3]=name[k];
- }
- //printf("str:%s\n",str);
- str[15]=(char)strlen(time);//放本地时间
- for(k=0;time[k]!='\0';k++)
- {
- str[k+16]=time[k];
- }
- //printf("str:%s\n",str);
- str[42]=(char)strlen(title);//放标题
- for(k=0;title[k]!='\0';k++)
- {
- str[k+43]=title[k];
- }
- printf("str:%s\n",text);
- str[123]=(char)strlen(text);//放信的内容
- for(k=0;text[k]!='\0';k++)
- {
- str[k+124]=text[k];
- }
- printf("str:%s\n",str);
- strcat(re_name,misong_name);
- for(k=0;re_name[k]!='\0';k++)
- {
- if(re_name[k]==';')count++;
- }
- str[624]=(char)count;//收件人和密送人的总个数
- for(k=0;re_name[k]!='\0';k++)
- {
- str[k+625]=re_name[k];
- }
-
- printf("str:%s\n",str);
- printf("%d",count);
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- /*传入数据库的各个字符串的拼接结束*********************************************************/
-
-
- /*if(argc < 2)
- {
- printf("send default string.\n");
- }
- else
- {
- str=argv[1];
- }
- if((server_host_name=gethostbyname(host_name))==0)
- {
- herror("can not resoving localhost\n");
- exit(1);
- }*/
- int socket_descriptor;
- int temp_sock_descriptor;
- int size_of_addr;
- struct sockaddr_in sin;
- struct sockaddr_in pin;
- struct hostent * server_host_name;
- bzero(&pin, sizeof(pin));
- pin.sin_family=AF_INET;
- pin.sin_addr.s_addr = inet_addr("127.0.0.1");
- pin.sin_port=htons(port);
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if((socket_descriptor=socket(AF_INET, SOCK_STREAM, 0))==-1)
- {
- perror("error opening socket\n");
- exit(1);
- }
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if(connect(socket_descriptor, (void*)&pin, sizeof(pin))==-1)
- {
- perror("can not connecting to server\n");
- exit(1);
- }
-
- if(send(socket_descriptor, str, strlen(str), 0)==-1)
- {
- perror("can not send message\n");
- exit(1);
- }
-
- //printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- memset(buf, 0, 1024);
- if(recv(socket_descriptor, buf, sizeof(buf), 0)<0)//==-1)
- {
- perror("can not receive response\n");
- exit(1);
- }
- else{
- printf("message received from server:%s\n",buf);
- }
- close(socket_descriptor);
- return 0;
-
-
- }
-
-
-
- /*改变颜色*****************************************************************************/
-
- int change_color ( )
- {
- GtkWidget *vbox;
- GtkWidget *frame;
- GtkWidget *button;
- color.red = 0;
- color.blue = 65535;
- color.green = 0;
- window_color = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- g_signal_connect(G_OBJECT(window_color),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
- gtk_window_set_title(GTK_WINDOW(window_color),"选择颜色");
- gtk_window_set_position(GTK_WINDOW(window_color),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width(GTK_CONTAINER(window_color),20);
- vbox = gtk_vbox_new(FALSE,0);
- gtk_container_add(GTK_CONTAINER(window_color),vbox);
- frame = gtk_frame_new(NULL);
- gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_IN);
- gtk_box_pack_start(GTK_BOX(vbox),frame,TRUE,TRUE,5);
- drawarea = gtk_drawing_area_new();
- gtk_widget_set_size_request(drawarea,200,200);//kongjian daxiao
- gtk_widget_modify_bg (drawarea, GTK_STATE_NORMAL,&color);//kongjian beijing
- gtk_container_add(GTK_CONTAINER(frame),drawarea);
- button = gtk_button_new_from_stock(GTK_STOCK_SELECT_COLOR);
- gtk_box_pack_start(GTK_BOX(vbox),button,FALSE,FALSE,5);
- g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(on_ok_clicked),NULL);
- gtk_widget_show_all(window_color);
- gtk_main();
- return FALSE;
- }
- void on_ok_clicked (GtkButton* button, gpointer data)
- {
- GtkWidget *dialog;
- GtkColorSelection *colorsel;
- gint response;
- dialog = gtk_color_selection_dialog_new("选择颜色");
- gtk_window_set_transient_for (GTK_WINDOW (dialog),GTK_WINDOW (window_color));//注意:转换颜色选择对话框的颜色选择子控件
- colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel);
- gtk_color_selection_set_has_opacity_control(colorsel,TRUE);
- gtk_color_selection_set_has_palette(colorsel,TRUE);
- gtk_signal_connect(GTK_OBJECT(dialog),"destroy",GTK_SIGNAL_FUNC(gtk_widget_destroy),&dialog);
- gtk_color_selection_set_previous_color (colorsel, &color);
- gtk_color_selection_set_current_color (colorsel, &color);
- response = gtk_dialog_run(GTK_DIALOG(dialog));
- //注意:此处需要用戶判断对话框的运行结果,如果是确定按钮则改变颜色
- if(response == GTK_RESPONSE_OK)
- {
- gtk_color_selection_get_current_color (colorsel, &color);
- gtk_widget_modify_bg (drawarea, GTK_STATE_NORMAL, &color);
- GtkTextBuffer *pTextBuffer ;
- GtkTextIter iterStart;
- GtkTextIter iterEnd;
- pTextBuffer=gtk_text_view_get_buffer(view);
- gtk_text_buffer_get_start_iter(pTextBuffer,&iterStart);
- gtk_text_buffer_get_end_iter(pTextBuffer,&iterEnd);
- gtk_widget_modify_text(GTK_WIDGET(view),GTK_STATE_NORMAL,&color);//改变编辑框内文本颜色
-
- }
- gtk_widget_destroy(dialog);
- }
- /*****************************************************************************/
-
- /*改变字体******************************************************************************/
-
- void on_font_select_ok (GtkWidget *button,GtkFontSelectionDialog *fs)
- {
- PangoFontDescription *font_desc;///
- GtkWidget *dialog;
- gchar message[1024];
- gchar* ziti = gtk_font_selection_dialog_get_font_name(fs);
- font_desc = pango_font_description_from_string(ziti);
- sprintf(message,"你选择的字体是:%s \n",ziti);
- dialog = gtk_message_dialog_new(NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_OK,
- message,
- NULL);
- gtk_widget_destroy(GTK_WIDGET(fs));
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- GtkTextBuffer *pTextBuffer ;
- GtkTextIter iterStart;
- GtkTextIter iterEnd;
- pTextBuffer=gtk_text_view_get_buffer(view);
- gtk_text_buffer_get_start_iter(pTextBuffer,&iterStart);
- gtk_text_buffer_get_end_iter(pTextBuffer,&iterEnd);
- gtk_widget_modify_font(GTK_WIDGET(view), font_desc);/*/
- g_free(ziti);
- }
- void on_button_clicked (GtkWidget *button,gpointer userdata)
- {
- GtkWidget* dialog;
- dialog = gtk_font_selection_dialog_new("请选择一种字体:");
- gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER);
- gtk_signal_connect(GTK_OBJECT(dialog),"destroy",GTK_SIGNAL_FUNC(gtk_widget_destroy),&dialog);
- gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(dialog)->ok_button),"clicked",
- GTK_SIGNAL_FUNC(on_font_select_ok),GTK_FONT_SELECTION_DIALOG(dialog));
- gtk_signal_connect_object(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(dialog)->cancel_button),"clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(dialog));
- gtk_widget_show(dialog);
-
- }
- int change_ziti ( )
- {
- GtkWidget *window;
- GtkWidget *button;
- 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),"字体选择功能实现");
- //gtk_window_set_default_size(GTK_WINDOW(window),500,100);
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width(GTK_CONTAINER(window),40);
- button = gtk_button_new_with_label("按下此按钮来选择字体");
- g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(on_button_clicked),NULL);
- gtk_container_add(GTK_CONTAINER(window),button);
- gtk_widget_show(button);
- gtk_widget_show(window);
- gtk_main();
- return FALSE;
- }
- /*****************************************************************************************/
-
-
- /*清除重新编辑****************************************************************************/
- void cleanup()//GtkWidget *widget, gpointer view1)
- {
- char *text;/传递到数据库时使用
- GtkTextBuffer *pTextBuffer ;
- GtkTextIter iterStart;
- GtkTextIter iterEnd;
- pTextBuffer=gtk_text_view_get_buffer(view);
- gtk_text_buffer_get_start_iter(pTextBuffer,&iterStart);
- gtk_text_buffer_get_end_iter(pTextBuffer,&iterEnd);
- /*text=(gchar *)gtk_text_buffer_get_text(pTextBuffer,&iterStart,&iterEnd,FALSE);
- printf("%s\n",text);*/
- gtk_text_buffer_set_text(pTextBuffer,"\0",-1);
-
- }
-
-
-
-
-
- /*发送,存草稿,关闭的横盒******************************************************************/
- GtkWidget *make_box1( gboolean homogeneous, //写信
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("发送");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
- g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(xiexin_cbd),NULL);
-
- button = gtk_button_new_with_label ("存草稿");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
- g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(caogao_cbd),NULL);
-
-
- button = gtk_button_new_with_label ("关閉");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- return box;
- }
-
-
- GtkWidget *make_box2( gboolean homogeneous, //已发送
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("删除");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("彻底删除");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("转发");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("全部标记为已读");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- return box;
- }
-
- GtkWidget *make_box3( gboolean homogeneous, //已删除
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("彻底删除");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("转发");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("全部标记为已读");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
-
- return box;
- }
-
- /*GtkWidget *make_box4( gboolean homogeneous, //草稿箱
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- box = gtk_hbox_new (homogeneous, spacing);
-
-
- button = gtk_button_new_with_label ("删除草稿");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("转发");
- gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 2);
- gtk_widget_show (button);
-
- return box;
- }*/
-
-
- /*notebook部分函数**********************************************************************/
- void tabsborder_book( GtkButton *button,
- GtkNotebook *notebook )
- {
- gint bval = FALSE;
-
- if (notebook->show_border == 0)
- bval = TRUE;
-
- gtk_notebook_set_show_border (notebook, bval);
- }
-
- void delete(GtkWidget *widget,GtkWidget *event,gpointer data)
- {
- gtk_main_quit();
- }
- /*工具栏的函数******************************************************************/
- /*static void onDestroy( GtkWidget *widget, gpointer user_data)
- {
- gtk_main_quit();
- }*/
- // tianjia kucun ID gongju anniu
- GtkWidget * addStockToolItem(GtkWidget *toolbar, const gchar *stockid, const gchar *tooltip)
- {
- GtkToolItem *toolitem;
- toolitem = gtk_tool_button_new_from_stock(stockid);
- gtk_tool_item_set_tooltip_text(toolitem,tooltip);
- //jiang gong ju xiang cha ru gongju lan wei bu
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolitem,-1);
- gtk_widget_show(GTK_WIDGET(toolitem));
- return GTK_WIDGET(toolitem);
- }
- //tian jia fen ge gong ju xiang
- GtkWidget *addSeparatorToolItem(GtkWidget* toolbar)
- {
- GtkToolItem *toolitem;
- //chuang jian fen ge gong ju xiang
- toolitem = gtk_separator_tool_item_new();
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolitem,-1);
- gtk_widget_show(GTK_WIDGET(toolitem));
-
- return GTK_WIDGET(toolitem);
- }
- //tian jia gong ju xiang
- GtkWidget * addToolItem(GtkWidget* toolbar, const gchar *pLabel, const gchar *tooltip, const gchar *pImageFile)
-
- {
- GtkWidget *image = NULL;
- GtkToolItem *toolitem = NULL;
- //chuang jian tu pian gou jian
- image = gtk_image_new_from_file(pImageFile);
- gtk_widget_show(image);
- //chuang jian gong ju an niu
- toolitem = gtk_tool_button_new(image,pLabel);
- gtk_tool_item_set_tooltip_text(toolitem,tooltip);
- gtk_toolbar_insert(GTK_TOOLBAR(toolbar),toolitem,-1);
- gtk_widget_show(GTK_WIDGET(toolitem));
- return GTK_WIDGET(toolitem);
- }
-
-
-
-
- int main(int argc, char*argv[])
- {
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *notebook;
- GtkWidget *label;
- GtkWidget *checkbutton;
- char bufferf[32];
- char bufferl[32];
- GtkWidget *vbox0;//整个窗口纵盒
- GtkWidget *vbox;//整个窗口纵盒
- GtkWidget *vbox2;//整个窗口纵盒
- GtkWidget *vbox3;//整个窗口纵盒
- GtkWidget *vbox4;//整个窗口纵盒
- GtkWidget *vbox5;//整个窗口纵盒
- GtkWidget *vbox6;//整个窗口纵盒
- GtkWidget *vbox7;//整个窗口纵盒
- GtkWidget *bbox1;//收件人横盒
- GtkWidget *bbox11;//密送横盒
- GtkWidget *bbox2;//主题横盒
- GtkWidget *bbox3;//正文标签横盒
- GtkWidget *label1;
- GtkWidget *label11;//密送
- GtkWidget *label2;
- GtkWidget *label3;
- GtkWidget *box1;//发送,存草稿,关闭的横盒
- // GtkWidget *entry1;//收件人
- // GtkWidget *entry11;//密送
- // GtkWidget *entry2;//主题
- GtkWidget *toolbar;
- GtkWidget *toolitem;
- GtkWidget *handlebox;
- GtkWidget *frame;
- GtkWidget *tvbox;/
- GtkWidget *shouyehbox1;
- GtkWidget *shouyehbox2;
- GtkWidget *nullbox1;
- GtkWidget *nullbox2;
- GtkWidget *nullbox3;
-
-
- GtkWidget *boxx1;
- GtkWidget *labell;
- GtkWidget *boxxx1;
- GtkWidget *labelll;
- //GtkWidget *boxxxx1;
- GtkWidget *labellll;
-
-
- GtkWidget *weidu_eventbox;
- GtkWidget *shouye_label1;//标签晚上好
- GtkWidget *shouye_label2;//标签昵称
- GtkWidget *shouye_label3;//标签您有
- GtkWidget *shouye_label4;//标签未读邮件个数
- GtkWidget *shouye_label5;//封未读邮件
- //char greeting1[50];
- //char greeting2[50];
- char *greeting1=" 晚上好,";
- char *greeting2=" 您有";
- char* greeting3="封未读邮件";
- // strcpy(greeting1,"晚上好,");
- //strcpy(greeting2,"晚上好,");
-
-
-
-
- gtk_init(&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(GTK_WIDGET(window),550,500);
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
- gtk_window_set_title(GTK_WINDOW(window),"写信");
- vbox0 = gtk_vbox_new(FALSE,0);
- vbox = gtk_vbox_new(FALSE,0);
- vbox2 = gtk_vbox_new(FALSE,0);
- vbox3 = gtk_vbox_new(FALSE,0);
- //vbox4= gtk_vbox_new(FALSE,0);
- //vbox5 = gtk_vbox_new(FALSE,0);
- vbox6 = gtk_vbox_new(FALSE,0);
- vbox7 = gtk_vbox_new(FALSE,0);
- box1 = make_box1(FALSE,0,FALSE,FALSE,3); //写信
- boxx1 = make_box2(FALSE,0,FALSE,FALSE,3); //已发送
- boxxx1 = make_box3(FALSE,0,FALSE,FALSE,3); // 已删除
- //boxxxx1 = make_box4(FALSE,0,FALSE,FALSE,3); //草稿
- gtk_box_pack_start(GTK_BOX(vbox),box1,FALSE,FALSE,2);
- bbox1 = gtk_hbox_new(FALSE,0);
- bbox11 = gtk_hbox_new(FALSE,0);
- bbox2 = gtk_hbox_new(FALSE,0);
- bbox3 = gtk_hbox_new(FALSE,0);
- label1 = gtk_label_new("收件人");
- //gtk_misc_set_alignment(GTK_MISC(label1),0,0);/?????
- label11 = gtk_label_new("密送 ");
- label2 = gtk_label_new("主题 ");
- entry1 = gtk_entry_new();
- entry11 = gtk_entry_new();
- entry2 = gtk_entry_new();
-
-
- shouyehbox1=gtk_hbox_new(FALSE,0);
- shouyehbox2=gtk_hbox_new(FALSE,0);
- nullbox1=gtk_hbox_new(FALSE,10);
- nullbox2=gtk_hbox_new(FALSE,10);
- nullbox3=gtk_hbox_new(FALSE,10);
- weidu_eventbox= gtk_event_box_new();
- //sprintf(greeting1,nickname);
- //strcat(nickname,greeting1);
- //sprintf(greeting2,weidu_number);
-
-
-
-
-
- view = gtk_text_view_new();//涉及全局变量和环境变量
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view),GTK_WRAP_WORD_CHAR);
-
-
-
- /*首页盒子的排列************************************************************************************************/
- PangoFontDescription *font_desc = pango_font_description_from_string ("Serif 20");
- shouye_label1= gtk_label_new(greeting1);
- gtk_widget_modify_font(GTK_WIDGET(shouye_label1),font_desc );
- //gtk_label_set_markup(GTK_LABEL(shouye_label1),"<span foreground='black'font_desc='59'>(&greeting1) </span>");///
-
- shouye_label2= gtk_label_new(nickname);
- gtk_widget_modify_font(GTK_WIDGET(shouye_label2),font_desc );
- shouye_label3= gtk_label_new(greeting2);
- gtk_widget_modify_font(GTK_WIDGET(shouye_label3),font_desc );
- shouye_label4= gtk_label_new(weidu_number);
- gtk_widget_modify_font(GTK_WIDGET(shouye_label4),font_desc );
- shouye_label5= gtk_label_new(greeting3);
- gtk_widget_modify_font(GTK_WIDGET(shouye_label5),font_desc );
- /****************************************************************************************************************/
-
- gtk_container_add (GTK_CONTAINER (weidu_eventbox), shouye_label4);
- gtk_widget_set_events (weidu_eventbox, GDK_BUTTON_PRESS_MASK);
- //g_signal_connect(G_OBJECT (weidu_eventbox), "button_press_event",
- // G_CALLBACK (), vbox0 ); ///
- //gtk_widget_realize (weidu_eventbox);
- gdk_window_set_cursor (weidu_eventbox->window, gdk_cursor_new (GDK_HAND1));
-
-
-
- sprintf(bufferl,"已发送(共%d封)",q);
- labell = gtk_label_new(bufferl);
- gtk_label_set_justify(GTK_LABEL(labell),GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(vbox6),labell,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox6),boxx1,FALSE,FALSE,2);
-
- sprintf(bufferl,"已删除(共%d封)",p);
- labelll = gtk_label_new(bufferl);
- gtk_label_set_justify(GTK_LABEL(labelll),GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(vbox7),labelll,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox7),boxxx1,FALSE,FALSE,2);
- ///原草稿箱中的按钮
-
- /* sprintf(bufferl,"草稿箱(共%d封)",m);
- labellll = gtk_label_new(bufferl);
- gtk_label_set_justify(GTK_LABEL(labell),GTK_JUSTIFY_LEFT);
- gtk_box_pack_start(GTK_BOX(vbox5),labellll,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox5),boxxxx1,FALSE,FALSE,2);*/
-
-
-
-
-
-
- gtk_box_pack_start(GTK_BOX(bbox1),label1,FALSE,FALSE,0);//2
- gtk_box_pack_start(GTK_BOX(bbox1),entry1,TRUE,TRUE,0);
- gtk_box_pack_start(GTK_BOX(bbox11),label11,FALSE,FALSE,2);//3
- gtk_box_pack_start(GTK_BOX(bbox11),entry11,TRUE,TRUE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox1,FALSE,FALSE,2);//2fangru zonghe
- gtk_box_pack_start(GTK_BOX(vbox),bbox11,FALSE,FALSE,2);//3fangru zonghe
- gtk_box_pack_start(GTK_BOX(bbox2),label2,FALSE,FALSE,2);//4
- gtk_box_pack_start(GTK_BOX(bbox2),entry2,TRUE,TRUE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox2,FALSE,FALSE,2);//4fangru zonghe
-
-
-
- /*首页盒子的排列************************************************************************************************/
- gtk_box_pack_start(GTK_BOX(shouyehbox1),shouye_label1,FALSE,FALSE,2);//晚上好 昵称放横盒
- gtk_box_pack_start(GTK_BOX(shouyehbox1),shouye_label2,FALSE,FALSE,2);
-
- gtk_box_pack_start(GTK_BOX(shouyehbox2),shouye_label3,FALSE,FALSE,2);//您有n封未读邮件放横盒
- gtk_box_pack_start(GTK_BOX(shouyehbox2),weidu_eventbox,FALSE,FALSE,2);//数字n放事件盒
- gtk_box_pack_start(GTK_BOX(shouyehbox2),shouye_label5,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox0),nullbox1,FALSE,FALSE,10);
- gtk_box_pack_start(GTK_BOX(vbox0),nullbox2,FALSE,FALSE,10);
- gtk_box_pack_start(GTK_BOX(vbox0),nullbox3,FALSE,FALSE,10);
- gtk_box_pack_start(GTK_BOX(vbox0),shouyehbox1,FALSE,FALSE,2);//两个横盒放纵盒
- gtk_box_pack_start(GTK_BOX(vbox0),shouyehbox2,FALSE,FALSE,2);
-
- /***********************************************************************************************************/
-
-
-
-
- toolbar = gtk_toolbar_new();
- //shezhi gongju lan feng ge
- gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),GTK_TOOLBAR_ICONS);
- //shezhi gongjulan tubiao daxiao
- gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),GTK_ICON_SIZE_SMALL_TOOLBAR);
- handlebox = gtk_handle_box_new();
- gtk_container_add(GTK_CONTAINER(handlebox),toolbar);
-
- toolitem = addToolItem(toolbar, "font","清空重新编辑","xinjian.bmp");
- g_signal_connect(toolitem,"clicked",G_CALLBACK(cleanup),NULL);
- toolitem = addToolItem(toolbar, "font","附件","fujian.bmp");
- // g_signal_connect(toolitem,"clicked",G_CALLBACK(onCommand),(gpointer)CMD_OPEN);
- toolitem = addToolItem(toolbar, "font","字体","ziti.bmp");
- g_signal_connect(toolitem,"clicked",G_CALLBACK(on_button_clicked),NULL);
- toolitem = addToolItem(toolbar, "color","顏色","yanse.bmp");
- g_signal_connect(toolitem,"clicked",G_CALLBACK(on_ok_clicked),NULL);
- toolitem = addToolItem(toolbar, "paper","信纸","xinzhi.bmp");
- // g_signal_connect(toolitem,"clicked",G_CALLBACK(onCommand),(gpointer)CMD_QUIT);
- // GtkWidget *vbox;//整个窗口纵盒
-
- frame = gtk_frame_new("正文");
- gtk_widget_set_size_request(frame,50,500);
-
- tvbox = gtk_vbox_new(FALSE,0);
- gtk_box_pack_start(GTK_BOX(vbox),handlebox,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(vbox),frame,TRUE,TRUE,0);
- gtk_container_add(GTK_CONTAINER(frame),view);
-
-
-
-
-
-
-
-
- gtk_box_pack_start(GTK_BOX(vbox),tvbox,FALSE,FALSE,2);// gongjulan fang zonghe999999
-
- gtk_box_pack_start(GTK_BOX(vbox),bbox3,TRUE,TRUE,2);//zhengwen henghe fang zonghe
-
-
-
-
-
-
- //gtk_container_add(GTK_CONTAINER(window),vbox);
- //gtk_widget_show_all(vbox);
- //初始化GTK
- gtk_init(&argc,&argv);
- //创建最上层主窗口
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- //连接信号"delete_event",使得窗口关闭时发生
- g_signal_connect(G_OBJECT(window),"delete_event",GTK_SIGNAL_FUNC(delete),NULL);
- //设置窗口标题
- gtk_window_set_title(GTK_WINDOW(window),"wingmail");
- //设定窗口的默认宽高
- gtk_window_set_default_size(GTK_WINDOW(window),800,400);
- //设定窗口的位置,让窗口总在最前端
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- //设定容器边框的宽度
- gtk_container_set_border_width(GTK_CONTAINER(window),15);
-
- notebook = gtk_notebook_new();
- gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_LEFT);
- gtk_container_add(GTK_CONTAINER(window),notebook);
- gtk_widget_show(notebook);
-
- sprintf(bufferl,"已删除");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox7,label);
-
-
-
- sprintf(bufferl,"已发送");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox6,label);
-
- //草稿箱vbox5制作
- vbox5=make_caogaoxiang();
- sprintf(bufferl,"草稿箱(%d)",i);
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox5,label);
- 收件箱vbox4制作
- vbox4=make_receive_all();
- sprintf(bufferl,"收件箱(%d)",i);
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox4,label);
-
-
- sprintf(bufferl,"通讯录");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox3,label);
-
-
- sprintf(bufferl,"收信");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox2,label);
-
- sprintf(bufferl,"写信");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
- sprintf(bufferl,"首页");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox0,label);
-
- gtk_notebook_set_page(GTK_NOTEBOOK(notebook),0);
-
-
-
-
-
-
- gtk_widget_show(notebook);
- gtk_widget_show_all(window);
- gtk_main();
- return FALSE;
- }
-
-
- #include <gtk/gtk.h>
- #include <string.h>
- #include "main.h"
- GtkWidget *window_receive;
- //char name[20]="hjlhsa";//邮件地址gggggggggggggggggg
- /* 用于list view */
- enum ListCols
- {
- LIST_CHECKED,
- LIST_SENDER,
- LIST_SUBJECT,
- LIST_TIME
- };
-
- void select_show_letter(GtkTreeSelection* select, gpointer data) //获得sender和发送时间发送给数据库
- {
- GtkTreeIter iter;
- GtkTreeModel* model;
- gchar* sender;
- gchar* time1;
- gchar* subject;
- char buf[100]={"hiierjhejkhjkdfh"};
- //gchar* info;
- char request[50];
- int len;
- int i;
- memset(request,' ',sizeof(request));
-
- if(gtk_tree_selection_get_selected(select, &model, &iter))
- {
- gtk_tree_model_get(model, &iter, LIST_SENDER, &sender,LIST_TIME,&time1,LIST_SUBJECT,&subject,-1);
- printf("%s\n",time1);
- request[0]='2';
- request[1]='2';
- len=strlen(sender);
- request[2]=(char)len;
- for(i=0;i<len;i++){
- request[i+3]=sender[i];
- }
- request[15]=26;
- for(i=0;i<26;i++){
- request[i+16]=time1[i];
- }
- //连接数据库,获得装有邮件内容的buf
- /**************************/
-
- window_show_letter(sender,subject,time1,name,buf);///弹出邮件阅读窗口,显示邮件
-
- printf("%s\n",request);
- g_free(sender);
- g_free(time1);
- }
- }
-
-
- GtkWidget * create_list()//创建显示邮件信息的列表
- {
-
- GtkWidget* vbox ;
-
- GtkTreeView* list;
- GtkListStore* list_store;
- GtkTreeIter iter;
- GtkCellRenderer* renderer;
- GtkTreeViewColumn* column;
- GtkTreeSelection* select;
- vbox = gtk_vbox_new (FALSE, 2);
-
- /* 创建ListView */
- list = gtk_tree_view_new();
- /* 创建ListView的model, 添加数据 */
- list_store = gtk_list_store_new(4,G_TYPE_BOOLEAN,
- G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING);
- //连接数据库,获得邮件列表
- /**************************/
-
-
- gtk_list_store_append(list_store, &iter);
- gtk_list_store_set(list_store, &iter,
- LIST_CHECKED,FALSE,
- LIST_SENDER, "KENBER",
- LIST_SUBJECT, "HHHHHHHHHHH",
- LIST_TIME,"2014年02月03日13时34分26秒" , -1);
- gtk_list_store_append(list_store, &iter);
- gtk_list_store_set(list_store, &iter,
- LIST_CHECKED,FALSE,
- LIST_SENDER, "guosiyu",
- LIST_SUBJECT, "uuuuuuu",
- LIST_TIME,"2012年02月07日13时34分26秒" , -1);
- gtk_tree_view_set_model(list, list_store);
- //g_object_unref(list_store);
-
- /* 创建ListView的View */
- renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes("选择", renderer,
- "active", LIST_CHECKED, NULL);
- column = gtk_tree_view_append_column(list, column);
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("发件人", renderer,
- "text", LIST_SENDER, NULL);
- column = gtk_tree_view_append_column(list, column);
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("主题", renderer,
- "text", LIST_SUBJECT, NULL);
- column = gtk_tree_view_append_column(list, column);
- column = gtk_tree_view_column_new_with_attributes("日期", renderer,
- "text", LIST_TIME, NULL);
- column = gtk_tree_view_append_column(list, column);
-
- //设置点击列表触发事件
- select = gtk_tree_view_get_selection(list);
- gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
- g_signal_connect(G_OBJECT(select), "changed",
- G_CALLBACK(select_show_letter), NULL);
-
-
- gtk_box_pack_start(vbox, list, TRUE, TRUE, 1);
- return vbox;
- }
-
-
-
-
-
-
-
- GtkWidget *make_receive_all()
- {
- // GtkWidget *window;
-
- GtkWidget *total_vbox;
- GtkWidget *table1;
-
- GtkWidget *button6;
- GtkWidget *button7;
- GtkWidget *button8;
- GtkWidget *button9;
- GtkWidget *button10;
- GtkWidget *button11;
-
- GtkWidget *label3;
- GtkWidget *label4;
- GtkWidget *entry1;
- GtkWidget *image;
- GtkWidget *vbox1;
-
-
- GtkWidget *hdimage;
- GtkWidget *label5;
- GtkWidget *label6;
- GtkWidget *label7;
- GtkWidget *label8;
- GtkWidget *label9;
-
- GtkWidget *show_box;
-
- int indx;
- GtkWidget *vbox;
- GtkWidget *scrolled_window, *clist;
-
-
- /*gtk_init (&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window), "GtkScrolledWindow");
- gtk_window_set_default_size(GTK_WINDOW(window), 320, 200);
-
- g_signal_connect_swapped(G_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit), NULL);*/
-
- total_vbox= gtk_vbox_new(FALSE,0);
- window_receive = gtk_scrolled_window_new (NULL, NULL);
-
- gtk_container_add (GTK_CONTAINER (total_vbox), window_receive);
-
-
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window_receive),GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-
-
- table1 = gtk_table_new (15,8, TRUE);
-
- image=gtk_image_new_from_file("receive.png");
-
- label3 = gtk_label_new (g_locale_to_utf8("显示:", -1, NULL, NULL, NULL));
- label4 = gtk_label_new (g_locale_to_utf8("搜索:", -1, NULL, NULL, NULL));
-
- button6 = gtk_button_new_with_label(g_locale_to_utf8("回 复", -1, NULL, NULL, NULL));
- button7 = gtk_button_new_with_label(g_locale_to_utf8("转 发", -1, NULL, NULL, NULL));
- button8 = gtk_button_new_with_label(g_locale_to_utf8("删 除", -1, NULL, NULL, NULL));
- button9 = gtk_button_new_with_label(g_locale_to_utf8("标 记", -1, NULL, NULL, NULL));
- button10 = gtk_button_new_with_label(g_locale_to_utf8("全部信件", -1, NULL, NULL, NULL));
- button11 = gtk_button_new_with_label(g_locale_to_utf8("搜 索", -1, NULL, NULL, NULL));
- entry1 = gtk_entry_new ();
- //添加表格到窗口
- gtk_container_add(GTK_CONTAINER (window_receive), table1);
- //将元件分别添加到表格中
-
- //左半边
- gtk_table_attach (GTK_TABLE(table1), image, 4, 8, 9, 15,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
-
-
- gtk_table_attach (GTK_TABLE(table1), label3, 0, 1, 1, 2,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label4, 0, 1, 2, 3,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
-
- gtk_table_attach (GTK_TABLE(table1), button6, 0, 1, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button7, 1, 2, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button8, 2, 3, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button9, 3, 4, 0, 1,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button10,1, 2, 1, 2,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), button11,3, 4, 2, 3,
- (GtkAttachOptions)(0), (GtkAttachOptions)(0), 0, 0);
- gtk_table_attach (GTK_TABLE(table1), entry1,1, 3, 2, 3,
- GTK_FILL, GTK_FILL, 0, 0);
- //右半边
-
- hdimage=gtk_image_new_from_file("HD.png");
- label5 = gtk_label_new (g_locale_to_utf8(" 用户名: lzr", -1, NULL, NULL, NULL));
- label6 = gtk_label_new (g_locale_to_utf8(" 等级组: 小学生", -1, NULL, NULL, NULL));
- label7 = gtk_label_new (g_locale_to_utf8("个性签名:瓦格你好帅!!", -1, NULL, NULL, NULL));
- label8 = gtk_label_new (g_locale_to_utf8(" QQ : 保密 ", -1, NULL, NULL, NULL));
- label9 = gtk_label_new (g_locale_to_utf8("联系电话 : 保密 ", -1, NULL, NULL, NULL));
-
-
- gtk_table_attach (GTK_TABLE(table1), hdimage,4, 6, 0, 4,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label5, 5, 7, 1, 2,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label6, 5, 7, 2, 3,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label7, 3, 8, 4, 5,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label8, 3, 8, 5, 6,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
- gtk_table_attach (GTK_TABLE(table1), label9, 3, 8, 6, 7,(GtkAttachOptions)(0), (GtkAttachOptions)(0), 5, 5);
-
-
- //加入滚动列表框
- vbox=gtk_vbox_new(FALSE, 5);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
- //gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
- gtk_table_attach (GTK_TABLE(table1), vbox,0, 4, 3, 15,
- GTK_FILL, GTK_FILL, 0, 0);
-
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
- gtk_widget_show (scrolled_window);
-
- show_box=gtk_vbox_new(FALSE, 5);
- show_box=create_list();
-
- gtk_container_add(GTK_CONTAINER(scrolled_window), show_box);
- /* gtk_signal_connect(GTK_OBJECT(clist), "select_row",
- GTK_SIGNAL_FUNC(selection_made),NULL
- );*/
-
- // gtk_widget_show_all (window);
- // gtk_main();
- return total_vbox;
-
- }
- #include "main.h"
-
- GtkWidget *make_box11( gboolean homogeneous,
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("关閉");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("回复");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("转发");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("删除");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("彻底删除");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- return box;
- }
- GtkWidget *make_box12( gboolean homogeneous,
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("关閉");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("发送");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- /*button = gtk_button_new_with_label ("转发");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);*/
-
- button = gtk_button_new_with_label ("删除");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("彻底删除");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- return box;
- }
-
- void window_show_letter(gchar *sender,gchar *subject,gchar* time1,char *receiver,char *buf)///弹出邮件阅读窗口,显示邮件
- {
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *bbox1;
- GtkWidget *box1;
- GtkWidget *bbox2;
- GtkWidget *bbox3;
- GtkWidget *bbox4;
- GtkWidget *label1;
- GtkWidget *label2;
- GtkWidget *label3;
- GtkWidget *label4;
- GtkWidget *label5;
- GtkWidget *label6;
- GtkWidget *label7;
- GtkWidget *label8;
- //gtk_init(&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(GTK_WIDGET(window),550,500);
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- //g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
- gtk_window_set_title(GTK_WINDOW(window),"邮件内容");
- vbox = gtk_vbox_new(FALSE,0);
- box1 = make_box11(FALSE,0,FALSE,FALSE,3);
- gtk_box_pack_start(GTK_BOX(vbox),box1,FALSE,FALSE,2);
- bbox1 = gtk_hbox_new(FALSE,0);
- bbox2 = gtk_hbox_new(FALSE,0);
- bbox3 = gtk_hbox_new(FALSE,0);
- bbox4 = gtk_hbox_new(FALSE,0);
- label1 = gtk_label_new("主题: ");
- gtk_misc_set_alignment(GTK_MISC(label1),0,0);
- label2 = gtk_label_new("发件人:");
- label3 = gtk_label_new("时间: ");
- label4 = gtk_label_new("收件人:");
-
- label5 = gtk_label_new(subject);
- label6 = gtk_label_new(sender);
- label7 = gtk_label_new(time1);
- label8 = gtk_label_new(receiver);
-
- gtk_box_pack_start(GTK_BOX(bbox1),label1,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(bbox1),label5,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(vbox),bbox1,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox2),label2,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox2),label6,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox2,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox3),label3,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox3),label7,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox3,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox4),label4,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox4),label8,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox4,FALSE,FALSE,2);
-
-
-
- gtk_container_add(GTK_CONTAINER(window),vbox);
- gtk_widget_show_all(vbox);
- gtk_widget_show_all(window);
- //gtk_main();
- return 0;
- }
-
- void window_show_caogao(gchar *sender,gchar *subject,char *receiver,char *buf)///弹出邮件阅读窗口,显示邮件
- {
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *bbox1;
- GtkWidget *box1;
- GtkWidget *bbox2;
- GtkWidget *bbox3;
- GtkWidget *bbox4;
- GtkWidget *label1;
- GtkWidget *label2;
- //GtkWidget *label3;
- GtkWidget *label4;
- GtkWidget *label5;
- GtkWidget *label6;
- //GtkWidget *label7;
- GtkWidget *label8;
- //gtk_init(&argc, &argv);
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_widget_set_size_request(GTK_WIDGET(window),550,500);
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- //g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
- gtk_window_set_title(GTK_WINDOW(window),"邮件内容");
- vbox = gtk_vbox_new(FALSE,0);
- box1 = make_box12(FALSE,0,FALSE,FALSE,3);
- gtk_box_pack_start(GTK_BOX(vbox),box1,FALSE,FALSE,2);
- bbox1 = gtk_hbox_new(FALSE,0);
- bbox2 = gtk_hbox_new(FALSE,0);
- bbox3 = gtk_hbox_new(FALSE,0);
- bbox4 = gtk_hbox_new(FALSE,0);
- label1 = gtk_label_new("主题: ");
- gtk_misc_set_alignment(GTK_MISC(label1),0,0);
- label2 = gtk_label_new("发件人:");
- //label3 = gtk_label_new("时间: ");
- label4 = gtk_label_new("收件人:");
-
- label5 = gtk_label_new(subject);
- label6 = gtk_label_new(sender);
- //label7 = gtk_label_new(time1);
- label8 = gtk_label_new(receiver);
-
- gtk_box_pack_start(GTK_BOX(bbox1),label1,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(bbox1),label5,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(vbox),bbox1,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox2),label2,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox2),label6,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox2,FALSE,FALSE,2);
- //gtk_box_pack_start(GTK_BOX(bbox3),label3,FALSE,FALSE,2);
- //gtk_box_pack_start(GTK_BOX(bbox3),label7,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox3,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox4),label4,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox4),label8,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox4,FALSE,FALSE,2);
-
-
-
- gtk_container_add(GTK_CONTAINER(window),vbox);
- gtk_widget_show_all(vbox);
- gtk_widget_show_all(window);
- //gtk_main();
- return 0;
- }
main.h:
- #ifndef _ADD_H_
- #define _ADD_H_
- #include <gtk/gtk.h>
- #include <string.h>
-
-
-
- char name[20];
-
- void select_show_letter(GtkTreeSelection* select, gpointer data); //获得sender和发送时间发送给数据库
- GtkWidget * create_list();//创建显示邮件信息的列表
- void window_show_letter(gchar *sender,gchar *subject,gchar* time1,char *receiver,char *buf);///弹出邮件阅读窗口,显示邮件
- GtkWidget *make_box1( gboolean homogeneous,
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding ) ;
-
-
- //nootbook中的函数
-
- int change_color ( );//改变颜色
- void on_ok_clicked (GtkButton* button, gpointer data);//改变颜色
- void cleanup();//清空重新编辑
- int change_ziti();//改变字体
- void on_font_select_ok (GtkWidget *button,GtkFontSelectionDialog *fs);
- void on_button_clicked (GtkWidget *button,gpointer userdata);
- void get_recer(char* re_name);
- void get_misong(char* misong_name);
- void get_title(char* title);
- void get_text();
- void get_time(char* time);
- /*发送写信页面发送所有内容********************************************************************gggggggggggggggggggggg*/
- int xiexin_cbd();
- /*草稿箱************************************************************************************/
- int caogao_cbd();
- int change_color ( );
- void on_ok_clicked (GtkButton* button, gpointer data);
- /*改变字体******************************************************************************/
- void on_font_select_ok (GtkWidget *button,GtkFontSelectionDialog *fs);
- void on_button_clicked (GtkWidget *button,gpointer userdata);
- GtkWidget *make_box1( gboolean homogeneous, //写信
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding );
- GtkWidget *make_box2( gboolean homogeneous, //已发送
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding );
- GtkWidget *make_box3( gboolean homogeneous, //已删除
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding );
- /*GtkWidget *make_box4( gboolean homogeneous, //草稿箱
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding );*/
- /*notebook部分函数**********************************************************************/
- void tabsborder_book( GtkButton *button,
- GtkNotebook *notebook );
- void delete(GtkWidget *widget,GtkWidget *event,gpointer data);
-
- // tianjia kucun ID gongju anniu
- GtkWidget * addStockToolItem(GtkWidget *toolbar, const gchar *stockid, const gchar *tooltip);
- //tian jia fen ge gong ju xiang
- GtkWidget *addSeparatorToolItem(GtkWidget* toolbar);
- //tian jia gong ju xiang
- GtkWidget * addToolItem(GtkWidget* toolbar, const gchar *pLabel, const gchar *tooltip, const gchar *pImageFile);
- ///
- GtkWidget *make_receive_all();//制作收件箱包含在笔记本中的vbox
- GtkWidget *make_caogaoxiang();//制作草稿箱包含在笔记本中的vbox
- void select_show_caogao(GtkTreeSelection* select, gpointer data); //获得账号和发送时间发送给数据库
- void window_show_caogao(gchar *sender,gchar *subject,char *receiver,char *buf);///弹出草稿阅读窗口,显示邮件
- GtkWidget * create_list_caogao();//创建显示草稿箱信息的列表
- #endif
CC=gcc
INCLUDIR = ./include
all:
# gcc register.c -o register `pkg-config --cflags --libs gtk+-2.0`
gcc ./src/*.c -o login -I./include `pkg-config --cflags --libs gtk+-2.0`
# gcc main.c -o main `pkg-config --cflags --libs gtk+-2.0`
# gcc new.c -o new `pkg-config --cflags --libs gtk+-2.0`
- #include<gtk/gtk.h>
- #include<stdio.h>
- #include<string.h>
-
-
- #include<stdlib.h>
- #include<sys/socket.h>
- #include<netinet/in.h>
- #include<arpa/inet.h>
- #include<netdb.h>
-
- char* host_name="127.0.0.1";//"192.168.100.1";
- int port=8888;
- char name[20],nicheng[20],pass[20],pass1[20],tel[20];
- GtkWidget *entry_name;//邮件地址
- GtkWidget *entry_nicheng;//昵称
- GtkWidget *entry_pass;//密码
- GtkWidget *entry_pass1;//确认密码
- GtkWidget *entry_tel;//手机号
-
-
- /*调用连接数据库的函数**********************************************************************/
- int zhuce_cdb()
- {
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- char buf[1024];
- memset(buf,0,sizeof(buf));
- /*传入数据库的各个字符串的拼接*********************************************************/
- char str[1024];//str表示拼接后的字符串
- memset(str,' ',sizeof(str));
- printf("str0:%s\n",str);
- int i,j,a=11;
- str[0]='u';
- str[1]='0';
- str[2]=(char)strlen(name);
- printf("char c:%c\n",str[2]);
- for(i=0;name[i]!='\0';i++)
- {
- str[i+3]=name[i];
- }
- printf("str:%s\n",str);
- str[15]=(char)strlen(pass);
- for(i=0;pass[i]!='\0';i++)
- {
- str[i+16]=pass[i];
- }
- printf("str:%s\n",str);
- str[32]=(char)strlen(nicheng);
- for(i=0;nicheng[i]!='\0';i++)
- {
- str[i+33]=nicheng[i];
- }
- printf("str:%s\n",str);
- str[53]=(char)a;
- for(i=0;tel[i]!='\0';i++)
- {
- str[i+54]=tel[i];
- }
- printf("str:%s\n",str);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- /*传入数据库的各个字符串的拼接结束*********************************************************/
-
-
- /*if(argc < 2)
- {
- printf("send default string.\n");
- }
- else
- {
- str=argv[1];
- }
- if((server_host_name=gethostbyname(host_name))==0)
- {
- herror("can not resoving localhost\n");
- exit(1);
- }*/
- int socket_descriptor;
- int temp_sock_descriptor;
- int size_of_addr;
- struct sockaddr_in sin;
- struct sockaddr_in pin;
- struct hostent * server_host_name;
- bzero(&pin, sizeof(pin));
- pin.sin_family=AF_INET;
- pin.sin_addr.s_addr = inet_addr("127.0.0.1");
- pin.sin_port=htons(port);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if((socket_descriptor=socket(AF_INET, SOCK_STREAM, 0))==-1)
- {
- perror("error opening socket\n");
- exit(1);
- }
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if(connect(socket_descriptor, (void*)&pin, sizeof(pin))==-1)
- {
- perror("can not connecting to server\n");
- exit(1);
- }
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- printf("%c,%c,%c,%c\n",str[3],str[16],str[33],str[54]);
- if(send(socket_descriptor, str, strlen(str), 0)==-1)
- {
- perror("can not send message\n");
- exit(1);
- }
- printf("%c,%c,%c,%c\n",str[3],str[16],str[33],str[54]);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- memset(buf, 0, 1024);
- if(recv(socket_descriptor, buf, sizeof(buf), 0)<0)//==-1)
- {
- perror("can not receive response\n");
- exit(1);
- }
- else{
- printf("message received from server:%s\n",buf);
- }
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- close(socket_descriptor);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- return 0;
- }
- /*显示错误信息并跳出警告对话框*************************************************/
- void warning(char *warn)
- {
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *label; //错误信息的label
- GtkWidget *box;
- window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window),"警告");
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width (GTK_CONTAINER (window),100);
- label=gtk_label_new (warn);
- //gtk_label_set_markup(GTK_LABEL(label),"<span foreground='black'font_desc='16'>收信 </span>");
- //gtk_label_set_markup(GTK_LABEL(recive_label),"<span foreground='black'font_desc='16'>收信 </span>");
-
-
- button=gtk_button_new_with_label ("确定");
- box=gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box),label,FALSE,FALSE,3);
- gtk_box_pack_start(GTK_BOX(box),button,FALSE,FALSE,3);
- gtk_container_add (GTK_CONTAINER (window), box);
- gtk_widget_show_all(box);
- gtk_widget_show_all(window);
- g_signal_connect_swapped(G_OBJECT (button), "clicked",
- G_CALLBACK (gtk_widget_destroy), window);
- //return FALSE;
- }
-
- /*返回值是1时提示注册成功*************************************************/
- int success()
- {
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *label; //成功的label
- GtkWidget *box;
- window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window),NULL);
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width (GTK_CONTAINER (window),100);
- label=gtk_label_new ("恭喜,注册成功!");
- //gtk_label_set_markup(GTK_LABEL(rlabel),"<span foreground='black'font_desc='16'>恭喜,注册成功! </span>");
-
- button=gtk_button_new_with_label ("确定");
- box=gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box),label,FALSE,FALSE,3);
- gtk_box_pack_start(GTK_BOX(box),button,FALSE,FALSE,3);
- gtk_container_add (GTK_CONTAINER (window), box);
- gtk_widget_show_all(box);
- gtk_widget_show_all(window);
- g_signal_connect_swapped(G_OBJECT (button), "clicked",
- G_CALLBACK (gtk_main_quit), window);
- return FALSE;
- }
- /*返回值是0时提示邮件地址重复*************************************************/
- int fail()
- {
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *label; //用户名重复的label
- GtkWidget *box;
- window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window),NULL);
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width (GTK_CONTAINER (window),100);
- label=gtk_label_new ("对不起,邮件地址已存在,请更换新的邮件地址");
- //gtk_label_set_markup(GTK_LABEL(label),"<span foreground='black'font_desc='16'>对不起,邮件地址已存在,请更换新的邮件地址</span>");
-
- button=gtk_button_new_with_label ("确定");
- box=gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box),label,FALSE,FALSE,3);
- gtk_box_pack_start(GTK_BOX(box),button,FALSE,FALSE,3);
- gtk_container_add (GTK_CONTAINER (window), box);
- gtk_widget_show_all(box);
- gtk_widget_show_all(window);
- g_signal_connect_swapped(G_OBJECT (button), "clicked",
- G_CALLBACK (gtk_widget_destroy), window);
- return FALSE;
-
- }
-
- /*点击重置按钮后重置*******************************************************/
- void chongzhi(GtkWidget *widget)
- {
- gtk_entry_set_text(GTK_ENTRY(entry_name),"");
- gtk_entry_set_text(GTK_ENTRY(entry_nicheng),"");
- gtk_entry_set_text(GTK_ENTRY(entry_pass),"");
- gtk_entry_set_text(GTK_ENTRY(entry_pass1),"");
- gtk_entry_set_text(GTK_ENTRY(entry_tel),"");
- }
- /*点击提交按钮,判断无误后提交,调用传给数据库的函数*************************/
- int tijiao(GtkWidget *widget)
- {
- int i,l;
- char* warn=NULL;
- strcpy(name,gtk_entry_get_text(GTK_ENTRY(entry_name)));
- strcpy(nicheng,gtk_entry_get_text(GTK_ENTRY(entry_nicheng)));
- strcpy(pass,gtk_entry_get_text(GTK_ENTRY(entry_pass)));
- strcpy(pass1,gtk_entry_get_text(GTK_ENTRY(entry_pass1)));
- strcpy(tel,gtk_entry_get_text(GTK_ENTRY(entry_tel)));
- /*判断各个entry是否为空*******************/
- if(strlen(name)==0)
- {
- warn="邮件地址不能为空";
- warning(warn);
- return 0;
- }
- else if(strlen(nicheng)==0)
- {
- warn="昵称不能为空";
- warning(warn);
- return 0;
- }
- else if(strlen(pass)==0)
- {
- warn="密码不能为空";
- warning(warn);
- return 0;
- }
- else if(strlen(pass1)==0)
- {
- warn="确认密码不能为空";
- warning(warn);
- return 0;
- }
- else if(strlen(tel)==0)
- {
- warn="手机号不能为空";
- warning(warn);
- return 0;
- }
- else //当内容都不为空时,开始检验输入是否合法
- {
- for(i=0;i<strlen(name);)//判断name内容是否符合要求
- {
- if(strlen(name)<6||strlen(name)>12){warn="邮件地址输入不符合要求";warning(warn);return 0;}
- else if((name[i]>='A'&&name[i]<='Z')||(name[i]>='a'&&name[i]<='z')||(name[i]>='0'&&name[i]<='9')||name[i]=='_')
- {
- i++;
- }
- else
- {
- warn="邮件地址输入不符合要求";
- warning(warn);
- return 0;
- }
- }
- for(i=0;i<strlen(nicheng);)//判断nicheng内容是否符合要求
- {
- if(strlen(nicheng)<3||strlen(nicheng)>10){warn="昵称输入不符合要求";warning(warn);return 0;}
- else if((nicheng[i]>='A'&&nicheng[i]<='Z')||(nicheng[i]>='a'&&nicheng[i]<='z')||(nicheng[i]>='0'&&nicheng[i]<='9')||nicheng[i]=='_')
- {
- i++;
- }
- else
- {
- warn="昵称输入不符合要求";
- warning(warn);
- return 0;
- }
- }
-
- for(i=0;i<strlen(pass);)//判断pass内容是否符合要求
- {
- if(strlen(pass)<6||strlen(pass)>16){warn="密码输入不符合要求";warning(warn);return 0;}
- else if((pass[i]>='A'&&pass[i]<='Z')||(pass[i]>='a'&&pass[i]<='z')||(pass[i]>='0'&&pass[i]<='9')||pass[i]=='_')
- {
- i++;
- }
- else
- {
- warn="密码输入不符合要求";
- warning(warn);
- return 0;
- }
- }
- for(i=0;i<strlen(pass);)//判断pass1内容是否符合与pass一致
- {
- if(pass1[i]==pass[i])
- {
- i++;
- }
- else
- {
- warn="两次输入密码不一致";
- warning(warn);
- return 0;
- }
- }
- for(i=0;i<strlen(tel);)//判断tel内容是否符合要求
- {
- if(strlen(tel)==11&&tel[i]>='0'&&tel[i]<='9')
- {
- i++;
- }
- else
- {
- warn="手机号输入不符合要求";
- warning(warn);
- return 0;
- }
- }
-
- }//当内容都不为空时,开始检验输入是否合法
- /*调用连接数据库的函数****************************/
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- zhuce_cdb();
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- }
-
- int main(int argc ,char *argv[])//此函数中1,2,3,4,5分别代表5行
- {
- GtkWidget *window;
- GtkWidget *totalbox;
- GtkWidget *hbox1;
- GtkWidget *hbox2;
- GtkWidget *hbox3;
- GtkWidget *hbox4;
- GtkWidget *hbox5;
- GtkWidget *hbox6;
- GtkWidget *ybutton;//提交按钮
- GtkWidget *nbutton;//重置
- GtkWidget *label11;
- GtkWidget *label12;
- GtkWidget *label21;
- GtkWidget *label22;
- GtkWidget *label31;
- GtkWidget *label32;
- GtkWidget *label41;
- GtkWidget *label42;
- GtkWidget *label51;
- GtkWidget *label52;
- GtkWidget *name_entry;
- GtkWidget *nicheng_entry;
- GtkWidget *pass_entry;
- GtkWidget *pass1_entry;
- GtkWidget *tel_entry;
- gtk_init(&argc,&argv);
-
- window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (window),150);
- g_signal_connect(G_OBJECT(window),"delete_event",
- G_CALLBACK(gtk_main_quit),NULL);
-
- gtk_window_set_title(GTK_WINDOW(window),"用戶注冊");
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- /* 设置窗口边框的宽度。*/
- gtk_container_set_border_width (GTK_CONTAINER (window),90);
- /* 整个盒为一个纵盒,將纵盒装入窗口*/
- totalbox=gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (window), totalbox);
- hbox1=gtk_hbox_new (FALSE, 0);
- hbox2=gtk_hbox_new (FALSE, 6);
- hbox3=gtk_hbox_new (FALSE, 6);
- hbox4=gtk_hbox_new (FALSE, 0);
- hbox5=gtk_hbox_new (FALSE, 1);
- hbox6=gtk_hbox_new (FALSE, 80);
-
- label11=gtk_label_new("*邮件地址");
- label12=gtk_label_new("6~12个数字字母下划线组成");
- label21=gtk_label_new("*呢称 ");
- label22=gtk_label_new("3~10个数字字母下划线组成");
- label31=gtk_label_new("*密码 ");
- label32=gtk_label_new("6~16个數字字母下划线组成");
- label41=gtk_label_new("*确认密码");
- label42=gtk_label_new("再次输入以确认密码");
- label51=gtk_label_new("*手机号 ");
- label52=gtk_label_new("以便找回时使用");
-
- entry_name=name_entry=gtk_entry_new();
- //gtk_entry_set_text(GTK_ENTRY(name_entry),FALSE);
- entry_nicheng=nicheng_entry=gtk_entry_new();
- //gtk_entry_set_text(GTK_ENTRY(nicheng_entry),FALSE);
- entry_pass=pass_entry=gtk_entry_new();
- gtk_entry_set_visibility(GTK_ENTRY(pass_entry),FALSE);
- entry_pass1=pass1_entry=gtk_entry_new();
- gtk_entry_set_visibility(GTK_ENTRY(pass1_entry),FALSE);
- entry_tel=tel_entry=gtk_entry_new();
- //gtk_entry_set_text(GTK_ENTRY(tel_entry),FALSE);
- ybutton = gtk_button_new_with_label ("提交");
- nbutton = gtk_button_new_with_label ("重置");
-
- gtk_box_pack_start(GTK_BOX(hbox1),label11,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox1),entry_name,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox1),label12,FALSE,FALSE,10);
-
- gtk_box_pack_start(GTK_BOX(hbox2),label21,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox2),entry_nicheng,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox2),label22,FALSE,FALSE,5);
-
- gtk_box_pack_start(GTK_BOX(hbox3),label31,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox3),entry_pass,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox3),label32,FALSE,FALSE,5);
-
- gtk_box_pack_start(GTK_BOX(hbox4),label41,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox4),entry_pass1,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox4),label42,FALSE,FALSE,9);
-
- gtk_box_pack_start(GTK_BOX(hbox5),label51,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox5),entry_tel,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(hbox5),label52,FALSE,FALSE,9);
-
- gtk_box_pack_start(GTK_BOX(hbox6),ybutton,FALSE,FALSE,90);
- gtk_box_pack_start(GTK_BOX(hbox6),nbutton,FALSE,FALSE,5);
-
- gtk_box_pack_start(GTK_BOX(totalbox),hbox1,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(totalbox),hbox2,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(totalbox),hbox3,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(totalbox),hbox4,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(totalbox),hbox5,FALSE,FALSE,5);
- gtk_box_pack_start(GTK_BOX(totalbox),hbox6,FALSE,FALSE,50);
- g_signal_connect(G_OBJECT(nbutton), "clicked",G_CALLBACK(chongzhi), NULL);
- g_signal_connect(G_OBJECT(ybutton), "clicked",G_CALLBACK(tijiao), NULL);
- gtk_widget_show_all(window);
- gtk_main();
- return FALSE;
-
- }
- #include <gtk/gtk.h>
- #include <string.h>
- #include<stdio.h>
- #include<stdlib.h>
- #include<sys/socket.h>
- #include<netinet/in.h>
- #include<arpa/inet.h>
- #include<netdb.h>
- //int sign=1;
- /*typedef struct
- {
- char name[20];
- char pass[20];
- }info;
- info *information;*/
- GtkWidget *entry_name;
- GtkWidget *entry_pass;
- GtkWidget *window_all;
-
- char* host_name="127.0.0.1";//"192.168.100.1";
- int port=9999;
-
- GtkWidget *make_box1( gboolean homogeneous,
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("发送");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("存草稿");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("关閉");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- return box;
- }
- GtkWidget *make_box2( gboolean homogeneous,
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("添加抄送");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("添加密送");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- return box;
- }
- GtkWidget *make_box3( gboolean homogeneous,
- gint spacing,
- gboolean expand,
- gboolean fill,
- guint padding )
- {
- GtkWidget *box;
- GtkWidget *button;
- char padstr[80];
-
- /* 以合适的 homogeneous 和 spacing 设置创建一个新的横向盒 */
- box = gtk_hbox_new (homogeneous, spacing);
-
- /* 以合适的设置创建一系列的按钮 */
- button = gtk_button_new_with_label ("添加附件");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
- button = gtk_button_new_with_label ("格式");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
-
-
- button = gtk_button_new_with_label ("信纸");
- gtk_box_pack_start (GTK_BOX (box), button, expand, fill, padding);
- gtk_widget_show (button);
- return box;
- }
-
- void tabsborder_book( GtkButton *button,
- GtkNotebook *notebook )
- {
- gint bval = FALSE;
-
- if (notebook->show_border == 0)
- bval = TRUE;
-
- gtk_notebook_set_show_border (notebook, bval);
- }
- void delete(GtkWidget *widget,GtkWidget *event,gpointer data)
- {
- gtk_main_quit();
- }
-
-
-
- void quit( GtkWidget *widget, gpointer data )
- {
- g_print ("Hello World\n");
- }
-
- int compare(char *name,char *pass)//將用戶名和密码与数据库中的相对比,合法返回1,不合法返回0
- {
- int sign=0;
- printf("name:%s\n",name);
- printf("pass:%s\n",pass);
- char buf[8192];
- char str[1024];//str表示拼接后的字符串
- memset(str,' ',sizeof(str));
- memset(buf,0,sizeof(buf));
- int socket_descriptor;
- int temp_sock_descriptor;
- int size_of_addr;
- struct sockaddr_in sin;
- struct sockaddr_in pin;
- struct hostent * server_host_name;
- bzero(&pin, sizeof(pin));
- pin.sin_family=AF_INET;
- pin.sin_addr.s_addr = inet_addr("127.0.0.1");
- pin.sin_port=htons(port);
-
- str[0]='u';
- str[1]='1';
- int i=0,l=0;
- l=strlen(name);
- printf("len_name:%d\nname:",l);
- str[2]=(char)l;
- for(i=3;i<l+3;i++){
- str[i]=name[i-3];
- printf("%c",str[i]);
- }
- printf("\n");
- l=strlen(pass);
- printf("len_pass:%d\npassword:",l);
- str[15]=(char)l;
- for(i=16;i<l+16;i++){
- str[i]=pass[i-16];
- printf("%c",str[i]);
- }
- printf("\n");
- printf("str:%s\n",str);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if((socket_descriptor=socket(AF_INET, SOCK_STREAM, 0))==-1)
- {
- perror("error opening socket\n");
- exit(1);
- }
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if(connect(socket_descriptor, (void*)&pin, sizeof(pin))==-1)
- {
- perror("can not connecting to server\n");
- exit(1);
- }
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- if(send(socket_descriptor, str, strlen(str), 0)==-1)
- {
- perror("can not send message\n");
- exit(1);
- }
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- memset(buf, 0, 8192);
- if(recv(socket_descriptor, buf, sizeof(buf), 0)<0)//==-1)
- {
- perror("can not receive response\n");
- exit(1);
- }
- else{
- printf("message received from server:%s\n",buf);
- if(strcmp(buf,"login_success")==0){
- sign=1;
- }
- else{
- sign=0;
- }
- }
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- close(socket_descriptor);
- printf("[%s, %s, %d]\n", __FILE__, __FUNCTION__, __LINE__);
- return sign;
- }
-
- void log_in( GtkWidget *widget,gpointer data )
- {
- char name[20];
- char pass[20];
- int sign=0;
- strcpy(name,gtk_entry_get_text(GTK_ENTRY(entry_name)));
- strcpy(pass,gtk_entry_get_text(GTK_ENTRY(entry_pass)));
- sign=compare(name,pass);
- if(sign)//登入主界面
- {
-
- /*.......*/
- GtkWidget *window;
- GtkWidget *table;
- GtkWidget *logo;
- GtkWidget *name_label;
- GtkWidget *out_event_box;
- GtkWidget *out_label;
- GtkWidget *temp_label;
- GtkWidget *settings_label;
- GtkWidget *settings_event_box;
- GtkWidget *change_event_box;
- GtkWidget *change_label;
- GtkWidget *write_image;
- GtkWidget *write_label;
- GtkWidget *write_event_box;
- GtkWidget *recive_label;
- GtkWidget *recive_image;
- GtkWidget *recive_event_box;
- GtkWidget *contactor_image;
- GtkWidget *contactor_label;
- GtkWidget *contactor_event_box;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window),"主界面");
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width (GTK_CONTAINER (window),100);
-
- //添一个表控件
- table = gtk_table_new (12, 14, FALSE);
- gtk_container_add (GTK_CONTAINER (window), table);
- //添loge
- logo = gtk_image_new_from_file ("logo.png");
- gtk_table_attach_defaults (GTK_TABLE (table), logo, 0, 2, 0, 2);
- //用户名
- name_label=gtk_label_new ("用户名<");
- gtk_table_attach_defaults (GTK_TABLE (table), name_label, 5, 6, 0, 1);
- name_label=gtk_label_new (name);
- gtk_table_attach_defaults (GTK_TABLE (table), name_label, 6, 8, 0, 1);
- name_label=gtk_label_new (">");
- gtk_table_attach_defaults (GTK_TABLE (table), name_label, 9, 10, 0, 1);
- //时间
- /*........*/
-
- //退出
- out_event_box= gtk_event_box_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), out_event_box, 13, 14, 0, 1);
- out_label=gtk_label_new_with_mnemonic("_退出");
- gtk_label_set_pattern (GTK_LABEL (out_label), "___");
- gtk_container_add (GTK_CONTAINER (out_event_box), out_label);
- gtk_widget_set_events (out_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (out_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- //gtk_widget_realize (out_event_box);
- gdk_window_set_cursor (out_event_box->window, gdk_cursor_new (GDK_HAND1));
- //邮箱首页
- //邮件搜索
- //设置
- settings_event_box= gtk_event_box_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), settings_event_box, 5, 6, 1, 2);
- settings_label=gtk_label_new_with_mnemonic("_设置");
- gtk_label_set_pattern (GTK_LABEL (settings_label), "___");
- gtk_container_add (GTK_CONTAINER (settings_event_box), settings_label);
- gtk_widget_set_events (settings_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (settings_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- //gtk_widget_realize (settings_event_box); //failed
- gdk_window_set_cursor (settings_event_box->window, gdk_cursor_new (GDK_HAND1));
-
- //换肤
- change_event_box= gtk_event_box_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), change_event_box, 6, 7, 1, 2);
- change_label=gtk_label_new_with_mnemonic("_换肤");
- gtk_label_set_pattern (GTK_LABEL (change_label), "___");
- gtk_container_add (GTK_CONTAINER (change_event_box), change_label);
- gtk_widget_set_events (change_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (change_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- //gtk_widget_realize (change_event_box); //failed
- gdk_window_set_cursor (change_event_box->window, gdk_cursor_new (GDK_HAND1));
-
- //写信
- /* write_image = gtk_image_new_from_file ("w_m.bmp");
- gtk_table_attach_defaults (GTK_TABLE (table), write_image, 0, 1, 2, 3);
- write_event_box= gtk_event_box_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), write_event_box, 1, 2, 2, 3);
- write_label=gtk_label_new_with_mnemonic("_写信");
- gtk_label_set_pattern (GTK_LABEL (write_label), "___");
- gtk_container_add (GTK_CONTAINER (write_event_box), write_label);
- gtk_widget_set_events (write_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (write_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- // gtk_widget_realize (write_event_box); //failed
- gdk_window_set_cursor (write_event_box->window, gdk_cursor_new (GDK_HAND1));
- //收信
- recive_image = gtk_image_new_from_file ("r_m.bmp");
- gtk_table_attach_defaults (GTK_TABLE (table), recive_image, 0, 1, 3, 4);
- recive_event_box= gtk_event_box_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), recive_event_box, 1, 2, 3, 4);
- recive_label=gtk_label_new_with_mnemonic("收信");
- //gtk_label_set_pattern (GTK_LABEL (recive_label), "___");
- gtk_label_set_markup(GTK_LABEL(recive_label),"<span foreground='black'font_desc='16'>收信 </span>");//调整字体颜色大小
- gtk_container_add (GTK_CONTAINER (recive_event_box), recive_label);
- gtk_widget_set_events (recive_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (recive_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- // gtk_widget_realize (write_event_box); //failed
- gdk_window_set_cursor (recive_event_box->window, gdk_cursor_new (GDK_HAND1));
-
- //通讯录
- contactor_image = gtk_image_new_from_file ("c_p.bmp");
- gtk_table_attach_defaults (GTK_TABLE (table), contactor_image, 0, 1, 5, 6);
- contactor_event_box= gtk_event_box_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), contactor_event_box, 1, 2, 5, 6);
- contactor_label=gtk_label_new_with_mnemonic("通讯录");
- gtk_label_set_pattern (GTK_LABEL (contactor_label), "___");
- gtk_container_add (GTK_CONTAINER (contactor_event_box), contactor_label);
- gtk_widget_set_events (contactor_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (contactor_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- // gtk_widget_realize (write_event_box); //failed
- gdk_window_set_cursor (contactor_event_box->window, gdk_cursor_new (GDK_HAND1)); */
- //插入notebook
- {
- int i=10;
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *notebook;
- GtkWidget *label;
- GtkWidget *checkbutton;
- char bufferf[32];
- char bufferl[32];
- GtkWidget *vbox;
- GtkWidget *bbox1;
- GtkWidget *bbox2;
- GtkWidget *bbox3;
- GtkWidget *label1;
- GtkWidget *label2;
- GtkWidget *label3;
- GtkWidget *box1;
- GtkWidget *box2;
- GtkWidget *box3;
- GtkWidget *entry1;
- GtkWidget *entry2;
- //gtk_init(&argc, &argv);
- //window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- //gtk_widget_set_size_request(GTK_WIDGET(window),550,500);
- //gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- //g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
- //gtk_window_set_title(GTK_WINDOW(window),"写信");
- vbox = gtk_vbox_new(FALSE,0);
- box1 = make_box1(FALSE,0,FALSE,FALSE,3);
- gtk_box_pack_start(GTK_BOX(vbox),box1,FALSE,FALSE,2);
- box2 = make_box2(FALSE,0,FALSE,FALSE,3);
- box3 = make_box3(FALSE,0,FALSE,FALSE,3);
- bbox1 = gtk_hbox_new(FALSE,0);
- bbox2 = gtk_hbox_new(FALSE,0);
- bbox3 = gtk_hbox_new(FALSE,0);
- label1 = gtk_label_new("收件人");
- gtk_misc_set_alignment(GTK_MISC(label1),0,0);
- label2 = gtk_label_new("主题");
- label3 = gtk_label_new("正文");
- entry1 = gtk_entry_new();
- entry2 = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(bbox1),label1,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(bbox1),entry1,FALSE,FALSE,0);
- gtk_box_pack_start(GTK_BOX(vbox),bbox1,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),box2,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox2),label2,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox2),entry2,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox2,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),box3,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(bbox3),label3,FALSE,FALSE,2);
- gtk_box_pack_start(GTK_BOX(vbox),bbox3,FALSE,FALSE,2);
-
- //gtk_container_add(GTK_CONTAINER(window),vbox);
- //gtk_widget_show_all(vbox);
- //初始化GTK
- //gtk_init(&argc,&argv);
- //创建最上层主窗口
- //window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- //连接信号"delete_event",使得窗口关闭时发生
- //g_signal_connect(G_OBJECT(window),"delete_event",GTK_SIGNAL_FUNC(delete),NULL);
- //设置窗口标题
- //gtk_window_set_title(GTK_WINDOW(window),"wingmail");
- //设定窗口的默认宽高
- //gtk_window_set_default_size(GTK_WINDOW(window),800,700);
- //设定窗口的位置,让窗口总在最前端
- //gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- //设定容器边框的宽度
- //gtk_container_set_border_width(GTK_CONTAINER(window),15);
-
- notebook = gtk_notebook_new();
- gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook),GTK_POS_LEFT);
- //gtk_container_add(GTK_CONTAINER(window),notebook);
- gtk_widget_show(notebook);
-
- sprintf(bufferl,"已删除");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
- sprintf(bufferl,"已发送");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
-
- sprintf(bufferl,"草稿箱(%d)",i);
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
- sprintf(bufferl,"收件箱(%d)",i);
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
-
- sprintf(bufferl,"通讯录");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
-
- sprintf(bufferl,"收信");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
- sprintf(bufferl,"写信");
-
- label = gtk_label_new(bufferl);
- gtk_notebook_prepend_page(GTK_NOTEBOOK(notebook),vbox,label);
-
- gtk_notebook_set_page(GTK_NOTEBOOK(notebook),0);
- gtk_widget_show(notebook);
- //gtk_widget_show_all(window);
- //gtk_main();
- //return FALSE;
- gtk_table_attach_defaults (GTK_TABLE (table), notebook, 0, 14, 2, 12);
- }
-
- //插入notebook
- gtk_widget_show_all(window);
- //gtk_widget_destroy(window_all);
- }
- else//警告界面
- {
- /*......*/
- GtkWidget *window;
- GtkWidget *y_button;
- GtkWidget *warning;
- GtkWidget *total_box;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window),"警告");
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width (GTK_CONTAINER (window),50);
-
- total_box=gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (window), total_box);
-
- warning = gtk_label_new ("用戶名或密码不正确,登录矢败\n");
- gtk_box_pack_start(GTK_BOX(total_box),warning,FALSE,FALSE,3);
- gtk_widget_show (warning);
-
- y_button = gtk_button_new_with_label ("确定");
- gtk_box_pack_start(GTK_BOX(total_box),y_button,FALSE,FALSE,3);
- g_signal_connect_swapped(G_OBJECT (y_button), "clicked",
- G_CALLBACK (gtk_widget_destroy),
- window);
- gtk_widget_show_all(window);
-
- }
- //g_print ("Hello World\n");
- g_print("%s\n",name);
- g_print("%s\n",pass);
- }
-
-
-
- gint delete_event( GtkWidget *widget, GdkEvent *event, gpointer data )
- {
- /* 如果你的 "delete_event" 信号处理函数返回 FALSE,GTK 会发出 "destroy" 信号。
- * 返回 TRUE,你不希望关闭窗口。
- * 当你想弹出“你确定要退出吗?”对话框时它很有用。*/
-
- g_print ("delete event occurred\n");
-
- GtkWidget *window;
- GtkWidget *y_button;
- GtkWidget *n_button;
- GtkWidget *warning;
- //GtkWidget *warning_box;
- GtkWidget *button_box;
- GtkWidget *total_box;
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window),"warning");
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
- gtk_container_set_border_width (GTK_CONTAINER (window),50);
- //竖框裝所有控件
- total_box=gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (window), total_box);
- //提示语句
- warning = gtk_label_new ("确定要退出吗?\n");
- gtk_box_pack_start(GTK_BOX(total_box),warning,FALSE,FALSE,3);
- gtk_widget_show (warning);
- //横框装两个按钮
- button_box = gtk_hbox_new (FALSE, 0);
- y_button = gtk_button_new_with_label ("确定");
- n_button = gtk_button_new_with_label ("取消");
-
- //將按钮装入横框
- gtk_box_pack_start(GTK_BOX(button_box),y_button,FALSE,FALSE,3);
- gtk_box_pack_start(GTK_BOX(button_box),n_button,FALSE,FALSE,3);
- gtk_widget_show (y_button);
- gtk_widget_show (n_button);
- //將横框装入竖框
- gtk_box_pack_start(GTK_BOX(total_box),button_box,FALSE,FALSE,3);
-
- gtk_widget_show(total_box);
- gtk_widget_show(button_box);
- gtk_widget_show(window);
-
- g_signal_connect_swapped(G_OBJECT (y_button), "clicked",
- G_CALLBACK (gtk_main_quit), window);
- g_signal_connect_swapped(G_OBJECT (n_button), "clicked",
- G_CALLBACK (gtk_widget_destroy),
- window);
- /* 改 TRUE 为 FALSE 程序会关闭。*/
- return TRUE;
- }
-
- void destroy( GtkWidget *widget, gpointer data )
- {
- gtk_main_quit ();
- }
-
- int main( int argc, char *argv[] )
- {
- GtkWidget *window;
- GtkWidget *button;
- GtkWidget *total_box;
- GtkWidget *image;
- GtkWidget *name_box;
- GtkWidget *pass_box;
- GtkWidget *check_box;
- GtkWidget *end_box;
- GtkWidget *name_entry;
- GtkWidget *pass_entry;
- GtkWidget *rem_check;
- GtkWidget *auto_check;
- GtkWidget *r_event_box;
- GtkWidget *f_event_box;
- GtkWidget *reg_label;
- GtkWidget *forg_label;
-
- gtk_init (&argc, &argv);
-
- window_all=window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window),"用戶登录");
- gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
- /* 当窗口收到 "delete_event" 信号 (这个信号由窗口管理器发出,通常是“关闭”
- * 选项或是标题栏上的关闭按钮发出的),我们让它调用在前面定义的 delete_event() 函数。
- * 传给回调函数的 data 参数值是 NULL,它会被回调函数忽略。*/
- g_signal_connect (G_OBJECT (window), "delete_event",
- G_CALLBACK (delete_event), NULL);
-
- /* 在这里我们连接 "destroy" 事件到一个信号处理函数。
- * 对这个窗口调用 gtk_widget_destroy() 函数或在 "delete_event" 回调函数中返回 FALSE 值
- * 都会触发这个事件。*/
- g_signal_connect (G_OBJECT (window), "destroy",
- G_CALLBACK (destroy), NULL);
-
- /* 设置窗口边框的宽度。*/
- gtk_container_set_border_width (GTK_CONTAINER (window),100);
-
- total_box=gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (window), total_box);
- //插入图片
- image = gtk_image_new_from_file ("hh.jpg");
- gtk_box_pack_start(GTK_BOX(total_box),image,FALSE,FALSE,1);
- //插入横hbox
- name_box=gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(total_box),name_box,FALSE,FALSE,3);
- //插入用戶名
- entry_name=name_entry=gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(name_entry),"用戶名");
- gtk_box_pack_start(GTK_BOX(name_box),name_entry,FALSE,FALSE,3);
- //strcpy(information->name,gtk_entry_get_text(GTK_ENTRY(name_entry)));
-
- //插入横hbox
- pass_box=gtk_vbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(total_box),pass_box,FALSE,FALSE,3);
- //输入密码
- entry_pass=pass_entry=gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(pass_entry),"密码");
- gtk_entry_set_visibility(GTK_ENTRY(pass_entry),FALSE);
- gtk_box_pack_start(GTK_BOX(pass_box),pass_entry,FALSE,FALSE,3);
- //strcpy(information->pass,gtk_entry_get_text(GTK_ENTRY(pass_entry)));
- //插入横hbox
- check_box=gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(total_box),check_box,FALSE,FALSE,3);
- //插入记密码和自动登录
- rem_check = gtk_check_button_new_with_label ("记住密码");
- gtk_box_pack_start (GTK_BOX (check_box), rem_check, TRUE, TRUE, 0);
- //g_signal_connect (G_OBJECT (check), "toggled",
- // G_CALLBACK (entry_toggle_editable), entry);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rem_check), TRUE); ///
- gtk_widget_show (rem_check);
-
- auto_check = gtk_check_button_new_with_label ("自动登录");
- gtk_box_pack_start (GTK_BOX (check_box), auto_check, TRUE, TRUE, 0);
- //g_signal_connect (G_OBJECT (check), "toggled",
- // G_CALLBACK (entry_toggle_editable), entry);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (auto_check), TRUE);
- gtk_widget_show (auto_check);
- //插入按扭
- button = gtk_button_new_with_label ("登录");
- gtk_box_pack_start(GTK_BOX(total_box),button,FALSE,FALSE,3);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (log_in), NULL);
-
- /* 当点击按钮时,会通过调用 gtk_widget_destroy(window) 来关闭窗口。
- * "destroy" 信号会从这里或从窗口管理器发出。*/
-
- /*g_signal_connect_swapped(G_OBJECT (button), "clicked",
- G_CALLBACK (gtk_widget_destroy),
- window); */
-
- end_box=gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start(GTK_BOX(total_box),end_box,FALSE,FALSE,20);
- //注冊事件盒
- r_event_box = gtk_event_box_new ();
- gtk_box_pack_start(GTK_BOX(end_box),r_event_box,FALSE,FALSE,3);
-
- gtk_widget_show (r_event_box);
- reg_label = gtk_label_new ("注冊新用戶\n");
- gtk_container_add (GTK_CONTAINER (r_event_box), reg_label);
- gtk_widget_show (reg_label);
- gtk_widget_set_events (r_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (r_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- gtk_widget_realize (r_event_box);
- gdk_window_set_cursor (r_event_box->window, gdk_cursor_new (GDK_HAND1));
- //忘记密码
- f_event_box = gtk_event_box_new ();
- gtk_box_pack_end(GTK_BOX(end_box),f_event_box,FALSE,FALSE,3);
-
- gtk_widget_show (f_event_box);
- forg_label = gtk_label_new ("忘记密码\n");
- gtk_container_add (GTK_CONTAINER (f_event_box), forg_label);
- gtk_widget_show (forg_label);
- gtk_widget_set_events (f_event_box, GDK_BUTTON_PRESS_MASK);
- g_signal_connect (G_OBJECT (f_event_box), "button_press_event",
- G_CALLBACK (quit), NULL);
- gtk_widget_realize (f_event_box);
- gdk_window_set_cursor (f_event_box->window, gdk_cursor_new (GDK_HAND1));
-
- /* 最后一步是显示新创建的按钮和窗口 */
- gtk_widget_show (total_box);
- gtk_widget_show (name_box);
- gtk_widget_show (pass_box);
- gtk_widget_show (check_box);
- gtk_widget_show (end_box);
- gtk_widget_show (name_entry);
- gtk_widget_show (pass_entry);
- gtk_widget_show (image);
- gtk_widget_show (button);
- gtk_widget_show (window);
-
- /*所有的 GTK 程序必须有一个 gtk_main() 函数。程序运行停在这里
- * 等待事件 (如键盘事件或鼠标事件) 的发生。*/
- gtk_main ();
-
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。