Beispiel #1
0
static GtkWidget *
bonobo_window_find_internal_child (GladeXML    *xml,
				   GtkWidget   *parent,
				   const gchar *childname)
{
	if (!strcmp (childname, "vbox")) {
		GtkWidget *ret;

		if ((ret = bonobo_window_get_contents (
			BONOBO_WINDOW (parent))))
			return ret;

		else {
			GtkWidget *box;

			box = gtk_vbox_new (FALSE, 0);
			
			bonobo_window_set_contents (
				BONOBO_WINDOW (parent), box);

			return box;
		}
	}

    return NULL;
}
Beispiel #2
0
static void
create_icon_entry(void)
{
	TestGnomeApp *app;
	GtkWidget *vbox;
	GtkWidget *button;
	GtkWidget *label;
	GtkWidget *entry;

	app = create_newwin (TRUE, "testGNOME", "Icon Entry");

	vbox = gtk_vbox_new (FALSE, 5);

	entry = gnome_icon_entry_new ("Foo", "Icon");
	gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0);

	button = gtk_button_new_with_label ("Update label below");
	gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

	label = gtk_label_new ("Nothing selected");
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

	g_signal_connect (entry, "changed",
			  G_CALLBACK (icon_entry_changed), NULL);
	g_signal_connect (button, "clicked",
			  G_CALLBACK (get_icon), entry);
	g_object_set_data (G_OBJECT (button), "label", label);

	bonobo_window_set_contents (BONOBO_WINDOW (app->app), vbox);
	gtk_widget_show_all (vbox);
	gtk_widget_show (app->app);
}
Beispiel #3
0
static TestGnomeApp *
create_newwin(gboolean normal, gchar *appname, gchar *title)
{
        TestGnomeApp *app;

	app = g_new0 (TestGnomeApp, 1);
	app->app = bonobo_window_new (appname, title);
	if (!normal) {
		g_signal_connect(app->app, "delete_event",
				 G_CALLBACK(quit_test), app);
	};
	app->ui_container = bonobo_ui_engine_get_ui_container (
		bonobo_window_get_ui_engine (BONOBO_WINDOW (app->app)));

	app->ui_component = bonobo_ui_component_new (appname);
	bonobo_ui_component_set_container (app->ui_component,
					   BONOBO_OBJREF(app->ui_container),
					   NULL);

	/* This is a test program only run on the build system, so
	 * it's OK to use GNOMEUISRCDIR which is valid of course only
	 * on the build system.
	 */
	bonobo_ui_util_set_ui (app->ui_component, "",
			       GNOMEUISRCDIR "/testgnome.xml",
			       appname, NULL);

	bonobo_ui_component_add_verb_list_with_data (app->ui_component, verbs, app);
	
	return app;
}
Beispiel #4
0
static void
on_view_as_activate (GtkMenuItem *item, ViewAsData *d)
{
	GtkWidget *w, *c, *s;
	Bonobo_Control control;
	CORBA_Environment ev;
	CameraFile *f;
	int result;
	Bonobo_PersistStream pstream;
	BonoboObject *stream;
	const char *data = NULL;
	unsigned long int size;
	const char *type;

	g_return_if_fail (d->iid != NULL);

	CORBA_exception_init (&ev);
	control = bonobo_get_object (d->iid, "IDL:Bonobo/Control:1.0", &ev);
	if (BONOBO_EX (&ev) || (control == CORBA_OBJECT_NIL)) {
		CORBA_exception_free (&ev);
		g_warning ("Could not get control from '%s'.", d->iid);
		return;
	}

	w = bonobo_window_new (d->file, d->file);
	c = bonobo_widget_new_control_from_objref (control, CORBA_OBJECT_NIL);
	gtk_widget_show (c);
	bonobo_window_set_contents (BONOBO_WINDOW (w), c);

	gtk_widget_show (w);

	s = gtkam_status_new (_("Downloading '%s' from '%s'..."), d->file,
			      d->folder);
	g_signal_emit (G_OBJECT (d->list), signals[NEW_STATUS], 0, s);
	gp_file_new (&f);
	result = gp_camera_file_get (d->camera->camera, d->folder, d->file,
				     GP_FILE_TYPE_NORMAL, f,
				     GTKAM_STATUS (s)->context->context);
	if (d->camera->multi)
		gp_camera_exit (d->camera->camera, NULL);
	if (result >= 0) {
		CORBA_exception_init (&ev);
		pstream = Bonobo_Unknown_queryInterface (control,
					"IDL:Bonobo/PersistStream:1.0", &ev);
		if (!BONOBO_EX (&ev) && (pstream != CORBA_OBJECT_NIL)) {
			gp_file_get_data_and_size (f, &data, &size);
			gp_file_get_mime_type (f, &type);
			stream = bonobo_stream_mem_create (data, size,
							   TRUE, FALSE);
			Bonobo_PersistStream_load (pstream,
				bonobo_object_corba_objref (stream), type, &ev);
			g_object_unref (G_OBJECT (stream));
			bonobo_object_release_unref (pstream, NULL);
		}
		CORBA_exception_free (&ev);
	}
	gp_file_unref (f);
	gtk_object_destroy (GTK_OBJECT (s));
}
Beispiel #5
0
static void
create_color_picker (void)
{
	TestGnomeApp *app;
	GtkWidget *table;
	GtkWidget *w;

	app = create_newwin (TRUE, "testGNOME", "Color Picker");

	table = gtk_table_new (3, 3, FALSE);
	gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL);
	gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
	gtk_table_set_col_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
	bonobo_window_set_contents (BONOBO_WINDOW (app->app), table);
	gtk_widget_show (table);

	/* Labels */

	w = gtk_label_new ("Dither");
	gtk_table_attach (GTK_TABLE (table), w,
			  1, 2, 0, 1,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	w = gtk_label_new ("No dither");
	gtk_table_attach (GTK_TABLE (table), w,
			  2, 3, 0, 1,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	w = gtk_label_new ("No alpha");
	gtk_table_attach (GTK_TABLE (table), w,
			  0, 1, 1, 2,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	w = gtk_label_new ("Alpha");
	gtk_table_attach (GTK_TABLE (table), w,
			  0, 1, 2, 3,
			  GTK_FILL,
			  GTK_FILL,
			  0, 0);
	gtk_widget_show (w);

	/* Color pickers */

	create_cp (table, TRUE,  FALSE, 1, 2, 1, 2);
	create_cp (table, FALSE, FALSE, 2, 3, 1, 2);
	create_cp (table, TRUE,  TRUE,  1, 2, 2, 3);
	create_cp (table, FALSE, TRUE,  2, 3, 2, 3);

	gtk_widget_show (app->app);
}
Beispiel #6
0
static void
create_entry(void)
{
	TestGnomeApp *app;
	GtkWidget *entry;

	app = create_newwin(TRUE,"testGNOME","Entry");
	entry = gnome_entry_new("test-entry");
	g_assert(entry != NULL);
	bonobo_window_set_contents(BONOBO_WINDOW(app->app), entry);
	gtk_widget_show(entry);
	gtk_widget_show(app->app);
}
Beispiel #7
0
static void
create_date_edit (void)
{
	GtkWidget *datedit;
	TestGnomeApp *app;
	time_t curtime = time(NULL);

	datedit = gnome_date_edit_new(curtime,1,1);
	app = create_newwin(TRUE,"testGNOME","Date Edit");
	bonobo_window_set_contents (BONOBO_WINDOW (app->app), datedit);
	gtk_widget_show(datedit);
	gtk_widget_show(app->app);
}
Beispiel #8
0
static Bonobo_UIContainer
widget_get_uic (GtkWidget *widget)
{
  GtkWidget *top;

  top = gtk_widget_get_toplevel (widget);

  if (!BONOBO_IS_WINDOW (top))
    return CORBA_OBJECT_NIL;

  /* FIXME: Should we unref this somewhere? */
  return (Bonobo_UIContainer) BONOBO_OBJREF (bonobo_window_get_ui_container (BONOBO_WINDOW (top)));
}
Beispiel #9
0
/*
 * PixmapEntry
 */
static void
create_pixmap_entry(void)
{
	TestGnomeApp *app;
	GtkWidget *entry;

	app = create_newwin (TRUE, "testGNOME", "Pixmap Entry");

	entry = gnome_pixmap_entry_new ("Foo", "Pixmap", TRUE);

	bonobo_window_set_contents (BONOBO_WINDOW (app->app), entry);
	gtk_widget_show (entry);
	gtk_widget_show (app->app);
}
Beispiel #10
0
static SampleApp *
sample_app_new (SampleDoc *doc)
{
	SampleApp *app = g_new0 (SampleApp, 1);
	GtkWidget *view;

	/* Create a document */
	app->doc = sample_doc_new ();
	if (!app->doc) {
		g_free (app);
		return NULL;
	}

	/* Create toplevel window */
	app->win = bonobo_window_new ("sample-doc-container",
				      "Sample Document container");

	gtk_window_set_default_size (GTK_WINDOW (app->win), 400, 600);
	g_signal_connect_data (G_OBJECT (app->win), "delete_event",
			       G_CALLBACK (delete_cb), app, NULL, 0);

	/* Create and merge the UI elements. */
	sample_app_fill_menu (app);

	/* Create a doc view and stuff it into a box in the toplevel. */
	app->box = gtk_vbox_new (FALSE, 10);
	bonobo_window_set_contents (BONOBO_WINDOW (app->win), app->box);

	view = sample_doc_view_new (app->doc, BONOBO_OBJREF (
		bonobo_window_get_ui_container (BONOBO_WINDOW (app->win))));
	app->doc_views = g_list_prepend (app->doc_views, view);
	app->curr_view = view;

	gtk_widget_show_all (app->win);

	return app;
}
Beispiel #11
0
static void
create_icon_list(void)
{
	TestGnomeApp *app;
	GtkWidget *sw;
	GtkWidget *iconlist;
	GdkPixbuf *pix;
	int i;

	app = create_newwin(TRUE,"testGNOME","Icon List");

	sw = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	bonobo_window_set_contents (BONOBO_WINDOW (app->app), sw);
	gtk_widget_set_size_request (sw, 430, 300);
	gtk_widget_show (sw);

	iconlist = gnome_icon_list_new (80, NULL, GNOME_ICON_LIST_IS_EDITABLE);
	gtk_container_add (GTK_CONTAINER (sw), iconlist);
	g_signal_connect (iconlist, "select_icon",
			  G_CALLBACK (select_icon),
			  NULL);
	g_signal_connect (iconlist, "unselect_icon",
			  G_CALLBACK (unselect_icon),
			  NULL);

	GTK_WIDGET_SET_FLAGS(iconlist, GTK_CAN_FOCUS);
	pix = gdk_pixbuf_new_from_xpm_data ((const gchar **)bomb_xpm);

	gtk_widget_grab_focus (iconlist);

	gnome_icon_list_freeze (GNOME_ICON_LIST (iconlist));

	for (i = 0; i < 30; i++) {
		gnome_icon_list_append_pixbuf (GNOME_ICON_LIST(iconlist), pix, "bomb.xpm", "Foo");
		gnome_icon_list_append_pixbuf (GNOME_ICON_LIST(iconlist), pix, "bomb.xpm", "Bar");
		gnome_icon_list_append_pixbuf (GNOME_ICON_LIST(iconlist), pix, "bomb.xpm", "LaLa");
	}

	gnome_icon_list_append (GNOME_ICON_LIST(iconlist), "non-existant.png", "No Icon");

	gnome_icon_list_set_selection_mode (GNOME_ICON_LIST (iconlist), GTK_SELECTION_EXTENDED);
	gnome_icon_list_thaw (GNOME_ICON_LIST (iconlist));
	gtk_widget_show (iconlist);
	gtk_widget_show(app->app);
}
Beispiel #12
0
static void
create_file_entry(void)
{
	TestGnomeApp *app;
	GtkWidget *entry;
	GtkWidget *l1,*l2;
	GtkWidget *but;
	GtkWidget *box;

	app = create_newwin(TRUE,"testGNOME","File Entry");

	box = gtk_vbox_new(FALSE,5);
	entry = gnome_file_entry_new("Foo","Bar");
	gtk_box_pack_start(GTK_BOX(box),entry,FALSE,FALSE,0);

	l1 = gtk_label_new("File name: ");
	gtk_box_pack_start(GTK_BOX(box),l1,FALSE,FALSE,0);

	l2 = gtk_label_new("File name(if exists only): ");
	gtk_box_pack_start(GTK_BOX(box),l2,FALSE,FALSE,0);

	but = gtk_button_new_with_label("Update file labels");
	g_object_set_data(G_OBJECT(but),"l1",l1);
	g_object_set_data(G_OBJECT(but),"l2",l2);
	g_signal_connect(but,"clicked",
			 G_CALLBACK(file_entry_update_files),
			 entry);
	gtk_box_pack_start(GTK_BOX(box),but,FALSE,FALSE,0);

	but = gtk_toggle_button_new_with_label("Make browse dialog modal");
	g_signal_connect(but,"toggled",
			 G_CALLBACK(file_entry_modal_toggle),
			 entry);
	gtk_box_pack_start(GTK_BOX(box),but,FALSE,FALSE,0);

	but = gtk_toggle_button_new_with_label("Directory only picker");
	g_signal_connect(but,"toggled",
			 G_CALLBACK(file_entry_directory_toggle),
			 entry);
	gtk_box_pack_start(GTK_BOX(box),but,FALSE,FALSE,0);

	bonobo_window_set_contents (BONOBO_WINDOW(app->app), box);
	gtk_widget_show_all(app->app);
}
Beispiel #13
0
static void
create_href(void)
{
	TestGnomeApp *app;
	GtkWidget *vbox, *href, *ent1, *ent2, *wid;

	app = create_newwin(TRUE,"testGNOME","HRef test");
	vbox = gtk_vbox_new(FALSE, 5);
	gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
	bonobo_window_set_contents(BONOBO_WINDOW(app->app), vbox);

	href = gnome_href_new("http://www.gnome.org/", "Gnome Website");
	gtk_box_pack_start(GTK_BOX(vbox), href, FALSE, FALSE, 0);

	wid = gtk_hseparator_new();
	gtk_box_pack_start(GTK_BOX(vbox), wid, TRUE, FALSE, 0);

	wid = gtk_label_new("The launch behaviour of the\n"
			    "configured with the control center");
	gtk_box_pack_start(GTK_BOX(vbox), wid, TRUE, FALSE, 0);

	ent1 = gtk_entry_new();
	gtk_entry_set_text (GTK_ENTRY(ent1), "http://www.gnome.org/");
	gtk_box_pack_start (GTK_BOX(vbox), ent1, TRUE, TRUE, 0);

	ent2 = gtk_entry_new ();
	gtk_entry_set_text (GTK_ENTRY(ent2), "Gnome Website");
	gtk_box_pack_start (GTK_BOX(vbox), ent2, TRUE, TRUE, 0);

	wid = gtk_button_new_with_label ("set href props");
	g_object_set_data (G_OBJECT(wid), "href", href);
	g_object_set_data (G_OBJECT(wid), "url", ent1);
	g_object_set_data (G_OBJECT(wid), "label", ent2);
	g_signal_connect (wid, "clicked",
			  G_CALLBACK(href_cb), NULL);
	gtk_box_pack_start (GTK_BOX(vbox), wid, TRUE, TRUE, 0);

	gtk_widget_show_all(app->app);
}
Beispiel #14
0
PeacockFileClient *
peacock_file_new (PeacockWindow *window)
{
	GtkWidget *control;
	BonoboUIContainer *uiContainer;
	PeacockFileClient *fileClient;
	CORBA_Environment ev;
	CORBA_Object interface;

	uiContainer = bonobo_window_get_ui_container (BONOBO_WINDOW (window));
	control = bonobo_widget_new_control (PEACOCK_FILE_CONTROL_OAFIID,
					     BONOBO_OBJREF (uiContainer));
	peacock_util_activate_bonobo_control (BONOBO_WIDGET (control));
	gtk_widget_show (control);

	/* Get the PersistFile interface for loading/saving. */
	CORBA_exception_init (&ev);
	interface = Bonobo_Unknown_queryInterface (bonobo_widget_get_objref (BONOBO_WIDGET (control)), "IDL:Bonobo/PersistFile:1.0", &ev);
	CORBA_exception_free (&ev);

	if (interface == CORBA_OBJECT_NIL) {
		g_warning ("Oh No! Control doesn't support IDL:Bonobo/PersistFile:1.0!!!");
		return NULL;
	}

	/* Initialize the PeacockFileClient struct. */
	fileClient = peacock_file_client_new ();
	fileClient->control = control;
	fileClient->persistFile = interface;
	fileClient->tabWidget = peacock_file_client_create_tab_widget (fileClient, window);

	gtk_widget_ref (fileClient->control);
	gtk_widget_ref (fileClient->tabWidget);

	/* For setting the current_file in PeacockMDI. */
	g_object_set_data (G_OBJECT (fileClient->control), PEACOCK_FILE_CLIENT_TAG, fileClient);

	return fileClient;
}
Beispiel #15
0
int
main (int argc, char **argv)
{
	BonoboWindow *win;
	BonoboUIComponent *componenta;
	BonoboUIComponent *componentb;
	BonoboUIComponent *componentc;
	BonoboUIContainer *container;
	Bonobo_UIContainer corba_container;
	CORBA_Environment  real_ev, *ev;
	GnomeProgram *program;
	char *txt, *fname;
	int i;

	char simplea [] =
		"<menu>\n"
		"	<submenu name=\"File\" _label=\"_Ga'\">\n"
		"		<menuitem name=\"open\" pos=\"bottom\" _label=\"_Open\" verb=\"FileOpen\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Wibble\"/>\n"
		"		<control name=\"MyControl\"/>\n"
		"		<control name=\"MyControl2\"/>\n"
		"		<control name=\"ThisIsEmpty\"/>\n"
		"		<menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseA\" _tip=\"hi\""
		"		pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n"
		"	</submenu>\n"
		"</menu>";
	char keysa [] =
		"<keybindings>\n"
		"   <accel name=\"*Control*3\" id=\"MyFoo\"/>\n"
		"</keybindings>\n";
	char simpleb [] =
		"<submenu name=\"File\" _label=\"_File\">\n"
		"	<menuitem name=\"open\" _label=\"_OpenB\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Open you fool\"/>\n"
		"       <separator/>\n"
		"       <menuitem name=\"toggle\" type=\"toggle\" id=\"MyFoo\" _label=\"_ToggleMe\" _tip=\"a\" accel=\"*Control*t\"/>\n"
		"       <placeholder name=\"Nice\" delimit=\"top\"/>\n"
		"	<menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseB\" _tip=\"hi\""
		"        pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n"
		"</submenu>\n";
	char simplec [] =
		"<submenu name=\"File\" _label=\"_FileC\" _tip=\"what!\">\n"
		"    <placeholder name=\"Nice\" delimit=\"top\" hidden=\"0\">\n"
		"	<menuitem name=\"fooa\" _label=\"_FooA\" type=\"radio\" group=\"foogroup\" _tip=\"Radio1\"/>\n"
		"	<menuitem name=\"foob\" _label=\"_FooB\" type=\"radio\" group=\"foogroup\" _tip=\"kippers\"/>\n"
		"	<menuitem name=\"wibble\" verb=\"ThisForcesAnError\" _label=\"_Baa\""
		"        pixtype=\"stock\" pixname=\"Open\" sensitive=\"0\" _tip=\"fish\"/>\n"
		"       <separator/>\n"
		"    </placeholder>\n"
		"</submenu>\n";
	char simpled [] =
		"<menuitem name=\"save\" _label=\"_SaveD\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip1\"/>\n";
	char simplee [] =
		"<menuitem name=\"fish\" _label=\"_Inplace\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip2\"/>\n";
	char toola [] =
		"<dockitem name=\"Toolbar\" homogeneous=\"0\" vlook=\"icon\">\n"
		"	<toolitem type=\"toggle\" name=\"foo2\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Save\""
		"        _label=\"TogSave\" _tip=\"My tooltip\" priority=\"1\"/>\n"
		"	<separator/>\n"
		"	<toolitem name=\"baa\" pixtype=\"stock\" pixname=\"Open\" _label=\"baa\" _tip=\"My 2nd tooltip\" verb=\"testme\"/>\n"
		"	<control name=\"AControl\" _tip=\"a tip on a control\" hidden=\"0\" vdisplay=\"button\"\n"
		"	pixtype=\"stock\" pixname=\"gtk-italic\" _label=\"EntryControl\" verb=\"OpenEntry\"/>\n"
		"	<control name=\"BControl\" _tip=\"another tip on a control\" hidden=\"0\"\n"
		"	pixtype=\"stock\" pixname=\"gtk-stop\"/>\n"
		"</dockitem>";
	char toolb [] =
		"<dockitem name=\"Toolbar\" look=\"icon\" relief=\"none\">\n"
		"	<toolitem name=\"foo1\" _label=\"Insensitive\" sensitive=\"0\" hidden=\"0\" priority=\"1\"/>\n"
		"	<toolitem type=\"toggle\" name=\"foo5\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Close\""
		"	 _label=\"TogSame\" _tip=\"My tooltip\"/>\n"
		"</dockitem>";
/*	char statusa [] =
		"<item name=\"main\">Kippers</item>\n";*/
	char statusb [] =
		"<status>\n"
		"	<item name=\"main\"/>\n"
		"	<control name=\"Progress\"/>\n"
		"</status>";

	ev = &real_ev;
	CORBA_exception_init (ev);

	free (malloc (8));

	program = gnome_program_init ("test-ui", VERSION,
			    LIBBONOBOUI_MODULE,
			    argc, argv, NULL);

	textdomain (GETTEXT_PACKAGE);

	bonobo_activate ();

	dump_prefs ();

	win = BONOBO_WINDOW (bonobo_window_new ("Win", "My Test Application"));
	container = bonobo_window_get_ui_container (win);
	
	bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (win),
					  "/test-ui/UIConfig/kvps");

	corba_container = BONOBO_OBJREF (container);

	{
		GtkWidget *box = gtk_vbox_new (FALSE, 0);
		GtkWidget *button;
		GtkWidget *path_entry, *state_entry;

		button = gtk_button_new_with_label ("Press me to test!");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_quit, NULL);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Dump Xml tree");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_dump, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Popup");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_popup, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		button = gtk_button_new_with_label ("Hide toolbar");
		g_signal_connect (GTK_OBJECT (button), "clicked",
				    (GtkSignalFunc) cb_do_hide_toolbar, win);
		gtk_widget_show (GTK_WIDGET (button));
		gtk_box_pack_start_defaults (GTK_BOX (box), button);

		path_entry = gtk_entry_new ();
		gtk_entry_set_text (GTK_ENTRY (path_entry), "/commands/MyFoo");
		gtk_widget_show (GTK_WIDGET (path_entry));
		gtk_box_pack_start_defaults (GTK_BOX (box), path_entry);

		state_entry = gtk_entry_new ();
		gtk_entry_set_text (GTK_ENTRY (state_entry), "1");
		g_signal_connect (GTK_OBJECT (state_entry), "changed",
				    (GtkSignalFunc) cb_set_state, path_entry);
		gtk_widget_show (GTK_WIDGET (state_entry));
		gtk_box_pack_start_defaults (GTK_BOX (box), state_entry);

		gtk_widget_show (GTK_WIDGET (box));
		bonobo_window_set_contents (win, box);
	}

	g_signal_connect (GTK_OBJECT (win), "size_request", 
			    G_CALLBACK (slow_size_request), NULL);

	componenta = bonobo_ui_component_new ("A");
	bonobo_object_unref (BONOBO_OBJECT (componenta));

	componenta = bonobo_ui_component_new ("A");
	componentb = bonobo_ui_component_new ("B");
	componentc = bonobo_ui_component_new ("C");


	bonobo_ui_component_set_container (componenta, corba_container, NULL);
	bonobo_ui_component_set_container (componentb, corba_container, NULL);
	bonobo_ui_component_set_container (componentc, corba_container, NULL);

	global_component = componenta;

	fname = bonobo_ui_util_get_ui_fname (NULL, "../doc/std-ui.xml");
	if (fname && g_file_test (fname, G_FILE_TEST_EXISTS)) {
		fprintf (stderr, "\n\n--- Add std-ui.xml ---\n\n\n");
		bonobo_ui_util_set_ui (componenta, NULL, "../doc/std-ui.xml",
				       "gdm", NULL);

/*		bonobo_ui_component_set_prop (
			componenta, "/menu/Preferences",
			"pixname", "/demo/a.xpm", NULL);*/

		gtk_widget_show (GTK_WIDGET (win));

		bonobo_main ();
	} else {
		g_warning ("Can't find ../doc/std-ui.xml");
		gtk_widget_show (GTK_WIDGET (win));
	}
	g_free (fname);


	bonobo_ui_component_freeze (componenta, NULL);

	fprintf (stderr, "\n\n--- Remove A ---\n\n\n");
	bonobo_ui_component_rm (componenta, "/", ev);
	g_assert (!BONOBO_EX (ev));

