Beispiel #1
0
void Gobby::TaskOpenMultiple::on_location_response(int response_id)
{
	if(response_id == Gtk::RESPONSE_ACCEPT)
	{
		DocumentLocationDialog& dialog =
			get_document_location_dialog();

		InfBrowserIter iter;
		InfBrowser* browser = dialog.get_selected_directory(&iter);
		g_assert(browser != NULL);

		OperationOpenMultiple* operation =
			get_operations().create_documents(
				browser, &iter,
				get_preferences(), m_files);
	}

	finish();
}
Beispiel #2
0
int AModule::import_samples(AEdit *edit, 
	int64_t start_project,
	int64_t edit_startproject,
	int64_t edit_startsource,
	int direction,
	int sample_rate,
	Samples *buffer,
	int64_t fragment_len)
{
	int result = 0;
// start in EDL samplerate
	int64_t start_source = start_project - 
		edit_startproject + 
		edit_startsource;
// fragment size adjusted for speed curve
	int64_t speed_fragment_len = fragment_len;
// boundaries of input fragment required for speed curve
	double max_position = 0;
	double min_position = 0;

	double speed_position = edit_startsource;
// position in source where speed curve starts reading
	double speed_position1 = speed_position;
// position in source where speed curve finishes
	double speed_position2 = speed_position;

// Need speed curve processing
	int have_speed = 0;
// Temporary buffer for rendering speed curve
	Samples *speed_buffer = buffer;
	const int debug = 0;

if(debug) printf("AModule::import_samples %d edit=%p nested_edl=%p\n", 
__LINE__,
edit,
nested_edl);
	if(nested_edl && edit->channel >= nested_edl->session->audio_channels)
		return 1;
if(debug) printf("AModule::import_samples %d\n", __LINE__);

	this->channel = edit->channel;
if(debug) printf("AModule::import_samples %d speed_fragment_len=%ld\n", 
__LINE__,
speed_fragment_len);




// apply speed curve to source position so the timeline agrees with the playback
	if(track->has_speed())
	{
// get speed adjusted position from start of edit.
		FloatAuto *previous = 0;
		FloatAuto *next = 0;
		FloatAutos *speed_autos = (FloatAutos*)track->automation->autos[AUTOMATION_SPEED];
		for(int64_t i = edit_startproject; i < start_project; i++)
		{
			double speed = speed_autos->get_value(i, 
				PLAY_FORWARD,
				previous,
				next);
			speed_position += speed;
		}

		speed_position1 = speed_position;


// calculate boundaries of input fragment required for speed curve
		max_position = speed_position;
		min_position = speed_position;
		for(int64_t i = start_project; i < start_project + fragment_len; i++)
		{
			double speed = speed_autos->get_value(i, 
				PLAY_FORWARD,
				previous,
				next);
			speed_position += speed;
			if(speed_position > max_position) max_position = speed_position;
			if(speed_position < min_position) min_position = speed_position;
		}

		speed_position2 = speed_position;
		if(speed_position2 < speed_position1)
		{
			max_position += 1.0;
//			min_position -= 1.0;
			speed_fragment_len = (int64_t)(max_position - min_position);
		}
		else
		{
			max_position += 1.0;
			speed_fragment_len = (int64_t)(max_position - min_position);
		}

printf("AModule::import_samples %d %f %f %f %f\n", 
__LINE__, 
min_position, 
max_position,
speed_position1,
speed_position2);

// new start of source to read from file
		start_source = (int64_t)min_position;
		have_speed = 1;



// swap in the temp buffer
		if(speed_temp && speed_temp->get_allocated() < speed_fragment_len)
		{
			delete speed_temp;
			speed_temp = 0;
		}
		
		if(!speed_temp)
		{
			speed_temp = new Samples(speed_fragment_len);
		}
		
		speed_buffer = speed_temp;
	}



	if(speed_fragment_len == 0)
		return 1;



// Source is a nested EDL
	if(edit->nested_edl)
	{
		int command;
		asset = 0;
		
		if(direction == PLAY_REVERSE)
			command = NORMAL_REWIND;
		else
			command = NORMAL_FWD;

if(debug) printf("AModule::import_samples %d\n", __LINE__);
		if(!nested_edl || nested_edl->id != edit->nested_edl->id)
		{
			nested_edl = edit->nested_edl;
			if(nested_renderengine)
			{
				delete nested_renderengine;
				nested_renderengine = 0;
			}

			if(!nested_command)
			{
				nested_command = new TransportCommand;
			}


			if(!nested_renderengine)
			{
				nested_command->command = command;
				nested_command->get_edl()->copy_all(nested_edl);
				nested_command->change_type = CHANGE_ALL;
				nested_command->realtime = renderengine->command->realtime;
				nested_renderengine = new RenderEngine(0,
					get_preferences(), 
					0,
					renderengine ? renderengine->channeldb : 0,
					1);
				nested_renderengine->set_acache(get_cache());
// Must use a private cache for the audio
// 				if(!cache) 
// 				{
// 					cache = new CICache(get_preferences());
// 					private_cache = 1;
// 				}
// 				nested_renderengine->set_acache(cache);
				nested_renderengine->arm_command(nested_command);
			}
		}
if(debug) printf("AModule::import_samples %d speed_fragment_len=%d\n", __LINE__, (int)speed_fragment_len);

// Allocate output buffers for all channels
		for(int i = 0; i < nested_edl->session->audio_channels; i++)
		{
			if(nested_allocation < speed_fragment_len)
			{
				delete nested_output[i];
				nested_output[i] = 0;
			}

			if(!nested_output[i])
			{
				nested_output[i] = new Samples(speed_fragment_len);
			}
		}
if(debug) printf("AModule::import_samples %d\n", __LINE__);

		if(nested_allocation < speed_fragment_len)
			nested_allocation = speed_fragment_len;

// Update direction command
		nested_renderengine->command->command = command;

// Render the segment
		if(!nested_renderengine->arender)
		{
			bzero(speed_buffer->get_data(), speed_fragment_len * sizeof(double));
		}
		else
		if(sample_rate != nested_edl->session->sample_rate)
		{
// Read through sample rate converter.
			if(!resample)
			{
				resample = new AModuleResample(this);
			}

if(debug) printf("AModule::import_samples %d %d %d\n", 
__LINE__,
(int)sample_rate,
(int)nested_edl->session->sample_rate);
			result = resample->resample(speed_buffer,
				speed_fragment_len,
				nested_edl->session->sample_rate,
				sample_rate,
				start_source,
				direction);
// Resample reverses to keep it running forward.
if(debug) printf("AModule::import_samples %d\n", __LINE__);
		}
		else
		{
// Render without resampling
if(debug) printf("AModule::import_samples %d\n", __LINE__);
			result = nested_renderengine->arender->process_buffer(
				nested_output, 
				speed_fragment_len,
				start_source);
if(debug) printf("AModule::import_samples %d\n", __LINE__);
			memcpy(speed_buffer->get_data(),
				nested_output[edit->channel]->get_data(),
				speed_fragment_len * sizeof(double));
if(debug) printf("AModule::import_samples %d\n", __LINE__);

// Reverse fragment so ::render can apply transitions going forward.
			if(direction == PLAY_REVERSE)
			{
				Resample::reverse_buffer(speed_buffer->get_data(), speed_fragment_len);
			}
		}

if(debug) printf("AModule::import_samples %d\n", __LINE__);
	}
	else
// Source is an asset
	if(edit->asset)
	{
		nested_edl = 0;
if(debug) printf("AModule::import_samples %d\n", __LINE__);
		asset = edit->asset;

if(debug) printf("AModule::import_samples %d\n", __LINE__);
		get_cache()->age();

if(debug) printf("AModule::import_samples %d\n", __LINE__);
		if(nested_renderengine)
		{
			delete nested_renderengine;
			nested_renderengine = 0;
		}

if(debug) printf("AModule::import_samples %d\n", __LINE__);

		if(!(file = get_cache()->check_out(
			asset,
			get_edl())))
		{
// couldn't open source file / skip the edit
			printf(_("AModule::import_samples Couldn't open %s.\n"), asset->path);
			result = 1;
		}
		else
		{
			result = 0;


			if(sample_rate != asset->sample_rate)
			{
// Read through sample rate converter.
				if(!resample)
				{
					resample = new AModuleResample(this);
				}

if(debug) printf("AModule::import_samples %d %d %d\n", 
__LINE__,
sample_rate,
asset->sample_rate);
				result = resample->resample(speed_buffer,
					speed_fragment_len,
					asset->sample_rate,
					sample_rate,
					start_source,
					direction);
// Resample reverses to keep it running forward.
			}
			else
			{

if(debug)
printf("AModule::import_samples %d channel=%d start_source=%ld len=%d\n", __LINE__, edit->channel, start_source, (int)speed_fragment_len);
				file->set_audio_position(start_source);
				file->set_channel(edit->channel);
				result = file->read_samples(speed_buffer, speed_fragment_len);
// Reverse fragment so ::render can apply transitions going forward.
if(debug) printf("AModule::import_samples %d speed_buffer=%p data=%p speed_fragment_len=%d\n", 
__LINE__, 
(void*)speed_buffer,
(void*)speed_buffer->get_data(), 
(int)speed_fragment_len);
				if(direction == PLAY_REVERSE)
				{
					Resample::reverse_buffer(speed_buffer->get_data(), speed_fragment_len);
				}
if(debug) printf("AModule::import_samples %d\n", __LINE__);
			}

if(debug) printf("AModule::import_samples %d\n", __LINE__);
			get_cache()->check_in(asset);
if(debug) printf("AModule::import_samples %d\n", __LINE__);
			file = 0;





		}
	}
	else
	{
		nested_edl = 0;
		asset = 0;
if(debug) printf("AModule::import_samples %d %p %d\n", __LINE__, speed_buffer->get_data(), (int)speed_fragment_len);
		if(speed_fragment_len > 0) bzero(speed_buffer->get_data(), speed_fragment_len * sizeof(double));
if(debug) printf("AModule::import_samples %d\n", __LINE__);
	}
if(debug) printf("AModule::import_samples %d\n", __LINE__);









// Stretch it to fit the speed curve
// Need overlapping buffers to get the interpolation to work, but this
// screws up sequential effects.
	if(have_speed)
	{
		FloatAuto *previous = 0;
		FloatAuto *next = 0;
		FloatAutos *speed_autos = (FloatAutos*)track->automation->autos[AUTOMATION_SPEED];
		double *buffer_samples = buffer->get_data();
		double *speed_samples = speed_buffer->get_data();

//printf("AModule::import_samples %d %lld\n", __LINE__, speed_fragment_len);

		if(speed_fragment_len == 0)
		{
			bzero(buffer_samples, fragment_len * sizeof(double));
			bzero(prev_tail, SPEED_OVERLAP * sizeof(double));
			bzero(prev_head, SPEED_OVERLAP * sizeof(double));
		}
		else
		{
// buffer is now reversed
			if(direction == PLAY_REVERSE)
			{
				int out_offset = 0;
				speed_position = speed_position2;
	//printf("AModule::import_samples %d %lld %lld\n", __LINE__, start_project, speed_fragment_len);
				for(int64_t i = start_project + fragment_len;
					i != start_project;
					i--)
				{
	// funky sample reordering, because the source is a reversed buffer
					int in_offset = (int64_t)(speed_fragment_len - 1 - speed_position);
					CLAMP(in_offset, 0, speed_fragment_len - 1);
					buffer_samples[out_offset++] = speed_samples[in_offset];
					double speed = speed_autos->get_value(i, 
						PLAY_REVERSE,
						previous,
						next);
					speed_position -= speed;
				}
	//printf("AModule::import_samples %d %f\n", __LINE__, speed_position);
 			}
			else
			{
				int out_offset = 0;
// position in buffer to read
				speed_position = speed_position1 - start_source;

//printf("AModule::import_samples %d %f\n", __LINE__, speed_position);
				for(int64_t i = start_project; i < start_project + fragment_len; i++)
				{
					double speed = speed_autos->get_value(i, 
						PLAY_FORWARD,
						previous,
						next);
					double next_speed_position = speed_position + speed;

					int in_offset = (int)(speed_position);
					if(fabs(speed) >= 1.0)
					{
						int total = abs(speed);
						double accum = 0;
						for(int j = 0; j < total; j++)
						{
							int in_offset2 = in_offset + (speed > 0 ? j : -j);

							CLAMP(in_offset2, 0, speed_fragment_len - 1);
							accum += speed_samples[in_offset2];
						}


						buffer_samples[out_offset++] = accum / total;
					}
					else
					{


// if(in_offset < 0 || in_offset >= speed_fragment_len)
// printf("AModule::import_samples %d %d %d\n", 
// __LINE__, 
// in_offset, 
// speed_fragment_len);

						int in_offset1 = in_offset;
						int in_offset2 = in_offset;

						if(speed < 0)
						{
							in_offset1 += SPEED_OVERLAP;
							in_offset2 = in_offset1 - 1;
						}
						else
						{
							in_offset1 -= SPEED_OVERLAP;
							in_offset2 = in_offset1 + 1;
						}

						CLAMP(in_offset1, -SPEED_OVERLAP, speed_fragment_len - 1 + SPEED_OVERLAP);
						CLAMP(in_offset2, -SPEED_OVERLAP, speed_fragment_len - 1 + SPEED_OVERLAP);
						
						double value1 = 0;
						if(in_offset1 >= speed_fragment_len)
						{
							value1 = prev_head[in_offset1 - speed_fragment_len];
						}
						else
						if(in_offset1 >= 0)
						{ 
							value1 = speed_samples[in_offset1];
						}
						else
						{
//printf("AModule::import_samples %d %d\n", __LINE__, in_offset1);
							value1 = prev_tail[SPEED_OVERLAP + in_offset1];
						}
#if 0
						double value2 = 0;
						if(in_offset2 >= speed_fragment_len)
						{
							value2 = prev_head[in_offset2 - speed_fragment_len];
						}
						else
						if(in_offset2 >= 0)
						{
							value2 = speed_samples()[in_offset2];
						}
						else
						{
							value2 = prev_tail[SPEED_OVERLAP + in_offset2];
						}

						double fraction = speed_position - floor(speed_position);
						buffer_samples[out_offset++] = 
							value1 * (1.0 - fraction) +
							value2 * fraction;
#endif
						buffer_samples[out_offset++] = value1;


					}

					speed_position = next_speed_position;
				}
			}
			
			for(int i = 0; i < SPEED_OVERLAP; i++)
			{
				int offset = speed_fragment_len - 
					SPEED_OVERLAP +
					i;
				CLAMP(offset, 0, speed_fragment_len - 1);
//printf("AModule::import_samples %d %d\n", __LINE__, offset, );
				prev_tail[i] = speed_samples[offset];
				offset = i;
				CLAMP(offset, 0, speed_fragment_len - 1);
				prev_head[i] = speed_samples[offset];
			}
		}
	}
	
	
	
 

	return result;
}
Beispiel #3
0
 GtkWidget * yank_app_new(EYank *yank) 
{
    yank_preferences      *prefs;


    static GtkTargetEntry drop_types[] =
    {
        { "text/uri-list", 0, 1 },
    };
    static gint n_drop_types = sizeof (drop_types)/sizeof (drop_types [0]);
    gchar     *treetitle[] =
    {
        _("NoteTree"),
        NULL
    };
    gchar     *todotitles[] =
    {
        _("Deadline"),
        _("Priority"),
        _("Complete"),
        _("Title"),
        NULL
    };
     GtkWidget   *app; 
    GtkWidget   *scrolledwindow1;
    GtkWidget   *scrolledwindow2;
    GtkWidget   *scrolledwindow3;
    GtkWidget   *hbox;
    GtkWidget   *hbox3;
    GtkWidget   *vbox;
    GtkWidget   *label;
    GdkFont     *font;
    GtkObject   *prio_adjust;
/*     gint        got_crash; */
    GtkWidget   *b_toggle_ext_flags;
    GtkWidget   *hbox_ext_flags;
		GtkWidget		*hpaned;
    
		hpaned = app = yank->priv->hpaned; 
    yank_main_app(app);  


	 sp->edit_tree = NULL;

	 sp->title_entry =NULL;
	 sp->todo_check =NULL;
	 sp->prio_entry =NULL;
	 sp->de_deadline =NULL;
	 sp->ad_complete =NULL;
	 sp->tlabel_created =NULL;
	 sp->tlabel_changed =NULL;
	 sp->label_changes =NULL;
	 sp->tlabel_expire =NULL;
	 sp->note_id_entry =NULL;
	 sp->text_entry =NULL;
	 sp->note_tree =NULL;
	 sp->b_ok =NULL;
	 sp->b_apply =NULL;
	 sp->b_cancel =NULL;
	 sp->todolist =NULL; 
	 sp->notebook =NULL;
	 sp->status =NULL;  
	 sp->prio_date_box =NULL; 
	 sp->edit_tree=NULL;

   
    yank_root_win(GTK_WINDOW(app)); 
   


    /*
     * main tree
     */
    
    scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    /* gtk_widget_show will be called later */
/*     gtk_container_add(GTK_CONTAINER(hpaned), scrolledwindow1); */
		e_paned_add1(E_PANED(hpaned), scrolledwindow1);

    sp->note_tree = gtk_ctree_new_with_titles(1, 0, treetitle);
    gtk_widget_show(sp->note_tree);
    gtk_container_add(GTK_CONTAINER(scrolledwindow1), sp->note_tree);
    gtk_clist_set_column_width(GTK_CLIST(sp->note_tree), 0, 80);
    gtk_clist_set_column_auto_resize(GTK_CLIST(sp->note_tree), 0, TRUE);
    gtk_clist_set_row_height(GTK_CLIST(sp->note_tree), 19);
    gtk_clist_set_selection_mode(GTK_CLIST(sp->note_tree), GTK_SELECTION_EXTENDED);
    gtk_clist_set_reorderable(GTK_CLIST(sp->note_tree), TRUE);
    gtk_clist_set_use_drag_icons(GTK_CLIST(sp->note_tree), TRUE);
    gtk_clist_column_titles_show(GTK_CLIST(sp->note_tree));
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "tree_select_row",
                       GTK_SIGNAL_FUNC (note_tree_row_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "tree_unselect_row",
                       GTK_SIGNAL_FUNC (note_tree_row_unselected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "click_column",
                       GTK_SIGNAL_FUNC (cb_note_tree_col_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "drag_data_received",
		       GTK_SIGNAL_FUNC(cb_note_tree_reordered), NULL);
    /*
     * FIXME:
     * dnd on the note-tree disables reordering of notes by dnd
     */
/*     gtk_signal_connect(GTK_OBJECT(sp->note_tree), "drag_data_received", */
/*                        GTK_SIGNAL_FUNC(cb_note_tree_drop), NULL); */
/*     gtk_drag_dest_set(sp->note_tree, GTK_DEST_DEFAULT_MOTION | */
/*                       GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, */
/*                       drop_types, n_drop_types, GDK_ACTION_COPY); */

    sp->notebook = gtk_notebook_new();
    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(sp->notebook), FALSE);
    gtk_notebook_set_show_border(GTK_NOTEBOOK(sp->notebook), FALSE);
    gtk_widget_show(sp->notebook);
/*     gtk_container_add(GTK_CONTAINER(hpaned), sp->notebook); */
		e_paned_add2(E_PANED(hpaned), sp->notebook);

    /*
     * todo-list
     */
    
    scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow2),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    gtk_widget_show(scrolledwindow2);
    gtk_container_add(GTK_CONTAINER(sp->notebook), scrolledwindow2);
    
    sp->todolist = gtk_clist_new_with_titles(4, todotitles);
    gtk_signal_connect(GTK_OBJECT(sp->todolist), "select_row",
                       GTK_SIGNAL_FUNC (cb_todo_row_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->todolist), "click_column",
                       GTK_SIGNAL_FUNC (cb_todo_col_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->todolist), "drag_data_received",
                       GTK_SIGNAL_FUNC(cb_todo_list_drop), NULL);
    gtk_drag_dest_set(sp->todolist, GTK_DEST_DEFAULT_MOTION |
                      GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
                      drop_types, n_drop_types, GDK_ACTION_COPY);    
    gtk_widget_show(sp->todolist);
    gtk_container_add(GTK_CONTAINER(scrolledwindow2), sp->todolist);
    gtk_clist_column_titles_show(GTK_CLIST(sp->todolist));
    gtk_clist_set_column_auto_resize(GTK_CLIST(sp->todolist), 0 , TRUE);
    gtk_clist_set_column_auto_resize(GTK_CLIST(sp->todolist), 3 , TRUE);
    gtk_clist_set_column_justification(GTK_CLIST(sp->todolist), 1,
                                       GTK_JUSTIFY_RIGHT);
    gtk_clist_set_column_justification(GTK_CLIST(sp->todolist), 2,
                                       GTK_JUSTIFY_RIGHT);
    

    /*
     * text/ data
     */
    
    vbox = gtk_vbox_new(FALSE, 3);
    gtk_widget_show(vbox);
    gtk_container_add(GTK_CONTAINER (sp->notebook), vbox);
    
    hbox = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);

    sp->prio_date_box = gtk_vbox_new(FALSE, 3);
    gtk_widget_show(sp->prio_date_box);
    gtk_box_pack_start(GTK_BOX(vbox), sp->prio_date_box, FALSE, FALSE, 0);
    
    hbox_ext_flags = gui_ext_flags();
    gtk_box_pack_start(GTK_BOX(vbox), hbox_ext_flags, FALSE, FALSE, 3);

    label = gtk_label_new(_("Title:"));
    font = gtk_widget_get_style(label)->font;
    gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
    gtk_widget_show(label);
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);

    sp->title_entry = gtk_entry_new();
    gtk_widget_set_usize(sp->title_entry, -1, gdk_string_height(font, "W") + 10);
    gtk_widget_show(sp->title_entry);
    gtk_box_pack_start(GTK_BOX(hbox), sp->title_entry, TRUE, TRUE, 5);

    sp->todo_check = gtk_check_button_new_with_label(_("Done"));
    gtk_widget_set_usize(sp->todo_check, -1, gdk_string_height(font, "W") + 10);
    gtk_widget_show(sp->todo_check);
    gtk_box_pack_start(GTK_BOX(hbox), sp->todo_check, FALSE, FALSE, 5);

    /*
     * button for extra flags& data
     */
    
    b_toggle_ext_flags = gtk_button_new();
    {
        GtkWidget *p_up;
        GtkWidget *p_down;
        GtkWidget *box;
        
        box = gtk_hbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(b_toggle_ext_flags), box);
        gtk_widget_show(box);
        p_up = gnome_stock_pixmap_widget_at_size(
            GTK_WIDGET(yank_root_win(NULL)), GNOME_STOCK_BUTTON_UP, 12, 14);
        p_down = gnome_stock_pixmap_widget_at_size(
            GTK_WIDGET(yank_root_win(NULL)), GNOME_STOCK_BUTTON_DOWN, 12, 14);
        gtk_widget_hide(p_up);
        gtk_widget_show(p_down);
        gtk_container_add(GTK_CONTAINER(box), p_up);
        gtk_container_add(GTK_CONTAINER(box), p_down);
        gtk_object_set_data(GTK_OBJECT(b_toggle_ext_flags), "up", p_up);
        gtk_object_set_data(GTK_OBJECT(b_toggle_ext_flags), "down", p_down);
    }
    gtk_widget_show(b_toggle_ext_flags);
    gtk_box_pack_start(GTK_BOX(hbox), b_toggle_ext_flags, FALSE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(b_toggle_ext_flags), "clicked",
                       GTK_SIGNAL_FUNC(cb_toggle_ext_flags), hbox_ext_flags);
    
    /*
     * deadline/ prio/ complete
     */
    
    {
        GtkWidget *prio_hbox1;
        GtkWidget *prio_hbox2;
        GtkWidget *sc_complete;
        
        prio_hbox1 = gtk_hbox_new(FALSE, 0);
        gtk_widget_show(prio_hbox1);
        gtk_box_pack_start(GTK_BOX(sp->prio_date_box), prio_hbox1, FALSE, FALSE,
                           0);
        prio_hbox2 = gtk_hbox_new(FALSE, 0);
        gtk_widget_show(prio_hbox2);
        gtk_box_pack_start(GTK_BOX(sp->prio_date_box), prio_hbox2, FALSE, FALSE,
                           0);
        
        label = gtk_label_new(_("Deadline:"));
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), label, FALSE, FALSE, 5);
        sp->de_deadline = gnome_date_edit_new(0, 1, 1);
        gnome_date_edit_set_popup_range(GNOME_DATE_EDIT(sp->de_deadline), 0, 23);
        gtk_widget_set_sensitive(GNOME_DATE_EDIT(sp->de_deadline)->date_entry,
                                 FALSE);
        gtk_widget_set_sensitive(GNOME_DATE_EDIT(sp->de_deadline)->time_entry,
                                 FALSE);
        gtk_widget_show(sp->de_deadline);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), sp->de_deadline, FALSE, FALSE, 0);
        
        label = gtk_label_new(_("Priority:"));
        gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), label, FALSE, FALSE, 5);
        
        prio_adjust = gtk_adjustment_new(0, 0, 9999, 1, 10, 10);
        sp->prio_entry = gtk_spin_button_new(GTK_ADJUSTMENT(prio_adjust), 1, 0);
        /* NOTE: this is note 100% ok */
        gtk_widget_set_usize(GTK_WIDGET(sp->prio_entry),
                             gdk_string_width(font, "999999") + 10,
                             gdk_string_height(font, "W") + 10);
        gtk_widget_show(sp->prio_entry);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), sp->prio_entry, FALSE, FALSE, 0);
        
        label = gtk_label_new(_("Complete:"));
        gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox2), label, FALSE, FALSE, 5);
        
        sp->ad_complete = gtk_adjustment_new(0, 0, 101, 1, 1, 1);
        sc_complete = gtk_hscale_new(GTK_ADJUSTMENT(sp->ad_complete));
        gtk_scale_set_digits(GTK_SCALE(sc_complete), 0);
        gtk_scale_set_value_pos(GTK_SCALE(sc_complete), GTK_POS_LEFT);
        gtk_widget_show(sc_complete);
        gtk_box_pack_start(GTK_BOX(prio_hbox2), sc_complete, TRUE, TRUE, 5);

        label = gtk_label_new(_("%"));
        gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox2), label, FALSE, FALSE, 5);
        
    }
    
    /*
     * additional note data
     */

    sp->note_id_entry = gtk_entry_new();
