/* 测试 eicon */ int main() { si_t video_access_mode = VIDEO_ACCESS_MODE_BUFFER; ewindow * w; eicon * ic; /* 初始化用户应用程序 */ application_init(video_access_mode, "eicon"); /* 申请窗口 */ w = window_init(1); /* 申请失败 */ if(w == NULL) { application_exit(); return -1; } window_set_bounds(w,300,100,500,200); w->title = "window with eicon"; w->minimize_enable = 1; w->maximize_enable = 1; w->callback = window_default_callback; /* 申请按钮 */ ic = icon_init(2); /* 申请失败 */ if(ic == NULL) { application_exit(); return -1; } icon_set_bounds(ic ,50,50,100,120); icon_set_text(ic,"ehello"); icon_set_img_path(ic,"/home/orange/Egui2.0/img/2.bmp"); icon_set_is_text_visiable(ic ,1); ic->callback = icon_default_callback; /* 将按钮添加到窗口 */ object_attach_child(OBJECT_POINTER(w), OBJECT_POINTER(ic)); /* 添加顶层窗口 */ application_add_window(NULL, w); /* 设置主窗口 */ application_set_main_window(w); /* 运行 */ application_exec(); return 0; }
int main(int argc, char **argv) { FILE *fnotify; int pipefds[2]; pid_t cpid; pthread_t thread; int r; g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); gtk_init(&argc, &argv); gdk_threads_leave(); if (argc != 2) { if (argc >= 1) { fprintf(stderr, "Usage: %s server\n", argv[0]); } else { fprintf(stderr, "Usage: ssh_irssi_notify server\n"); } fprintf(stderr, "If connecting via ssh to server requires some other \n" "options, specify these in your ssh_config.\n\n"); exit(EXIT_FAILURE); } icon_init(); if (!notify_init("ssh_irssi_fnotify")) { fprintf(stderr, "Failed to connect to the notify server"); exit(EXIT_FAILURE); } r = pipe(pipefds); if (r == -1) { perror("pipe"); exit(EXIT_FAILURE); } fnotify = fdopen(pipefds[0], "r"); if (fnotify == NULL) { perror("fdopen"); exit(EXIT_FAILURE); } cpid = fork(); if (cpid == -1) { perror("fork"); exit(EXIT_FAILURE); } if (cpid == 0) { /* ssh -tt forces sshd to give us a pseudo-tty (pts), meaning that when * the connection dies or ends tail will receive a SIGHUP, preventing * a massive amount of useless tail processes */ char *ssh_exec[] = { "ssh", argv[1], "-tt", "tail -n 0 -f .irssi/fnotify", NULL }; close(0); dup2(pipefds[1], 1); execvp(ssh_exec[0], ssh_exec); exit(EXIT_FAILURE); } else { if (pthread_create(&thread, NULL, gtk_thread, NULL) != 0) { perror("pthread_create"); exit(EXIT_FAILURE); } if (pthread_create(&thread, NULL, reaper_thread, &cpid) != 0) { perror("pthread_create"); gdk_threads_enter(); gtk_main_quit(); gdk_threads_leave(); return EXIT_FAILURE; } parent(fnotify); return EXIT_FAILURE; } }