Browse Source

Minor cleanups: replaced iterating pending events with C++ functions, corrected return value in Notebook::size, and replaced NULL with nullptr in source_clang_test.cc

merge-requests/365/head
eidheim 10 years ago
parent
commit
66e5122c6a
  1. 4
      src/dialogs.cc
  2. 6
      src/notebook.cc
  3. 4
      src/selectiondialog.cc
  4. 2
      src/source.cc
  5. 4
      src/source_clang.cc
  6. 4
      src/terminal.cc
  7. 2
      tests/source_clang_test.cc

4
src/dialogs.cc

@ -24,8 +24,8 @@ Dialog::Message::Message(const std::string &text): Gtk::MessageDialog(text, fals
show_now(); show_now();
while(g_main_context_pending(nullptr)) while(Gtk::Main::events_pending())
g_main_context_iteration(nullptr, false); Gtk::Main::iteration(false);
} }
bool Dialog::Message::on_delete_event(GdkEventAny *event) { bool Dialog::Message::on_delete_event(GdkEventAny *event) {

6
src/notebook.cc

@ -95,7 +95,7 @@ Notebook::Notebook() : Gtk::HPaned(), notebooks(2) {
} }
size_t Notebook::size() { size_t Notebook::size() {
return static_cast<int>(source_views.size()); return source_views.size();
} }
Source::View* Notebook::get_view(size_t index) { Source::View* Notebook::get_view(size_t index) {
@ -159,8 +159,8 @@ void Notebook::open(const boost::filesystem::path &file_path, size_t notebook_in
source_views.emplace_back(new Source::GenericView(file_path, language)); source_views.emplace_back(new Source::GenericView(file_path, language));
source_views.back()->scroll_to_cursor_delayed=[this](Source::View* view, bool center, bool show_tooltips) { source_views.back()->scroll_to_cursor_delayed=[this](Source::View* view, bool center, bool show_tooltips) {
while(g_main_context_pending(nullptr)) while(Gtk::Main::events_pending())
g_main_context_iteration(nullptr, false); Gtk::Main::iteration(false);
if(get_current_view()==view) { if(get_current_view()==view) {
if(center) if(center)
view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5);

4
src/selectiondialog.cc

@ -122,8 +122,8 @@ void SelectionDialogBase::show() {
cursor_changed(); cursor_changed();
} }
else if(list_view_text.get_model()->children().begin()!=list_view_text.get_selection()->get_selected()) { else if(list_view_text.get_model()->children().begin()!=list_view_text.get_selection()->get_selected()) {
while(g_main_context_pending(nullptr)) while(Gtk::Main::events_pending())
g_main_context_iteration(nullptr, false); Gtk::Main::iteration(false);
list_view_text.scroll_to_row(list_view_text.get_model()->get_path(list_view_text.get_selection()->get_selected()), 0.5); list_view_text.scroll_to_row(list_view_text.get_model()->get_path(list_view_text.get_selection()->get_selected()), 0.5);
} }
} }

2
src/source.cc

@ -111,7 +111,7 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtr<Gsv::L
//TODO: why does this not work?: Might be best to use the styles from sourceview. These has to be read from file, search-matches got style "search-match" //TODO: why does this not work?: Might be best to use the styles from sourceview. These has to be read from file, search-matches got style "search-match"
//TODO: in header if trying again: GtkSourceStyle* search_match_style; //TODO: in header if trying again: GtkSourceStyle* search_match_style;
//TODO: We can drop this, only work on newer versions of gtksourceview. //TODO: We can drop this, only work on newer versions of gtksourceview.
//search_match_style=(GtkSourceStyle*)g_object_new(GTK_SOURCE_TYPE_STYLE, "background-set", 1, "background", "#00FF00", NULL); //search_match_style=(GtkSourceStyle*)g_object_new(GTK_SOURCE_TYPE_STYLE, "background-set", 1, "background", "#00FF00", nullptr);
//gtk_source_search_context_set_match_style(search_context, search_match_style); //gtk_source_search_context_set_match_style(search_context, search_match_style);
//TODO: either use lambda if possible or create a gtkmm wrapper around search_context (including search_settings): //TODO: either use lambda if possible or create a gtkmm wrapper around search_context (including search_settings):

4
src/source_clang.cc

@ -1321,8 +1321,8 @@ void Source::ClangViewRefactor::wait_parsing(const std::vector<Source::View*> &v
} }
if(message) { if(message) {
for(;;) { for(;;) {
while(g_main_context_pending(nullptr)) while(Gtk::Main::events_pending())
g_main_context_iteration(nullptr, false); Gtk::Main::iteration(false);
bool all_parsed=true; bool all_parsed=true;
for(auto &clang_view: clang_views) { for(auto &clang_view: clang_views) {
if(!clang_view->parsed) { if(!clang_view->parsed) {

4
src/terminal.cc

@ -334,8 +334,8 @@ void Terminal::clear() {
for(auto &in_progress: in_progresses) for(auto &in_progress: in_progresses)
in_progress->stop=true; in_progress->stop=true;
} }
while(g_main_context_pending(nullptr)) while(Gtk::Main::events_pending())
g_main_context_iteration(nullptr, false); Gtk::Main::iteration(false);
get_buffer()->set_text(""); get_buffer()->set_text("");
} }

2
tests/source_clang_test.cc

@ -24,7 +24,7 @@ int main() {
Gsv::init(); Gsv::init();
#ifdef _WIN32 #ifdef _WIN32
g_assert_cmpstr(std::getenv("MSYSTEM_PREFIX"), !=, NULL); g_assert_cmpstr(std::getenv("MSYSTEM_PREFIX"), !=, nullptr);
#endif #endif
Config::get().project.default_build_path="./build"; Config::get().project.default_build_path="./build";

Loading…
Cancel
Save