/*	bonobo_ui_component_set_translate (componentb, "/status", statusa, ev);
	g_assert (!BONOBO_EX (ev));*/

	bonobo_ui_component_set_translate (componenta, "/", simplea, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",
				 "<popups> <popup name=\"MyStuff\"/> </popups>", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componenta, "/popups/MyStuff", simpleb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componenta, "/", keysa, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",   toola, ev);
	g_assert (!BONOBO_EX (ev));

	{
		GtkWidget *widget = gtk_button_new_with_label ("My Label");
		BonoboControl *control = bonobo_control_new (widget);
		BonoboUIComponent *componentp;

		g_signal_connect (GTK_OBJECT (widget), "button_press_event",
				    G_CALLBACK (do_sane_popup), control);
		componentp = bonobo_control_get_popup_ui_component (control);
#if 1
		bonobo_ui_component_set (componentp, "/", "<popups>"
					 "<popup name=\"button3\"/></popups>", ev);
		g_assert (!BONOBO_EX (ev));
		bonobo_ui_component_set_translate (
			componentp, "/popups/button3", simpleb, ev);
		g_assert (!BONOBO_EX (ev));
#endif

		gtk_widget_show (widget);
		bonobo_ui_component_object_set (componenta,
						"/menu/File/MyControl",
						BONOBO_OBJREF (control),
						ev);
		bonobo_object_unref (BONOBO_OBJECT (control));
		g_assert (!BONOBO_EX (ev));

		widget = gtk_menu_item_new_with_mnemonic ("_Foo item");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/menu/File/MyControl2",
						widget, ev);
	}

	{
		GtkWidget *widget = gtk_entry_new ();
		
		gtk_entry_set_text (GTK_ENTRY (widget), "Example text");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/Toolbar/AControl",
						widget, ev);
		g_assert (!BONOBO_EX (ev));
	}
	{
		GtkWidget *widget;
		GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (tame_xpm);
		widget = bonobo_ui_toolbar_button_item_new (pixbuf, "Test Control");
		gtk_widget_show (widget);
		bonobo_ui_component_widget_set (componenta,
						"/Toolbar/BControl",
						widget, ev);
		g_assert (!BONOBO_EX (ev));
	}

	bonobo_ui_component_add_listener (componentb, "MyFoo", toggled_cb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/",     statusb, ev);
	g_assert (!BONOBO_EX (ev));

	/* Duplicate set */
	bonobo_ui_component_set_translate (componenta, "/", simplea, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_add_verb_list_with_data (
		componenta, verbs, GUINT_TO_POINTER (15));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_status (componenta, "WhatA1", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA1", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB2", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA3", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_rm (componenta, "/status", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB4", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA5", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componenta, "WhatA6>", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "WhatB7", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_status (componentb, "", ev);
	g_assert (!BONOBO_EX (ev));

	g_assert (bonobo_ui_component_get_prop (
		componentb, "/status/main", "non-existant", ev) == NULL);
	g_assert (!strcmp (BONOBO_EX_REPOID (ev), ex_Bonobo_UIContainer_NonExistentAttr));
	CORBA_exception_free (ev);

  	{
 		const char *good = "<item name=\"main\">WhatA6&gt;</item>\n";

  		txt = bonobo_ui_component_get (componenta, "/status/main", TRUE, NULL);
 
 		if (!txt || strcmp (txt, good)) {
 			g_warning ("Broken merging code '%s' should be '%s'", txt, good);
 			bonobo_window_dump (win, "on fatal error");
  			g_assert_not_reached ();
  		}

		CORBA_free (txt);
  	}

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_translate (componentb, "/menu", simpleb, ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_translate (componenta, "/",     toolb, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_set_prop (componenta, "/menu/File", "label", "_Goo-wan>", ev);
	g_assert (!BONOBO_EX (ev));

	/* A 'transparent' node merge */
	txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev);
	g_assert (!BONOBO_EX (ev));
	printf ("Before merge look '%s'\n", txt);
	bonobo_ui_component_set_translate (componenta, "/", "<dockitem name=\"Toolbar\"/>", ev);
	g_assert (!BONOBO_EX (ev));
	g_free (txt);
	txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev);
	g_assert (!BONOBO_EX (ev));
	printf ("After merge look '%s'\n", txt);
	if (txt == NULL || strcmp (txt, "icon"))
		g_warning ("Serious transparency regression");
	g_free (txt);

	bonobo_ui_component_set_translate (componenta, "/menu/File/Nice", simplee, ev);
	g_assert (!BONOBO_EX (ev));

	{
		GtkWidget *widget = gtk_progress_bar_new ();
		BonoboControl *control = bonobo_control_new (widget);
		guint id;

		gtk_widget_show (widget);
		bonobo_ui_component_object_set (componenta, "/status/Progress",
						BONOBO_OBJREF (control),
						NULL);

		id = gtk_timeout_add (100, (GSourceFunc) update_progress, widget);
		g_signal_connect (GTK_OBJECT (widget), "destroy",
				    G_CALLBACK (disconnect_progress), GUINT_TO_POINTER (id));
		bonobo_object_unref (BONOBO_OBJECT (control));
	}

	bonobo_ui_component_set_status (componenta, "This is a very long status message "
					"that should cause the window to be resized if "
					"there is in fact a bug in it", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	g_warning ("Begginning stress test, this may take some time ...");
	for (i = 0; i < 100; i++) {
		bonobo_ui_component_freeze (componentc, ev);
		g_assert (!BONOBO_EX (ev));
		
		bonobo_ui_component_set_translate (componentc, "/commands",
						   "<cmd name=\"MyFoo\" sensitive=\"0\"/>", ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_ui_component_set_translate (componentc, "/menu", simplec, ev);
		g_assert (!BONOBO_EX (ev));
	
		bonobo_ui_component_set_translate (componentc, "/menu/File", simpled, ev);
		g_assert (!BONOBO_EX (ev));

		bonobo_ui_component_thaw (componentc, ev);
		g_assert (!BONOBO_EX (ev));
	}
	g_warning ("Done stress test");
	bonobo_main ();
	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 2 ---\n\n\n");
	bonobo_ui_component_rm (componentb, "/", ev);
	g_assert (!BONOBO_EX (ev));
	bonobo_ui_component_set_prop (componentc, "/menu/File/save",
				      "label", "SaveC", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 3 ---\n\n\n");
	bonobo_ui_component_rm (componentc, "/", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_ui_component_freeze (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	fprintf (stderr, "\n\n--- Remove 1 ---\n\n\n");
	bonobo_ui_component_rm (componenta, "/", ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_ui_component_thaw (componenta, ev);
	g_assert (!BONOBO_EX (ev));

	bonobo_main ();

	bonobo_object_unref (BONOBO_OBJECT (componenta));
	bonobo_object_unref (BONOBO_OBJECT (componentb));
	bonobo_object_unref (BONOBO_OBJECT (componentc));

	gtk_widget_destroy (GTK_WIDGET (win));

	CORBA_exception_free (ev);

	g_object_unref (program);

	return bonobo_ui_debug_shutdown ();
}
Beispiel #16
0
static void
create_font_picker (void)
{
	GtkWidget *fontpicker1,*fontpicker2,*fontpicker3;

	TestGnomeApp *app;
	GtkWidget *vbox,*vbox1,*vbox2,*vbox3;
	GtkWidget *hbox1,*hbox3;
	GtkWidget *frPixmap,*frFontInfo,*frUser;
	GtkWidget *lbPixmap,*lbFontInfo,*lbUser;
	GtkWidget *ckUseFont,*spUseFont,*ckShowSize;
	GtkAdjustment *adj;

	app = create_newwin(TRUE,"testGNOME","Font Picker");


	vbox=gtk_vbox_new(FALSE,5);
	gtk_container_set_border_width(GTK_CONTAINER(vbox),5);
	bonobo_window_set_contents(BONOBO_WINDOW(app->app),vbox);

	/* Pixmap */
	frPixmap=gtk_frame_new("Default Pixmap");
	gtk_box_pack_start(GTK_BOX(vbox),frPixmap,TRUE,TRUE,0);
	vbox1=gtk_vbox_new(FALSE,FALSE);
	gtk_container_add(GTK_CONTAINER(frPixmap),vbox1);
	
	/* GnomeFontPicker with pixmap */
	fontpicker1 = gnome_font_picker_new();
	gtk_container_set_border_width(GTK_CONTAINER(fontpicker1),5);
	gtk_box_pack_start(GTK_BOX(vbox1),fontpicker1,TRUE,TRUE,0);
	lbPixmap=gtk_label_new("If you choose a font it will appear here");
	gtk_box_pack_start(GTK_BOX(vbox1),lbPixmap,TRUE,TRUE,5);

	g_signal_connect(fontpicker1,"font_set",
			 G_CALLBACK(cfp_set_font),
			 lbPixmap);

	/* Font_Info */
	frFontInfo=gtk_frame_new("Font Info");
	gtk_box_pack_start(GTK_BOX(vbox),frFontInfo,TRUE,TRUE,0);
	vbox2=gtk_vbox_new(FALSE,FALSE);
	gtk_container_set_border_width(GTK_CONTAINER(vbox2),5);
	gtk_container_add(GTK_CONTAINER(frFontInfo),vbox2);

	fontpicker2 = gnome_font_picker_new();

	/* GnomeFontPicker with fontinfo */
	hbox1=gtk_hbox_new(FALSE,5);
	gtk_box_pack_start(GTK_BOX(vbox2),hbox1,FALSE,FALSE,0);
	ckUseFont=gtk_check_button_new_with_label("Use Font in button with size");
	gtk_box_pack_start(GTK_BOX(hbox1),ckUseFont,TRUE,TRUE,0);

	adj=GTK_ADJUSTMENT(gtk_adjustment_new(14,5,150,1,1,1));
	g_signal_connect (adj, "value_changed",
			  G_CALLBACK (cfp_sp_value_changed),
			  fontpicker2);
	spUseFont=gtk_spin_button_new(adj,1,0);
	gtk_box_pack_start(GTK_BOX(hbox1),spUseFont,FALSE,FALSE,0);
	g_object_set_data (G_OBJECT (fontpicker2), "spUseFont", spUseFont);

	g_signal_connect (ckUseFont, "toggled",
			  G_CALLBACK (cfp_ck_UseFont),
			  fontpicker2);

	ckShowSize=gtk_check_button_new_with_label("Show font size");
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ckShowSize),TRUE);
	gtk_box_pack_start(GTK_BOX(vbox2),ckShowSize,FALSE,FALSE,5);

	g_signal_connect (ckShowSize, "toggled",
			  G_CALLBACK (cfp_ck_ShowSize),
			  fontpicker2);

	gnome_font_picker_set_mode(GNOME_FONT_PICKER(fontpicker2),GNOME_FONT_PICKER_MODE_FONT_INFO);
	gtk_box_pack_start(GTK_BOX(vbox2),fontpicker2,TRUE,TRUE,0);

	lbFontInfo=gtk_label_new("If you choose a font it will appear here");
	gtk_box_pack_start(GTK_BOX(vbox2),lbFontInfo,TRUE,TRUE,5);


	g_signal_connect(fontpicker2,"font_set",
			 G_CALLBACK(cfp_set_font),lbFontInfo);


	/* User Widget */
	frUser=gtk_frame_new("User Widget");
	gtk_box_pack_start(GTK_BOX(vbox),frUser,TRUE,TRUE,0);
	vbox3=gtk_vbox_new(FALSE,FALSE);
	gtk_container_add(GTK_CONTAINER(frUser),vbox3);
	
	/* GnomeFontPicker with User Widget */
	fontpicker3 = gnome_font_picker_new();
	gnome_font_picker_set_mode(GNOME_FONT_PICKER(fontpicker3),GNOME_FONT_PICKER_MODE_USER_WIDGET);

	hbox3=gtk_hbox_new(FALSE,0);
	gtk_box_pack_start(GTK_BOX(hbox3),gtk_image_new_from_stock
                           (GNOME_STOCK_PIXMAP_SPELLCHECK, GTK_ICON_SIZE_BUTTON),
			   FALSE,FALSE,5);
	gtk_box_pack_start(GTK_BOX(hbox3),gtk_label_new("This is an hbox with pixmap and text"),
			   FALSE,FALSE,5);
	gnome_font_picker_uw_set_widget(GNOME_FONT_PICKER(fontpicker3),hbox3);
	gtk_container_set_border_width(GTK_CONTAINER(fontpicker3),5);
	gtk_box_pack_start(GTK_BOX(vbox3),fontpicker3,TRUE,TRUE,0);

	lbUser=gtk_label_new("If you choose a font it will appear here");
	gtk_box_pack_start(GTK_BOX(vbox3),lbUser,TRUE,TRUE,5);

	g_signal_connect(fontpicker3,"font_set",
			 G_CALLBACK(cfp_set_font),lbUser);

	gtk_widget_show_all(app->app);

}
Beispiel #17
0
int
main (int argc, char **argv)
{
	struct {
		char *label;
		void (*func) ();
	} buttons[] =
	  {
		  { "app window", create_app_helper },
		  { "color picker", create_color_picker },
		  { "date edit", create_date_edit },
		  { "entry", create_entry },
		  { "file entry", create_file_entry },
		  { "pixmap entry", create_pixmap_entry },
		  { "icon entry", create_icon_entry },
		  { "font picker", create_font_picker },
		  { "href", create_href },
		  { "icon list", create_icon_list },
		  { "about box", create_about_box }
	  };
	int nbuttons = sizeof (buttons) / sizeof (buttons[0]);
	GnomeProgram *program;
	TestGnomeApp *app;
	GtkWidget *box1;
	GtkWidget *box2;
	GtkWidget *button;
	GtkWidget *scrolled_window;
	int i;

	program = gnome_program_init ("testGNOME", VERSION,
			    LIBGNOMEUI_MODULE,
			    argc, argv,
			    GNOME_PARAM_GOPTION_CONTEXT,
			    g_option_context_new ("test-gnome"),
			    NULL);

	app = create_newwin (FALSE, "testGNOME", "testGNOME");
	gtk_window_set_default_size (GTK_WINDOW (app->app), 200, 300);
	box1 = gtk_vbox_new (FALSE, 0);
	bonobo_window_set_contents (BONOBO_WINDOW (app->app), box1);
	gtk_widget_show (box1);
	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
					GTK_POLICY_AUTOMATIC,
					GTK_POLICY_AUTOMATIC);
	GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (scrolled_window)->vscrollbar,
				GTK_CAN_FOCUS);
	gtk_box_pack_start (GTK_BOX (box1), scrolled_window, TRUE, TRUE, 0);
	gtk_widget_show (scrolled_window);
	box2 = gtk_vbox_new (FALSE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (box2), 10);
	gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), box2);
	gtk_container_set_focus_vadjustment (GTK_CONTAINER (box2), gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW(scrolled_window)));
	gtk_widget_show (box2);
	for (i = 0; i < nbuttons; i++) {
		button = gtk_button_new_with_label (buttons[i].label);
		if (buttons[i].func)
			g_signal_connect (button, "clicked",
					  G_CALLBACK(buttons[i].func),
					  NULL);
		else
			gtk_widget_set_sensitive (button, FALSE);
		gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
		gtk_widget_show (button);
	}

	gtk_widget_show (app->app);

	gtk_main ();

	g_object_unref (program);

	return 0;
}