Re: [gtk-list] Re: Button and Window Questions



Here's the code that I'm using in a dialog. It packs two buttons in a
dialog with one that gets the default. The other is set with
GTK_CAN_DEFAULT so that it looks the same when they get shown. If it
doesn't work for you, maybe there is something else going on that seems
unrelated?

  ok_button = gtk_button_new_with_label ("Insert");
  GTK_WIDGET_SET_FLAGS (ok_button, GTK_CAN_DEFAULT);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
                             ok_button, TRUE, TRUE, 0);
  
  gtk_widget_grab_default (GTK_WIDGET(ok_button));
  gtk_widget_show (ok_button);

  cancel_button = gtk_button_new_with_label ("Cancel");
  GTK_WIDGET_SET_FLAGS (cancel_button, GTK_CAN_DEFAULT);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area),
		      cancel_button, TRUE, TRUE, 0);
  gtk_signal_connect_object (GTK_OBJECT(cancel_button), "clicked",
			     GTK_SIGNAL_FUNC(destroy_dialog),
			     GTK_OBJECT(dialog));
  
  gtk_widget_show (cancel_button);

	HTH,
		Stephen

Marc Fearby wrote:
> 
> I've discovered that if I place a button directly onto a window by the
> following code:
> 
> gtk_container_add (GTK_CONTAINER (window) button);
> 
> my button looks like it has the default.  However, when I start using hbox's
> and the like, the button refuses to show the default.  Since windows and
> hbox's are both containers, why should the button widget behave differently?
> 
> This is really annoying.  Is this a bug in GTK?
> 

> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null



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