Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6554091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:39:32+00:00 2026-05-25T12:39:32+00:00

i have a simple program which is compiled with gtk2.0 in ubuntu.In ubuntu11.04 i

  • 0

i have a simple program which is compiled with gtk2.0 in ubuntu.In ubuntu11.04 i installed gtk3.then i compile the same code,i got an error in the following line

/* Add a timer callback to update the value of the progress bar */
timer = gtk_timeout_add (100, progress_timeout, pdata);

i just comment the line and recompile it.then i got output file.but it is not properly working without the commented line.

in gtk2.0 i compiled by the following command

gcc progressbar.c `pkg-config --cflags --libs gtk+-2.0`

and in gtk3

gcc progressbar.c `pkg-config --cflags --libs gtk+-3.0`

I have a doubt that,is there any deprecation in that method in gtk3.please give me a link to an easy documentation with examples.what are the main difference between 2 and 3.
The full source code is as shown below

#include <gtk/gtk.h>

typedef struct _ProgressData {
GtkWidget *pbar; 
} ProgressData;

gint progress_timeout( gpointer data )
{
  ProgressData *pdata = (ProgressData *)data;
  gdouble new_val;
  new_val = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (pdata->pbar)) + 0.01;

  if (new_val > 1.0)
new_val = 0.0;

  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (pdata->pbar), new_val);

  return TRUE;
} 


int main( int   argc,
      char *argv[])
{
ProgressData *pdata;
GtkWidget *align;
GtkWidget *window;

int timer;  

GtkWidget *vbox;

gtk_init (&argc, &argv);

/* Allocate memory for the data that is passed to the callbacks */
pdata = g_malloc (sizeof (ProgressData));

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);

    g_signal_connect ( window, "destroy", gtk_main_quit, NULL ) ;

gtk_window_set_title (GTK_WINDOW (window), "GtkProgressBar");
gtk_container_set_border_width (GTK_CONTAINER (window), 0);

vbox = gtk_vbox_new (FALSE, 5);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox);

/* Create a centering alignment object */
align = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 5);
gtk_widget_show (align);

/* Create the GtkProgressBar */
pdata->pbar = gtk_progress_bar_new ();

gtk_container_add (GTK_CONTAINER (align), pdata->pbar);
gtk_widget_show (pdata->pbar);

/* Add a timer callback to update the value of the progress bar */
timer = gtk_timeout_add (100, progress_timeout, pdata);


gtk_widget_show (window);

gtk_main ();

return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:39:33+00:00Added an answer on May 25, 2026 at 12:39 pm

    You need to change the gtk_timeout_add call to g_timeout_add.

    gtk_timeout_add ()

    guint               gtk_timeout_add                     (guint32 interval,
                                                             GtkFunction function,
                                                             gpointer data);
    
    Warning
    
    gtk_timeout_add has been deprecated since version 2.4 and should not be used in 
    newly-written code. Use g_timeout_add() instead.
    

    Google “gtk_timeout_add g_timeout_add” will get you examples, e.g. this one, http://gna.org/patch/?2563.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple program which I have compiled in both MinGW and Visual
I have a simple C++ program compiled using gcc 4.2.4 on 32-bit Ubuntu 8.04.
I have a simple C program (one source file) which I want to compile
I have avery simple program which uses MediaPLayer. I am new to java and
Below, I have a simple program which uses the CImg library (http://cimg.sourceforge.net/) which iterates
I have a simple Delphi program that I'm working on, in which I am
I have been trying to create a simple program with Python which uses OpenCV
In my google maps program I have simple KML parser which retrieve only coordinates
I have Simple java program named MainController.java. Wehn I try to compile it from
I have a simple program that creates a thread, loops twenty times and then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.