/*     gtk_widget_show(sp->note_id_entry); */
    gtk_widget_hide(sp->note_id_entry);
    gtk_box_pack_start(GTK_BOX(hbox), sp->note_id_entry, FALSE, FALSE, 5);

    /*
     * note text
     */
    
    scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow3),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    gtk_widget_show(scrolledwindow3);
    gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow3, TRUE, TRUE, 0);
                       
    sp->text_entry = gtk_text_new(NULL, NULL);
    gtk_text_set_editable(GTK_TEXT(sp->text_entry), TRUE);
    gtk_widget_show(sp->text_entry);
    gtk_container_add(GTK_CONTAINER(scrolledwindow3), sp->text_entry);

    /* text dnd */
    gtk_signal_connect(GTK_OBJECT(sp->text_entry), "drag_data_received",
                       GTK_SIGNAL_FUNC(cb_text_entry_drop), NULL);
    gtk_drag_dest_set(sp->text_entry, GTK_DEST_DEFAULT_MOTION |
                      GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
                      drop_types, n_drop_types, GDK_ACTION_COPY);

    hbox3 = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox3);
    gtk_box_pack_start(GTK_BOX(vbox), hbox3, FALSE, FALSE, 3);

    sp->b_ok = gnome_stock_button(GNOME_STOCK_BUTTON_OK);
    gtk_widget_show(sp->b_ok);
    gtk_box_pack_start(GTK_BOX(hbox3), sp->b_ok, TRUE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(sp->b_ok), "clicked",
                       GTK_SIGNAL_FUNC(cb_b_ok), NULL);

    sp->b_apply = gnome_stock_button(GNOME_STOCK_BUTTON_APPLY);
    gtk_widget_show(sp->b_apply);
    gtk_box_pack_start(GTK_BOX(hbox3), sp->b_apply, TRUE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(sp->b_apply), "clicked",
                       GTK_SIGNAL_FUNC(cb_b_apply), NULL);
        
    sp->b_cancel = gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL);
    gtk_widget_show(sp->b_cancel);
    gtk_box_pack_start(GTK_BOX(hbox3), sp->b_cancel, TRUE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(sp->b_cancel), "clicked",
                       GTK_SIGNAL_FUNC(cb_b_cancel), NULL);

    /*
     * a bit suboptimal
     */
    
    gtk_signal_connect(GTK_OBJECT(sp->title_entry), "changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->de_deadline), "date-changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->de_deadline), "time-changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->tlabel_expire), "time_changed",
		       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->prio_entry), "changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->ad_complete), "value_changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->ad_complete), "value_changed",
                       GTK_SIGNAL_FUNC(cb_complete_updates_done), sp->todo_check);
    gtk_signal_connect(GTK_OBJECT(sp->todo_check), "toggled",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->text_entry), "changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);

    /*
     * keyboard-control
     */
    
    gtk_signal_connect(GTK_OBJECT(sp->title_entry), "activate",
                       GTK_SIGNAL_FUNC(cb_finished_note), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->text_entry), "activate",
                       GTK_SIGNAL_FUNC(cb_finished_note), NULL);

    /*
     * create pixmaps
     */
    
    pix_text_xpm = gnome_pixmap_new_from_xpm_d(text_xpm);
    gtk_widget_show(pix_text_xpm);
    pix_box_xpm = gnome_pixmap_new_from_xpm_d(box_xpm);
    gtk_widget_show(pix_box_xpm);
    pix_box2_xpm = gnome_pixmap_new_from_xpm_d(box2_xpm);
    gtk_widget_show(pix_box2_xpm);
    pix_circle_xpm = gnome_pixmap_new_from_xpm_d(circle_xpm);
    gtk_widget_show(pix_circle_xpm);
    pix_circle2_xpm = gnome_pixmap_new_from_xpm_d(circle2_xpm);
    gtk_widget_show(pix_circle2_xpm);

    /*
     * menus
     */
    
