Re: [gtk-list] Re: Bug in gtk 1.2?



On Mon, 5 Apr 1999, Ketil Froyn wrote:

>   gtk_signal_connect(GTK_OBJECT(button),"destroy",
> 		     GTK_SIGNAL_FUNC(destroy),NULL);

I meant to connect this to window, but it seemed to work fine anyway. 

Anyway, the included program is a v0.2 of my bug-program. This includes a
button that gets it's callback stolen by the button in question. If you
press the button first, it will become over-sensitive. Then, if you click
the Quit button, the callback will be the other button's callback.
Clicking the label does nothing.

Ketil Froyn
--
He who Laughs, Lasts.

http://www.ifi.uio.no/~ketilf/       
mailto:ketilf@ifi.uio.no
#include <gtk/gtk.h>

void destroy(GtkWidget *widget, gpointer data)
{
  gtk_main_quit();
}

void callback(GtkWidget *widget, gpointer data)
{
  g_print("Pressed\n");
  gtk_main_iteration();
}

int main(int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *button, *button2;
  GtkWidget *vbox;
  GtkWidget *label;

  gtk_init(&argc,&argv);

  window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
  button=gtk_button_new_with_label("Test");
  button2=gtk_button_new_with_label("Quit");
  label=gtk_label_new("Label");
  vbox=gtk_vbox_new(FALSE,0);
  

  gtk_box_pack_start(GTK_BOX(vbox),label,TRUE,TRUE,0);
  gtk_box_pack_start(GTK_BOX(vbox),button,TRUE,TRUE,0);
  gtk_box_pack_start(GTK_BOX(vbox),button2,TRUE,TRUE,0);
  gtk_container_add(GTK_CONTAINER(window),vbox);

  gtk_signal_connect(GTK_OBJECT(button),"button_press_event",
		     GTK_SIGNAL_FUNC(callback),NULL);
  gtk_signal_connect(GTK_OBJECT(button2),"button_press_event",
		     GTK_SIGNAL_FUNC(destroy),NULL);
  gtk_signal_connect(GTK_OBJECT(window),"destroy",
		     GTK_SIGNAL_FUNC(destroy),NULL);
  
  gtk_widget_show(button);
  gtk_widget_show(button2);
  gtk_widget_show(label);
  gtk_widget_show(vbox);
  gtk_widget_show(window);

  gtk_main();

  return 1;
}
/*
  Local Variables:
  mode: font-lock
  End:
*/


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