Dialog problems



Hi everybody

a few days ago, I programmed a little test with libgnome/libgnomeui (I have
attached the full sources). *Very* easy to do menus, toolbars, ... !!

But the "about" dialog didn't work. I have a callback to create one:

static void
about_cb (GtkWidget *button, gpointer data)
{
	GtkWidget *about_dialog;
	const gchar *authors [] = {
		"Thomas Rast <t.rast@iname.com>",
		NULL
	};
	
	about_dialog = gnome_about_new ("Menu Test", "0.1", "(c) 2000 Thomas Rast",
		authors, "Just a test", NULL);
	
	gnome_dialog_set_parent (GNOME_DIALOG (about_dialog), GTK_WINDOW (app));
	
	gtk_widget_show (about_dialog);
}

It's like in the tutorial, except the strings. I had a look at the
gmenu-sources (well, i've got very old gnome-core/libs, shame on me :),
it's the same too.

The menus are defined with

GnomeUIInfo helpmenu [] = {
	GNOMEUIINFO_MENU_ABOUT_ITEM (about_cb, NULL),
	GNOMEUIINFO_END
};

GnomeUIInfo menubar [] = {
	GNOMEUIINFO_MENU_HELP_TREE (helpmenu),
	GNOMEUIINFO_END
};

void
create_menu (void)
{
	gnome_app_create_menus (GNOME_APP (app), menubar);
}

I call create_menu from main ().

Now I compiled, runned and clicked help -> about, and then there is nothing
happening. file -> exit (see full source) worked.

Thanks in advance for your help.

Thomas
#include <gnome.h>
#include <stdlib.h>
#include <unistd.h>

GtkWidget *app;

int main (int argc, char *argv[]);

gint
del_event (GtkWidget *widget, GdkEvent *event, gpointer data);

void
exit_cb (GtkWidget *button, gpointer data);

gint
dialogbutton_clicked (GtkWidget *widget, GdkEvent *event, gpointer data);
#include "main.h"

static void about_cb (GtkWidget *button, gpointer data);
void create_menu (void);
void create_tool (void);

GnomeUIInfo filemenu [] = {
	GNOMEUIINFO_MENU_EXIT_ITEM (exit_cb, NULL),
	GNOMEUIINFO_END
};

GnomeUIInfo helpmenu [] = {
	GNOMEUIINFO_MENU_ABOUT_ITEM (about_cb, NULL),
	GNOMEUIINFO_END
};

GnomeUIInfo menubar [] = {
	GNOMEUIINFO_MENU_FILE_TREE (filemenu),
	GNOMEUIINFO_MENU_HELP_TREE (helpmenu),
	GNOMEUIINFO_END
};

GnomeUIInfo toolbar [] = {
	GNOMEUIINFO_ITEM_STOCK ("Exit", "Exit the Application", exit_cb, GNOME_STOCK_PIXMAP_EXIT),
	GNOMEUIINFO_SEPARATOR,
	GNOMEUIINFO_ITEM_STOCK ("About", NULL, about_cb, GNOME_STOCK_PIXMAP_ABOUT),
	GNOMEUIINFO_END
};

int
main (int argc, char *argv[])
{
	GtkWidget *dialogbutton;
	
	gnome_init ("menu-test", "0.1", argc, argv);
	
	app = gnome_app_new ("menu-test", "Menu Creation");
	
	gtk_signal_connect (GTK_OBJECT (app), "delete_event", GTK_SIGNAL_FUNC (del_event), NULL);
	
	create_menu ();
	create_tool ();
	
	dialogbutton = gtk_button_new_with_label ("Some Dialog");
	
	gtk_signal_connect (GTK_OBJECT (dialogbutton), "clicked", GTK_SIGNAL_FUNC (dialogbutton_clicked), NULL);
	
	gnome_app_set_contents (GNOME_APP (app), dialogbutton);
	
	gtk_widget_show_all (app);
	
	gtk_main ();
	
	return 0;
}

gint
del_event (GtkWidget *widget, GdkEvent *event, gpointer data)
{
	gtk_main_quit ();
	
	return FALSE;
}

void
exit_cb (GtkWidget *button, gpointer data)
{
	gtk_main_quit ();
}

static void
about_cb (GtkWidget *button, gpointer data)
{
	GtkWidget *about_dialog;
	const gchar *authors [] = {
		"Thomas Rast <t.rast@iname.com>",
		NULL
	};
	
	about_dialog = gnome_about_new ("Menu Test", "0.1", "(c) 2000 Thomas Rast",
		authors, "Just a test", NULL);
	
	fprintf (stdout, "about_dialog = %p\n", about_dialog);
	
	gnome_dialog_set_parent (GNOME_DIALOG (about_dialog), GTK_WINDOW (app));
	
	gtk_widget_show (about_dialog);
}

gint
dialogbutton_clicked (GtkWidget *widget, GdkEvent *event, gpointer data)
{
	GtkWidget *dialog;
	
	dialog = gnome_message_box_new ("Fine, it worked!", GNOME_MESSAGE_BOX_INFO, GNOME_STOCK_BUTTON_OK, NULL);
	
	gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (app));
	
	gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
}

void
create_menu (void)
{
	gnome_app_create_menus (GNOME_APP (app), menubar);
}

void
create_tool (void)
{
	gnome_app_create_toolbar (GNOME_APP (app), toolbar);
}


----------------------------------------
Thomas Rast
t.rast@iname.com
----------------------------------------


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