예제 #1
0
void load_rcfile_cb ( GtkWidget *widget, AnypaperWindow *window )
{
	GtkWidget *dialog;
	gint positionx, positiony, rangex, rangey;

	dialog = gtk_file_chooser_dialog_new ("Open File", GTK_WINDOW(window->priv->window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER (dialog), rcfile);

	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) 
	{
		block_callback(window);
		g_free(rcfile);
		rcfile = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
		anypaper_parameters_load(window->parameters, rcfile);
		positionx = window->parameters->positionx;
		positiony = window->parameters->positiony;
		anypaper_image_make (window->image, window->parameters);
		rangex = window->parameters->positionx;
		rangey = window->parameters->positiony;
		anypaper_parameters_position_test(window->parameters, rangex, rangey, positionx, positiony);
		anypaper_image_move (window->image, window->parameters);
		gtk_entry_set_text (GTK_ENTRY (window->priv->def_entry), window->parameters->defaultfile);
		gtk_entry_set_text (GTK_ENTRY (window->priv->com_entry), window->parameters->command);
		gtk_combo_box_set_active (GTK_COMBO_BOX (window->priv->combo_interpolation), interpolation_int (window->parameters->interpolation));
		gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->preview), window->image->preview);
		unblock_callback(window);
		}
	gtk_widget_destroy (dialog);
}
예제 #2
0
//Yes, this uses goto. Yes, goto is evil. We need a single point of exit.
void Simulation::getBlock(float* out, unsigned int channels, bool mayApplyMixingMatrix) {
	if(out == nullptr || channels == 0) goto end; //nothing to do.
	if(block_callback) block_callback(outgoingObject(this->shared_from_this()), block_callback_time, block_callback_userdata);
	//configure our connection to the number of channels requested.
	final_output_connection->reconfigure(0, channels);
	//append buffers to the final_outputs vector until it's big enough.
	//in a sane application, we'll never go above 8 channels so keeping them around is no big deal.
	while(final_outputs.size() < channels) final_outputs.push_back(allocArray<float>(block_size));
	//zero the outputs we need.
	for(unsigned int i= 0; i < channels; i++) memset(final_outputs[i], 0, sizeof(float)*block_size);
	//Inform nodes that we are going to tick.
	for(auto &i: nodes) {
		auto n = i.lock();
		if(n) n->willTick();
	}
	//Use the planner.
	planner->execute(std::dynamic_pointer_cast<Job>(shared_from_this()), threads);
	//write, applying mixing matrices as needed.
	final_output_connection->addNodeless(&final_outputs[0], true);
	//interleave the samples.
	interleaveSamples(channels, block_size, channels, &final_outputs[0], out);
	block_callback_time +=block_size/sr;
	end:
	int maintenance_count=maintenance_start;
	for(auto &i: nodes) {
		auto i_s=i.lock();
		if(i_s == nullptr) continue;
		if(maintenance_count % maintenance_rate== 0) i_s->doMaintenance();
		maintenance_count++;
	}
	maintenance_start++;
	//and ourselves.
	if(maintenance_start%maintenance_rate == 0) doMaintenance();
	tick_count ++;
}
예제 #3
0
static void set_image_position_cb ( GtkWidget *widget, AnypaperWindow *window )
{
	block_callback(window);
	window->parameters->positionx = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (window->priv->spin1));
	window->parameters->positiony = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (window->priv->spin2));
	anypaper_image_move (window->image, window->parameters);
	gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->preview), window->image->preview);
	unblock_callback(window);
}
예제 #4
0
static void change_other_scale_cb ( GtkWidget *widget, AnypaperWindow *window )
{
	gdouble value;
	g_signal_handlers_block_by_func (G_OBJECT (window->priv->spin5), G_CALLBACK (change_other_scale_cb), window);
	g_signal_handlers_block_by_func (G_OBJECT (window->priv->spin6), G_CALLBACK (change_other_scale_cb), window);
	block_callback(window);
	value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (window->priv->spin5), value);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (window->priv->spin6), value);
	window->parameters->scalex = window->parameters->scaley = value;
	g_signal_handlers_unblock_by_func (G_OBJECT (window->priv->spin5), G_CALLBACK (change_other_scale_cb), window);
	g_signal_handlers_unblock_by_func (G_OBJECT (window->priv->spin6), G_CALLBACK (change_other_scale_cb), window);
	unblock_callback(window);
	set_image_common (window);
}
예제 #5
0
static void set_image_interpolation_cb ( GtkWidget *widget, AnypaperWindow *window )
{
	int i, positionx, positiony;
	block_callback(window);
	i = gtk_combo_box_get_active (GTK_COMBO_BOX (window->priv->combo_interpolation));
	if (i == 0) window->parameters->interpolation=GDK_INTERP_NEAREST;
	if (i == 1) window->parameters->interpolation=GDK_INTERP_TILES;
	if (i == 2) window->parameters->interpolation=GDK_INTERP_BILINEAR;
	if (i == 3) window->parameters->interpolation=GDK_INTERP_HYPER;	
	positionx = window->parameters->positionx;
	positiony = window->parameters->positiony;
	anypaper_image_make (window->image, window->parameters);
	window->parameters->positionx = positionx;
	window->parameters->positiony = positiony;
	anypaper_image_move (window->image, window->parameters);
	gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->preview), window->image->preview);
	unblock_callback(window);
}
예제 #6
0
static void set_image_common( AnypaperWindow *window )
{
	GtkWidget *dialog_error;

	block_callback(window);
	if (!anypaper_image_make (window->image, window->parameters))
	{
		dialog_error = gtk_message_dialog_new (GTK_WINDOW (window->priv->window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Could not open image file");
		gtk_window_set_title (GTK_WINDOW (dialog_error), "Error");
	 	g_signal_connect_swapped (dialog_error, "response", G_CALLBACK (gtk_widget_destroy), dialog_error);
		gtk_widget_show(dialog_error);
	}
	anypaper_window_set_position_range(window, window->parameters->positionx, window->parameters->positiony);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin1), (gdouble) window->parameters->positionx);
	gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin2), (gdouble) window->parameters->positiony);
	anypaper_image_move (window->image, window->parameters);
	gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->preview), window->image->preview);
	unblock_callback(window);
}
예제 #7
0
void load_lastwallpaperfile_cb ( GtkWidget *widget, AnypaperWindow *window )
{
	GtkWidget *dialog;
	GdkColor color;
	gint positionx, positiony, rangex, rangey;

	dialog = gtk_file_chooser_dialog_new ("Open File", GTK_WINDOW(window->priv->window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER (dialog), lastwallpaperfile);

	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) 
	{
		block_callback(window);
		g_free(lastwallpaperfile);
		lastwallpaperfile = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
		anypaper_parameters_load(window->parameters, lastwallpaperfile);
		positionx = window->parameters->positionx;
		positiony = window->parameters->positiony;
		anypaper_image_make (window->image, window->parameters);
		rangex = window->parameters->positionx;
		rangey = window->parameters->positiony;
		anypaper_parameters_position_test(window->parameters, rangex, rangey, positionx, positiony);
		anypaper_image_move (window->image, window->parameters);
		gtk_entry_set_text (GTK_ENTRY (window->priv->file_entry), window->parameters->file);
		anypaper_window_set_position_range(window, rangex, rangey);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin1), window->parameters->positionx);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin2), window->parameters->positiony);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin3), window->parameters->width);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin4), window->parameters->height);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin5), window->parameters->scalex);
		gtk_spin_button_set_value(GTK_SPIN_BUTTON (window->priv->spin6), window->parameters->scaley);
		gtk_combo_box_set_active (GTK_COMBO_BOX (window->priv->combo), window->parameters->style);
		gdk_color_parse (window->parameters->background, &color);
		gtk_color_button_set_color (GTK_COLOR_BUTTON(window->priv->cbutton), &color);
		gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->preview), window->image->preview);
		unblock_callback(window);
	}
	gtk_widget_destroy (dialog);
}