[Glade-users] Button only receiving input after leaving & re-entering button
Tristan Van Berkom
tristan.van.berkom at gmail.com
Mon May 4 11:28:24 EDT 2009
I think you are running into the most famous GTK+ bug[1], which
version of GTK+ are you running exactly ? the good new is that
bug has been fixed.
Cheers,
-Tristan
[1] http://bugzilla.gnome.org/show_bug.cgi?id=56070
On Mon, May 4, 2009 at 3:31 AM, RNG <rgasch at gmail.com> wrote:
> Hi,
>
> I have a window which contains a button created through the custom
> function below:
>
> GtkWidget*
> create_randomize (gchar *widget_name, gchar *string1, gchar *string2,
> gint int1, gint int2)
> {
> GtkWidget *button;
> GtkWidget *hbox;
> GtkWidget *label;
> GtkWidget *die;
>
> button = gtk_button_new ();
> hbox = gtk_hbox_new (FALSE, 0);
> die = create_pixmap (button, DATA_DIR "/glade/die.xpm");
> label = gtk_label_new (_("Roll Again"));
> gtk_box_pack_start (GTK_BOX (hbox), die, FALSE, FALSE, 0);
> gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
> gtk_container_add (GTK_CONTAINER (button), hbox);
> gtk_widget_show_all (button);
>
> gtk_signal_connect (GTK_OBJECT (button), "clicked",
> (GtkSignalFunc) on_randomize_clicked,
> NULL);
> gtk_widget_show_all (button);
> return button;
> }
>
>
> The code handling a click on this button looks like this:
>
> void
> on_randomize_clicked (GtkButton *button,
> gpointer user_data)
> {
> MainState *main_state;
> GtkWidget *chooser_window;
> GtkWidget *main_window;
> gint i;
> int types;
> char *widgets[] = {
> "t1", "tt2", "t3", "t4", "tt5", "t6", "t7", "t8", "tt9", NULL };
>
> chooser_window = lookup_toplevel (GTK_WIDGET (button));
> main_window = lookup_data (chooser_window, "data_parent");
> main_state = lookup_data (main_window, "data_state");
>
> gtk_object_ref (GTK_OBJECT (chooser_window));
> gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
>
> /* make sure the type bitmap holds a valid value */
> if (user_data != NULL)
> types = *((int*)user_data);
> else
> types = 0;
>
> for (i = 0; widgets[i] != NULL; i++)
> {
> TTerrain *terrain;
> GtkWidget *widget;
> GtkWidget *view;
>
> while (gtk_events_pending ())
> gtk_main_iteration ();
>
> /* Break out of loop if window is closed. */
> if (!GTK_WIDGET_REALIZED (chooser_window))
> break;
>
> widget = lookup_widget (GTK_WIDGET (button), widgets[i]);
> view = gtk_object_get_data (GTK_OBJECT (widget), "view");
>
> terrain = t_terrain_generate_random (main_state->default_size,
> main_state->genfactor, main_state->gentypes);
> t_terrain_view_set_terrain (T_TERRAIN_VIEW (view), terrain);
> }
>
> gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
> gtk_object_unref (GTK_OBJECT (chooser_window));
> }
>
>
> This works but the problem is that when the randomization process
> finishes and the mouse is still on the randomize button, the randomize
> button seems active (ie: it is not grayed out) but clicking on the
> button does not result in any actions. When I move the mouse out of
> the button and then again into the button, then clicks are once again
> received and properly processed. It seems that I am not setting some
> state correctly, but I don't know what I would have to do in order to
> fix this.
>
> Any ideas would be much appreciated.
>
> Greetings/Thanks
> Robert
> _______________________________________________
> Glade-users maillist - Glade-users at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/glade-users
>
More information about the Glade-users
mailing list