zoukankan      html  css  js  c++  java
  • GTK 3+ GtkProgressBar 使用



    #include <gtk/gtk.h>
    
    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;
    }
  • 相关阅读:
    Fleury算法
    2012 MultiUniversity Training Contest 2
    高斯若尔当消元法(线性代数)
    hdu4307(最小割)
    hdu4305(生成树计数)
    hdu4318(最短路)
    hdu4309(网络流)
    hdu4313(生成树)
    生成树计数
    MYSQL 远程登录及常用命令
  • 原文地址:https://www.cnblogs.com/dgwblog/p/12168585.html
Copyright © 2011-2022 走看看