So,

I was hoping that upgrading to python-gnome 1.4.1 would solve this
bug where creating a GnomeDialog from an applet callback causes a
hangup, but it didn't.  It was suggested earlier that this might be
a bug in the GNOME libraries, but I don't think so.  I've attached
basically equivalent programs in C and Python, and only the Python
one shows the bug (at least for me).

Anyone made any progress on figuring out this bug?

Attachment: clock-applet.py
Description: test.py

#include <gnome.h>
#include <applet-widget.h>
#include <stdio.h>
#include <time.h>

int alive(void)
{
  time_t curtime = time(0);
  fprintf(stderr, "%s\n", asctime(localtime(&curtime)));
  return TRUE;
}

void foo(GtkWidget *button, void *data)
{
  GnomeDialog *dialog = (GnomeDialog *) gnome_dialog_new("Choose a plugin...",
							 GNOME_STOCK_BUTTON_OK,
							 GNOME_STOCK_BUTTON_CANCEL,
							 NULL);
  GtkWidget *lab = gtk_label_new("Choose a plugin:");
  gtk_widget_show(lab);
  gtk_box_pack_start(GTK_BOX(dialog->vbox), lab, 1, 1, 0);
  fprintf(stderr, "%d chosen\n", gnome_dialog_run_and_close(dialog));
}

int
main(int argc, char **argv)
{
	GtkWidget *app, *butt;

	applet_widget_init("clock_applet", "0.1", argc, argv, NULL, 0, NULL);

	app = applet_widget_new("clock_applet");
	if(!app)
	  g_error("Cannot create applet!");
	butt = gtk_button_new_with_label("Click me!!");
	gtk_signal_connect(GTK_OBJECT(butt), "clicked", foo, NULL);
	gtk_widget_show(butt);
	applet_widget_register_stock_callback(APPLET_WIDGET(app), "choose", GNOME_STOCK_MENU_OPEN, "Choose a plugin...", foo, NULL);

	gtk_timeout_add(1000, alive, NULL);

	applet_widget_add(APPLET_WIDGET(app), butt);
	gtk_widget_show(GTK_WIDGET(app));
	applet_widget_gtk_main();
	return(0);
}

/*
  Local Variables:
  compile-command: "gcc-3.0 -g -Wall `gnome-config --cflags applets` -o clock-applet `gnome-config --libs applets` clock-applet.c"
  End:
*/

Reply via email to