/*     gnome_app_set_contents(GNOME_APP(app), hpaned); */
/*     sp->status = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER); */
/*     gnome_app_set_statusbar(GNOME_APP(app), sp->status); */
/*     yank_install_menus_and_toolbar(app); */
    yank_tree_item_context_menu(sp->note_tree);
    yank_todo_item_context_menu(sp->todolist);
    yank_text_item_context_menu(sp->title_entry);
    yank_text_item_context_menu(sp->text_entry);
    
/*     gtk_signal_connect(GTK_OBJECT(app), "delete_event", */
/*                        GTK_SIGNAL_FUNC(cb_delete_event), NULL); */

    /*
     * initialize preferences
     * also preloads plugins
     */
    
    load_preferences();
    prefs = get_preferences();

    gtk_text_set_word_wrap(GTK_TEXT(sp->text_entry), prefs->wordwrap);
    gtk_text_set_line_wrap(GTK_TEXT(sp->text_entry), prefs->linewrap);
    
    
/*     if (prefs->yank_width * prefs->yank_height) */
/*     { */
/*         gtk_window_set_default_size(GTK_WINDOW(app), prefs->yank_width, */
/*                                     prefs->yank_height); */
/*     } */
/*     else */
/*     { */
/*         gtk_window_set_default_size(GTK_WINDOW(app), 600, 400); */
/*     } */
    
    if (prefs->use_custom_font)
    {
	if (prefs->note_font)
        {
	    set_note_font_str(prefs->note_font);
	}
	if (prefs->note_tree_font)
	{
	    set_note_tree_font_str(prefs->note_tree_font);
        }
        if (prefs->todolist_font)
        {
            set_todolist_font_str(prefs->todolist_font);
        }
    }
    else
    {
        set_default_font();
    }
    
    
    /*
     * parse geometry if given
     */
    
