GTK界面编程时不想用系统的toolbar,向自己做最大化,最小化的按钮,所以用gtk_window_set_decorated()删除toolbar,然后用gtk_window_iconify()来实现最小化,但是有点问题,可以简单描述为一下代码:
(gcc `pkg-config --cflags --libs` iconify.c -o iconify).
< ---------------------------------------------------------------
#include <gtk/gtk.h>
int main(int argc, char **argv)
{
GtkWidget *window;
GtkWidget *vbox;
GtkWidget *button;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(window), 8);
g_signal_connect(window, "delete_event", (GCallback)gtk_main_quit, 0);
vbox = gtk_vbox_new(TRUE, 0);
gtk_container_add(GTK_CONTAINER(window), vbox);
button = gtk_button_new_with_label("Iconify");
gtk_box_pack_start(GTK_BOX(vbox), button, TRUE,TRUE, 0);
g_signal_connect_swapped(button, "clicked",(GCallback)gtk_window_iconify, window);
button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
gtk_box_pack_start(GTK_BOX(vbox), button, TRUE,TRUE, 0);
g_signal_connect(button, "clicked", (GCallback)gtk_main_quit, 0);
//gtk_window_set_decorated(window, FALSE);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
------------------------------------------------------------------->
这段代码直接运行用自己的button最小化没有问题,但是如果在gtk_widget_show_all(window);之前加上gtk_window_set_decorated(window, FALSE);来删除toolbar之后用button最小化就有问题了,窗口会在最小化后又蹦了出来,不知道是怎么会事?谢谢了