void Gobby::UserJoinCommands::UserJoinInfo:: add_text_user_properties(std::vector<GParameter>& params, TextSessionView& view) { InfTextSession* session = view.get_session(); GParameter hue_param = { "hue", { 0 } }; g_value_init(&hue_param.value, G_TYPE_DOUBLE); g_value_set_double(&hue_param.value, m_commands.m_preferences.user.hue); params.push_back(hue_param); GParameter vector_param = { "vector", { 0 } }; g_value_init(&vector_param.value, INF_ADOPTED_TYPE_STATE_VECTOR); g_value_take_boxed(&vector_param.value, inf_adopted_state_vector_copy( inf_adopted_algorithm_get_current( inf_adopted_session_get_algorithm( INF_ADOPTED_SESSION(session))))); params.push_back(vector_param); GParameter caret_param = { "caret-position", { 0 } }; g_value_init(&caret_param.value, G_TYPE_UINT); GtkTextBuffer* buffer = GTK_TEXT_BUFFER(view.get_text_buffer()); GtkTextMark* mark = gtk_text_buffer_get_insert(buffer); GtkTextIter caret_iter; gtk_text_buffer_get_iter_at_mark(buffer, &caret_iter, mark); g_value_set_uint(&caret_param.value, gtk_text_iter_get_offset(&caret_iter)); params.push_back(caret_param); }
Gobby::OperationExportHtml::OperationExportHtml( Operations& operations, TextSessionView& view, const Glib::RefPtr<Gio::File>& file) : Operation(operations), m_title(view.get_title()), m_file(file), m_xml(export_html(view)), m_index(0) { }
Gobby::OperationSave::OperationSave(Operations& operations, TextSessionView& view, const Glib::RefPtr<Gio::File>& file, const std::string& encoding, DocumentInfoStorage::EolStyle eol_style): Operation(operations), m_file(file), m_view(&view), m_start_time(std::time(NULL)), m_current_line_index(0), m_encoding(encoding), m_eol_style(eol_style), m_storage_key(view.get_info_storage_key()), m_iconv(encoding.c_str(), "UTF-8"), m_buffer_size(0), m_buffer_index(0) { const Folder& folder = get_folder_manager().get_text_folder(); folder.signal_document_removed().connect( sigc::mem_fun(*this, &OperationSave::on_document_removed)); // Load content so that the session can go on while saving GtkTextBuffer* buffer = GTK_TEXT_BUFFER(view.get_text_buffer()); GtkTextIter prev; GtkTextIter pos; GtkTextIter old_pos; gtk_text_buffer_get_start_iter(buffer, &prev); pos = prev; if(!gtk_text_iter_ends_line(&pos)) gtk_text_iter_forward_to_line_end(&pos); do { Line line; line.first = gtk_text_buffer_get_text(buffer, &prev, &pos, TRUE); line.second = gtk_text_iter_get_line_index(&pos); m_lines.push_back(line); //if(gtk_text_iter_is_end(&prev)) // break; old_pos = pos; gtk_text_iter_forward_line(&prev); gtk_text_iter_forward_to_line_end(&pos); } while(!gtk_text_iter_equal(&pos, &old_pos)); m_current_line = m_lines.begin(); }
Gobby::TaskExportHtml::TaskExportHtml(FileCommands& file_commands, TextSessionView& view): Task(file_commands), m_file_dialog(get_file_chooser(), get_parent(), Glib::ustring::compose( _("Choose a location to export document \"%1\" to"), view.get_title()), Gtk::FILE_CHOOSER_ACTION_SAVE), m_view(&view), m_running(false) { get_folder().signal_document_removed().connect( sigc::mem_fun(*this, &TaskExportHtml::on_document_removed)); }
Gobby::TextTabLabel::TextTabLabel(Folder& folder, TextSessionView& view): TabLabel(folder, view, Gtk::Stock::EDIT), m_dot_char(0) { update_modified(); update_dots(); m_modified_changed_handle = g_signal_connect_after( G_OBJECT(view.get_text_buffer()), "modified-changed", G_CALLBACK(on_modified_changed_static), this); InfTextBuffer* buffer = INF_TEXT_BUFFER( inf_session_get_buffer( INF_SESSION(view.get_session()))); m_insert_text_handle = g_signal_connect_after( G_OBJECT(buffer), "text-inserted", G_CALLBACK(on_text_inserted_static), this); m_erase_text_handle = g_signal_connect_after( G_OBJECT(buffer), "text-erased", G_CALLBACK(on_text_erased_static), this); m_extra.pack_start(m_dots, Gtk::PACK_SHRINK); }