/*     if (geometry != NULL) */
/*     { */
/*         gint x, y, w, h; */
/*         if (gnome_parse_geometry(geometry, &x, &y, &w, &h )) */
/*         { */
/*             if (x != -1) */
/*             { */
/*                 gtk_widget_set_uposition(app, x, y); */
/*             } */
/*              */
/*             if (w != -1) */
/*             { */
/*                 gtk_window_set_default_size(GTK_WINDOW(app), w, h); */
/*             } */
/*         } */
/*         else */
/*         { */
/*             g_error(_("Could not parse geometry string `%s'"), geometry); */
/*         } */
/*     } */
/*      */
/*     if (prefs->note_tree_width) */
/*     { */
/*         gtk_widget_set_usize(scrolledwindow1, prefs->note_tree_width, -1); */
/*     } */
/*     else */
/*     { */
/*         gtk_widget_set_usize(scrolledwindow1, 200, -1); */
/*     } */
/*     gtk_widget_show(scrolledwindow1); */

    /*
     * try to read files from killed sessions
     */

/*     got_crash = get_crash_file(); */
    
    
    /*
     * load file from the command-line
     */
    
/*     if (file != NULL && ! got_crash) */
/*     { */
/*         load_notes_from_cli((gchar *)file, GTK_CTREE(sp->note_tree), NULL); */
/*     } */

    /*
     * read default file
     */
    
/*     if (file == NULL && ! got_crash) */
/*     { */
/*         get_def_file(); */
/*     } */
    
    /*
     * register some signal-handlers
     */

/*     if (signal(SIGTERM, handle_sigterm) == SIG_ERR) */
/*     { */
/*         g_warning("Can't handle SIGTERM"); */
/*     } */
/*     if (signal(SIGCHLD, handle_sigchild) == SIG_ERR) */
/*     { */
/*         g_warning("Can't handle SIGCHILD"); */
/*     } */
/*     if (signal(SIGPIPE, handle_sigpipe) == SIG_ERR) */
/*     { */
/*         g_warning("Can't handle SIGPIPE"); */
/*     } */

    /*
     * init autosave
     */
    
/*     if (prefs->auto_save_minutes) */
/*     { */
/*         autosave_notes(NULL); */
/*     } */
    
    return (hpaned);
}