Example #1
0
/* notes_note_add */
Note * notes_note_add(Notes * notes, Note * note)
{
	GtkTreeIter iter;
	char * filename;

	if(note == NULL)
	{
		if((note = note_new()) == NULL)
			return NULL;
		if((filename = _notes_note_get_new_filename()) == NULL)
		{
			notes_error(notes, error_get(NULL), 0);
			note_delete(note);
			return NULL;
		}
		note_set_filename(note, filename);
		free(filename);
		note_set_title(note, _("New note"));
		note_save(note);
	}
	gtk_list_store_insert(notes->store, &iter, 0);
	gtk_list_store_set(notes->store, &iter, ND_COL_NOTE, note,
			ND_COL_TITLE, note_get_title(note), -1);
	return note;
}
Example #2
0
/* notes_note_set_title */
void notes_note_set_title(Notes * notes, GtkTreePath * path, char const * title)
{
	GtkTreeModel * model = GTK_TREE_MODEL(notes->store);
	GtkTreeIter iter;
	Note * note;

	_notes_get_iter(notes, &iter, path);
	gtk_tree_model_get(model, &iter, ND_COL_NOTE, &note, -1);
	note_set_title(note, title);
	gtk_list_store_set(notes->store, &iter, ND_COL_TITLE, title, -1);
	note_save(note);
}
Example #3
0
static void
control_deactivate (BonoboControl *control,
		    BonoboUIComponent *ui_component,
		    EYank *yank)
{
	gchar *filename;

  filename = g_concat_dir_and_file (yank->priv->uri + 7, YANK_FILENAME);
   	note_save(filename, GTK_CTREE(yank->priv->sp.note_tree));   
/*   edit_tree_node_clear(yank->priv->sp.edit_tree, NULL);   */
	sp = &(yank->priv->sp);
	yank->priv->sp.modified = FALSE;
	printf("control_desactivate : sp %x\n", sp);
  clear_tree_from_node(GTK_CTREE(yank->priv->sp.note_tree), NULL);
	g_free(filename);

/* 	bonobo_ui_component_rm (ui_component, "/", NULL); */
	bonobo_ui_component_unset_container (ui_component);


}
Example #4
0
void note_show(ConboyNote *note, gboolean modify_history, gboolean scroll, gboolean select_row)
{
	AppData *app_data = app_data_get();

	UserInterface *ui = app_data->note_window;
	GtkTextBuffer *buffer = ui->buffer;
	GtkWindow *window = GTK_WINDOW(ui->window);

	/* Before we switch to a new note, we save the last one if it was modified. */
	if (gtk_text_buffer_get_modified(buffer)) {
		note_save(ui);
	}

	/* Add to history */
	if (modify_history || app_data->current_element == NULL) {
		add_to_history(note);
	}

	/* Toggle forward/backward buttons */
	gtk_action_set_sensitive(ui->action_back, (gboolean) app_data->current_element->prev);
	gtk_action_set_sensitive(ui->action_forward, (gboolean) app_data->current_element->next);

	/* Block signals on TextBuffer until we are done with initializing the content. This is to prevent saves etc. */
	g_signal_handlers_block_matched(buffer, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ui);

	conboy_note_window_show_note(ui, note);

	/* Format note title and update window title */
	note_format_title(buffer);
	note_set_window_title_from_buffer(window, buffer); /* Replace this. And use note->title instead */

	/* Show widget and set focus to the text view */
	gtk_widget_show(GTK_WIDGET(window));
	gtk_widget_grab_focus(GTK_WIDGET(ui->view));


	while (gtk_events_pending()) {
		gtk_main_iteration_do(FALSE);
	}


	/* Select first row if wanted */
	if (select_row) {
		GtkTextIter start, end;
		gtk_text_buffer_get_iter_at_line(buffer, &start, 2);
		end = start;
		gtk_text_iter_forward_to_line_end(&end);
		gtk_text_buffer_select_range(buffer, &start, &end);
	}

	/* Scroll to cursor position */
	if (scroll && !select_row) {
		GtkTextIter iter;
		gtk_text_buffer_get_iter_at_offset(buffer, &iter, note->cursor_position);
		gtk_text_buffer_place_cursor(buffer, &iter);
		GtkTextMark *mark = gtk_text_buffer_get_insert(buffer);
		gtk_text_view_scroll_to_mark(ui->view, mark, 0.1, TRUE, 0, 0.5);
	}

	/* Set the buffer to unmodified */
	gtk_text_buffer_set_modified(buffer, FALSE);

	/* unblock signals */
	g_signal_handlers_unblock_matched(buffer, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, ui);

	/* Update active tags */
	conboy_note_buffer_update_active_tags(CONBOY_NOTE_BUFFER(buffer));

	/* Update the state of the buttons */
	conboy_note_window_update_button_states(ui);
}