From 66e5122c6a6a80481ec430ff18a68c2f4a285ad4 Mon Sep 17 00:00:00 2001 From: eidheim Date: Tue, 12 Jul 2016 07:33:55 +0200 Subject: [PATCH] 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 --- src/dialogs.cc | 4 ++-- src/notebook.cc | 6 +++--- src/selectiondialog.cc | 4 ++-- src/source.cc | 2 +- src/source_clang.cc | 4 ++-- src/terminal.cc | 4 ++-- tests/source_clang_test.cc | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/dialogs.cc b/src/dialogs.cc index 1baba08..5a44703 100644 --- a/src/dialogs.cc +++ b/src/dialogs.cc @@ -24,8 +24,8 @@ Dialog::Message::Message(const std::string &text): Gtk::MessageDialog(text, fals show_now(); - while(g_main_context_pending(nullptr)) - g_main_context_iteration(nullptr, false); + while(Gtk::Main::events_pending()) + Gtk::Main::iteration(false); } bool Dialog::Message::on_delete_event(GdkEventAny *event) { diff --git a/src/notebook.cc b/src/notebook.cc index 912eae3..9053ac1 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -95,7 +95,7 @@ Notebook::Notebook() : Gtk::HPaned(), notebooks(2) { } size_t Notebook::size() { - return static_cast(source_views.size()); + return source_views.size(); } 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.back()->scroll_to_cursor_delayed=[this](Source::View* view, bool center, bool show_tooltips) { - while(g_main_context_pending(nullptr)) - g_main_context_iteration(nullptr, false); + while(Gtk::Main::events_pending()) + Gtk::Main::iteration(false); if(get_current_view()==view) { if(center) view->scroll_to(view->get_buffer()->get_insert(), 0.0, 1.0, 0.5); diff --git a/src/selectiondialog.cc b/src/selectiondialog.cc index a4d6735..c977ee2 100644 --- a/src/selectiondialog.cc +++ b/src/selectiondialog.cc @@ -122,8 +122,8 @@ void SelectionDialogBase::show() { cursor_changed(); } else if(list_view_text.get_model()->children().begin()!=list_view_text.get_selection()->get_selected()) { - while(g_main_context_pending(nullptr)) - g_main_context_iteration(nullptr, false); + while(Gtk::Main::events_pending()) + 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); } } diff --git a/src/source.cc b/src/source.cc index e10a105..992f76d 100644 --- a/src/source.cc +++ b/src/source.cc @@ -111,7 +111,7 @@ Source::View::View(const boost::filesystem::path &file_path, Glib::RefPtr &v } if(message) { for(;;) { - while(g_main_context_pending(nullptr)) - g_main_context_iteration(nullptr, false); + while(Gtk::Main::events_pending()) + Gtk::Main::iteration(false); bool all_parsed=true; for(auto &clang_view: clang_views) { if(!clang_view->parsed) { diff --git a/src/terminal.cc b/src/terminal.cc index 45675b4..7b7b977 100644 --- a/src/terminal.cc +++ b/src/terminal.cc @@ -334,8 +334,8 @@ void Terminal::clear() { for(auto &in_progress: in_progresses) in_progress->stop=true; } - while(g_main_context_pending(nullptr)) - g_main_context_iteration(nullptr, false); + while(Gtk::Main::events_pending()) + Gtk::Main::iteration(false); get_buffer()->set_text(""); } diff --git a/tests/source_clang_test.cc b/tests/source_clang_test.cc index 3216068..44cb09c 100644 --- a/tests/source_clang_test.cc +++ b/tests/source_clang_test.cc @@ -24,7 +24,7 @@ int main() { Gsv::init(); #ifdef _WIN32 - g_assert_cmpstr(std::getenv("MSYSTEM_PREFIX"), !=, NULL); + g_assert_cmpstr(std::getenv("MSYSTEM_PREFIX"), !=, nullptr); #endif Config::get().project.default_build_path="./build";