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;
}