예제 #1
0
void simulation_show (GtkWidget *widget, SchematicView *sv)
{
	GtkWidget *w;
	GtkBuilder *gui;
	GError *e = NULL;
	Simulation *s;
	Schematic *sm;

	g_return_if_fail (sv != NULL);

	sm = schematic_view_get_schematic (sv);
	s = schematic_get_simulation (sm);

	if ((gui = gtk_builder_new ()) == NULL) {
		log_append (s->logstore, _ ("Simulation"),
		            _ ("Could not create simulation dialog - Builder creation failed."));
		return;
	}
	gtk_builder_set_translation_domain (gui, NULL);

	// Only allow one instance of the dialog box per schematic.
	if (s->dialog) {
		gdk_window_raise (gtk_widget_get_window (GTK_WIDGET (s->dialog)));
		return;
	}

	if (gtk_builder_add_from_file (gui, OREGANO_UIDIR "/simulation.ui", &e) <= 0) {
		log_append_error (s->logstore, _ ("Simulation"), _ ("Could not create simulation dialog"),
		                  e);
		g_clear_error (&e);
		return;
	}

	w = GTK_WIDGET (gtk_builder_get_object (gui, "toplevel"));
	if (!w) {
		log_append (s->logstore, _ ("Simulation"),
		            _ ("Could not create simulation dialog - .ui file lacks widget "
		               "called \"toplevel\"."));
		return;
	}

	s->dialog = GTK_DIALOG (w);
	g_signal_connect (G_OBJECT (w), "delete_event", G_CALLBACK (delete_event_cb), s);

	w = GTK_WIDGET (gtk_builder_get_object (gui, "progressbar"));
	s->progress = GTK_PROGRESS_BAR (w);
	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (s->progress), 0.0);

	w = GTK_WIDGET (gtk_builder_get_object (gui, "progress_label"));
	s->progress_label = GTK_LABEL (w);

	g_signal_connect (G_OBJECT (s->dialog), "response", G_CALLBACK (cancel_cb), s);

	gtk_widget_show_all (GTK_WIDGET (s->dialog));

	s->sv = sv;
	simulate_cmd (s);
}
예제 #2
0
파일: simulation.c 프로젝트: Miuler/oregano
void
simulation_show (GtkWidget *widget, SchematicView *sv)
{
	GtkWidget *w;
	GladeXML *gui;
	Simulation *s;
	Schematic *sm;

	g_return_if_fail (sv != NULL);

	sm = schematic_view_get_schematic (sv);
	s = schematic_get_simulation (sm);

	/* Only allow one instance of the dialog box per schematic.  */
	if (s->dialog){
		gdk_window_raise (GTK_WIDGET (s->dialog)->window);
		return;
	}

	if (!g_file_test (OREGANO_GLADEDIR "/simulation.glade2",
		G_FILE_TEST_EXISTS)) {
		oregano_error (_("Could not create simulation dialog"));
		return;
	}

	gui = glade_xml_new (OREGANO_GLADEDIR "/simulation.glade2", "toplevel", NULL);

	if (!gui) {
		oregano_error (_("Could not create simulation dialog"));
		return;
	}

	w = glade_xml_get_widget (gui, "toplevel");
	if (!w) {
		oregano_error (_("Could not create simulation dialog"));
		return;
	}

	s->dialog = GTK_DIALOG (w);
	g_signal_connect (G_OBJECT (w), "delete_event", G_CALLBACK (delete_event_cb), s);

	w = glade_xml_get_widget (gui, "progressbar");
	s->progress = GTK_PROGRESS_BAR (w);
	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (s->progress), 0.0);

	w = glade_xml_get_widget (gui, "progress_label");
	s->progress_label = GTK_LABEL (w);

	g_signal_connect (G_OBJECT (s->dialog), "response", G_CALLBACK (cancel_cb), s);

	gtk_widget_show_all (GTK_WIDGET (s->dialog));

	s->sv = sv;
	simulate_cmd (s);
}