A queer problem

	I had written an application having a progress bar in a dialog window.
As an illustration, I am sending a small GTK program that has a button, clicking
on which a dialog window with a progress bar appears. 
	My first problem might be very common. How to force response on a
dialog window? A quick look of FAQ did not reveal much details. In my
program, every time you click on the button separate dialog windows appear. My
requirement is that when a dialog window appears, a person should be able to
click only on the dialog window and any click on the parent window should not
have any affect. Let me say that many GTK+/GNOME programs show this behavior.
My version of gnome-games(1.0.51) have some games like Same Gnome that show
dialog windows every time you click on the close button on the top right
window. Some programs like gEdit crashed when I clicked on the close button
	A queer problem seen when compiling and running this program is that
when you create many dialog windows by clicking on the button, and killed some
of them, error messages like
> Gtk-CRITICAL **: file gtkprogress.c: line 554 (gtk_progress_set_value):
> assertion `GTK_IS_PROGRESS (progress)' failed.

> Gtk-WARNING **: invalid cast from `(unknown)' to `GtkProgress'

appears. Now when trying to create another dialog window by clicking once more,
the program segfaults with the message
> Gtk-WARNING **: invalid cast from `GtkDialog' to `GtkProgress'
The behavior is unpredictable. Sometimes this occurs when we just move the mouse
over the button.   	
	What is this `cast' problem? Where have I gone wrong? Or is this some
bug? Sorry if the mail has become too long. I just wanted to state my
problem clealry.
"Once a saty‚grahi, always a saty‚grahi"
Nikhil Bhavad‚s K. <nikhil@linuxstart.com>
#include <gtk/gtk.h>
gint progress_timeout( gpointer data )
         gfloat new_val;
         GtkAdjustment *adj;
         new_val = gtk_progress_get_value( GTK_PROGRESS(data) ) + 1;
         adj = GTK_PROGRESS (data)->adjustment;
         if (new_val > adj->upper)
           new_val = adj->lower;
         gtk_progress_set_value (GTK_PROGRESS (data), new_val);
static void button_click_cb(GtkWidget *butt)
	GtkWidget *window;
	GtkWidget *pbar;
	GtkObject *adj;
	int timer;
	adj = gtk_adjustment_new (0, 1, 150, 0, 0, 0);
        window = gtk_dialog_new ();
	pbar=gtk_progress_bar_new_with_adjustment (GTK_ADJUSTMENT(adj));
	timer = gtk_timeout_add (100, progress_timeout, pbar);
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),pbar, TRUE, TRUE, 0);

void delete_event( GtkWidget *widget,
                   GdkEvent *event,
                   gpointer data)
int main(int argc, char *argv[])
	GtkWidget *window;
	GtkTooltips *tooltips;
        GtkWidget *button;
        gtk_init (&argc, &argv);
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_signal_connect(GTK_OBJECT(window),"delete_event",GTK_SIGNAL_FUNC(delete_event), NULL); 
	tooltips = gtk_tooltips_new ();
     	button = gtk_button_new_with_label ("button 1");
	gtk_container_set_border_width(GTK_CONTAINER(button), 100);
	gtk_tooltips_set_tip (tooltips, button, "This is button 1", NULL);
	gtk_container_add(GTK_CONTAINER(window), button); 
       	gtk_widget_show (window);
        gtk_main ();

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]