Пример #1
0
void Gobby::OperationNew::start()
{
	InfRequest* request;

	if(m_directory)
	{
		request = inf_browser_add_subdirectory(
			m_browser, &m_parent, m_name.c_str(), NULL,
			on_request_finished_static, this);
	}
	else
	{
		request = inf_browser_add_note(
			m_browser, &m_parent, m_name.c_str(),
			"InfText", NULL, NULL, TRUE,
			on_request_finished_static, this);
	}

	if(request != NULL)
	{
		m_request = request;
		g_object_ref(m_request);

		m_message_handle = get_status_bar().add_info_message(
			Glib::ustring::compose(
				m_directory ?
					_("Creating directory \"%1\"...") :
					_("Creating document \"%1\"..."),
				m_name));
  	}
}
Пример #2
0
void layer_new_mouse(void)
{
	// Local variables
	GdkCursor			*selection_cursor;			// Holds the new temporary selection cursor


	// If no project is loaded then don't run this function
	if (NULL == get_current_slide())
	{
		// Make a beep, then return
		gdk_beep();
		return;
	}

	// Change the focus of the window to be this widget
	set_delete_focus(FOCUS_LAYER);

	// Change the cursor to something suitable
	selection_cursor = gdk_cursor_new(GDK_CROSSHAIR);
	gdk_window_set_cursor(get_main_drawing_area()->window, selection_cursor);
	gdk_cursor_unref(selection_cursor);

	// Set a toggle so the release button callback will know to do the rest
	set_new_layer_selected(TYPE_MOUSE_CURSOR);

	// Update the status bar
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Please click the insertion point"));
	gdk_flush();
}
Пример #3
0
void Gobby::OperationNew::on_request_finished(const InfBrowserIter* iter,
                                              const GError* error)
{
	if(error)
	{
		const Glib::ustring prefix = Glib::ustring::compose(
			m_directory ?
				_("Failed to create directory \"%1\""):
				_("Failed to create document \"%1\""),
			m_name);

		get_status_bar().add_error_message(prefix, error->message);

		fail();
	}
	else
	{
		if(!m_directory)
		{
			InfSessionProxy* proxy =
				inf_browser_get_session(m_browser, iter);
			g_assert(proxy != NULL);

			get_folder_manager().add_document(
				m_browser, iter, proxy, NULL);
		}

		finish();
	}
}
Пример #4
0
Gobby::OperationExportHtml::~OperationExportHtml()
{
	if(m_file)
	{
		// TODO: Cancel outstanding async operations?
		get_status_bar().remove_message(m_message_handle);
	}
}
Пример #5
0
void Gobby::OperationExportHtml::error(const Glib::ustring& message)
{
	get_status_bar().add_error_message(
		Glib::ustring::compose(
			_("Failed to export document \"%1\" to HTML"), m_file->get_uri()),
		message);

	fail();
}
Пример #6
0
void Gobby::OperationSave::error(const Glib::ustring& message)
{
	get_status_bar().add_error_message(
		Glib::ustring::compose(_("Failed to save document \"%1\""),
		                         m_file->get_uri()),
		message);

	fail();
}
Пример #7
0
void Gobby::OperationExportHtml::start()
{
	m_file->replace_async(
		sigc::mem_fun(*this, &OperationExportHtml::on_file_replace));

	m_message_handle = get_status_bar().add_info_message(
		Glib::ustring::compose(
			_("Exporting document \"%1\" to \"%2\" in HTML..."),
			m_title, m_file->get_uri()));
}
Пример #8
0
Gobby::OperationOpen::~OperationOpen()
{
	// TODO: Cancel outstanding async operations?

	if(m_request != NULL)
	{
		g_signal_handlers_disconnect_by_func(
			G_OBJECT(m_request),
			(gpointer)G_CALLBACK(on_request_finished_static),
			this);
		g_object_unref(m_request);
	}

	if(m_content != NULL)
		g_object_unref(m_content);

	if(m_message_handle != get_status_bar().invalid_handle())
		get_status_bar().remove_message(m_message_handle);
}
Пример #9
0
void Gobby::OperationSave::start()
{
	m_file->replace_async(sigc::mem_fun(*this,
	                                   &OperationSave::on_file_replace));

	m_message_handle = get_status_bar().add_info_message(
		Glib::ustring::compose(
			_("Saving document \"%1\" to \"%2\"..."),
			m_view->get_title(), m_file->get_uri()));
}
Пример #10
0
Gobby::OperationSave::~OperationSave()
{
	// TODO: Cancel outstanding async operations?

	for(std::list<Line>::iterator iter = m_lines.begin();
	    iter != m_lines.end(); ++ iter)
	{
		g_free(iter->first);
	}

	get_status_bar().remove_message(m_message_handle);
}
Пример #11
0
void layer_copy(void)
{
	// Local variables
	slide				*current_slide_data;		// Alias to make things easier
	guint				selected_layer;				// Holds the number of the layer that is selected
	layer				*this_layer;				// Pointer to the presently selected layer


	// Initialise some things
	current_slide_data = get_current_slide_data();

	// Determine which layer the user has selected in the timeline
	selected_layer = time_line_get_selected_layer_num(current_slide_data->timeline_widget);
	current_slide_data->layers = g_list_first(current_slide_data->layers);
	this_layer = g_list_nth_data(current_slide_data->layers, selected_layer);

	// If there is already a layer in the copy buffer, then we free it
	if (NULL != get_copy_layer())
	{
		layer_free(get_copy_layer());
	}

	// Create a new layer
	set_copy_layer(layer_duplicate(this_layer));
	if (NULL == get_copy_layer())
	{
		// Something went wrong duplicating the existing layer.  Not much we can do
		gdk_beep();
		gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Copy failed"));
		gdk_flush();
		return;
	}

	// Update the status bar
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Layer copied to buffer"));
	gdk_flush();
	return;
}
Пример #12
0
Gobby::OperationNew::~OperationNew()
{
	if(m_request != NULL)
	{
		g_signal_handlers_disconnect_by_func(
			G_OBJECT(m_request),
			(gpointer)G_CALLBACK(on_request_finished_static),
			this);
		g_object_unref(m_request);

		get_status_bar().remove_message(m_message_handle);
	}

	g_object_unref(m_browser);
}
Пример #13
0
Gobby::OperationOpen::OperationOpen(Operations& operations,
                                    const Preferences& preferences,
                                    InfBrowser* browser,
                                    const InfBrowserIter* parent,
                                    const std::string& name,
                                    const Glib::RefPtr<Gio::File>& file,
                                    const char* encoding):
	Operation(operations), m_preferences(preferences),
	m_name(name), m_file(file), m_parent(browser, parent),
	m_encoding_auto_detect_index(-1),
	m_eol_style(DocumentInfoStorage::EOL_CR), m_request(NULL),
	m_raw_pos(0), m_content(NULL),
	m_message_handle(get_status_bar().invalid_handle())
{
	if(encoding != NULL)
	{
		m_encoding = encoding;
	}
	else
	{
		m_encoding_auto_detect_index = 0;
		m_encoding = get_autodetect_encoding(0);
	}
}
Пример #14
0
void Gobby::OperationOpen::start()
{
	m_iconv.reset(new Glib::IConv("UTF-8", m_encoding));

	try
	{
		m_file->read_async(sigc::mem_fun(
			*this, &OperationOpen::on_file_read));

		m_message_handle = get_status_bar().add_info_message(
			Glib::ustring::compose(
				_("Opening document \"%1\"..."), m_file->get_uri()));

		m_parent.signal_node_removed().connect(
			sigc::mem_fun(
				*this, &OperationOpen::on_node_removed));

		m_content = GTK_TEXT_BUFFER(gtk_source_buffer_new(NULL));
	}
	catch(const Gio::Error& err)
	{
		error(err.what());
	}
}
Пример #15
0
void layer_move_up(void)
{
	// Local variables
	GList				*above_layer;				// The layer above the selected one
	GList				*layer_pointer;				// Points to the layers in the selected slide
	GList				*our_layer;					// The selected layer
	guint				selected_row;				// Holds the row that is selected


	// If no project is loaded then don't run this function
	if (NULL == get_current_slide())
	{
		// Make a beep, then return
		gdk_beep();
		return;
	}

	// Initialise various things
	layer_pointer = get_current_slide_layers_pointer();
	layer_pointer = g_list_first(layer_pointer);

	// Change the focus of the window to be this widget
	set_delete_focus(FOCUS_LAYER);

	// Determine which layer the user has selected in the timeline
	selected_row = time_line_get_selected_layer_num(get_current_slide_timeline_widget());
	if (0 == selected_row)
	{
		// We're already at the top of the list, so return
		gdk_beep();
		return;
	}

	// Get details of the layers we're moving around
	our_layer = g_list_nth(layer_pointer, selected_row);
	above_layer = g_list_nth(layer_pointer, selected_row - 1);

	// Check if the user has selected the Background layer, if so we return (ignoring this move request)
	if (TRUE == ((layer *) our_layer->data)->background)
	{
		// We're processing a background layer, so return
		gdk_beep();
		return;
	}

	// Move the row up one in the layer list
	layer_pointer = g_list_remove_link(layer_pointer, our_layer);
	layer_pointer = g_list_insert_before(layer_pointer, above_layer, our_layer->data);
	set_current_slide_layers_pointer(layer_pointer);

	// Move the row up one in the timeline widget
	time_line_set_selected_layer_num(get_current_slide_timeline_widget(), selected_row - 1);

	// Redraw the timeline area
	draw_timeline();

	// Redraw the workspace
	draw_workspace();

	// Recreate the slide thumbnail
	film_strip_create_thumbnail(get_current_slide_data());

	// Set the changes made variable
	set_changes_made(TRUE);

	// Update the status bar
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Layer moved up"));
	gdk_flush();
}
Пример #16
0
void slide_delete(void)
{
	// Local variables
	GString				*message;					// Used to construct message strings
	GtkTreePath			*new_path;					// Temporary path
	gint				num_slides;					// Number of slides in the whole slide list
	GtkTreePath			*old_path = NULL;			// The old path, which we'll free
	gint				slide_position;				// Which slide in the slide list we are deleting
	GtkTreeSelection	*film_strip_selector;		//
	GtkTreeIter			selection_iter;				//
	undo_history_data	*undo_item_data = NULL;		// Memory structure undo history items are created in


	// Are we trying to delete the only slide in the project (not good)?
	set_slides(g_list_first(get_slides()));
	num_slides = g_list_length(get_slides());
	if (1 == num_slides)
	{
		// Yes we are, so give a warning message and don't delete the slide
		message = g_string_new(NULL);
		g_string_printf(message, "%s ED462: %s", _("Error"), _("You must leave at least one slide in a project."));
		display_warning(message->str);
		g_string_free(message, TRUE);
		return;
	}

	// Determine where the slide is positioned in the project
	slide_position = g_list_position(get_slides(), get_current_slide());

	// Create and store the undo history item for this slide
	undo_item_data = g_new0(undo_history_data, 1);
	undo_item_data->layer_data_new = NULL;  // NULL means not set
	undo_item_data->layer_data_old = NULL;  // NULL means not set
	undo_item_data->position_new = -1;  // -1 means not set
	undo_item_data->position_old = slide_position;
	undo_item_data->slide_data = get_current_slide_data();
	undo_history_add_item(UNDO_DELETE_SLIDE, undo_item_data, TRUE);

	// Remove the current slide from the slide list
	set_slides(g_list_remove_link(get_slides(), get_current_slide()));

	// Remove the current slide from the film strip
	film_strip_selector = gtk_tree_view_get_selection(GTK_TREE_VIEW(get_film_strip_view()));
	gtk_tree_selection_get_selected(film_strip_selector, NULL, &selection_iter);
	gtk_list_store_remove(GTK_LIST_STORE(get_film_strip_store()), &selection_iter);

	// * Update the currently selected slide to point to the next slide *
	if (num_slides == (slide_position + 1))
	{
		// If we're deleting the last slide, we'll need to point to the previous one instead
		slide_position--;
	}
	set_current_slide(g_list_nth(get_slides(), slide_position));

	// Select the next thumbnail in the film strip and scroll to display it
	gtk_tree_view_get_cursor(GTK_TREE_VIEW(get_film_strip_view()), &new_path, NULL);
	if (NULL != new_path)
		old_path = new_path;  // Make a backup of the old path, so we can free it
	new_path = gtk_tree_path_new_from_indices(slide_position, -1);
	gtk_tree_view_set_cursor(GTK_TREE_VIEW(get_film_strip_view()), new_path, NULL, FALSE);
	gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(get_film_strip_view()), new_path, NULL, TRUE, 0.5, 0.0);
	if (NULL != old_path)
		gtk_tree_path_free(old_path);  // Free the old path

	// Redraw the timeline
	draw_timeline();

	// Redraw the workspace
	draw_workspace();

	// Set the changes made variable
	set_changes_made(TRUE);

	// Update the status bar
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Slide deleted"));
	gdk_flush();
}
Пример #17
0
void slide_move_down(void)
{
	// Local variables
	GtkTreeIter			from_iter, to_iter;
	GtkTreePath			*new_path;					// Temporary path
	GList				*next_slide;				// Pointer to the slide below
	gint				num_slides;					// The total number of slides
	GtkTreePath			*old_path = NULL;			// The old path, which we'll free
	gint				slide_position;				// Which slide in the slide list we are moving
	slide				*this_slide_data;			// Pointer to the data for this slide
	GString				*tmp_gstring;


	// Initialise some things
	tmp_gstring = g_string_new(NULL);

	// Safety check
	set_slides(g_list_first(get_slides()));
	slide_position = g_list_position(get_slides(), get_current_slide());
	num_slides = g_list_length(get_slides());
	if (num_slides == (slide_position + 1))
	{
		// We can't move the bottom most slide any further down, so just return
		return;
	}

	// Swap the slides around
	this_slide_data = get_current_slide_data();
	next_slide = g_list_nth(get_slides(), slide_position + 1);
	set_current_slide_data(next_slide->data);
	next_slide->data = this_slide_data;
	set_current_slide(next_slide);

	// Move the thumbnail down one position in the film strip list
	g_string_printf(tmp_gstring, "%u", slide_position);
	if (TRUE == gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(get_film_strip_store()), &from_iter, tmp_gstring->str))
	{
		g_string_printf(tmp_gstring, "%u", slide_position + 1);
		if (TRUE == gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(get_film_strip_store()), &to_iter, tmp_gstring->str))
		{
			gtk_list_store_move_after(GTK_LIST_STORE(get_film_strip_store()), &from_iter, &to_iter);
		}
	}
	g_string_free(tmp_gstring, TRUE);

	// Scroll the film strip to show the new thumbnail position
	gtk_tree_view_get_cursor(GTK_TREE_VIEW(get_film_strip_view()), &new_path, NULL);
	if (NULL != new_path)
		old_path = new_path;  // Make a backup of the old path, so we can free it
	new_path = gtk_tree_path_new_from_indices(slide_position + 1, -1);
	gtk_tree_view_set_cursor(GTK_TREE_VIEW(get_film_strip_view()), new_path, NULL, FALSE);
	gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(get_film_strip_view()), new_path, NULL, TRUE, 0.5, 0.0);
	if (NULL != old_path)
		gtk_tree_path_free(old_path);  // Free the old path

	// Set the changes made variable
	set_changes_made(TRUE);

	// Update the status bar
	gtk_progress_bar_set_text(GTK_PROGRESS_BAR(get_status_bar()), _(" Slide moved down"));
	gdk_flush();
}