diff --git a/src/notebook.cc b/src/notebook.cc index 344ee44..4e7833b 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -6,7 +6,7 @@ #include "project.h" #include "filesystem.h" -#if GTKSOURCEVIEWMM_MAJOR_VERSION > 2 & GTKSOURCEVIEWMM_MINOR_VERSION > 17 +#if GTKSOURCEVIEWMM_MAJOR_VERSION > 3 || (GTKSOURCEVIEWMM_MAJOR_VERSION == 3 && GTKSOURCEVIEWMM_MINOR_VERSION >= 18) #include "gtksourceview-3.0/gtksourceview/gtksourcemap.h" #endif @@ -283,7 +283,7 @@ void Notebook::open(const boost::filesystem::path &file_path, size_t notebook_in scrolled_windows.back()->add(*source_views.back()); hboxes.back()->pack_start(*scrolled_windows.back()); -#if GTKSOURCEVIEWMM_MAJOR_VERSION > 2 & GTKSOURCEVIEWMM_MINOR_VERSION > 17 +#if GTKSOURCEVIEWMM_MAJOR_VERSION > 3 || (GTKSOURCEVIEWMM_MAJOR_VERSION == 3 && GTKSOURCEVIEWMM_MINOR_VERSION >= 18) source_maps.emplace_back(Glib::wrap(gtk_source_map_new())); gtk_source_map_set_view(GTK_SOURCE_MAP(source_maps.back()->gobj()), source_views.back()->gobj()); #endif @@ -429,7 +429,7 @@ void Notebook::open(const boost::filesystem::path &file_path, size_t notebook_in } void Notebook::configure(size_t index) { -#if GTKSOURCEVIEWMM_MAJOR_VERSION > 2 & GTKSOURCEVIEWMM_MINOR_VERSION > 17 +#if GTKSOURCEVIEWMM_MAJOR_VERSION > 3 || (GTKSOURCEVIEWMM_MAJOR_VERSION == 3 && GTKSOURCEVIEWMM_MINOR_VERSION >= 18) auto source_font_description=Pango::FontDescription(Config::get().source.font); auto source_map_font_desc=Pango::FontDescription(static_cast(source_font_description.get_family())+" "+Config::get().source.map_font_size); source_maps.at(index)->override_font(source_map_font_desc); @@ -513,7 +513,7 @@ bool Notebook::close(size_t index) { auto notebook_page=get_notebook_page(index); notebooks[notebook_page.first].remove_page(notebook_page.second); -#if GTKSOURCEVIEWMM_MAJOR_VERSION > 2 & GTKSOURCEVIEWMM_MINOR_VERSION > 17 +#if GTKSOURCEVIEWMM_MAJOR_VERSION > 3 || (GTKSOURCEVIEWMM_MAJOR_VERSION == 3 && GTKSOURCEVIEWMM_MINOR_VERSION >= 18) source_maps.erase(source_maps.begin()+index); #endif diff --git a/src/source.cc b/src/source.cc index cfedcb4..a2c9c7e 100644 --- a/src/source.cc +++ b/src/source.cc @@ -533,7 +533,7 @@ void Source::View::configure() { property_show_line_numbers() = Config::get().source.show_line_numbers; if(Config::get().source.font.size()>0) override_font(Pango::FontDescription(Config::get().source.font)); -#if GTKSOURCEVIEWMM_MAJOR_VERSION > 2 & GTKSOURCEVIEWMM_MINOR_VERSION > 15 +#if GTKSOURCEVIEWMM_MAJOR_VERSION > 3 || (GTKSOURCEVIEWMM_MAJOR_VERSION == 3 && GTKSOURCEVIEWMM_MINOR_VERSION >= 16) if(Config::get().source.show_background_pattern) gtk_source_view_set_background_pattern(this->gobj(), GTK_SOURCE_BACKGROUND_PATTERN_TYPE_GRID); else @@ -697,7 +697,12 @@ void Source::View::search_forward() { get_buffer()->get_selection_bounds(insert, selection_bound); auto& start=selection_bound; Gtk::TextIter match_start, match_end; +#if defined(GTK_SOURCE_MAJOR_VERSION) && (GTK_SOURCE_MAJOR_VERSION > 3 || (GTK_SOURCE_MAJOR_VERSION == 3 && GTK_SOURCE_MINOR_VERSION >= 22)) + gboolean has_wrapped_around; + if(gtk_source_search_context_forward2(search_context, start.gobj(), match_start.gobj(), match_end.gobj(), &has_wrapped_around)) { +#else if(gtk_source_search_context_forward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) { +#endif get_buffer()->select_range(match_start, match_end); scroll_to(get_buffer()->get_insert()); } @@ -708,7 +713,12 @@ void Source::View::search_backward() { get_buffer()->get_selection_bounds(insert, selection_bound); auto &start=insert; Gtk::TextIter match_start, match_end; +#if defined(GTK_SOURCE_MAJOR_VERSION) && (GTK_SOURCE_MAJOR_VERSION > 3 || (GTK_SOURCE_MAJOR_VERSION == 3 && GTK_SOURCE_MINOR_VERSION >= 22)) + gboolean has_wrapped_around; + if(gtk_source_search_context_backward2(search_context, start.gobj(), match_start.gobj(), match_end.gobj(), &has_wrapped_around)) { +#else if(gtk_source_search_context_backward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) { +#endif get_buffer()->select_range(match_start, match_end); scroll_to(get_buffer()->get_insert()); } @@ -719,9 +729,18 @@ void Source::View::replace_forward(const std::string &replacement) { get_buffer()->get_selection_bounds(insert, selection_bound); auto &start=insert; Gtk::TextIter match_start, match_end; +#if defined(GTK_SOURCE_MAJOR_VERSION) && (GTK_SOURCE_MAJOR_VERSION > 3 || (GTK_SOURCE_MAJOR_VERSION == 3 && GTK_SOURCE_MINOR_VERSION >= 22)) + gboolean has_wrapped_around; + if(gtk_source_search_context_forward2(search_context, start.gobj(), match_start.gobj(), match_end.gobj(), &has_wrapped_around)) { +#else if(gtk_source_search_context_forward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) { +#endif auto offset=match_start.get_offset(); +#if defined(GTK_SOURCE_MAJOR_VERSION) && (GTK_SOURCE_MAJOR_VERSION > 3 || (GTK_SOURCE_MAJOR_VERSION == 3 && GTK_SOURCE_MINOR_VERSION >= 22)) + gtk_source_search_context_replace2(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), nullptr); +#else gtk_source_search_context_replace(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), nullptr); +#endif Glib::ustring replacement_ustring=replacement; get_buffer()->select_range(get_buffer()->get_iter_at_offset(offset), get_buffer()->get_iter_at_offset(offset+replacement_ustring.size())); @@ -734,9 +753,18 @@ void Source::View::replace_backward(const std::string &replacement) { get_buffer()->get_selection_bounds(insert, selection_bound); auto &start=selection_bound; Gtk::TextIter match_start, match_end; +#if defined(GTK_SOURCE_MAJOR_VERSION) && (GTK_SOURCE_MAJOR_VERSION > 3 || (GTK_SOURCE_MAJOR_VERSION == 3 && GTK_SOURCE_MINOR_VERSION >= 22)) + gboolean has_wrapped_around; + if(gtk_source_search_context_backward2(search_context, start.gobj(), match_start.gobj(), match_end.gobj(), &has_wrapped_around)) { +#else if(gtk_source_search_context_backward(search_context, start.gobj(), match_start.gobj(), match_end.gobj())) { +#endif auto offset=match_start.get_offset(); +#if defined(GTK_SOURCE_MAJOR_VERSION) && (GTK_SOURCE_MAJOR_VERSION > 3 || (GTK_SOURCE_MAJOR_VERSION == 3 && GTK_SOURCE_MINOR_VERSION >= 22)) + gtk_source_search_context_replace2(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), nullptr); +#else gtk_source_search_context_replace(search_context, match_start.gobj(), match_end.gobj(), replacement.c_str(), replacement.size(), nullptr); +#endif get_buffer()->select_range(get_buffer()->get_iter_at_offset(offset), get_buffer()->get_iter_at_offset(offset+replacement.size())); scroll_to(get_buffer()->get_insert());