A queer problem
- From: "Nikhil Bhavadas K." <nijbhav md5 vsnl net in>
- To: GTK <gtk-list gnome org>
- Subject: A queer problem
- Date: Thu, 10 Aug 2000 00:34:29 +0400
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
twice.
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.
Thanks!
Regards,
Nikhil.
--
"Once a satyâgrahi, always a satyâgrahi"
Nikhil Bhavadâs K. <nikhil@linuxstart.com>
<kaplingat@yahoo.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);
return(TRUE);
}
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);
gtk_widget_show(pbar);
gtk_widget_show(window);
}
void delete_event( GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
gtk_main_quit();
}
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_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(button_click_cb),NULL);
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show(button);
gtk_widget_show (window);
gtk_main ();
return(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]