void GscPreferencesWindow::on_device_options_device_entry_changed()
{
	Gtk::Entry* entry = 0;
	if ((entry = this->lookup_widget<Gtk::Entry*>("device_options_device_entry")))
		device_options_treeview->update_selected_row_device(entry->get_text());
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	memset(&last_refreshed, 0, sizeof(last_refreshed));
	for(int i = 1; i < argc; i++)
	{
		string tmp(argv[i]);
		if(tmp == "-s")display_spectrum = true;
		if(tmp == "-S")display_spectrogram = true;
	}
	Util.ChDir(Util.GetDirFromPath(Util.GetProgramPath()));
	//goto aaaaa;
	//fft=rfftw_create_plan(8192,
	for(UInt i = 0; i < CHANNELS; i++)
	{
		FFTFilter<jack_default_audio_sample_t>* trololo = new FFTFilter<jack_default_audio_sample_t>
		//bs, inbuffers,	outbuffers,	overlap,buffersperperiod,	paddingL,paddingR,	fftsize
		(1024, 12,			12,			2,		8,					0,		 0,			8192);

		//trololo->freq_scale=9./10.;
		setFilterParams(*trololo);
		filt[i] = trololo;
	}

	
	jack_set_error_function(error);
	JackStatus st;
	if((client = jack_client_open("jackfft", JackNoStartServer, &st)) == 0) {
		fprintf(stderr, "could not connect to server: status %i\n", st);
		return 1;
	}
	jack_set_process_callback(client, process, 0);
	jack_on_shutdown(client, jack_shutdown, 0);
	printf("engine sample rate: %u\n", srate = jack_get_sample_rate(client));
	/* create ports */
	int i;
	for(i = 0; i < CHANNELS; i++)
	{
		inputs.push_back(jack_port_register(client, CONCAT("input_" << i).c_str(),
						JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0));
		outputs.push_back(jack_port_register(client, CONCAT("output_" << i).c_str(),
						JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0));
#ifdef JACKFFT_USE_SOUNDTOUCH
		soundTouch[i].setSampleRate(srate);
		soundTouch[i].setChannels(1);
#endif
	}

//aaaaa:
	Gtk::Main kit(argc, argv);

	b = Gtk::Builder::create_from_file("main2.ui");
	
	Gtk::Window* window1;
	Gtk::Button* b_save;
	Gtk::Button* b_saveas;
	Gtk::Button* b_open;
	Gtk::Button* b_revert;
	Gtk::Button* b_apply;
	Gtk::Button* b_params;
	Gtk::Button* b_shift;
	Gtk::CheckButton* c_pitchshift;
	Gtk::CheckButton* c_spectrum;
	Gtk::CheckButton* c_spectrogram;
	Gtk::CheckButton* c_spectrogram1;
	Gtk::CheckButton* c_spectrum2;
	Gtk::CheckButton* c_mux;
	Gtk::Label* label8;
	Gtk::FileChooserDialog* filechooserdialog1;
	Gtk::Viewport* viewport1;
	Gtk::Viewport* viewport2;
	Gtk::Viewport* viewport4;
	Gtk::Scale* s_mux;
	
	//get controls
	JACKFFT_GETWIDGET(window1); JACKFFT_GETWIDGET(b_save); JACKFFT_GETWIDGET(b_saveas);
	JACKFFT_GETWIDGET(b_open); JACKFFT_GETWIDGET(b_revert); JACKFFT_GETWIDGET(b_apply);
	JACKFFT_GETWIDGET(c_pitchshift); JACKFFT_GETWIDGET(label8); JACKFFT_GETWIDGET(b_params);
	JACKFFT_GETWIDGET(b_shift); JACKFFT_GETWIDGET(filechooserdialog1); JACKFFT_GETWIDGET(viewport1);
	JACKFFT_GETWIDGET(viewport2); JACKFFT_GETWIDGET(c_spectrum); JACKFFT_GETWIDGET(c_spectrum2);
	JACKFFT_GETWIDGET(s_mux); JACKFFT_GETWIDGET(c_mux); JACKFFT_GETWIDGET(viewport4);
	JACKFFT_GETWIDGET(c_spectrogram); JACKFFT_GETWIDGET(c_spectrogram1);
	
	//initialize controls
	b_save->signal_clicked().connect(&save);
	b_saveas->signal_clicked().connect(&saveas);
	b_open->signal_clicked().connect(&loadfile);
	b_revert->signal_clicked().connect(&load);
	b_apply->signal_clicked().connect(&apply_pitchshift);
	c_pitchshift->signal_toggled().connect(&apply_pitchshift);
	
	
	c = new EQControl(EQ_POINTS);
	
	c->Change += EQControl::ChangeDelegate(&on_change, c);
	c->MouseMove += EQControl::MouseDelegate(&on_mousemove, c);
	
#ifdef CEPSTRUM
	c_eq2 = new EQControl(EQ_POINTS);
	c_eq2->Change += EQControl::ChangeDelegate(&on_change, c_eq2);
	c_eq2->MouseMove += EQControl::MouseDelegate(&on_mousemove, c_eq2);
#endif
	//UInt complexsize = (UInt)(((FFTFilter<jack_default_audio_sample_t>*)filt[0])->PeriodSize() / 2) + 1;


	apply_label_workaround(label8);

	b_params->signal_clicked().connect([]()
	{
		Gtk::Window* w1;
		Gtk::Dialog* d;
		b->get_widget("window1", w1);
		b->get_widget("dialog1", d);
		d->set_transient_for(*w1);
		if(d->run() != RESPONSE_APPLY)goto hhhhh;

		FFTFilter<jack_default_audio_sample_t>** tmp;
		tmp = new FFTFilter<jack_default_audio_sample_t>*[CHANNELS];
		Int bs, overlap, bpp, padding1, padding2, fftsize;
		Gtk::Entry* ent;
		b->get_widget("t_bs", ent);
		bs = atoi(ent->get_text().c_str());
		b->get_widget("t_overlap", ent);
		overlap = atoi(ent->get_text().c_str());
		b->get_widget("t_bpp", ent);
		bpp = atoi(ent->get_text().c_str());
		b->get_widget("t_padding1", ent);
		padding1 = atoi(ent->get_text().c_str());
		b->get_widget("t_padding2", ent);
		padding2 = atoi(ent->get_text().c_str());
		b->get_widget("t_fftsize", ent);
		fftsize = atoi(ent->get_text().c_str());
		Int buffers;
		buffers = (bpp + padding1 + padding2) + 4;
		for(int i = 0; i < CHANNELS; i++)
		{
			tmp[i] = new FFTFilter<jack_default_audio_sample_t>
			//bs, inbuffers,	outbuffers,	overlap,buffersperperiod,	padding1,padding2	fftsize
			(bs,  buffers,		buffers,	overlap,bpp,				padding1,padding2,	fftsize);
			setFilterParams(*(tmp[i]));
		}
		update_fft(tmp);
		apply_pitchshift1(tmp);
		filt2 = tmp; //assumed to be atomic on all cpus, otherwise the cpu sucks and is not supported
hhhhh:
		d->hide();
	});

	b_shift->signal_clicked().connect([]()
	{
		Gtk::Window* w1;
		Gtk::Dialog* d;
		b->get_widget("window1", w1);
		b->get_widget("dialog_shift", d);
		d->set_transient_for(*w1);
		if(d->run() != RESPONSE_OK)goto hhhhh;
		Gtk::Entry* ent;
		b->get_widget("t_x", ent);
		double x;
		x = atof(ent->get_text().c_str());
		for(Int i=0;i<EQ_POINTS;i++)
		{
			c->data[i]=scale_value_r(scale_value(c->data[i])*pow(2,x));
		}
		c->do_draw();
		update_fft();
	hhhhh:
		d->hide();
	});
	//d->signal_response().connect(&on_response);
	filechooserdialog1->add_button(Stock::CANCEL, RESPONSE_CANCEL);
	viewport1->add(*c);

	//c->set_hexpand(true);
	//c->set_vexpand(true);
	c->show();
	
#ifdef CEPSTRUM
	Gtk::Viewport* vp_eq2;
	b->get_widget("vp_eq2", vp_eq2);
	vp_eq2->add(*c_eq2);
	c_eq2->show();
#endif
	

	//if(display_spectrum)
	//{
	c2 = new EQControl(EQ_POINTS);
	viewport2->add(*c2);
	c2->show();
	c2->MouseMove += EQControl::MouseDelegate(&on_mousemove, c2);
	
	c3 = new HistoryControl(SPECTROGRAM_LEN,EQ_POINTS);
	c3->show();
	viewport4->add(*c3);
	/*}
	else
	{
		Gtk::Table* t1;
		b->get_widget("table1",t1);
		t1->remove(*v);
	}*/

	//spectrum display
	c_spectrum->set_active(display_spectrum);
	viewport2->set_visible(display_spectrum);
	c_spectrum->signal_toggled().connect([c_spectrum]()
	{
		Gtk::Window* w1;
		Gtk::Viewport* v;
		b->get_widget("window1", w1);
		b->get_widget("viewport1", v);
		
		gint ww,wh; w1->get_size(ww,wh);
		if(display_spectrum && !c_spectrum->get_active()) {
			w1->resize(ww,wh-v->get_allocation().get_height());
		} else if(!display_spectrum && c_spectrum->get_active()) {
			w1->resize(ww,wh+v->get_allocation().get_height());
		}
		display_spectrum = c_spectrum->get_active();
		Gtk::Viewport* vp;
		b->get_widget("viewport2", vp);
		vp->set_visible(display_spectrum);
	});
	
	//spectrogram display
	c_spectrogram->set_active(display_spectrogram);
	viewport4->set_visible(display_spectrogram);
	c_spectrogram->signal_toggled().connect([c_spectrogram]()
	{
		Gtk::Window* w1;
		Gtk::Viewport* v;
		b->get_widget("window1", w1);
		b->get_widget("viewport1", v);
		
		gint ww,wh; w1->get_size(ww,wh);
		if(display_spectrogram && !c_spectrogram->get_active()) {
			w1->resize(ww,wh-v->get_allocation().get_height());
		} else if(!display_spectrogram && c_spectrogram->get_active()) {
			w1->resize(ww,wh+v->get_allocation().get_height());
		}
		display_spectrogram = c_spectrogram->get_active();
		Gtk::Viewport* vp;
		b->get_widget("viewport4", vp);
		vp->set_visible(display_spectrogram);
	});
	
	//spectrogram output
	c_spectrogram1->set_active(output_spectrogram);
	c_spectrogram1->signal_toggled().connect([c_spectrogram1]()
	{
		if(output_spectrogram && !c_spectrogram1->get_active()) {
			disableSpectrogramOutput();
		} else if(!output_spectrogram && c_spectrogram1->get_active()) {
			enableSpectrogramOutput();
		}
		wmb();
		output_spectrogram=c_spectrogram1->get_active();
	});
	
	c_spectrum2->set_active(spectrum2);
	c_spectrum2->signal_toggled().connect([c_spectrum2]()
	{
		spectrum2 = c_spectrum2->get_active();
	});
	
	c_mux->set_active(do_mux);
	Gtk::Adjustment adj_mux(v_mux,0,1,0.01);
	s_mux->set_adjustment(adj_mux);
	
	auto update_mux=[&]() {
		do_mux=c_mux->get_active();
		v_mux=adj_mux.get_value();
	};
	
	s_mux->signal_value_changed().connect(update_mux);
	c_mux->signal_toggled().connect(update_mux);
	
	load();
	if(jack_activate(client)) {
		fprintf(stderr, "cannot activate client");
		return 1;
	}
	g_thread_init (NULL);
	gdk_threads_init();
	//glib_threads_init();
	
	pthread_t thr;
	pthread_create(&thr,NULL,&thread1,NULL);
	gdk_threads_enter();
	kit.run(*window1);
	gdk_threads_leave();
	jack_client_close(client);
	return 0;
}
Exemplo n.º 3
0
	synfig::String get_id()const { return entry_id.get_text(); }
