From 6aee69b3988118c99937c1de38af5dfa3315293f Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 23 Dec 2015 10:38:33 +0100 Subject: [PATCH] Minor cleanup of selectiondialog.* --- src/selectiondialog.cc | 13 +++++++------ src/selectiondialog.h | 1 - src/source.cc | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/selectiondialog.cc b/src/selectiondialog.cc index 4ad73ca..12cf580 100644 --- a/src/selectiondialog.cc +++ b/src/selectiondialog.cc @@ -31,6 +31,10 @@ ListViewText::ListViewText(bool use_markup) : Gtk::TreeView(), use_markup(use_ma set_activate_on_single_click(true); set_hover_selection(false); set_rules_hint(true); + + signal_hide().connect([this]() { + list_store->clear(); + }); } void ListViewText::append(const std::string& value) { @@ -38,11 +42,6 @@ void ListViewText::append(const std::string& value) { new_row->set_value(column_record.text, value); } -void ListViewText::hide() { - Gtk::TreeView::hide(); - list_store->clear(); -} - SelectionDialogBase::SelectionDialogBase(Gtk::TextView& text_view, Glib::RefPtr start_mark, bool show_search_entry, bool use_markup): text_view(text_view), list_view_text(use_markup), start_mark(start_mark), show_search_entry(show_search_entry) { if(!show_search_entry) @@ -101,10 +100,12 @@ void SelectionDialogBase::show() { } void SelectionDialogBase::hide() { + if(!shown) + return; window->hide(); if(tooltips) tooltips->hide(); - if(on_hide && shown) + if(on_hide) on_hide(); shown=false; } diff --git a/src/selectiondialog.h b/src/selectiondialog.h index 09a28f1..474e799 100644 --- a/src/selectiondialog.h +++ b/src/selectiondialog.h @@ -18,7 +18,6 @@ public: bool use_markup; ListViewText(bool use_markup); void append(const std::string& value); - void hide(); private: Glib::RefPtr list_store; ColumnRecord column_record; diff --git a/src/source.cc b/src/source.cc index 42064c8..a9faacf 100644 --- a/src/source.cc +++ b/src/source.cc @@ -217,7 +217,7 @@ Source::View::View(const boost::filesystem::path &file_path, const boost::filesy return; if(mark->get_name()=="insert") { - if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) + if(spellcheck_suggestions_dialog) spellcheck_suggestions_dialog->hide(); delayed_spellcheck_suggestions_connection.disconnect(); delayed_spellcheck_suggestions_connection=Glib::signal_timeout().connect([this]() { @@ -429,11 +429,11 @@ void Source::View::set_tooltip_and_dialog_events() { type_tooltips.hide(); diagnostic_tooltips.hide(); - if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) + if(spellcheck_suggestions_dialog) spellcheck_suggestions_dialog->hide(); - if(autocomplete_dialog && autocomplete_dialog->shown) + if(autocomplete_dialog) autocomplete_dialog->hide(); - if(selection_dialog && selection_dialog->shown) + if(selection_dialog) selection_dialog->hide(); set_info(info); @@ -445,11 +445,11 @@ void Source::View::set_tooltip_and_dialog_events() { type_tooltips.hide(); diagnostic_tooltips.hide(); delayed_spellcheck_suggestions_connection.disconnect(); - if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) + if(spellcheck_suggestions_dialog) spellcheck_suggestions_dialog->hide(); - if(autocomplete_dialog && autocomplete_dialog->shown) + if(autocomplete_dialog) autocomplete_dialog->hide(); - if(selection_dialog && selection_dialog->shown) + if(selection_dialog) selection_dialog->hide(); return false; }); @@ -459,9 +459,9 @@ void Source::View::set_tooltip_and_dialog_events() { type_tooltips.hide(); diagnostic_tooltips.hide(); delayed_spellcheck_suggestions_connection.disconnect(); - if(spellcheck_suggestions_dialog && spellcheck_suggestions_dialog->shown) + if(spellcheck_suggestions_dialog) spellcheck_suggestions_dialog->hide(); - if(autocomplete_dialog && autocomplete_dialog->shown) + if(autocomplete_dialog) autocomplete_dialog->hide(); return false; });