I'm new in gtk. I have a noisy image and to reduce it, I use a function from opencv. It has a run time, for example 5 seconds. I want to show progressing the run time by using progress bar. This is my code:

#include <opencv2/opencv.hpp>
#include <gtk/gtk.h>
#include <time.h>

using namespace cv;
using namespace std;

gboolean Func (gpointer data) {
gdouble value;
GString *text;

//part of code that generate run time
clock_t start, end;
start = clock();

Mat image, src1, DENO;
image = imread("C:/Users/Alireza/Desktop/1.png");
cvtColor(image, src1, CV_RGB2GRAY);
fastNlMeansDenoising(src1, DENO, 19, 29, 38);
imwrite("DENO.png", DENO);

end = clock();
int runtime = ((int)(end - start)) / CLOCKS_PER_SEC;
cout << "Time1 = " << runtime << "s" << endl;

//part of code that I want to show run time progress by progress bar
value = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(data));

value += 0.01;
if (value > 1.0) {
    value = 0.0;

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_fraction(GTK_PROGRESS_BAR(data), value);
gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(data), TRUE);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(data), text->str);

while (gtk_events_pending())

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 = g_timeout_add(100, Func, progressBar);

gtk_container_add(GTK_CONTAINER(window), progressBar);



return 0;


and this is my image:

How to design a progress bar button  with gtk3 c code?-1-png

But I can't combine these codes together to show progress run time of  
my project. I'm new in gtk3. Does any one have any thoughts or  
suggestions on this?