Exemplo n.º 4
0
//shortcut keys TODO: customizable shortcut keys would be awesome.
bool studio::Widget_Preview::on_key_pressed(GdkEventKey *ev)
{
	//hide and show toolbar
	if (ev->keyval == gdk_keyval_from_name("h"))
	{
		if (toolbarisshown) hide_toolbar();
		else show_toolbar();
		return true;
	}

	//previous rendered frame
	if (ev->keyval == gdk_keyval_from_name("a"))
	{
		if(playing) pause();
		seek_frame(-1);
		return true;
	}

	//play/pause
	if (ev->keyval == gdk_keyval_from_name("s"))
	{
		on_play_pause_pressed();
		return true;
	}

	//next render frame
	if (ev->keyval == gdk_keyval_from_name("d"))
	{
		if(playing) pause();
		seek_frame(+1);
		return true;
	}

	//loop
	if (ev->keyval == gdk_keyval_from_name("f"))
	{
		if(get_loop_flag()) set_loop_flag(false);
		else set_loop_flag(true);
		return true;
	}

	//zoom level switching
	//zoom to 25%
	Gtk::Entry* entry = zoom_preview.get_entry();
	Glib::ustring text = entry->get_text();

	if (ev->keyval == gdk_keyval_from_name("1"))
	{
		if(entry->get_text() != "25%")
		{
			entry->set_text("25%");
		}
		return true;
	}

	if (ev->keyval == gdk_keyval_from_name("2"))
	{
		if(entry->get_text() != "50%")
		{
			entry->set_text("50%");
		}
		return true;
	}

	if (ev->keyval == gdk_keyval_from_name("3"))
	{
		if(entry->get_text() != "100%")
		{
			entry->set_text("100%");
		}
		return true;
	}

	if (ev->keyval == gdk_keyval_from_name("4"))
	{
		if(entry->get_text() != "200%")
		{
			entry->set_text("200%");
		}
		return true;
	}

	if (ev->keyval == gdk_keyval_from_name("5"))
	{
		if(entry->get_text() != _("Fit"))
		{
			entry->set_text(_("Fit"));
		}
		return true;
	}

	return false;
}
Exemplo n.º 5
0
bool studio::Widget_Preview::redraw(const Cairo::RefPtr<Cairo::Context> &cr)
{
	//And render the drawing area
	Glib::RefPtr<Gdk::Pixbuf> pxnew, px = currentbuf;
	cairo_surface_t* cs;
	bool use_cairo= preview->get_use_cairo();
	if(use_cairo)
	{
		if(current_surface)
			cs=cairo_surface_reference(current_surface);
		else
			return true;
	}
	
	int dw = draw_area.get_width();
	int dh = draw_area.get_height();
	
	if(use_cairo && !cs)
		return true;
	else if(!use_cairo && !px)
		return true;
	//made not need this line
	//if ( draw_area.get_height() == 0 || px->get_height() == 0 || px->get_width() == 0)
	//	return true;

	//figure out the scaling factors...
	float sx, sy;
	float q = 1 / preview->get_zoom();
	int nw, nh;
	int w,h;
	
	// grab the source dimensions
	if(use_cairo)
	{
		w=cairo_image_surface_get_width(cs);
		h=cairo_image_surface_get_height(cs);
	}
	else
	{
		w=px->get_width();
		h=px->get_height();
	}

	Gtk::Entry* entry = zoom_preview.get_entry();
	String str(entry->get_text());
	Glib::ustring text = str;
	const char *c = text.c_str();

	if (text == _("Fit") || text == "fit")
	{
		sx = dw / (float)w;
		sy = dh/ (float)h;

		//synfig::info("widget_preview redraw: now to scale the bitmap: %.3f x %.3f",sx,sy);

		//round to smallest scale (fit entire thing in window without distortion)
		if(sx > sy) sx = sy;

		//cleanup previous size request
		draw_area.set_size_request();
	}

	//limit zoom level from 0.01 to 10 times
	else if (atof(c) > 1000)
	{
		sx = sy = 10 * q;
	}

	else if (atof(c) <= 0 )
	{
		sx = sy = 0 ;
		draw_area.set_size_request(0, 0);
	}

	else sx = sy = atof(c) / 100 * q;

	//scale to a new pixmap and then copy over to the window
	nw = (int)(w * sx);
	nh = (int)(h * sx);

	if(nw == 0 || nh == 0)return true;

	if(!use_cairo)
		pxnew = px->scale_simple(nw, nh, Gdk::INTERP_NEAREST);

	//except "Fit" or "fit", we need to set size request for scrolled window
	if (text != _("Fit") && text != "fit")
	{
		draw_area.set_size_request(nw, nh);
		dw = draw_area.get_width();
		dh = draw_area.get_height();
	}

	//synfig::info("Now to draw to the window...");
	//copy to window
	Glib::RefPtr<Gdk::Window> wind = draw_area.get_window();
	if(!wind) synfig::warning("The destination window is broken...");

	if(!use_cairo)
	{
		/* Options for drawing...
			1) store with alpha, then clear and render with alpha every frame
				- more time consuming
				+ more expandable
			2) store with just pixel info
				- less expandable
				+ faster
				+ better memory footprint
		*/
		//px->composite(const Glib::RefPtr<Gdk::Pixbuf>& dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, InterpType interp_type, int overall_alpha) const

		cr->save();
		Gdk::Cairo::set_source_pixbuf(
			cr, //cairo context
			pxnew, //pixbuf
			//coordinates to place center of the preview window
			(dw - nw) / 2, (dh - nh) / 2
			);
		cr->paint();
		cr->restore();
	}
	else
	{
		cr->save();
		cr->scale(sx, sx);
		cairo_set_source_surface(cr->cobj(), cs, (dw - nw)/(2*sx), (dh - nh)/(2*sx));
		cairo_pattern_set_filter(cairo_get_source(cr->cobj()), CAIRO_FILTER_NEAREST);
		cairo_surface_destroy(cs);
		cr->paint();
		cr->restore();
	}

	//synfig::warning("Refresh the draw area");
	//make sure the widget refreshes

	return false;
}
void AsistenteJerarquia::on_botonAceptar_click() {
	VistaEntidadNueva* entidadPadre = NULL;
	VistaEntidadNueva* entidad = NULL;
	VistaEntidad * vep = NULL;
	Gtk::RadioButton* radio = NULL;
	bool musthide = false;
	int countSelected=0;
	Gtk::Entry *entryNombre = 0;
	this->m_builder->get_widget("entryNombre", entryNombre);
	string nom =entryNombre->get_text();
	if ( nom != "") {
		this->vjerarquia->setNombre(nom);
		Gtk::TreeModel::iterator iter = this->comboBox.get_active();
		if (iter) {
			//Si esta nodificando y ya tenia un padre
			vep = this->vjerarquia->getEntidadPadre();
			if (vep != NULL){
				vep->getEntidad()->quitarJerarquiaHija();
			}
			Gtk::TreeModel::Row row = *iter;
			entidadPadre = row[this->m_ColumnasCombo.m_col_vEnt_Pointer];
			this->vjerarquia->setEntidadPadre(entidadPadre);
			entidadPadre->getEntidad()->setJerarquiaHija(this->vjerarquia->getJerarquia());

			//cobertura, interseccion
			this->m_builder->get_widget("radioParcial", radio);
			if (radio->get_active() == true){
				this->vjerarquia->getJerarquia()->setCobertura(TIPO_COBERTURA_PARCIAL);
			}else{
				this->vjerarquia->getJerarquia()->setCobertura(TIPO_COBERTURA_TOTAL);
			}
			this->m_builder->get_widget("radioExclusiva", radio);
			if (radio->get_active() == true){
				this->vjerarquia->getJerarquia()->setInterseccion(TIPO_INTERSECCION_EXCLUSIVA);
			}else{
				this->vjerarquia->getJerarquia()->setInterseccion(TIPO_INTERSECCION_SUPERPUESTA);
			}

			//Ahora seteo las entidades hijas
			typedef Gtk::TreeModel::Children type_children;
			type_children children = this->refTreeModel->children();
			type_children::iterator iter = children.begin();
			type_children::iterator iter1 = children.end();
			while (iter != iter1) {
				Gtk::TreeModel::Row row = *iter;
				// si esta seleccionada la agrego o actualizo
				if (row[this->m_Columnas.m_col_selected] == true) {
					countSelected++;
					if (this->vjerarquia->unidaConEntidad(row[this->m_Columnas.m_col_vEnt_Pointer]) == false){
						entidad = row[this->m_Columnas.m_col_vEnt_Pointer];
						this->vjerarquia->agregarEntidadEspecializada(entidad);
						this->vjerarquia->getJerarquia()->agregarEntidadEspecializada(entidad->getEntidadNueva());
						entidad->getEntidadNueva()->agregarJerarquiaPadre(this->vjerarquia->getJerarquia());
					}
				}else{
					if (this->vjerarquia->unidaConEntidad(row[this->m_Columnas.m_col_vEnt_Pointer]) == true){
						this->vjerarquia->removerEntidadEspecializada(row[this->m_Columnas.m_col_vEnt_Pointer]);
					}
				}
				iter++;
			}
			if (countSelected>0){
				musthide = true;
			}else{
				Gtk::MessageDialog err_dialog1(*this, "Select at least one children", false,
										Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
				err_dialog1.run();
			}
		}else{
			Gtk::MessageDialog err_dialog2(*this, "Select the father", false,
													Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
							err_dialog2.run();
		}
	} else {
		Gtk::MessageDialog err_dialog(*this, "No name", false,
						Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
		err_dialog.run();
	}
	if (musthide==true){
		this->vjerarquia->resetearLanzarProp();
		this->hide();
	}
	Ide::getInstance()->getDiagActual()->queue_draw();
	Ide::getInstance()->regenerarTreePanel();
}
 std::string getEditedOptions() const { return m_OptionsEntry.get_text(); };
Exemplo n.º 8
0
 PinString getPin() {
     return m_textInput.get_text().c_str();
     }
Exemplo n.º 9
0
void Settings::get_from_gui (Builder &builder, int i)
{
  const char *glade_name = settings[i].glade_name;

  if (glade_name == NULL)
        return; /* Not an automatically connected setting */

  switch (settings[i].type) {
  case T_BOOL: {
    Gtk::CheckButton *check = NULL;
    builder->get_widget (glade_name, check);
    if (!check)
      std::cerr << "Missing boolean config item " << glade_name << "\n";
    else
      *PTR_BOOL(this, i) = check->get_active();
    break;
  }
  case T_INT:
  case T_FLOAT: {
    Gtk::Widget *w = NULL;
    builder->get_widget (glade_name, w);
    if (!w) {
      std::cerr << "Missing GUI element " << glade_name << "\n";
      break;
    }

    Gtk::SpinButton *spin = dynamic_cast<Gtk::SpinButton *>(w);
    if (spin) {
      if (settings[i].type == T_INT)
          *PTR_INT(this, i) = spin->get_value();
      else
          *PTR_FLOAT(this, i) = spin->get_value();
      break;
    }

    Gtk::Range *range = dynamic_cast<Gtk::Range *>(w);
    if (range) {
      if (settings[i].type == T_INT)
          *PTR_INT(this, i) = range->get_value();
      else
          *PTR_FLOAT(this, i) = range->get_value();
    }
    break;
  }
  case T_STRING: {
    Gtk::Entry *e = NULL;
    builder->get_widget (glade_name, e);
    if (!e) {
      std::cerr << "Missing user interface item " << glade_name << "\n";
      break;
    }
    *PTR_STRING(this, i) = std::string(e->get_text());
    break;
  }
  case T_COLOUR_MEMBER:
    // Ignore, colour members are special
    break;
  default:
    std::cerr << "corrupt setting type\n";
    break;
  }

  if (settings[i].triggers_redraw)
    m_signal_visual_settings_changed.emit();
}
Exemplo n.º 10
0
	synfig::String get_id()const { return id_entry.get_text(); }
Exemplo n.º 11
0
int common___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji) {
	const Glib::ustring& p0=(*p)[0];

	if(p0=="剪贴板"){
		if(siz==-1)return 1;
		Glib::RefPtr<Gtk::Clipboard> cb = Gtk::Clipboard::get();
		if(p->size()>1)
			cb->set_text((*p)[1].c_str());
		else
			*addr_ret=dup__(cb->wait_for_text().c_str());
		return 1;
	}
	if(p0=="全屏"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->fullscreen();
		return 1;
	}
	if(p0=="取消全屏"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->unfullscreen();
		return 1;
	}
	if(p0=="置顶"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_keep_above(true);
		return 1;
	}
	if(p0=="取消置顶"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_keep_above(false);
		return 1;
	}
	if(p0=="无边框"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_decorated(false);
		return 1;
	}
	if(p0=="跳过任务栏"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		w->set_skip_taskbar_hint(true);
		return 1;
	}
	if(p0=="窗口活动"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,1);
		if(!w)
			return 1;
		cpy__(buf,w->property_is_active(),siz);
		return 1;
	}
	if(p0=="图标"){
		if(siz==-1)return 1;
		Gtk::Window* w=w__(p,2);
		if(!w)
			return 1;
		if(p->size()>1){
			const Glib::ustring& p1=(*p)[1];
			w->set_icon_name(p1);
			Glib::RefPtr<Gdk::Pixbuf> pb=Gdk::Pixbuf::create_from_file(p1);
			if(pb)
				w->set_icon(pb);
		}else
			cpy__(buf,w->get_icon_name().c_str(),siz);
		return 1;
	}

	if(p->size()<2){
		return 0;
	}

	Gtk::Entry* e;
	Gtk::Label* l;
	Gtk::Button* b;
	Gtk::ToolButton* tb;
	Gtk::TextView* tv;
	Gtk::Notebook* n;
	Gtk::Bin* bi;
	Gtk::Widget* w;
	Gtk::Statusbar* sb;
	Gtk::FileChooserButton* fcb;
	Gtk::ToggleButton* cb;//CheckButton RadioButton
	Gtk::ToggleToolButton*ttb;
	//Gtk::RadioButtonGroup* rbg;
	Gtk::MenuItem* mi;
	Gtk::CheckMenuItem* cmi;

	if(p0=="窗口标题"){
		if(siz==-1)return 1;
		Gtk::Window* w1;
		if((*p)[1]=="")
			w1=sh_->main_win_;
		else{
			sh_->builder_->get_widget((*p)[1], w);
			if(!w){
				d_(sh_,err_show_wufa_,2,p,1);
				return 1;
			}
			w1=(Gtk::Window*)w;
		}
		if(p->size()<3){
			cpy__(buf,w1->get_title().c_str(),siz);
		}else{
			w1->set_title((*p)[2]);
		}
		return 1;
	}

	if(p0=="内容"){
		if(siz==-1)return 1;
		Glib::ustring text;
		bool read=false;
		int start=2;
		if(p->size()>2&&(*p)[2]=="读取"){
			read=true;
			start=3;
		}
		for(size_t i=start;i<p->size();i++){
			if((*p)[i]=="源码")
				text+=sh_->src_;
			else{
				if(read){
					string name=sh_->ui_file_;
					size_t i1=name.rfind('/');
					if(i1==string::npos)
						i1=name.rfind('\\');
					if(i1!=string::npos)
						name=name.substr(0,i1+1);
					name+=(*p)[i];
					file_get__(name.c_str(),text);
				}else
					text+=(*p)[i];
			}
		}
		if((*p)[1]=="源码"){
			if(p->size()>2)
				sh_->src_=text;
			else
				*addr_ret=dup__(sh_->src_.c_str());
			return 1;
		}else{
			sh_->builder_->get_widget((*p)[1], e);
			if(e){
				if(p->size()<3){
					*addr_ret=dup__(e->get_text().c_str());
				}else{
					e->set_text(text);
				}
				return 1;
			}
			sh_->builder_->get_widget((*p)[1], l);
			if(l){
				if(p->size()<3){
					*addr_ret=dup__(l->get_text().c_str());
				}else{
					l->set_markup(text);
				}
				return 1;
			}
			sh_->builder_->get_widget((*p)[1], tv);
			if(tv){
				if(p->size()<3){
					*addr_ret=dup__(tv->get_buffer()->get_text().c_str());
				}else{
					tv->get_buffer()->set_text(text);
				}
				return 1;
			}
			sh_->builder_->get_widget((*p)[1], fcb);
			if(fcb){
				if(p->size()<3){
					*addr_ret=dup__(fcb->get_filename().c_str());
				}else{
					fcb->set_filename(text);

					  /*GtkFileChooser *chooser=(GtkFileChooser *)fcb->gobj();
					  const gchar    *filename=text.c_str();
					  gtk_file_chooser_unselect_all (chooser);
					  //gtk_file_chooser_select_filename (chooser, filename);
					  GFile *file;
					  gboolean result;
					  file = g_file_new_for_path (filename);
					  result = gtk_file_chooser_select_file (chooser, file, NULL);
//#define GTK_FILE_CHOOSER_GET_IFACE(inst)  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_CHOOSER, GtkFileChooserIface))
					  //result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, NULL);
					  g_object_unref (file);*/
				}
				return 1;
			}
			sh_->builder_->get_widget((*p)[1], cb);
			if(cb){
				if(p->size()<3){
					cpy__(buf,cb->get_label().c_str(),siz);
				}else{
					cb->set_label(text);
				}
				return 1;
			}
			sh_->builder_->get_widget((*p)[1], sb);
			if(sb){
				if(p->size()<3){
				}else{
					sb->push(text,sb->get_context_id(text));
					return 1;
				}
			}
			sh_->builder_->get_widget((*p)[1], n);
			if(n){
				if(p->size()<3){
					cpy__(buf,n->get_current_page()+1,siz);
				}else{
					n->set_current_page(s2i__(text,1)-1);
				}
				return 1;
			}
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="勾选"){
		if(siz==-1)return 1;
		if(p->size()>2){
			bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str());
			for(size_t i=1;i<p->size()-1;i++){
				sh_->builder_->get_widget((*p)[i], cb);
				if(cb){
					cb->set_active(b);
					continue;
				}
				sh_->builder_->get_widget((*p)[i], ttb);
				if(ttb){
					ttb->set_active(b);
					continue;
				}
				sh_->builder_->get_widget((*p)[i], cmi);
				if(cmi){
					cmi->set_active(b);
					continue;
				}
				d_(sh_,err_show_wufa_,2,p,i);
				return 1;
			}
		}else{
			sh_->builder_->get_widget((*p)[1], cb);
			if(cb){
				cpy__(buf,cb->get_active(),siz);
				return 1;
			}
			sh_->builder_->get_widget((*p)[1], ttb);
			if(ttb){
				cpy__(buf,ttb->get_active(),siz);
				return 1;
			}
			sh_->builder_->get_widget((*p)[1], cmi);
			if(cmi){
				cpy__(buf,cmi->get_active(),siz);
				return 1;
			}
			d_(sh_,err_show_wufa_,2,p,1);
		}
		return 1;
	}
	if(p0=="提示文字"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], w);
		if(w){
			if(p->size()<3){
				cpy__(buf,w->get_tooltip_markup().c_str(),siz);
			}else{
				w->set_tooltip_markup((*p)[2]);
			}
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="焦点"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], w);
		if(w){
			w->grab_focus();
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="侦听"){
		if(siz==-1)return 1;
		if(p->size()>2){
			if((*p)[1]=="点击"){
				Glib::ustring code;
				size_t size=p->size();
				if(size>=4)
					code=(*p)[--size];
				for(size_t i=2;i<size;i++){
					if((*p)[i].length()==0)
						continue;
					Glib::SignalProxy0< void >* sp0=NULL;
					Glib::SignalProxy1< bool, GdkEventButton* >* sp1=NULL;
					Glib::ustring dong;
					bi=NULL;
					w=NULL;
					for(;;){
						sh_->builder_->get_widget((*p)[i], b);
						if(b){
							bi=b;
							w=b;
							dong=b->get_label();
							sp0=&b->signal_clicked();
							break;
						}

						sh_->builder_->get_widget((*p)[i], tb);
						if(tb){
							bi=tb;
							w=tb;
							dong=tb->get_label();
							sp0=&tb->signal_clicked();
							break;
						}

						sh_->builder_->get_widget((*p)[i], mi);
						if(mi){
							bi=mi;
							w=mi;
							sp1=&mi->signal_button_press_event();
							break;
						}

						sh_->builder_->get_widget((*p)[i], w);
						if(w){
							sp1=&w->signal_button_press_event();
							break;
						}

						d_(sh_,err_show_wufa_,3,p,i,0);
						return 1;
					}

					if(w){
						const char*arg4;
						if(dong.empty()){
							dong=(*p)[i];
							arg4=NULL;
						}else
							arg4=(*p)[i].c_str();
						control___* c;
						const char*zhao;
						const char*arg3;
						//不buf会乱指
						Glib::ustring buf3;
						if(w==mi){
							zhao="菜单";
							buf3=mi->get_label();
						}else{
							zhao=bi!=NULL?"按钮":(*p)[1].c_str();
							buf3=w->get_tooltip_text();
						}
						arg3=buf3.c_str();
						if(!arg4)
							c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3);
						else
							c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3,arg4);
						if(sp0)
							sp0->connect(sigc::mem_fun(*c, &control___::on__));
						else if(sp1)
							sp1->connect(sigc::mem_fun(*c, &control___::on1__));
						w->set_data("ctl",c);
						if(p->size()==4)
							break;
					}
				}
				return 1;
			}
			d_(sh_,err_show_wufa_,2,p,1);
			return 1;
		}
		d_(sh_,err_show_buzu_,p);
		return 1;
	}
	if(p0=="点击"){
		if(siz==-1)return 1;
		for(size_t i=1;i<p->size();i++){
			w=NULL;
			for(;;){
				sh_->builder_->get_widget((*p)[i], b);
				if(b){
					w=b;
					break;
				}
				sh_->builder_->get_widget((*p)[i], tb);
				if(tb){
					w=tb;
					break;
				}
				sh_->builder_->get_widget((*p)[i], mi);
				if(mi){
					w=mi;
					break;
				}
				sh_->builder_->get_widget((*p)[i], w);
				if(w){
					break;
				}
				d_(sh_,err_show_wufa_,3,p,i,0);
				return 1;
			}
			control___* c=(control___*)w->get_data("ctl");
			if(!c){
				d_(sh_,err_show_wufa_,3,p,i,0);
				return 1;
			}
			c->on__();
		}
		return 1;
	}
	if(p0=="可见"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], w);
		if(w){
			if(p->size()>2){
				bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str());
				for(size_t i=1;i<p->size()-1;i++){
					sh_->builder_->get_widget((*p)[i], w);
					if(w)
						w->set_visible(b);
					else
						d_(sh_,err_show_wufa_,2,p,i);
				}
			}else
				cpy__(buf,w->get_visible(),siz);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="可见状态"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], e);
		if(e){
			bool b;
			if(p->size()>2)
				b=d_(sh_,bool_,(*p)[2].c_str());
			else
				b=!e->get_visibility();
			e->set_visibility(b);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="敏感"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], w);
		if(w){
			if(p->size()>2){
				bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str());
				for(size_t i=1;i<p->size()-1;i++){
					sh_->builder_->get_widget((*p)[i], w);
					if(w)
						w->set_sensitive(b);
					else
						d_(sh_,err_show_wufa_,2,p,i);
				}
			}else
				cpy__(buf,w->get_sensitive(),siz);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="区域信息"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], w);
		if(w){
			Gtk::Allocation a=w->get_allocation();
			sprintf(buf,"%d,%d,%d,%d,",a.get_x(),a.get_y(),a.get_width(),a.get_height());
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="鼠标"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], w);
		if(w){
			gint  x,y;
			/*Glib::RefPtr<Gdk::Window> w2=w->get_window();
			w2->get_pointer(x,y,);*/
			w->get_pointer(x,y);
			sprintf(buf,"%d,%d,",x,y);
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="数目"){
		if(siz==-1)return 1;
		sh_->builder_->get_widget((*p)[1], n);
		if(n){
			sprintf(buf,"%d",n->get_n_pages());
			return 1;
		}
		d_(sh_,err_show_wufa_,2,p,1);
		return 1;
	}
	if(p0=="遍历"){
		if(siz==-1)return 1;
		const Glib::ustring& code=(*p)[p->size()-1];
		bool exe=true;
		char s1[16];
		const char*argv[]={s1};
		int err;
		for(size_t i=1;i<p->size()-1&&exe;i++){
			sh_->builder_->get_widget((*p)[i], n);
			if(n){
				for(int pn=0;pn<n->get_n_pages();pn++){
					w=n->get_nth_page(pn);
					sprintf(s1,"%d",pn+1);
					d_(sh_,call4_1_,code.c_str(),shangji,NULL,NULL,NULL,1,argv,0,&err);
					if(err){
						if(err==jieshiqi_go_+keyword_break_)
							break;
						if(err==jieshiqi_go_+keyword_continue_)
							continue;
						if(err==jieshiqi_go_+keyword_exit_){
							exe=false;
							break;
						}
						d_(sh_,call4_2_,err);
						return 1;
					}
				}
				continue;
			}
			d_(sh_,err_show_wufa_,2,p,i);
		}
		return 1;
	}
	return 0;
}
Exemplo n.º 12
0
string getTextEntry(string entry) {
    Gtk::Entry* ent;
    VRGuiBuilder()->get_widget(entry, ent);
    return ent->get_text();
}