Spin button problem



Greetings,

I've got a problem that I have been wrestling with for some time now. I have 
a spin button that is set sensitive off and on based on what other widgets 
are depressed, selected, etc. It would seem as though everything is working 
the way it should until I try to edit the spin button with the keyboard. 
After changing the value once with the keyboard, dimming it once, and then 
setting it sensitive again, the keyboard can no longer edit the widget 
directly. The arrows to the right can change the value, but not the keyboard. 
Can someone tell me why this is? Is there a bug in gtk with this? Thanks.

Here's a section of the offending code :

// I  call draw_townwatch( target_t *target ) initally from main and also 
when target->race_num is changed
// check_townwatch() is the signal function for the townwatch widget
// draw_peasants() is the section that contains the peasant_num_widget spin 
button that doesn't seem to allow me to manually edit it after a couple dims 
and changes of the text.

void
draw_peasants(target_t *target)
{
        static GtkWidget *peasant_num_widget;

        // The draws the widget if it does not already exist //
        if(!peasant_num_widget) {
	GtkWidget *temp_hbox;
	GtkAdjustment *unit_incriment;
 	unit_incriment = GTK_ADJUSTMENT(gtk_adjustment_new (0.0, 0.0, 10000000.0, 
50.0, 0.0, 0.0));
                peasant_num_widget = gtk_spin_button_new(unit_incriment, 1.0, 
0.0);
                gtk_signal_connect(GTK_OBJECT(peasant_num_widget), "changed", 
GTK_SIGNAL_FUNC(check_target_peasant_num), target);
	temp_hbox = set_spin_button_alignment( peasant_num_widget );
                gtk_table_attach(GTK_TABLE(table), temp_hbox, 8, 9, 6, 7, 
GTK_FILL, GTK_FILL, 2, 2);
	return;
        }
         gtk_widget_set_sensitive( peasant_num_widget, target->townwatch );
}

void
check_townwatch(GtkObject *check1, target_t *target)
{
        if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check1) ) ) {
                target->townwatch = TRUE;
        }
        else {
                target->townwatch = FALSE;
        }
        draw_peasants( target );
        calculate_target( target );
}

void
draw_townwatch(target_t *target)
{
        static GtkWidget *townwatch_widget;

        // Draws button if not referenced already //
        if(!townwatch_widget) {
	GtkWidget *hbox;
               townwatch_widget = gtk_check_button_new_with_label("Peasants: 
");
               gtk_signal_connect(GTK_OBJECT(townwatch_widget), "toggled", 
GTK_SIGNAL_FUNC(check_townwatch), target);
	hbox = set_label_alignment( townwatch_widget );
	gtk_table_attach(GTK_TABLE(table), hbox, 7, 8, 6, 7, GTK_FILL, GTK_FILL, 1, 
1);
	draw_peasants( target );  // to draw peasant spin button
	return;
        }
        // These races have access to townwatch //
        if(target->race_num==1 || target->race_num==4) {
                gtk_widget_set_sensitive( townwatch_widget, TRUE);
        }
        // No one else has access to this //
        else {
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(townwatch_widget), FALSE );
	gtk_widget_set_sensitive( townwatch_widget, FALSE);
        }
        draw_peasants( target );
}



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