GTK 3+ GtkProgressBar 使用
#include gboolean timeout_callback(gpointer data) { gdouble value; GString *text; value = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(data)); value += 0.01; if(value > 1.0) { value = 0.0; } gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(data), value); text = g_string_new( gtk_progress_bar_get_text(GTK_PROGRESS_BAR(data))); g_string_sprintf(text, "%d %%", (int) (value * 100)); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(data), text->str); return TRUE;}int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *progressBar; gint timer; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "GtkProgressBar"); gtk_window_set_default_size(GTK_WINDOW(window), 300, 30); progressBar = gtk_progress_bar_new(); timer = gtk_timeout_add(100, timeout_callback, progressBar); gtk_container_add(GTK_CONTAINER(window), progressBar); g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(window); gtk_main(); return 0;}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~